[PATCH] D126694: [C++20][Modules] Initial implementation of GMF decl elision.

2022-05-31 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/Sema/Sema.cpp:1150
+  continue;
+if (!D->isUsed(false) && !D->isReferenced())
+  WorkList.push_back(D);

ChuanqiXu wrote:
> Should we check for `D->isUsed()` simply? It looks more straight forward to 
> me.
Does this work properly if the declaration is referenced within the header 
unit? I think we track whether we've seen any use of the declaration anywhere, 
not only if we've seen a use in the current translation unit, and we'll need a 
different mechanism here.



Comment at: clang/lib/Sema/Sema.cpp:1154-1155
+
+  for (auto *D : WorkList)
+DC->removeDecl(D);
+}

Please don't remove the declarations from the `DeclContext`; `removeDecl`  is 
inefficient, not well-tested, and not really compatible with the Clang 
philosophy of AST fidelity. For example, this will be very problematic for 
tooling that wants to inspect the translation unit after compilation.

As an alternative that should also fix the issue with checking `isUsed`, how 
would you feel about this:

* Create a new `ModuleOwnershipKind`, say `ReachableIfUsed`, and set that as 
the ownership kind for the TU when parsing the global module fragment so it 
gets inherited into everything we parse in that region. This'll mean that 
`NextInContextAndBits` needs an extra bit for the ownership field, but I think 
`Decl` is 8-byte-aligned so that seems fine.
* When a declaration is being marked as used, check if its ownership kind is 
`ReachableIfUsed` and if so change it to `ModulePrivate`.

That should be enough to get the desired semantic effect, and would allow us to 
get the improved diagnostic experience that @ChuanqiXu asked about. As a 
potentially separate step,  we can teach the ASTWriter code to (optionally) 
skip declarations that are `ReachableIfUsed` (and similarly for internal 
linkage declarations in module interfaces, function bodies for non-inline 
functions, and anything else we're allowed to omit).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126694/new/

https://reviews.llvm.org/D126694

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D124753: [HLSL] Set main as default entry.

2022-05-31 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/test/CodeGenHLSL/entry_default.hlsl:6
+// Make sure not mangle entry.
+// CHECK:define void @main() [[MAIN_ATTR:#[0-9]]]
+// CHECK:define void @_Z3foov() [[FOO_ATTR:#[0-9]]]

space between `:` and the value.



Comment at: clang/test/CodeGenHLSL/entry_default.hlsl:9
+// Make sure only main has dx.shader attribute.
+// CHECK:[[MAIN_ATTR]]
+// CHECK:"dx.shader"="compute"

[[MAIN_ATTR]] and the value should be on the same line.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124753/new/

https://reviews.llvm.org/D124753

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126192: [Driver] Support linking with lld for target AVR

2022-05-31 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

I am still uncomfortable with such a change. Trying to be smart sometimes may 
get in the way.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126192/new/

https://reviews.llvm.org/D126192

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D124699: [DeadArgElim] Set unused arguments for internal functions

2022-05-31 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In D124699#3549191 , @kstoimenov 
wrote:

> This change is breaking memory sanitizer in some cases. We observed that  
> when the argument is not actually removed the pass is dropping the noundef 
> attribute. See the diff snippet below. Is that an intended behavior?
>
> We would like to revert this as it is breaking MSan tests.
>
> Thanks, 
> Kirill
>
>   < define internal %struct._object* 
> @coro_wrapper_close(%struct.PyCoroWrapper* noundef %cw, %struct._object* 
> noundef %args) #0 !dbg !1065 {
>   ---
>   > define internal %struct._object* 
> @coro_wrapper_close(%struct.PyCoroWrapper* noundef %cw, %struct._object* 
> %args) #0 !dbg !1065 {

I guess I realized why msan, is broken. It's indirectly cased by this patch, 
but the problem is in our code.
This patch poisons more msan arguments (see NOTE below), but still correctly.
However I just noticed that the issues we are working with Kirill involves a 
peace of notinstrumented assembly, which fails to propagate Msan shadow. 
@kstoimenov and me will find a different solution.

*NOTE* This optimization is negative for msan with noundef mode 
(-fsanitizer-memory-param-retval)
If we remove noundef, then msan must to setup TLS for arguments. If it's undef, 
we set that into -1 to poison arg.
For msan it could be more efficient to keep noundef and pass null into that 
argument.
But that's not a problem of this patch, and we will address that later if 
needed.




Comment at: llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp:268
   // }
   if (!Fn.hasExactDefinition())
 return false;

@kstoimenov Offline I guessed that maybe our problem because we lost noundef on 
weak function arg, however this check protects against that.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124699/new/

https://reviews.llvm.org/D124699

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D124699: [DeadArgElim] Set unused arguments for internal functions

2022-05-31 Thread Kirill Stoimenov via Phabricator via cfe-commits
kstoimenov added a comment.

This change is breaking memory sanitizer in some cases. We observed that  when 
the argument is not actually removed the pass is dropping the noundef 
attribute. See the diff snippet below. Is that an intended behavior?

We would like to revert this as it is breaking MSan tests.

Thanks, 
Kirill

  < define internal %struct._object* @coro_wrapper_close(%struct.PyCoroWrapper* 
noundef %cw, %struct._object* noundef %args) #0 !dbg !1065 {
  ---
  > define internal %struct._object* @coro_wrapper_close(%struct.PyCoroWrapper* 
noundef %cw, %struct._object* %args) #0 !dbg !1065 {


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124699/new/

https://reviews.llvm.org/D124699

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 1013967 - [PowerPC] Remove const from paired vector store builtins

2022-05-31 Thread Nemanja Ivanovic via cfe-commits

Author: Nemanja Ivanovic
Date: 2022-05-31T21:51:15-05:00
New Revision: 1013967436694f362097a7c12f675c0ad7de90b7

URL: 
https://github.com/llvm/llvm-project/commit/1013967436694f362097a7c12f675c0ad7de90b7
DIFF: 
https://github.com/llvm/llvm-project/commit/1013967436694f362097a7c12f675c0ad7de90b7.diff

LOG: [PowerPC] Remove const from paired vector store builtins

For some reason, we implemented the xx_stxvp intrinsics
to require a const pointer. This absolutely doesn't make
sense for a store. Remove the const from the definition.

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsPPC.def
clang/test/CodeGen/PowerPC/builtins-ppc-pair-mma.c
clang/test/Sema/ppc-mma-builtins.c
clang/test/Sema/ppc-pair-mma-types.c

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsPPC.def 
b/clang/include/clang/Basic/BuiltinsPPC.def
index 923215cc3e5d0..04934ec2b9e18 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -843,7 +843,7 @@ BUILTIN(__builtin_dcbf, "vvC*", "")
 
 // Provided builtins with _mma_ prefix for compatibility.
 CUSTOM_BUILTIN(mma_lxvp, vsx_lxvp, "W256SLiW256C*", false)
-CUSTOM_BUILTIN(mma_stxvp, vsx_stxvp, "vW256SLiW256C*", false)
+CUSTOM_BUILTIN(mma_stxvp, vsx_stxvp, "vW256SLiW256*", false)
 CUSTOM_BUILTIN(mma_assemble_pair, vsx_assemble_pair, "vW256*VV", false)
 CUSTOM_BUILTIN(mma_disassemble_pair, vsx_disassemble_pair, "vv*W256*", false)
 CUSTOM_BUILTIN(vsx_build_pair, vsx_assemble_pair,  "vW256*VV", false)
@@ -855,7 +855,7 @@ CUSTOM_BUILTIN(mma_build_acc, mma_assemble_acc, 
"vW512*", false)
 // This avoids repeating the ID and INTR in the macro expression.
 
 UNALIASED_CUSTOM_BUILTIN(vsx_lxvp, "W256SLiW256C*", false)
-UNALIASED_CUSTOM_BUILTIN(vsx_stxvp, "vW256SLiW256C*", false)
+UNALIASED_CUSTOM_BUILTIN(vsx_stxvp, "vW256SLiW256*", false)
 UNALIASED_CUSTOM_BUILTIN(vsx_assemble_pair, "vW256*VV", false)
 UNALIASED_CUSTOM_BUILTIN(vsx_disassemble_pair, "vv*W256*", false)
 

diff  --git a/clang/test/CodeGen/PowerPC/builtins-ppc-pair-mma.c 
b/clang/test/CodeGen/PowerPC/builtins-ppc-pair-mma.c
index 72867007afddf..f7811a4d1129c 100644
--- a/clang/test/CodeGen/PowerPC/builtins-ppc-pair-mma.c
+++ b/clang/test/CodeGen/PowerPC/builtins-ppc-pair-mma.c
@@ -1048,7 +1048,7 @@ void test65(unsigned char *vqp, unsigned char *vpp, 
vector unsigned char vc, uns
 // CHECK-NEXT:tail call void @llvm.ppc.vsx.stxvp(<256 x i1> [[TMP1]], i8* 
[[TMP2]])
 // CHECK-NEXT:ret void
 //
-void test66(const __vector_pair *vpp, const __vector_pair *vp2) {
+void test66(const __vector_pair *vpp, __vector_pair *vp2) {
   __vector_pair vp = __builtin_vsx_lxvp(0L, vpp);
   __builtin_vsx_stxvp(vp, 0L, vp2);
 }
@@ -1063,7 +1063,7 @@ void test66(const __vector_pair *vpp, const __vector_pair 
*vp2) {
 // CHECK-NEXT:tail call void @llvm.ppc.vsx.stxvp(<256 x i1> [[TMP2]], i8* 
[[TMP4]])
 // CHECK-NEXT:ret void
 //
-void test67(const __vector_pair *vpp, signed long offset, const __vector_pair 
*vp2) {
+void test67(const __vector_pair *vpp, signed long offset, __vector_pair *vp2) {
   __vector_pair vp = __builtin_vsx_lxvp(offset, vpp);
   __builtin_vsx_stxvp(vp, offset, vp2);
 }
@@ -1078,7 +1078,7 @@ void test67(const __vector_pair *vpp, signed long offset, 
const __vector_pair *v
 // CHECK-NEXT:tail call void @llvm.ppc.vsx.stxvp(<256 x i1> [[TMP2]], i8* 
[[TMP4]])
 // CHECK-NEXT:ret void
 //
-void test68(const __vector_pair *vpp, const __vector_pair *vp2) {
+void test68(const __vector_pair *vpp, __vector_pair *vp2) {
   __vector_pair vp = __builtin_vsx_lxvp(18L, vpp);
   __builtin_vsx_stxvp(vp, 18L, vp2);
 }
@@ -1093,7 +1093,7 @@ void test68(const __vector_pair *vpp, const __vector_pair 
*vp2) {
 // CHECK-NEXT:tail call void @llvm.ppc.vsx.stxvp(<256 x i1> [[TMP2]], i8* 
[[TMP4]])
 // CHECK-NEXT:ret void
 //
-void test69(const __vector_pair *vpp, const __vector_pair *vp2) {
+void test69(const __vector_pair *vpp, __vector_pair *vp2) {
   __vector_pair vp = __builtin_vsx_lxvp(1L, vpp);
   __builtin_vsx_stxvp(vp, 1L, vp2);
 }
@@ -1108,7 +1108,7 @@ void test69(const __vector_pair *vpp, const __vector_pair 
*vp2) {
 // CHECK-NEXT:tail call void @llvm.ppc.vsx.stxvp(<256 x i1> [[TMP2]], i8* 
[[TMP4]])
 // CHECK-NEXT:ret void
 //
-void test70(const __vector_pair *vpp, const __vector_pair *vp2) {
+void test70(const __vector_pair *vpp, __vector_pair *vp2) {
   __vector_pair vp = __builtin_vsx_lxvp(42L, vpp);
   __builtin_vsx_stxvp(vp, 42L, vp2);
 }
@@ -1123,7 +1123,7 @@ void test70(const __vector_pair *vpp, const __vector_pair 
*vp2) {
 // CHECK-NEXT:tail call void @llvm.ppc.vsx.stxvp(<256 x i1> [[TMP2]], i8* 
[[TMP4]])
 // CHECK-NEXT:ret void
 //
-void test71(const __vector_pair *vpp, const __vector_pair *vp2) {
+void test71(const __vector_pair *vpp, __vector_pair *vp2) {
   __vector_pair vp = __builtin_vsx_lxvp(32768L, vpp);
   

[PATCH] D126694: [C++20][Modules] Initial implementation of GMF decl elision.

2022-05-31 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added inline comments.



Comment at: clang/test/CXX/basic/basic.scope/basic.scope.namespace/p2.cpp:32
 void test_early() {
-  in_header = 1; // expected-error {{missing '#include "foo.h"'; 'in_header' 
must be declared before it is used}}
-  // expected-note@*{{not visible}}
+  in_header = 1; // expected-error {{use of undeclared identifier 'in_header'}}
 

This error message looks worse. I image I could hear users complaining this. (I 
doesn't say it is your fault since this is specified in standard and the 
standard cases are harder to understand). I want to know if this is consistent 
with GCC?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126694/new/

https://reviews.llvm.org/D126694

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 92a606f - [HIP] Pass -Xoffload-linker option to device linker

2022-05-31 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2022-05-31T22:17:40-04:00
New Revision: 92a606f6de77f69f9eb86498deaeeeb8f821f4e1

URL: 
https://github.com/llvm/llvm-project/commit/92a606f6de77f69f9eb86498deaeeeb8f821f4e1
DIFF: 
https://github.com/llvm/llvm-project/commit/92a606f6de77f69f9eb86498deaeeeb8f821f4e1.diff

LOG: [HIP] Pass -Xoffload-linker option to device linker

Reuse -Xoffload-linker option for HIP toolchain.

Reviewed by: Artem Belevich

Differential Revision: https://reviews.llvm.org/D126704

Added: 


Modified: 
clang/lib/Driver/ToolChains/HIPAMD.cpp
clang/test/Driver/hip-options.hip

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/HIPAMD.cpp 
b/clang/lib/Driver/ToolChains/HIPAMD.cpp
index f672d2a108cc..bce3e729f7ee 100644
--- a/clang/lib/Driver/ToolChains/HIPAMD.cpp
+++ b/clang/lib/Driver/ToolChains/HIPAMD.cpp
@@ -147,6 +147,9 @@ void AMDGCN::Linker::constructLldCommand(Compilation , 
const JobAction ,
 
   addLinkerCompressDebugSectionsOption(TC, Args, LldArgs);
 
+  for (auto *Arg : Args.filtered(options::OPT_Xoffload_linker))
+LldArgs.push_back(Arg->getValue(1));
+
   LldArgs.append({"-o", Output.getFilename()});
   for (auto Input : Inputs)
 LldArgs.push_back(Input.getFilename());

diff  --git a/clang/test/Driver/hip-options.hip 
b/clang/test/Driver/hip-options.hip
index c995fa68dacc..c4f436669b0b 100644
--- a/clang/test/Driver/hip-options.hip
+++ b/clang/test/Driver/hip-options.hip
@@ -106,3 +106,13 @@
 // RUN:   --offload-arch=gfx906 -fopenmp -fopenmp-targets=amdgcn %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=OMPTGT %s
 // OMPTGT: unsupported option '-fopenmp-targets=' for language mode 'HIP'
+
+// Check -Xoffload-linker option is passed to lld.
+
+// RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
+// RUN:   --cuda-gpu-arch=gfx906 -fgpu-rdc -Xoffload-linker --build-id=md5 %s 
2>&1 \
+// RUN:   | FileCheck -check-prefix=OFL-LINK %s
+// RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
+// RUN:   --cuda-gpu-arch=gfx906 -Xoffload-linker --build-id=md5 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=OFL-LINK %s
+// OFL-LINK: lld{{.*}}"--build-id=md5"



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126704: [HIP] Pass -Xoffload-linker option to device linker

2022-05-31 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG92a606f6de77: [HIP] Pass -Xoffload-linker option to device 
linker (authored by yaxunl).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126704/new/

https://reviews.llvm.org/D126704

Files:
  clang/lib/Driver/ToolChains/HIPAMD.cpp
  clang/test/Driver/hip-options.hip


Index: clang/test/Driver/hip-options.hip
===
--- clang/test/Driver/hip-options.hip
+++ clang/test/Driver/hip-options.hip
@@ -106,3 +106,13 @@
 // RUN:   --offload-arch=gfx906 -fopenmp -fopenmp-targets=amdgcn %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=OMPTGT %s
 // OMPTGT: unsupported option '-fopenmp-targets=' for language mode 'HIP'
+
+// Check -Xoffload-linker option is passed to lld.
+
+// RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
+// RUN:   --cuda-gpu-arch=gfx906 -fgpu-rdc -Xoffload-linker --build-id=md5 %s 
2>&1 \
+// RUN:   | FileCheck -check-prefix=OFL-LINK %s
+// RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
+// RUN:   --cuda-gpu-arch=gfx906 -Xoffload-linker --build-id=md5 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=OFL-LINK %s
+// OFL-LINK: lld{{.*}}"--build-id=md5"
Index: clang/lib/Driver/ToolChains/HIPAMD.cpp
===
--- clang/lib/Driver/ToolChains/HIPAMD.cpp
+++ clang/lib/Driver/ToolChains/HIPAMD.cpp
@@ -147,6 +147,9 @@
 
   addLinkerCompressDebugSectionsOption(TC, Args, LldArgs);
 
+  for (auto *Arg : Args.filtered(options::OPT_Xoffload_linker))
+LldArgs.push_back(Arg->getValue(1));
+
   LldArgs.append({"-o", Output.getFilename()});
   for (auto Input : Inputs)
 LldArgs.push_back(Input.getFilename());


Index: clang/test/Driver/hip-options.hip
===
--- clang/test/Driver/hip-options.hip
+++ clang/test/Driver/hip-options.hip
@@ -106,3 +106,13 @@
 // RUN:   --offload-arch=gfx906 -fopenmp -fopenmp-targets=amdgcn %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=OMPTGT %s
 // OMPTGT: unsupported option '-fopenmp-targets=' for language mode 'HIP'
+
+// Check -Xoffload-linker option is passed to lld.
+
+// RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
+// RUN:   --cuda-gpu-arch=gfx906 -fgpu-rdc -Xoffload-linker --build-id=md5 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=OFL-LINK %s
+// RUN: %clang -### --target=x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
+// RUN:   --cuda-gpu-arch=gfx906 -Xoffload-linker --build-id=md5 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=OFL-LINK %s
+// OFL-LINK: lld{{.*}}"--build-id=md5"
Index: clang/lib/Driver/ToolChains/HIPAMD.cpp
===
--- clang/lib/Driver/ToolChains/HIPAMD.cpp
+++ clang/lib/Driver/ToolChains/HIPAMD.cpp
@@ -147,6 +147,9 @@
 
   addLinkerCompressDebugSectionsOption(TC, Args, LldArgs);
 
+  for (auto *Arg : Args.filtered(options::OPT_Xoffload_linker))
+LldArgs.push_back(Arg->getValue(1));
+
   LldArgs.append({"-o", Output.getFilename()});
   for (auto Input : Inputs)
 LldArgs.push_back(Input.getFilename());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125847: LTO: Decide upfront whether to use opaque/non-opaque pointer types

2022-05-31 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/test/Driver/lto-no-opaque-pointers.c:2
+// UNSUPPORTED: enable-opaque-pointers
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto 2> %t
+// RUN: FileCheck %s < %t

-target is a legacy option. Use `--target=` for new tests.

No need to use check fd 2 (`2> %t`). There is sufficient coverage testing that 
the options are in fd 2.

Just use `2>&1 | FileCheck %s`.



Comment at: clang/test/Driver/lto-opaque-pointers.c:2
+// REQUIRES: enable-opaque-pointers
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto 2> %t
+// RUN: FileCheck %s < %t

ditto


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125847/new/

https://reviews.llvm.org/D125847

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125847: LTO: Decide upfront whether to use opaque/non-opaque pointer types

2022-05-31 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

> Adds -opaque-pointers/-no-opaque-pointers options to the gold plugin; 
> disabled by default.

`-plugin-opt=[no-]opaque-pointers`

> --opaque-pointers/--no-opaque-pointers options with 
> -plugin-opt=-opaque-pointers/-plugin-opt=-no-opaque-pointers aliases to lld; 
> disabled by default.

For such temporary options, don't add regular options. Just add 
`-plugin-opt=[no-]opaque-pointers`.

> Changes the clang driver to pass -plugin-opt=-opaque-pointers to the linker 
> in LTO modes when clang was configured with opaque pointers enabled by 
> default.

`-plugin-opt=no-opaque-pointers`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125847/new/

https://reviews.llvm.org/D125847

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126694: [C++20][Modules] Initial implementation of GMF decl elision.

2022-05-31 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added inline comments.



Comment at: clang/lib/Sema/Sema.cpp:1130
 DiagnoseUseOfUnimplementedSelectors();
 
+// For C++20 modules, we are permitted to elide decls in the Global

I prefer to wrap this logic to a function to make it easier to read.



Comment at: clang/lib/Sema/Sema.cpp:1131-1133
+// For C++20 modules, we are permitted to elide decls in the Global
+// Module Fragment of a module interface if they are unused in the body
+// of the interface.

I prefer to cite the standard. And the original comment looks not so right 
(since we don't and couldn't remove a declaration in GMF due to it is not used 
by the body of the interface)



Comment at: clang/lib/Sema/Sema.cpp:1138-1141
+  for (DeclContext::decl_iterator DI = DC->decls_begin(),
+  DEnd = DC->decls_end();
+   DI != DEnd; ++DI) {
+Decl *D = *DI;

Prefer range based loop.



Comment at: clang/lib/Sema/Sema.cpp:1142
+Decl *D = *DI;
+Module *M;
+if (D->isImplicit() || !isa(D))

We could sink the declaration of M to its definition.



Comment at: clang/lib/Sema/Sema.cpp:1146
+M = D->getOwningModule();
+if (!M || !D->getOwningModule()->isGlobalModule())
+  continue;

`M == GlobalModuleFragment` says that M is a global module fragment in the 
current TU explicitly. The original implementation doesn't check if M is in the 
current TU or not.



Comment at: clang/lib/Sema/Sema.cpp:1150
+  continue;
+if (!D->isUsed(false) && !D->isReferenced())
+  WorkList.push_back(D);

Should we check for `D->isUsed()` simply? It looks more straight forward to me.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126694/new/

https://reviews.llvm.org/D126694

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126681: [HIP] Fix static lib name on windows

2022-05-31 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
yaxunl marked an inline comment as done.
Closed by commit rG377806a65ea9: [HIP] Fix static lib name on windows (authored 
by yaxunl).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D126681?vs=432996=433273#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126681/new/

https://reviews.llvm.org/D126681

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/hip-link-bundle-archive.hip


Index: clang/test/Driver/hip-link-bundle-archive.hip
===
--- clang/test/Driver/hip-link-bundle-archive.hip
+++ clang/test/Driver/hip-link-bundle-archive.hip
@@ -1,14 +1,28 @@
 // REQUIRES: x86-registered-target, amdgpu-registered-target
 
-// RUN: touch %T/libhipBundled.a
 
 // Check clang unbundle the archive and link them by lld.
 
+// RUN: touch %T/libhipBundled.a
 // RUN: %clang -### --offload-arch=gfx906 --offload-arch=gfx1030 \
+// RUN:   -target x86_64-unknown-linux-gnu \
 // RUN:   -nogpulib %s -fgpu-rdc -L%T -lhipBundled \
-// RUN:   2>&1 | FileCheck -check-prefix=CHECK %s
+// RUN:   2>&1 | FileCheck -check-prefix=GNU %s
+
+// RUN: touch %T/hipBundled2.lib
+// RUN: %clang -### --offload-arch=gfx906 --offload-arch=gfx1030 \
+// RUN:   -target x86_64-pc-windows-msvc \
+// RUN:   -nogpulib %s -fgpu-rdc -L%T -lhipBundled2 \
+// RUN:   2>&1 | FileCheck -check-prefix=MSVC %s
+
+// GNU: "{{.*}}clang-offload-bundler" "-unbundle" "-type=a" 
"-input={{.*}}libhipBundled.a" "-targets=hip-amdgcn-amd-amdhsa-gfx1030" 
"-output=[[A1030:.*\.a]]" "-allow-missing-bundles"
+// GNU: "{{.*}}lld{{.*}}" {{.*}}"-plugin-opt=mcpu=gfx1030" {{.*}} "[[A1030]]"
+// GNU: "{{.*}}clang-offload-bundler" "-unbundle" "-type=a" 
"-input={{.*}}libhipBundled.a" "-targets=hip-amdgcn-amd-amdhsa-gfx906" 
"-output=[[A906:.*\.a]]" "-allow-missing-bundles"
+// GNU: "{{.*}}lld{{.*}}" {{.*}}"-plugin-opt=mcpu=gfx906" {{.*}} "[[A906]]"
+// GNU: "{{.*}}ld{{.*}}" {{.*}}"-o" "a.out" {{.*}}"-lhipBundled"
 
-// CHECK: "{{.*}}clang-offload-bundler" "-unbundle" "-type=a" 
"-input={{.*}}libhipBundled.a" "-targets=hip-amdgcn-amd-amdhsa-gfx1030" 
"-output=[[A1030:.*\.a]]" "-allow-missing-bundles"
-// CHECK: "{{.*}}lld{{.*}}" {{.*}}"-plugin-opt=mcpu=gfx1030" {{.*}} "[[A1030]]"
-// CHECK: "{{.*}}clang-offload-bundler" "-unbundle" "-type=a" 
"-input={{.*}}libhipBundled.a" "-targets=hip-amdgcn-amd-amdhsa-gfx906" 
"-output=[[A906:.*\.a]]" "-allow-missing-bundles"
-// CHECK: "{{.*}}lld{{.*}}" {{.*}}"-plugin-opt=mcpu=gfx906" {{.*}} "[[A906]]"
+// MSVC: "{{.*}}clang-offload-bundler" "-unbundle" "-type=a" 
"-input={{.*}}hipBundled2.lib" "-targets=hip-amdgcn-amd-amdhsa-gfx1030" 
"-output=[[A1030:.*\.a]]" "-allow-missing-bundles"
+// MSVC: "{{.*}}lld{{.*}}" {{.*}}"-plugin-opt=mcpu=gfx1030" {{.*}} "[[A1030]]"
+// MSVC: "{{.*}}clang-offload-bundler" "-unbundle" "-type=a" 
"-input={{.*}}hipBundled2.lib" "-targets=hip-amdgcn-amd-amdhsa-gfx906" 
"-output=[[A906:.*\.a]]" "-allow-missing-bundles"
+// MSVC: "{{.*}}lld{{.*}}" {{.*}}"-plugin-opt=mcpu=gfx906" {{.*}} "[[A906]]"
+// MSVC: "{{.*}}link{{.*}}" {{.*}}"-out:a.exe" {{.*}}"hipBundled2.lib"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1782,8 +1782,13 @@
   for (auto LPath : LibraryPaths) {
 ArchiveOfBundles.clear();
 
-AOBFileNames.push_back(Twine(LPath + "/libdevice/lib" + Lib + ".a").str());
-AOBFileNames.push_back(Twine(LPath + "/lib" + Lib + ".a").str());
+llvm::Triple Triple(D.getTargetTriple());
+bool IsMSVC = Triple.isWindowsMSVCEnvironment();
+for (auto Prefix : {"/libdevice/", "/"}) {
+  if (IsMSVC)
+AOBFileNames.push_back(Twine(LPath + Prefix + Lib + ".lib").str());
+  AOBFileNames.push_back(Twine(LPath + Prefix + "lib" + Lib + ".a").str());
+}
 
 for (auto AOB : AOBFileNames) {
   if (llvm::sys::fs::exists(AOB)) {


Index: clang/test/Driver/hip-link-bundle-archive.hip
===
--- clang/test/Driver/hip-link-bundle-archive.hip
+++ clang/test/Driver/hip-link-bundle-archive.hip
@@ -1,14 +1,28 @@
 // REQUIRES: x86-registered-target, amdgpu-registered-target
 
-// RUN: touch %T/libhipBundled.a
 
 // Check clang unbundle the archive and link them by lld.
 
+// RUN: touch %T/libhipBundled.a
 // RUN: %clang -### --offload-arch=gfx906 --offload-arch=gfx1030 \
+// RUN:   -target x86_64-unknown-linux-gnu \
 // RUN:   -nogpulib %s -fgpu-rdc -L%T -lhipBundled \
-// RUN:   2>&1 | FileCheck -check-prefix=CHECK %s
+// RUN:   2>&1 | FileCheck -check-prefix=GNU %s
+
+// RUN: touch %T/hipBundled2.lib
+// RUN: %clang -### --offload-arch=gfx906 --offload-arch=gfx1030 \
+// RUN:   -target x86_64-pc-windows-msvc \
+// RUN:   -nogpulib %s 

[clang] 377806a - [HIP] Fix static lib name on windows

2022-05-31 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2022-05-31T22:13:50-04:00
New Revision: 377806a65ea97837c99d9791db9d462b63b9135a

URL: 
https://github.com/llvm/llvm-project/commit/377806a65ea97837c99d9791db9d462b63b9135a
DIFF: 
https://github.com/llvm/llvm-project/commit/377806a65ea97837c99d9791db9d462b63b9135a.diff

LOG: [HIP] Fix static lib name on windows

clang by default assumes static library name to be xxx.lib
when -lxxx is specified on Windows with MSVC environment,
instead of libxxx.a.

This patch fixes static device library unbundling for that.
It falls back to libxxx.a if xxx.lib is not found.

Reviewed by: Artem Belevich

Differential Revision: https://reviews.llvm.org/D126681

Added: 


Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/hip-link-bundle-archive.hip

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 45add8ad94a5..7a22ac4afa7e 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1782,8 +1782,13 @@ bool tools::GetSDLFromOffloadArchive(
   for (auto LPath : LibraryPaths) {
 ArchiveOfBundles.clear();
 
-AOBFileNames.push_back(Twine(LPath + "/libdevice/lib" + Lib + ".a").str());
-AOBFileNames.push_back(Twine(LPath + "/lib" + Lib + ".a").str());
+llvm::Triple Triple(D.getTargetTriple());
+bool IsMSVC = Triple.isWindowsMSVCEnvironment();
+for (auto Prefix : {"/libdevice/", "/"}) {
+  if (IsMSVC)
+AOBFileNames.push_back(Twine(LPath + Prefix + Lib + ".lib").str());
+  AOBFileNames.push_back(Twine(LPath + Prefix + "lib" + Lib + ".a").str());
+}
 
 for (auto AOB : AOBFileNames) {
   if (llvm::sys::fs::exists(AOB)) {

diff  --git a/clang/test/Driver/hip-link-bundle-archive.hip 
b/clang/test/Driver/hip-link-bundle-archive.hip
index 641bf59b6346..7ffe135405da 100644
--- a/clang/test/Driver/hip-link-bundle-archive.hip
+++ b/clang/test/Driver/hip-link-bundle-archive.hip
@@ -1,14 +1,28 @@
 // REQUIRES: x86-registered-target, amdgpu-registered-target
 
-// RUN: touch %T/libhipBundled.a
 
 // Check clang unbundle the archive and link them by lld.
 
+// RUN: touch %T/libhipBundled.a
 // RUN: %clang -### --offload-arch=gfx906 --offload-arch=gfx1030 \
+// RUN:   -target x86_64-unknown-linux-gnu \
 // RUN:   -nogpulib %s -fgpu-rdc -L%T -lhipBundled \
-// RUN:   2>&1 | FileCheck -check-prefix=CHECK %s
+// RUN:   2>&1 | FileCheck -check-prefix=GNU %s
+
+// RUN: touch %T/hipBundled2.lib
+// RUN: %clang -### --offload-arch=gfx906 --offload-arch=gfx1030 \
+// RUN:   -target x86_64-pc-windows-msvc \
+// RUN:   -nogpulib %s -fgpu-rdc -L%T -lhipBundled2 \
+// RUN:   2>&1 | FileCheck -check-prefix=MSVC %s
+
+// GNU: "{{.*}}clang-offload-bundler" "-unbundle" "-type=a" 
"-input={{.*}}libhipBundled.a" "-targets=hip-amdgcn-amd-amdhsa-gfx1030" 
"-output=[[A1030:.*\.a]]" "-allow-missing-bundles"
+// GNU: "{{.*}}lld{{.*}}" {{.*}}"-plugin-opt=mcpu=gfx1030" {{.*}} "[[A1030]]"
+// GNU: "{{.*}}clang-offload-bundler" "-unbundle" "-type=a" 
"-input={{.*}}libhipBundled.a" "-targets=hip-amdgcn-amd-amdhsa-gfx906" 
"-output=[[A906:.*\.a]]" "-allow-missing-bundles"
+// GNU: "{{.*}}lld{{.*}}" {{.*}}"-plugin-opt=mcpu=gfx906" {{.*}} "[[A906]]"
+// GNU: "{{.*}}ld{{.*}}" {{.*}}"-o" "a.out" {{.*}}"-lhipBundled"
 
-// CHECK: "{{.*}}clang-offload-bundler" "-unbundle" "-type=a" 
"-input={{.*}}libhipBundled.a" "-targets=hip-amdgcn-amd-amdhsa-gfx1030" 
"-output=[[A1030:.*\.a]]" "-allow-missing-bundles"
-// CHECK: "{{.*}}lld{{.*}}" {{.*}}"-plugin-opt=mcpu=gfx1030" {{.*}} "[[A1030]]"
-// CHECK: "{{.*}}clang-offload-bundler" "-unbundle" "-type=a" 
"-input={{.*}}libhipBundled.a" "-targets=hip-amdgcn-amd-amdhsa-gfx906" 
"-output=[[A906:.*\.a]]" "-allow-missing-bundles"
-// CHECK: "{{.*}}lld{{.*}}" {{.*}}"-plugin-opt=mcpu=gfx906" {{.*}} "[[A906]]"
+// MSVC: "{{.*}}clang-offload-bundler" "-unbundle" "-type=a" 
"-input={{.*}}hipBundled2.lib" "-targets=hip-amdgcn-amd-amdhsa-gfx1030" 
"-output=[[A1030:.*\.a]]" "-allow-missing-bundles"
+// MSVC: "{{.*}}lld{{.*}}" {{.*}}"-plugin-opt=mcpu=gfx1030" {{.*}} "[[A1030]]"
+// MSVC: "{{.*}}clang-offload-bundler" "-unbundle" "-type=a" 
"-input={{.*}}hipBundled2.lib" "-targets=hip-amdgcn-amd-amdhsa-gfx906" 
"-output=[[A906:.*\.a]]" "-allow-missing-bundles"
+// MSVC: "{{.*}}lld{{.*}}" {{.*}}"-plugin-opt=mcpu=gfx906" {{.*}} "[[A906]]"
+// MSVC: "{{.*}}link{{.*}}" {{.*}}"-out:a.exe" {{.*}}"hipBundled2.lib"



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126691: ASTContext: Provide a query for module initializer contents.

2022-05-31 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu accepted this revision.
ChuanqiXu added a comment.
This revision is now accepted and ready to land.

LGTM with a nits.




Comment at: clang/include/clang/AST/ASTContext.h:1083
+  /// Does the module initializer array contain this decl.
+  bool moduleInitializerContains(Module *M, const Decl *D);
+

Nit: It looks better with `containsModuleInitializer`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126691/new/

https://reviews.llvm.org/D126691

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D120484: More explicit message when failing to find a mandatory cfi ressource file

2022-05-31 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added inline comments.
This revision is now accepted and ready to land.
Herald added a subscriber: StephenFan.



Comment at: clang/include/clang/Basic/DiagnosticDriverKinds.td:216
+def err_drv_missing_sanitizer_ignorelist : Error<
+  "missing required sanitizer ignorelist: '%0'">;
 def err_drv_malformed_sanitizer_ignorelist : Error<

missing sanitizer ignorelist:


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D120484/new/

https://reviews.llvm.org/D120484

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126189: [C++20][Modules] Build module static initializers per P1874R1.

2022-05-31 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu accepted this revision.
ChuanqiXu added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126189/new/

https://reviews.llvm.org/D126189

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126137: [X86] Add support for `-mharden-sls=[none|all|return|indirect-jmp]`

2022-05-31 Thread Phoebe Wang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa2ea5b496bcd: [X86] Add support for 
`-mharden-sls=[none|all|return|indirect-jmp]` (authored by pengfei).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126137/new/

https://reviews.llvm.org/D126137

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/X86.cpp
  clang/test/Driver/x86-target-features.c
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86AsmPrinter.cpp
  llvm/lib/Target/X86/X86AsmPrinter.h
  llvm/test/CodeGen/X86/speculation-hardening-sls.ll

Index: llvm/test/CodeGen/X86/speculation-hardening-sls.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/speculation-hardening-sls.ll
@@ -0,0 +1,97 @@
+; RUN: llc -mattr=harden-sls-ret -mtriple=x86_64-unknown-unknown < %s | FileCheck %s -check-prefixes=CHECK,RET
+; RUN: llc -mattr=harden-sls-ijmp -mtriple=x86_64-unknown-unknown < %s | FileCheck %s -check-prefixes=CHECK,IJMP
+
+define dso_local i32 @double_return(i32 %a, i32 %b) local_unnamed_addr {
+; CHECK-LABEL: double_return:
+; CHECK: jle
+; CHECK-NOT: int3
+; CHECK: retq
+; RET-NEXT:  int3
+; IJMP-NOT:  int3
+; CHECK: retq
+; RET-NEXT:  int3
+; IJMP-NOT:  int3
+entry:
+  %cmp = icmp sgt i32 %a, 0
+  br i1 %cmp, label %if.then, label %if.else
+
+if.then:  ; preds = %entry
+  %div = sdiv i32 %a, %b
+  ret i32 %div
+
+if.else:  ; preds = %entry
+  %div1 = sdiv i32 %b, %a
+  ret i32 %div1
+}
+
+@__const.indirect_branch.ptr = private unnamed_addr constant [2 x i8*] [i8* blockaddress(@indirect_branch, %return), i8* blockaddress(@indirect_branch, %l2)], align 8
+
+; Function Attrs: norecurse nounwind readnone
+define dso_local i32 @indirect_branch(i32 %a, i32 %b, i32 %i) {
+; CHECK-LABEL: indirect_branch:
+; CHECK: jmpq *
+; RET-NOT:   int3
+; IJMP-NEXT: int3
+; CHECK: retq
+; RET-NEXT:  int3
+; IJMP-NOT:  int3
+; CHECK: retq
+; RET-NEXT:  int3
+; IJMP-NOT:  int3
+entry:
+  %idxprom = sext i32 %i to i64
+  %arrayidx = getelementptr inbounds [2 x i8*], [2 x i8*]* @__const.indirect_branch.ptr, i64 0, i64 %idxprom
+  %0 = load i8*, i8** %arrayidx, align 8
+  indirectbr i8* %0, [label %return, label %l2]
+
+l2:   ; preds = %entry
+  br label %return
+
+return:   ; preds = %entry, %l2
+  %retval.0 = phi i32 [ 1, %l2 ], [ 0, %entry ]
+  ret i32 %retval.0
+}
+
+define i32 @asmgoto() {
+; CHECK-LABEL: asmgoto:
+; CHECK:   # %bb.0: # %entry
+; CHECK: jmp .L
+; CHECK-NOT: int3
+; CHECK: retq
+; RET-NEXT:  int3
+; IJMP-NOT:  int3
+; CHECK: retq
+; RET-NEXT:  int3
+; IJMP-NOT:  int3
+entry:
+  callbr void asm sideeffect "jmp $0", "X"(i8* blockaddress(@asmgoto, %d))
+to label %asm.fallthrough [label %d]
+ ; The asm goto above produces a direct branch:
+
+asm.fallthrough:   ; preds = %entry
+  ret i32 0
+
+d: ; preds = %asm.fallthrough, %entry
+  ret i32 1
+}
+
+define void @bar(void ()* %0) {
+; CHECK-LABEL: bar:
+; CHECK: jmpq *
+; RET-NOT:   int3
+; IJMP-NEXT: int3
+; CHECK-NOT: ret
+  tail call void %0()
+  ret void
+}
+
+declare dso_local void @foo()
+
+define dso_local void @bar2() {
+; CHECK-LABEL: bar2:
+; CHECK: jmp foo
+; CHECK-NOT: int3
+; CHECK-NOT: ret
+  tail call void @foo()
+  ret void
+}
Index: llvm/lib/Target/X86/X86AsmPrinter.h
===
--- llvm/lib/Target/X86/X86AsmPrinter.h
+++ llvm/lib/Target/X86/X86AsmPrinter.h
@@ -131,10 +131,7 @@
 
   void emitInstruction(const MachineInstr *MI) override;
 
-  void emitBasicBlockEnd(const MachineBasicBlock ) override {
-AsmPrinter::emitBasicBlockEnd(MBB);
-SMShadowTracker.emitShadowPadding(*OutStreamer, getSubtargetInfo());
-  }
+  void emitBasicBlockEnd(const MachineBasicBlock ) override;
 
   bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
const char *ExtraCode, raw_ostream ) override;
Index: llvm/lib/Target/X86/X86AsmPrinter.cpp
===
--- llvm/lib/Target/X86/X86AsmPrinter.cpp
+++ llvm/lib/Target/X86/X86AsmPrinter.cpp
@@ -336,6 +336,37 @@
   }
 }
 
+static bool isSimpleReturn(const MachineInstr ) {
+  // We exclude all tail calls here which set both isReturn and isCall.
+  return MI.getDesc().isReturn() && !MI.getDesc().isCall();
+}
+
+static bool isIndirectBranchOrTailCall(const MachineInstr ) {
+  unsigned Opc = MI.getOpcode();
+  return MI.getDesc().isIndirectBranch() /*Make below code in a good shape*/ ||
+ Opc == X86::TAILJMPr || Opc == 

[clang] a2ea5b4 - [X86] Add support for `-mharden-sls=[none|all|return|indirect-jmp]`

2022-05-31 Thread Phoebe Wang via cfe-commits

Author: Phoebe Wang
Date: 2022-06-01T09:45:04+08:00
New Revision: a2ea5b496bcd3762f96c38a09db1d38729fa6325

URL: 
https://github.com/llvm/llvm-project/commit/a2ea5b496bcd3762f96c38a09db1d38729fa6325
DIFF: 
https://github.com/llvm/llvm-project/commit/a2ea5b496bcd3762f96c38a09db1d38729fa6325.diff

LOG: [X86] Add support for `-mharden-sls=[none|all|return|indirect-jmp]`

The patch addresses the feature request from 
https://github.com/ClangBuiltLinux/linux/issues/1633. The implementation 
borrows a lot from aarch64.

Reviewed By: nickdesaulniers, MaskRay

Differential Revision: https://reviews.llvm.org/D126137

Added: 
llvm/test/CodeGen/X86/speculation-hardening-sls.ll

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Arch/X86.cpp
clang/test/Driver/x86-target-features.c
llvm/lib/Target/X86/X86.td
llvm/lib/Target/X86/X86AsmPrinter.cpp
llvm/lib/Target/X86/X86AsmPrinter.h

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index c34d29c8762d..6453f4b302d8 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -449,6 +449,9 @@ CUDA Support in Clang
 X86 Support in Clang
 
 
+- Support ``-mharden-sls=[none|all|return|indirect-jmp]`` for straight-line
+  speculation hardening.
+
 DWARF Support in Clang
 --
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index a7622e0c9976..074dc56f2aa2 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3525,7 +3525,10 @@ def mbranch_protection_EQ : Joined<["-"], 
"mbranch-protection=">,
   HelpText<"Enforce targets of indirect branches and function returns">;
 
 def mharden_sls_EQ : Joined<["-"], "mharden-sls=">,
-  HelpText<"Select straight-line speculation hardening scope">;
+  HelpText<"Select straight-line speculation hardening scope (ARM/AArch64/X86"
+   " only).  must be: all, none, retbr(ARM/AArch64),"
+   " blr(ARM/AArch64), comdat(ARM/AArch64), nocomdat(ARM/AArch64),"
+   " return(X86), indirect-jmp(X86)">;
 
 def msimd128 : Flag<["-"], "msimd128">, Group;
 def mno_simd128 : Flag<["-"], "mno-simd128">, Group;

diff  --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp 
b/clang/lib/Driver/ToolChains/Arch/X86.cpp
index 993e13fdac30..cd7c014faa5e 100644
--- a/clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -246,4 +246,20 @@ void x86::getX86TargetFeatures(const Driver , const 
llvm::Triple ,
   Name = Name.substr(3);
 Features.push_back(Args.MakeArgString((IsNegative ? "-" : "+") + Name));
   }
+
+  // Enable/disable straight line speculation hardening.
+  if (Arg *A = Args.getLastArg(options::OPT_mharden_sls_EQ)) {
+StringRef Scope = A->getValue();
+if (Scope == "all") {
+  Features.push_back("+harden-sls-ijmp");
+  Features.push_back("+harden-sls-ret");
+} else if (Scope == "return") {
+  Features.push_back("+harden-sls-ret");
+} else if (Scope == "indirect-jmp") {
+  Features.push_back("+harden-sls-ijmp");
+} else if (Scope != "none") {
+  D.Diag(diag::err_drv_unsupported_option_argument)
+  << A->getOption().getName() << Scope;
+}
+  }
 }

diff  --git a/clang/test/Driver/x86-target-features.c 
b/clang/test/Driver/x86-target-features.c
index 09c17aceaa4d..453656a1b98f 100644
--- a/clang/test/Driver/x86-target-features.c
+++ b/clang/test/Driver/x86-target-features.c
@@ -304,3 +304,14 @@
 // RUN: %clang --target=i386 -march=i386 -mno-crc32 %s -### 2>&1 | FileCheck 
-check-prefix=NO-CRC32 %s
 // CRC32: "-target-feature" "+crc32"
 // NO-CRC32: "-target-feature" "-crc32"
+
+// RUN: %clang --target=i386 -march=i386 -mharden-sls=return %s -### -o %t.o 
2>&1 | FileCheck -check-prefixes=SLS-RET,NO-SLS %s
+// RUN: %clang --target=i386 -march=i386 -mharden-sls=indirect-jmp %s -### -o 
%t.o 2>&1 | FileCheck -check-prefixes=SLS-IJMP,NO-SLS %s
+// RUN: %clang --target=i386 -march=i386 -mharden-sls=none -mharden-sls=all %s 
-### -o %t.o 2>&1 | FileCheck -check-prefixes=SLS-IJMP,SLS-RET %s
+// RUN: %clang --target=i386 -march=i386 -mharden-sls=all -mharden-sls=none %s 
-### -o %t.o 2>&1 | FileCheck -check-prefix=NO-SLS %s
+// RUN: %clang --target=i386 -march=i386 -mharden-sls=return,indirect-jmp %s 
-### -o %t.o 2>&1 | FileCheck -check-prefix=BAD-SLS %s
+// NO-SLS-NOT: "+harden-sls-
+// SLS-RET-DAG: "-target-feature" "+harden-sls-ret"
+// SLS-IJMP-DAG: "-target-feature" "+harden-sls-ijmp"
+// NO-SLS-NOT: "+harden-sls-
+// BAD-SLS: unsupported argument '{{[^']+}}' to option '-mharden-sls='

diff  --git a/llvm/lib/Target/X86/X86.td b/llvm/lib/Target/X86/X86.td
index 0634194b2c4e..a5c6b40c493c 100644
--- a/llvm/lib/Target/X86/X86.td
+++ b/llvm/lib/Target/X86/X86.td
@@ -382,6 +382,17 @@ def FeatureTaggedGlobals
 

[PATCH] D126749: [RISCV][Clang] Support policy functions for Vector Mask Instructions.

2022-05-31 Thread Zakk Chen via Phabricator via cfe-commits
khchen created this revision.
khchen added reviewers: craig.topper, rogfer01, kito-cheng, fakepaper56, eopXD.
Herald added subscribers: sunshaoce, VincentWu, luke957, StephenFan, vkmr, 
frasercrmck, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, 
benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, edward-jones, 
zzheng, jrtc27, shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, 
arichardson.
Herald added a project: All.
khchen requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, MaskRay.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126749

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vid.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/viota.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmsbf.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmsif.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmsof.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vid.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/viota.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmsbf.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmsif.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmsof.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics/vmsof.c
===
--- clang/test/CodeGen/RISCV/rvv-intrinsics/vmsof.c
+++ clang/test/CodeGen/RISCV/rvv-intrinsics/vmsof.c
@@ -136,3 +136,21 @@
  size_t vl) {
   return vmsof_m_b64_m(mask, maskedoff, op1, vl);
 }
+
+// CHECK-RV64-LABEL: @test_vmsof_m_b4_ma(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmsof.mask.nxv16i1.i64( undef,  [[OP1:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vbool4_t test_vmsof_m_b4_ma(vbool4_t mask, vbool4_t op1, size_t vl) {
+  return vmsof_m_b4_ma(mask, op1, vl);
+}
+
+// CHECK-RV64-LABEL: @test_vmsof_m_b4_mu(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmsof.mask.nxv16i1.i64( [[MERGE:%.*]],  [[OP1:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vbool4_t test_vmsof_m_b4_mu(vbool4_t mask, vbool4_t merge, vbool4_t op1, size_t vl) {
+  return vmsof_m_b4_mu(mask, merge, op1, vl);
+}
Index: clang/test/CodeGen/RISCV/rvv-intrinsics/vmsif.c
===
--- clang/test/CodeGen/RISCV/rvv-intrinsics/vmsif.c
+++ clang/test/CodeGen/RISCV/rvv-intrinsics/vmsif.c
@@ -136,3 +136,21 @@
  size_t vl) {
   return vmsif_m_b64_m(mask, maskedoff, op1, vl);
 }
+
+// CHECK-RV64-LABEL: @test_vmsif_m_b4_ma(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmsif.mask.nxv16i1.i64( undef,  [[OP1:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vbool4_t test_vmsif_m_b4_ma(vbool4_t mask, vbool4_t op1, size_t vl) {
+  return vmsif_m_b4_ma(mask, op1, vl);
+}
+
+// CHECK-RV64-LABEL: @test_vmsif_m_b4_mu(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmsif.mask.nxv16i1.i64( [[MERGE:%.*]],  [[OP1:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vbool4_t test_vmsif_m_b4_mu(vbool4_t mask, vbool4_t merge, vbool4_t op1, size_t vl) {
+  return vmsif_m_b4_mu(mask, merge, op1, vl);
+}
Index: clang/test/CodeGen/RISCV/rvv-intrinsics/vmsbf.c
===
--- clang/test/CodeGen/RISCV/rvv-intrinsics/vmsbf.c
+++ clang/test/CodeGen/RISCV/rvv-intrinsics/vmsbf.c
@@ -136,3 +136,21 @@
  size_t vl) {
   return vmsbf_m_b64_m(mask, maskedoff, op1, vl);
 }
+
+// CHECK-RV64-LABEL: @test_vmsbf_m_b4_ma(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmsbf.mask.nxv16i1.i64( undef,  [[OP1:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vbool4_t test_vmsbf_m_b4_ma(vbool4_t mask, vbool4_t op1, size_t vl) {
+  return vmsbf_m_b4_ma(mask, op1, vl);
+}
+
+// CHECK-RV64-LABEL: @test_vmsbf_m_b4_mu(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmsbf.mask.nxv16i1.i64( [[MERGE:%.*]],  [[OP1:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vbool4_t test_vmsbf_m_b4_mu(vbool4_t mask, vbool4_t merge, vbool4_t op1, size_t vl) {
+  return vmsbf_m_b4_mu(mask, merge, op1, vl);
+}
Index: clang/test/CodeGen/RISCV/rvv-intrinsics/viota.c
===
--- clang/test/CodeGen/RISCV/rvv-intrinsics/viota.c
+++ clang/test/CodeGen/RISCV/rvv-intrinsics/viota.c
@@ -204,7 +204,7 @@
 
 // CHECK-RV64-LABEL: @test_viota_m_u8mf8_m(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.viota.mask.nxv1i8.i64( 

[PATCH] D126748: [RISCV][Clang] Support policy functions for Vector Reduction Instructions.

2022-05-31 Thread Zakk Chen via Phabricator via cfe-commits
khchen created this revision.
khchen added reviewers: craig.topper, rogfer01, kito-cheng, fakepaper56, eopXD.
Herald added subscribers: sunshaoce, VincentWu, luke957, StephenFan, vkmr, 
frasercrmck, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, 
benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, edward-jones, 
zzheng, jrtc27, shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, 
arichardson.
Herald added a project: All.
khchen requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, MaskRay.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126748

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfredmax.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfredmin.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfredsum.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwredsum.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vredand.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vredmax.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vredmin.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vredor.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vredsum.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vredxor.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vwredsum.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfredmax.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfredmin.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfredsum.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfwredsum.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vredand.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vredmax.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vredmin.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vredor.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vredsum.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vredxor.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vwredsum.c
  clang/utils/TableGen/RISCVVEmitter.cpp

Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -169,6 +169,9 @@
   if (RVVI->hasMaskedOffOperand() &&
   RVVI->getDefaultPolicy() == Policy::TAMA)
 OS << "  Ops.insert(Ops.begin(), llvm::UndefValue::get(ResultType));\n";
+  if (!RVVI->hasMaskedOffOperand() && RVVI->hasPassthruOperand() &&
+  RVVI->getDefaultPolicy() == Policy::TAMA)
+OS << "  Ops.insert(Ops.begin(), llvm::UndefValue::get(ResultType));\n";
 } else {
   OS << "  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end());\n";
 }
Index: clang/test/CodeGen/RISCV/rvv-intrinsics/vwredsum.c
===
--- clang/test/CodeGen/RISCV/rvv-intrinsics/vwredsum.c
+++ clang/test/CodeGen/RISCV/rvv-intrinsics/vwredsum.c
@@ -759,3 +759,75 @@
 vuint64m1_t scalar, size_t vl) {
   return vwredsumu_vs_u32m8_u64m1_m(mask, dst, vector, scalar, vl);
 }
+
+// CHECK-RV64-LABEL: @test_vwredsum_vs_i32mf2_i64m1_tu(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vwredsum.nxv1i64.nxv1i32.i64( [[MERGE:%.*]],  [[VECTOR:%.*]],  [[SCALAR:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vint64m1_t test_vwredsum_vs_i32mf2_i64m1_tu(vint64m1_t merge, vint32mf2_t vector, vint64m1_t scalar, size_t vl) {
+  return vwredsum_vs_i32mf2_i64m1_tu(merge, vector, scalar, vl);
+}
+
+// CHECK-RV64-LABEL: @test_vwredsumu_vs_u32mf2_u64m1_tu(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vwredsumu.nxv1i64.nxv1i32.i64( [[MERGE:%.*]],  [[VECTOR:%.*]],  [[SCALAR:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vuint64m1_t test_vwredsumu_vs_u32mf2_u64m1_tu(vuint64m1_t merge, vuint32mf2_t vector, vuint64m1_t scalar, size_t vl) {
+  return vwredsumu_vs_u32mf2_u64m1_tu(merge, vector, scalar, vl);
+}
+
+// CHECK-RV64-LABEL: @test_vwredsum_vs_i32mf2_i64m1_ta(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vwredsum.nxv1i64.nxv1i32.i64( undef,  [[VECTOR:%.*]],  [[SCALAR:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vint64m1_t test_vwredsum_vs_i32mf2_i64m1_ta(vint32mf2_t vector, vint64m1_t scalar, size_t vl) {
+  return vwredsum_vs_i32mf2_i64m1_ta(vector, scalar, vl);
+}
+
+// CHECK-RV64-LABEL: @test_vwredsumu_vs_u32mf2_u64m1_ta(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vwredsumu.nxv1i64.nxv1i32.i64( undef,  [[VECTOR:%.*]],  [[SCALAR:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vuint64m1_t test_vwredsumu_vs_u32mf2_u64m1_ta(vuint32mf2_t vector, vuint64m1_t scalar, size_t vl) {
+  return vwredsumu_vs_u32mf2_u64m1_ta(vector, scalar, 

[PATCH] D126746: [RISCV][Clang] Support policy functions for Vector Comparison Instructions.

2022-05-31 Thread Zakk Chen via Phabricator via cfe-commits
khchen created this revision.
khchen added reviewers: craig.topper, rogfer01, kito-cheng, fakepaper56, eopXD.
Herald added subscribers: sunshaoce, VincentWu, luke957, StephenFan, vkmr, 
frasercrmck, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, 
benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, edward-jones, 
zzheng, jrtc27, shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, 
arichardson.
Herald added a project: All.
khchen requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, MaskRay.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126746

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmfeq.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmfge.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmfgt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmfle.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmflt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmfne.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmseq.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmsge.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmsgt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmsle.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmslt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmsne.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmfeq.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmfge.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmfgt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmfle.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmflt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmfne.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmseq.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmsge.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmsgt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmsle.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmslt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmsne.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics/vmsne.c
===
--- clang/test/CodeGen/RISCV/rvv-intrinsics/vmsne.c
+++ clang/test/CodeGen/RISCV/rvv-intrinsics/vmsne.c
@@ -1699,3 +1699,75 @@
   vuint64m8_t op1, uint64_t op2, size_t vl) {
   return vmsne_vx_u64m8_b8_m(mask, maskedoff, op1, op2, vl);
 }
+
+// CHECK-RV64-LABEL: @test_vmsne_vv_i32mf2_b64_ma(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmsne.mask.nxv1i32.nxv1i32.i64( undef,  [[OP1:%.*]],  [[OP2:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vbool64_t test_vmsne_vv_i32mf2_b64_ma (vbool64_t mask, vint32mf2_t op1, vint32mf2_t op2, size_t vl) {
+  return vmsne_vv_i32mf2_b64_ma(mask, op1, op2, vl);
+}
+
+// CHECK-RV64-LABEL: @test_vmsne_vx_i32mf2_b64_ma(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmsne.mask.nxv1i32.i32.i64( undef,  [[OP1:%.*]], i32 [[OP2:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vbool64_t test_vmsne_vx_i32mf2_b64_ma (vbool64_t mask, vint32mf2_t op1, int32_t op2, size_t vl) {
+  return vmsne_vx_i32mf2_b64_ma(mask, op1, op2, vl);
+}
+
+// CHECK-RV64-LABEL: @test_vmsne_vv_u32mf2_b64_ma(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmsne.mask.nxv1i32.nxv1i32.i64( undef,  [[OP1:%.*]],  [[OP2:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vbool64_t test_vmsne_vv_u32mf2_b64_ma (vbool64_t mask, vuint32mf2_t op1, vuint32mf2_t op2, size_t vl) {
+  return vmsne_vv_u32mf2_b64_ma(mask, op1, op2, vl);
+}
+
+// CHECK-RV64-LABEL: @test_vmsne_vx_u32mf2_b64_ma(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmsne.mask.nxv1i32.i32.i64( undef,  [[OP1:%.*]], i32 [[OP2:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vbool64_t test_vmsne_vx_u32mf2_b64_ma (vbool64_t mask, vuint32mf2_t op1, uint32_t op2, size_t vl) {
+  return vmsne_vx_u32mf2_b64_ma(mask, op1, op2, vl);
+}
+
+// CHECK-RV64-LABEL: @test_vmsne_vv_i32mf2_b64_mu(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmsne.mask.nxv1i32.nxv1i32.i64( [[MERGE:%.*]],  [[OP1:%.*]],  [[OP2:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vbool64_t test_vmsne_vv_i32mf2_b64_mu (vbool64_t mask, vbool64_t merge, vint32mf2_t op1, vint32mf2_t op2, size_t vl) {
+  return vmsne_vv_i32mf2_b64_mu(mask, merge, op1, op2, vl);
+}
+
+// CHECK-RV64-LABEL: @test_vmsne_vx_i32mf2_b64_mu(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmsne.mask.nxv1i32.i32.i64( [[MERGE:%.*]],  [[OP1:%.*]], i32 [[OP2:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vbool64_t 

[PATCH] D126745: [RISCV][Clang] Support policy functions for vmerge, vfmerge and vcompress.

2022-05-31 Thread Zakk Chen via Phabricator via cfe-commits
khchen created this revision.
khchen added reviewers: craig.topper, rogfer01, kito-cheng, fakepaper56, eopXD.
Herald added subscribers: sunshaoce, VincentWu, luke957, StephenFan, vkmr, 
frasercrmck, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, 
benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, edward-jones, 
zzheng, jrtc27, shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, 
arichardson.
Herald added a project: All.
khchen requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, MaskRay.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126745

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vcompress.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfmerge.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmerge.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vcompress.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfmerge.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmerge.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics/vmerge.c
===
--- clang/test/CodeGen/RISCV/rvv-intrinsics/vmerge.c
+++ clang/test/CodeGen/RISCV/rvv-intrinsics/vmerge.c
@@ -981,7 +981,7 @@
 // CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmerge.nxv1f16.nxv1f16.i64( undef,  [[OP1:%.*]],  [[OP2:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
-vfloat16mf4_t test_vmerge_vvm_f16mf4 (vbool64_t mask, vfloat16mf4_t op1, vfloat16mf4_t op2, size_t vl) {
+vfloat16mf4_t test_vmerge_vvm_f16mf4(vbool64_t mask, vfloat16mf4_t op1, vfloat16mf4_t op2, size_t vl) {
   return vmerge_vvm_f16mf4(mask, op1, op2, vl);
 }
 
@@ -990,7 +990,7 @@
 // CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmerge.nxv2f16.nxv2f16.i64( undef,  [[OP1:%.*]],  [[OP2:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
-vfloat16mf2_t test_vmerge_vvm_f16mf2 (vbool32_t mask, vfloat16mf2_t op1, vfloat16mf2_t op2, size_t vl) {
+vfloat16mf2_t test_vmerge_vvm_f16mf2(vbool32_t mask, vfloat16mf2_t op1, vfloat16mf2_t op2, size_t vl) {
   return vmerge_vvm_f16mf2(mask, op1, op2, vl);
 }
 
@@ -999,7 +999,7 @@
 // CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmerge.nxv4f16.nxv4f16.i64( undef,  [[OP1:%.*]],  [[OP2:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
-vfloat16m1_t test_vmerge_vvm_f16m1 (vbool16_t mask, vfloat16m1_t op1, vfloat16m1_t op2, size_t vl) {
+vfloat16m1_t test_vmerge_vvm_f16m1(vbool16_t mask, vfloat16m1_t op1, vfloat16m1_t op2, size_t vl) {
   return vmerge_vvm_f16m1(mask, op1, op2, vl);
 }
 
@@ -1008,7 +1008,7 @@
 // CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmerge.nxv8f16.nxv8f16.i64( undef,  [[OP1:%.*]],  [[OP2:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
-vfloat16m2_t test_vmerge_vvm_f16m2 (vbool8_t mask, vfloat16m2_t op1, vfloat16m2_t op2, size_t vl) {
+vfloat16m2_t test_vmerge_vvm_f16m2(vbool8_t mask, vfloat16m2_t op1, vfloat16m2_t op2, size_t vl) {
   return vmerge_vvm_f16m2(mask, op1, op2, vl);
 }
 
@@ -1017,7 +1017,7 @@
 // CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmerge.nxv16f16.nxv16f16.i64( undef,  [[OP1:%.*]],  [[OP2:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
-vfloat16m4_t test_vmerge_vvm_f16m4 (vbool4_t mask, vfloat16m4_t op1, vfloat16m4_t op2, size_t vl) {
+vfloat16m4_t test_vmerge_vvm_f16m4(vbool4_t mask, vfloat16m4_t op1, vfloat16m4_t op2, size_t vl) {
   return vmerge_vvm_f16m4(mask, op1, op2, vl);
 }
 
@@ -1026,6 +1026,96 @@
 // CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmerge.nxv32f16.nxv32f16.i64( undef,  [[OP1:%.*]],  [[OP2:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
-vfloat16m8_t test_vmerge_vvm_f16m8 (vbool2_t mask, vfloat16m8_t op1, vfloat16m8_t op2, size_t vl) {
+vfloat16m8_t test_vmerge_vvm_f16m8(vbool2_t mask, vfloat16m8_t op1, vfloat16m8_t op2, size_t vl) {
   return vmerge_vvm_f16m8(mask, op1, op2, vl);
 }
+
+// CHECK-RV64-LABEL: @test_vmerge_vvm_i32mf2_tu(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmerge.nxv1i32.nxv1i32.i64( [[MERGE:%.*]],  [[OP1:%.*]],  [[OP2:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vint32mf2_t test_vmerge_vvm_i32mf2_tu(vbool64_t mask, vint32mf2_t merge, vint32mf2_t op1, vint32mf2_t op2, size_t vl) {
+  return vmerge_vvm_i32mf2_tu(mask, merge, op1, op2, vl);
+}
+
+// CHECK-RV64-LABEL: @test_vmerge_vxm_i32mf2_tu(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmerge.nxv1i32.i32.i64( [[MERGE:%.*]],  [[OP1:%.*]], i32 [[OP2:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vint32mf2_t 

[PATCH] D126743: [RISCV][Clang] Add tests for all supported policy functions. (NFC)

2022-05-31 Thread Zakk Chen via Phabricator via cfe-commits
khchen created this revision.
khchen added reviewers: craig.topper, rogfer01, kito-cheng, fakepaper56, eopXD.
Herald added subscribers: sunshaoce, VincentWu, luke957, StephenFan, vkmr, 
frasercrmck, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, 
benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, edward-jones, 
zzheng, jrtc27, shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, 
arichardson.
Herald added a project: All.
khchen requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, MaskRay.
Herald added a project: clang.

In order to make the review easier, I split some tests from
https://reviews.llvm.org/D126742


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126743

Files:
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vaadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vadc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vand.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vasub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vdiv.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfclass.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfcvt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfdiv.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfmacc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfmadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfmax.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfmin.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfmsac.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfmsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfmul.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfncvt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfnmacc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfnmadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfnmsac.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfnmsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfrdiv.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfrec7.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfrsqrt7.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfrsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfsgnj.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfslide1down.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfslide1up.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfsqrt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwcvt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwmacc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwmsac.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwmul.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwnmacc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwnmsac.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmacc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmax.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmin.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmul.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vnclip.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vnmsac.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vnmsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vnsra.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vnsrl.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vor.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vrem.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vrgather.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vrsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsbc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsext.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vslide1down.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vslide1up.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vslidedown.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vslideup.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsll.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsmul.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsra.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsrl.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vssra.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vssrl.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vssub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vwadd.c
  

[PATCH] D126602: [Clang][OpenMP] Replace IgnoreImpCasts with IgnoreImplicitAsWritten in atomic compare

2022-05-31 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Can you add the test?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126602/new/

https://reviews.llvm.org/D126602

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D113107: Support of expression granularity for _Float16.

2022-05-31 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added inline comments.



Comment at: clang/lib/Basic/Targets/X86.cpp:242
   HasAVX512FP16 = true;
   HasFloat16 = true;
+  HasLegalHalfType = true;

This can be removed.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113107/new/

https://reviews.llvm.org/D113107

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126741: [RISCV][Clang] Refactor RISCVVEmitter. (NFC)

2022-05-31 Thread Zakk Chen via Phabricator via cfe-commits
khchen created this revision.
khchen added reviewers: craig.topper, rogfer01, kito-cheng, fakepaper56, eopXD.
Herald added subscribers: sunshaoce, VincentWu, luke957, StephenFan, vkmr, 
frasercrmck, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, 
benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, edward-jones, 
zzheng, jrtc27, shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, 
arichardson.
Herald added a project: All.
khchen requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, MaskRay.
Herald added a project: clang.

Remove MaskedPrototype and add several fields in RVVIntrinsicRecord,
compute Prototype in runtime.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126741

Files:
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Sema/SemaRVVLookup.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  clang/utils/TableGen/RISCVVEmitter.cpp

Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -50,9 +50,6 @@
   // Prototype for this intrinsic.
   SmallVector Prototype;
 
-  // Prototype for masked intrinsic.
-  SmallVector MaskedPrototype;
-
   // Suffix of intrinsic name.
   SmallVector Suffix;
 
@@ -61,6 +58,10 @@
 
   // Number of field, large than 1 if it's segment load/store.
   unsigned NF;
+
+  bool HasMasked :1;
+  bool HasVL :1;
+  bool HasMaskedOffOperand :1;
 };
 
 class RVVEmitter {
@@ -478,11 +479,11 @@
 }
 
 SR.NF = NF;
+SR.HasMasked = HasMasked;
+SR.HasVL = HasVL;
+SR.HasMaskedOffOperand = HasMaskedOffOperand;
 
-SR.Prototype = std::move(Prototype);
-
-if (HasMasked)
-  SR.MaskedPrototype = std::move(MaskedPrototype);
+SR.Prototype = std::move(BasicPrototype);
 
 auto InitSuffixtype = [&](SmallVectorImpl ,
   StringRef Prototypes) {
@@ -566,7 +567,6 @@
 
   for (const auto  : SemaRecords) {
 InsertToSignatureSet(SemaRecord.Prototype);
-InsertToSignatureSet(SemaRecord.MaskedPrototype);
 InsertToSignatureSet(SemaRecord.Suffix);
 InsertToSignatureSet(SemaRecord.OverloadedSuffix);
   }
@@ -585,17 +585,18 @@
 Record.Name = SR.Name.c_str();
 Record.OverloadedName = SR.OverloadedName.c_str();
 Record.PrototypeIndex = GetSemaSignatureIndex(SR.Prototype);
-Record.MaskedPrototypeIndex = GetSemaSignatureIndex(SR.MaskedPrototype);
 Record.SuffixIndex = GetSemaSignatureIndex(SR.Suffix);
 Record.OverloadedSuffixIndex = GetSemaSignatureIndex(SR.OverloadedSuffix);
 Record.PrototypeLength = SR.Prototype.size();
-Record.MaskedPrototypeLength = SR.MaskedPrototype.size();
 Record.SuffixLength = SR.Suffix.size();
 Record.OverloadedSuffixSize = SR.OverloadedSuffix.size();
 Record.RequiredExtension = SR.RequiredExtension;
 Record.TypeRangeMask = SR.TypeRangeMask;
 Record.Log2LMULMask = SR.Log2LMULMask;
 Record.NF = SR.NF;
+Record.HasMasked = SR.HasMasked;
+Record.HasVL = SR.HasVL;
+Record.HasMaskedOffOperand = SR.HasMaskedOffOperand;
 Out.push_back(Record);
   }
 }
Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -983,17 +983,18 @@
   else
 OS << "\"" << Record.OverloadedName << "\",";
   OS << Record.PrototypeIndex << ",";
-  OS << Record.MaskedPrototypeIndex << ",";
   OS << Record.SuffixIndex << ",";
   OS << Record.OverloadedSuffixIndex << ",";
   OS << (int)Record.PrototypeLength << ",";
-  OS << (int)Record.MaskedPrototypeLength << ",";
   OS << (int)Record.SuffixLength << ",";
   OS << (int)Record.OverloadedSuffixSize << ",";
   OS << (int)Record.RequiredExtension << ",";
   OS << (int)Record.TypeRangeMask << ",";
   OS << (int)Record.Log2LMULMask << ",";
   OS << (int)Record.NF << ",";
+  OS << (int)Record.HasMasked << ",";
+  OS << (int)Record.HasVL << ",";
+  OS << (int)Record.HasMaskedOffOperand << ",";
   OS << "},\n";
   return OS;
 }
Index: clang/lib/Sema/SemaRVVLookup.cpp
===
--- clang/lib/Sema/SemaRVVLookup.cpp
+++ clang/lib/Sema/SemaRVVLookup.cpp
@@ -174,10 +174,17 @@
   for (auto  : RVVIntrinsicRecords) {
 // Create Intrinsics for each type and LMUL.
 BasicType BaseType = BasicType::Unknown;
-auto ProtoSeq =
+auto BasicProtoSeq =
 ProtoSeq2ArrayRef(Record.PrototypeIndex, Record.PrototypeLength);
-auto ProtoMaskSeq = ProtoSeq2ArrayRef(Record.MaskedPrototypeIndex,
-  Record.MaskedPrototypeLength);
+
+auto ProtoSeq = RVVIntrinsic::computeBuiltinTypes(
+BasicProtoSeq, /*IsMasked=*/false,
+/*HasMaskedOffOperand=*/false, Record.HasVL, Record.NF);
+
+auto ProtoMaskSeq = 

[PATCH] D126740: [RISCV][Clang] Refactor and rename rvv intrinsic related stuff. (NFC)

2022-05-31 Thread Zakk Chen via Phabricator via cfe-commits
khchen created this revision.
khchen added reviewers: craig.topper, rogfer01, kito-cheng, fakepaper56, eopXD.
Herald added subscribers: sunshaoce, VincentWu, luke957, StephenFan, vkmr, 
frasercrmck, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, 
benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, edward-jones, 
zzheng, jrtc27, shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, 
arichardson.
Herald added a project: All.
khchen requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, MaskRay.
Herald added a project: clang.

This changed is based on https://reviews.llvm.org/D111617


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126740

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  clang/utils/TableGen/RISCVVEmitter.cpp

Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -375,12 +375,12 @@
 bool HasMasked = R->getValueAsBit("HasMasked");
 bool HasMaskedOffOperand = R->getValueAsBit("HasMaskedOffOperand");
 bool HasVL = R->getValueAsBit("HasVL");
-Record *MaskedPolicyRecord = R->getValueAsDef("MaskedPolicy");
-PolicyScheme MaskedPolicy =
-static_cast(MaskedPolicyRecord->getValueAsInt("Value"));
-Record *UnMaskedPolicyRecord = R->getValueAsDef("UnMaskedPolicy");
-PolicyScheme UnMaskedPolicy =
-static_cast(UnMaskedPolicyRecord->getValueAsInt("Value"));
+Record *MPSRecord = R->getValueAsDef("MaskedPolicyScheme");
+auto MaskedPolicyScheme =
+static_cast(MPSRecord->getValueAsInt("Value"));
+Record *UMPSRecord = R->getValueAsDef("UnMaskedPolicyScheme");
+auto UnMaskedPolicyScheme =
+static_cast(UMPSRecord->getValueAsInt("Value"));
 bool HasUnMaskedOverloaded = R->getValueAsBit("HasUnMaskedOverloaded");
 std::vector Log2LMULList = R->getValueAsListOfInts("Log2LMUL");
 bool HasBuiltinAlias = R->getValueAsBit("HasBuiltinAlias");
@@ -396,50 +396,19 @@
 
 // Parse prototype and create a list of primitive type with transformers
 // (operand) in Prototype. Prototype[0] is output operand.
-SmallVector Prototype = parsePrototypes(Prototypes);
+SmallVector BasicPrototype =
+parsePrototypes(Prototypes);
 
 SmallVector SuffixDesc = parsePrototypes(SuffixProto);
 SmallVector OverloadedSuffixDesc =
 parsePrototypes(OverloadedSuffixProto);
 
 // Compute Builtin types
-SmallVector MaskedPrototype = Prototype;
-if (HasMasked) {
-  // If HasMaskedOffOperand, insert result type as first input operand.
-  if (HasMaskedOffOperand) {
-if (NF == 1) {
-  MaskedPrototype.insert(MaskedPrototype.begin() + 1, Prototype[0]);
-} else {
-  // Convert
-  // (void, op0 address, op1 address, ...)
-  // to
-  // (void, op0 address, op1 address, ..., maskedoff0, maskedoff1, ...)
-  PrototypeDescriptor MaskoffType = Prototype[1];
-  MaskoffType.TM &= ~static_cast(TypeModifier::Pointer);
-  for (unsigned I = 0; I < NF; ++I)
-MaskedPrototype.insert(MaskedPrototype.begin() + NF + 1,
-   MaskoffType);
-}
-  }
-  if (HasMaskedOffOperand && NF > 1) {
-// Convert
-// (void, op0 address, op1 address, ..., maskedoff0, maskedoff1, ...)
-// to
-// (void, op0 address, op1 address, ..., mask, maskedoff0, maskedoff1,
-// ...)
-MaskedPrototype.insert(MaskedPrototype.begin() + NF + 1,
-   PrototypeDescriptor::Mask);
-  } else {
-// If HasMasked, insert PrototypeDescriptor:Mask as first input operand.
-MaskedPrototype.insert(MaskedPrototype.begin() + 1,
-   PrototypeDescriptor::Mask);
-  }
-}
-// If HasVL, append PrototypeDescriptor:VL to last operand
-if (HasVL) {
-  Prototype.push_back(PrototypeDescriptor::VL);
-  MaskedPrototype.push_back(PrototypeDescriptor::VL);
-}
+auto Prototype = RVVIntrinsic::computeBuiltinTypes(
+BasicPrototype, /*IsMasked=*/false, /*HasMaskedOffOperand=*/false,
+HasVL, NF);
+auto MaskedPrototype = RVVIntrinsic::computeBuiltinTypes(
+BasicPrototype, /*IsMasked=*/true, HasMaskedOffOperand, HasVL, NF);
 
 // Create Intrinsics for each type and LMUL.
 for (char I : TypeRange) {
@@ -458,7 +427,7 @@
 Out.push_back(std::make_unique(
 Name, SuffixStr, OverloadedName, OverloadedSuffixStr, IRName,
 /*IsMasked=*/false, /*HasMaskedOffOperand=*/false, HasVL,
-UnMaskedPolicy, HasUnMaskedOverloaded, HasBuiltinAlias,
+UnMaskedPolicyScheme, HasUnMaskedOverloaded, HasBuiltinAlias,
 

[PATCH] D125338: [HLSL] add -D option for dxc mode.

2022-05-31 Thread Xiang Li via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd3e4727907e5: [HLSL] add -D option for dxc mode. (authored 
by python3kgae).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125338/new/

https://reviews.llvm.org/D125338

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/dxc_D.hlsl


Index: clang/test/Driver/dxc_D.hlsl
===
--- /dev/null
+++ clang/test/Driver/dxc_D.hlsl
@@ -0,0 +1,13 @@
+// RUN: %clang_dxc -DTEST=2  -### %s 2>&1 | FileCheck %s
+// RUN: %clang_dxc -DTEST=2  -Tlib_6_7 %s -fcgl -Fo - | FileCheck %s 
--check-prefix=ERROR
+
+// Make sure -D send to cc1.
+// CHECK:"-D" "TEST=2"
+
+#ifndef TEST
+#error "TEST not defined"
+#elif TEST != 2
+#error "TEST defined to wrong value"
+#endif
+
+// ERROR-NOT: error:
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3477,9 +3477,9 @@
 
 static void RenderHLSLOptions(const ArgList , ArgStringList ,
   types::ID InputType) {
-  const unsigned ForwardedArguments[] = {options::OPT_dxil_validator_version,
- options::OPT_S, 
options::OPT_emit_llvm,
- options::OPT_disable_llvm_passes};
+  const unsigned ForwardedArguments[] = {
+  options::OPT_dxil_validator_version, options::OPT_D, options::OPT_S,
+  options::OPT_emit_llvm, options::OPT_disable_llvm_passes};
 
   for (const auto  : ForwardedArguments)
 if (const auto *A = Args.getLastArg(Arg))
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -6804,6 +6804,8 @@
  "lib_6_3, lib_6_4, lib_6_5, lib_6_6, lib_6_7, lib_6_x,"
  "ms_6_5, ms_6_6, ms_6_7,"
  "as_6_5, as_6_6, as_6_7">;
+def dxc_D : Option<["--", "/", "-"], "D", KIND_JOINED_OR_SEPARATE>,
+  Group, Flags<[DXCOption, NoXarchOption]>, Alias;
 def emit_pristine_llvm : DXCFlag<"emit-pristine-llvm">,
   HelpText<"Emit pristine LLVM IR from the frontend by not running any LLVM 
passes at all."
"Same as -S + -emit-llvm + -disable-llvm-passes.">;


Index: clang/test/Driver/dxc_D.hlsl
===
--- /dev/null
+++ clang/test/Driver/dxc_D.hlsl
@@ -0,0 +1,13 @@
+// RUN: %clang_dxc -DTEST=2  -### %s 2>&1 | FileCheck %s
+// RUN: %clang_dxc -DTEST=2  -Tlib_6_7 %s -fcgl -Fo - | FileCheck %s --check-prefix=ERROR
+
+// Make sure -D send to cc1.
+// CHECK:"-D" "TEST=2"
+
+#ifndef TEST
+#error "TEST not defined"
+#elif TEST != 2
+#error "TEST defined to wrong value"
+#endif
+
+// ERROR-NOT: error:
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3477,9 +3477,9 @@
 
 static void RenderHLSLOptions(const ArgList , ArgStringList ,
   types::ID InputType) {
-  const unsigned ForwardedArguments[] = {options::OPT_dxil_validator_version,
- options::OPT_S, options::OPT_emit_llvm,
- options::OPT_disable_llvm_passes};
+  const unsigned ForwardedArguments[] = {
+  options::OPT_dxil_validator_version, options::OPT_D, options::OPT_S,
+  options::OPT_emit_llvm, options::OPT_disable_llvm_passes};
 
   for (const auto  : ForwardedArguments)
 if (const auto *A = Args.getLastArg(Arg))
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -6804,6 +6804,8 @@
  "lib_6_3, lib_6_4, lib_6_5, lib_6_6, lib_6_7, lib_6_x,"
  "ms_6_5, ms_6_6, ms_6_7,"
  "as_6_5, as_6_6, as_6_7">;
+def dxc_D : Option<["--", "/", "-"], "D", KIND_JOINED_OR_SEPARATE>,
+  Group, Flags<[DXCOption, NoXarchOption]>, Alias;
 def emit_pristine_llvm : DXCFlag<"emit-pristine-llvm">,
   HelpText<"Emit pristine LLVM IR from the frontend by not running any LLVM passes at all."
"Same as -S + -emit-llvm + -disable-llvm-passes.">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] d3e4727 - [HLSL] add -D option for dxc mode.

2022-05-31 Thread Xiang Li via cfe-commits

Author: Xiang Li
Date: 2022-05-31T17:50:36-07:00
New Revision: d3e4727907e533a088fdb42963b6efcd1f26ec88

URL: 
https://github.com/llvm/llvm-project/commit/d3e4727907e533a088fdb42963b6efcd1f26ec88
DIFF: 
https://github.com/llvm/llvm-project/commit/d3e4727907e533a088fdb42963b6efcd1f26ec88.diff

LOG: [HLSL] add -D option for dxc mode.

Create dxc_D as alias to option D which Define  to  (or 1 if 
 omitted).

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D125338

Added: 
clang/test/Driver/dxc_D.hlsl

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index fc8bda55c561..a7622e0c9976 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6804,6 +6804,8 @@ def target_profile : DXCJoinedOrSeparate<"T">, 
MetaVarName<"">,
  "lib_6_3, lib_6_4, lib_6_5, lib_6_6, lib_6_7, lib_6_x,"
  "ms_6_5, ms_6_6, ms_6_7,"
  "as_6_5, as_6_6, as_6_7">;
+def dxc_D : Option<["--", "/", "-"], "D", KIND_JOINED_OR_SEPARATE>,
+  Group, Flags<[DXCOption, NoXarchOption]>, Alias;
 def emit_pristine_llvm : DXCFlag<"emit-pristine-llvm">,
   HelpText<"Emit pristine LLVM IR from the frontend by not running any LLVM 
passes at all."
"Same as -S + -emit-llvm + -disable-llvm-passes.">;

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index a8706215bf60..f32dfdcdfe4b 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3477,9 +3477,9 @@ static void RenderOpenCLOptions(const ArgList , 
ArgStringList ,
 
 static void RenderHLSLOptions(const ArgList , ArgStringList ,
   types::ID InputType) {
-  const unsigned ForwardedArguments[] = {options::OPT_dxil_validator_version,
- options::OPT_S, 
options::OPT_emit_llvm,
- options::OPT_disable_llvm_passes};
+  const unsigned ForwardedArguments[] = {
+  options::OPT_dxil_validator_version, options::OPT_D, options::OPT_S,
+  options::OPT_emit_llvm, options::OPT_disable_llvm_passes};
 
   for (const auto  : ForwardedArguments)
 if (const auto *A = Args.getLastArg(Arg))

diff  --git a/clang/test/Driver/dxc_D.hlsl b/clang/test/Driver/dxc_D.hlsl
new file mode 100644
index ..d32d885f11b0
--- /dev/null
+++ b/clang/test/Driver/dxc_D.hlsl
@@ -0,0 +1,13 @@
+// RUN: %clang_dxc -DTEST=2  -### %s 2>&1 | FileCheck %s
+// RUN: %clang_dxc -DTEST=2  -Tlib_6_7 %s -fcgl -Fo - | FileCheck %s 
--check-prefix=ERROR
+
+// Make sure -D send to cc1.
+// CHECK:"-D" "TEST=2"
+
+#ifndef TEST
+#error "TEST not defined"
+#elif TEST != 2
+#error "TEST defined to wrong value"
+#endif
+
+// ERROR-NOT: error:



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 79e3d57 - [RISCV][NFC] Rename variables in rvv intrinsics related files.

2022-05-31 Thread Zakk Chen via cfe-commits

Author: Zakk Chen
Date: 2022-05-31T17:43:01-07:00
New Revision: 79e3d57f52284c7d911724ef6298f765c747c20d

URL: 
https://github.com/llvm/llvm-project/commit/79e3d57f52284c7d911724ef6298f765c747c20d
DIFF: 
https://github.com/llvm/llvm-project/commit/79e3d57f52284c7d911724ef6298f765c747c20d.diff

LOG: [RISCV][NFC] Rename variables in rvv intrinsics related files.

This patch does the same thing as D125886 did.

- Use `Overloaded` rather than `Mangled`.
- Use `Prototype` or `Desc` rather than `Seq`, it's not just a string
sequence.

Reviewed By: fakepaper56

Differential Revision: https://reviews.llvm.org/D126634

Added: 


Modified: 
clang/include/clang/Basic/riscv_vector.td
clang/include/clang/Support/RISCVVIntrinsicUtils.h
clang/lib/Support/RISCVVIntrinsicUtils.cpp
clang/utils/TableGen/RISCVVEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/riscv_vector.td 
b/clang/include/clang/Basic/riscv_vector.td
index 18304f55da0c..8a1e0eb74258 100644
--- a/clang/include/clang/Basic/riscv_vector.td
+++ b/clang/include/clang/Basic/riscv_vector.td
@@ -139,7 +139,7 @@ def HasPassthruOperand : Policy<1>;
 def HasPolicyOperand : Policy<2>;
 
 class RVVBuiltin {
+ string overloaded_suffix = ""> {
   // Base name that will be prepended in __builtin_rvv_ and appended the
   // computed Suffix.
   string Name = NAME;
@@ -148,14 +148,14 @@ class RVVBuiltin {
   let IRName = intrinsic_name;
   let MaskedIRName = intrinsic_name # "_mask";
-  let MangledName = NAME;
+  let OverloadedName = NAME;
   let IntrinsicTypes = [-1, 0];
 }
 
@@ -462,29 +462,29 @@ class RVVFloatingUnaryBuiltin;
 
 class RVVConvBuiltin
+ string overloaded_name>
 : RVVBuiltin {
   let IntrinsicTypes = [-1, 0];
-  let MangledName = mangled_name;
+  let OverloadedName = overloaded_name;
 }
 
-class RVVConvToSignedBuiltin
-: RVVConvBuiltin<"Iv", "Ivv", "xfd", mangled_name>;
+class RVVConvToSignedBuiltin
+: RVVConvBuiltin<"Iv", "Ivv", "xfd", overloaded_name>;
 
-class RVVConvToUnsignedBuiltin
-: RVVConvBuiltin<"Uv", "Uvv", "xfd", mangled_name>;
+class RVVConvToUnsignedBuiltin
+: RVVConvBuiltin<"Uv", "Uvv", "xfd", overloaded_name>;
 
-class RVVConvToWidenSignedBuiltin
-: RVVConvBuiltin<"Iw", "Iwv", "xf", mangled_name>;
+class RVVConvToWidenSignedBuiltin
+: RVVConvBuiltin<"Iw", "Iwv", "xf", overloaded_name>;
 
-class RVVConvToWidenUnsignedBuiltin
-: RVVConvBuiltin<"Uw", "Uwv", "xf", mangled_name>;
+class RVVConvToWidenUnsignedBuiltin
+: RVVConvBuiltin<"Uw", "Uwv", "xf", overloaded_name>;
 
-class RVVConvToNarrowingSignedBuiltin
-: RVVConvBuiltin<"Iv", "IvFw", "csi", mangled_name>;
+class RVVConvToNarrowingSignedBuiltin
+: RVVConvBuiltin<"Iv", "IvFw", "csi", overloaded_name>;
 
-class RVVConvToNarrowingUnsignedBuiltin
-: RVVConvBuiltin<"Uv", "UvFw", "csi", mangled_name>;
+class RVVConvToNarrowingUnsignedBuiltin
+: RVVConvBuiltin<"Uv", "UvFw", "csi", overloaded_name>;
 
 let HasMaskedOffOperand = false in {
   multiclass RVVSignedReductionBuiltin {
@@ -516,7 +516,7 @@ multiclass RVVWidenBuiltinSet;
@@ -532,7 +532,7 @@ multiclass RVVWidenWOp0BuiltinSet;
@@ -1424,7 +1424,7 @@ multiclass RVVPseudoVFUnaryBuiltin {
 multiclass RVVPseudoVWCVTBuiltin> suffixes_prototypes> {
   let Name = NAME,
-  MangledName = MName,
+  OverloadedName = MName,
   IRName = IR,
   MaskedIRName = IR # "_mask",
   ManualCodegen = [{
@@ -1462,7 +1462,7 @@ multiclass RVVPseudoVWCVTBuiltin> suffixes_prototypes> {
   let Name = NAME,
-  MangledName = MName,
+  OverloadedName = MName,
   IRName = IR,
   MaskedIRName = IR # "_mask",
   ManualCodegen = [{
@@ -1792,7 +1792,7 @@ let HasMasked = false, MaskedPolicy = NonePolicy,
 
 // 12.16. Vector Integer Move Instructions
 let HasMasked = false, UnMaskedPolicy = HasPassthruOperand, MaskedPolicy = 
NonePolicy in {
-  let MangledName = "vmv_v" in {
+  let OverloadedName = "vmv_v" in {
 defm vmv_v : RVVOutBuiltinSet<"vmv_v_v", "csil",
[["v", "Uv", "UvUv"]]>;
 defm vmv_v : RVVOutBuiltinSet<"vmv_v_v", "csilxfd",
@@ -2043,11 +2043,11 @@ let UnMaskedPolicy = HasPassthruOperand, 
HasUnMaskedOverloaded = false in {
 // 17. Vector Permutation Instructions
 // 17.1. Integer Scalar Move Instructions
 let HasMasked = false, MaskedPolicy = NonePolicy in {
-  let HasVL = false, MangledName = "vmv_x" in
+  let HasVL = false, OverloadedName = "vmv_x" in
 defm vmv_x : RVVOp0BuiltinSet<"vmv_x_s", "csil",
[["s", "ve", "ev"],
 ["s", "UvUe", "UeUv"]]>;
-  let MangledName = "vmv_s" in
+  let OverloadedName = "vmv_s" in
 defm vmv_s : RVVOutBuiltinSet<"vmv_s_x", "csil",
[["x", "v", "vve"],
 ["x", "Uv", "UvUvUe"]]>;
@@ -2055,10 +2055,10 @@ 

[PATCH] D126634: [RISCV][NFC] Rename variables in rvv intrinsics related files.

2022-05-31 Thread Zakk Chen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG79e3d57f5228: [RISCV][NFC] Rename variables in rvv 
intrinsics related files. (authored by khchen).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126634/new/

https://reviews.llvm.org/D126634

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  clang/utils/TableGen/RISCVVEmitter.cpp

Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -155,10 +155,10 @@
   OS << ");\n";
 }
 
-void emitMangledFuncDef(const RVVIntrinsic , raw_ostream ) {
+void emitOverloadedFuncDef(const RVVIntrinsic , raw_ostream ) {
   OS << "__attribute__((__clang_builtin_alias__(";
   OS << "__builtin_rvv_" << RVVI.getBuiltinName() << ")))\n";
-  OS << RVVI.getOutputType()->getTypeStr() << " " << RVVI.getMangledName()
+  OS << RVVI.getOutputType()->getTypeStr() << " " << RVVI.getOverloadedName()
  << "(";
   // Emit function arguments
   const RVVTypes  = RVVI.getInputTypes();
@@ -289,7 +289,7 @@
 if (!Inst.isMasked() && !Inst.hasUnMaskedOverloaded())
   return;
 OS << "__rvv_aio ";
-emitMangledFuncDef(Inst, OS);
+emitOverloadedFuncDef(Inst, OS);
   });
 
   OS << "#undef __rvv_aio\n";
@@ -387,8 +387,8 @@
   for (auto *R : RV) {
 StringRef Name = R->getValueAsString("Name");
 StringRef SuffixProto = R->getValueAsString("Suffix");
-StringRef OverloadedName = R->getValueAsString("MangledName");
-StringRef OverloadedSuffixProto = R->getValueAsString("MangledSuffix");
+StringRef OverloadedName = R->getValueAsString("OverloadedName");
+StringRef OverloadedSuffixProto = R->getValueAsString("OverloadedSuffix");
 StringRef Prototypes = R->getValueAsString("Prototype");
 StringRef TypeRange = R->getValueAsString("TypeRange");
 bool HasMasked = R->getValueAsBit("HasMasked");
Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -791,13 +791,13 @@
 
 Optional
 RVVType::computeTypes(BasicType BT, int Log2LMUL, unsigned NF,
-  ArrayRef PrototypeSeq) {
+  ArrayRef Prototype) {
   // LMUL x NF must be less than or equal to 8.
   if ((Log2LMUL >= 1) && (1 << Log2LMUL) * NF > 8)
 return llvm::None;
 
   RVVTypes Types;
-  for (const PrototypeDescriptor  : PrototypeSeq) {
+  for (const PrototypeDescriptor  : Prototype) {
 auto T = computeType(BT, Log2LMUL, Proto);
 if (!T.hasValue())
   return llvm::None;
@@ -847,8 +847,8 @@
 // RVVIntrinsic implementation
 //===--===//
 RVVIntrinsic::RVVIntrinsic(
-StringRef NewName, StringRef Suffix, StringRef NewMangledName,
-StringRef MangledSuffix, StringRef IRName, bool IsMasked,
+StringRef NewName, StringRef Suffix, StringRef NewOverloadedName,
+StringRef OverloadedSuffix, StringRef IRName, bool IsMasked,
 bool HasMaskedOffOperand, bool HasVL, PolicyScheme Scheme,
 bool HasUnMaskedOverloaded, bool HasBuiltinAlias, StringRef ManualCodegen,
 const RVVTypes , const std::vector ,
@@ -858,17 +858,17 @@
   HasBuiltinAlias(HasBuiltinAlias), ManualCodegen(ManualCodegen.str()),
   NF(NF) {
 
-  // Init BuiltinName, Name and MangledName
+  // Init BuiltinName, Name and OverloadedName
   BuiltinName = NewName.str();
   Name = BuiltinName;
-  if (NewMangledName.empty())
-MangledName = NewName.split("_").first.str();
+  if (NewOverloadedName.empty())
+OverloadedName = NewName.split("_").first.str();
   else
-MangledName = NewMangledName.str();
+OverloadedName = NewOverloadedName.str();
   if (!Suffix.empty())
 Name += "_" + Suffix.str();
-  if (!MangledSuffix.empty())
-MangledName += "_" + MangledSuffix.str();
+  if (!OverloadedSuffix.empty())
+OverloadedName += "_" + OverloadedSuffix.str();
   if (IsMasked) {
 BuiltinName += "_m";
 Name += "_m";
Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -256,7 +256,7 @@
   /// have illegal RVVType.
   static llvm::Optional
   computeTypes(BasicType BT, int Log2LMUL, unsigned NF,
-   llvm::ArrayRef PrototypeSeq);
+   llvm::ArrayRef Prototype);
   static llvm::Optional computeType(BasicType BT, int Log2LMUL,
 PrototypeDescriptor Proto);
 };
@@ -287,7 +287,7 @@
 private:
   std::string BuiltinName; // Builtin name
   std::string Name;  

[PATCH] D126364: Fix interaction of pragma FENV_ACCESS with other pragmas

2022-05-31 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

The way I see it, there are two possibilities here:

1. In Sema, we have two rounding modes that correspond to FE_DYNAMIC: 
llvm::RoundingMode::Dynamic, and llvm::RoundingMode::NearestTiesToEven, plus 
some boolean to indicate whether the user actually explicitly specified 
FE_TONEAREST.  (You're currently missing the boolean, which means that 
currently "#pragma STDC FENV_ACCESS OFF" followed by "#pragma STDC FENV_ACCESS 
ON" actually mutates the rounding mode.) We juggle the rounding modes and the 
bit based on whether FENV_ACCESS is currently enabled.
2. We just have one rounding mode in Sema that corresponds to FE_DYNAMIC.  Then 
in CodeGen, we set the actual rounding mode based on whether FENV_ACCESS is 
currently enabled.

(2) seems a lot simpler.

> On targets that support static rounding mode (like RISCV) dynamic and 
> constant rounding modes may be different and the behavior changes if default 
> mode is replaced by dynamic.

Whether a target supports static rounding modes on floating-point instructions 
is completely irrelevant.  The user-visible behavior must be the same either 
way.  If a target doesn't have specialized instructions, the code generator can 
save/restore the rounding mode.  This should be transparent to the user; the 
user can't read the rounding mode in between the save and restore.  (We already 
do this sort of rounding mode manipulation on x86, to implement float-to-int 
conversion on targets without SSE.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126364/new/

https://reviews.llvm.org/D126364

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D120290: [Clang][OpenMP] Add the codegen support for `atomic compare capture`

2022-05-31 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added a comment.

ping


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D120290/new/

https://reviews.llvm.org/D120290

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126602: [Clang][OpenMP] Replace IgnoreImpCasts with IgnoreImplicitAsWritten in atomic compare

2022-05-31 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added a comment.

ping


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126602/new/

https://reviews.llvm.org/D126602

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126735: [clang-tidy] Silence modernize-redundant-void-arg in the case of vexing parses

2022-05-31 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv created this revision.
george.burgess.iv added reviewers: LegalizeAdulthood, aaron.ballman.
george.burgess.iv added a project: clang-tools-extra.
Herald added subscribers: carlosgalvezp, xazax.hun.
Herald added a project: All.
george.burgess.iv requested review of this revision.
Herald added a subscriber: cfe-commits.

Clang's `-Wvexing-parse` is enabled by default 
. When the vexing statement was _intended_ to 
be interpreted as a function that takes zero arguments, the function's 
declaration can be rewritten as `T foo(void);` to silence `-Wvexing-parse`. 
This workaround seems to upset `clang-tidy`.

Given my own lack of understanding of the corners of C++ parsing, I'm... not 
entirely confident that this patch catches everything && has no unintended 
side-effects. The bits that `-Wvexing-parse` depends upon are stored within 
`DeclaratorChunk::FunctionTypeInfo`s, which seem to only exist during AST 
formation, so it's not clear to me how to directly get at that information from 
clang-tidy.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126735

Files:
  clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-redundant-void-arg.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/modernize-redundant-void-arg.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-redundant-void-arg.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-redundant-void-arg.cpp
@@ -592,3 +592,9 @@
   (void)a;
 }
 #undef return_t
+
+// Explicitly specifying `(void)` is a way to sidestep -Wvexing-parse, so we
+// should not warn about it here.
+void most_vexing_parse() {
+  int foo(void);
+}
Index: clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp
@@ -109,9 +109,13 @@
 }
 removeVoidArgumentTokens(Result, SourceRange(Start, End),
  "function definition");
-  } else
+  } else if (!Function->getLexicalDeclContext()->isFunctionOrMethod()) {
+// Only do this if our decl context is outside of a function or method;
+// otherwise, the user may have explicitly written `(void)` to avoid Most
+// Vexing Parse warnings.
 removeVoidArgumentTokens(Result, SourceRange(Start, End),
  "function declaration");
+  }
 }
 
 bool isMacroIdentifier(const IdentifierTable , const Token ) 
{


Index: clang-tools-extra/test/clang-tidy/checkers/modernize-redundant-void-arg.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-redundant-void-arg.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-redundant-void-arg.cpp
@@ -592,3 +592,9 @@
   (void)a;
 }
 #undef return_t
+
+// Explicitly specifying `(void)` is a way to sidestep -Wvexing-parse, so we
+// should not warn about it here.
+void most_vexing_parse() {
+  int foo(void);
+}
Index: clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp
@@ -109,9 +109,13 @@
 }
 removeVoidArgumentTokens(Result, SourceRange(Start, End),
  "function definition");
-  } else
+  } else if (!Function->getLexicalDeclContext()->isFunctionOrMethod()) {
+// Only do this if our decl context is outside of a function or method;
+// otherwise, the user may have explicitly written `(void)` to avoid Most
+// Vexing Parse warnings.
 removeVoidArgumentTokens(Result, SourceRange(Start, End),
  "function declaration");
+  }
 }
 
 bool isMacroIdentifier(const IdentifierTable , const Token ) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126534: [analyzer] Deadstore static analysis: Fix false positive on C++17 assignments

2022-05-31 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Oh nice, I think I've heard about such problems, thanks a lot.




Comment at: clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp:106
   while (Ex) {
-const BinaryOperator *BO =
-  dyn_cast(Ex->IgnoreParenCasts());
+Ex = Ex->IgnoreParenCasts();
+const BinaryOperator *BO = dyn_cast(Ex);

It looks like this introduces a change in behavior in unrelated situations, eg. 
the ones in `objc-arc.m.plist` where the diagnostic is moved to the right:
```lang=c
id obj1 = (__bridge_transfer id)CFCreateSomething(); // expected-warning{{never 
read}}
  ^before   ^after
```
I think this change is undesirable because it distracts from the assignment. In 
this case you can easily avoid this problem by using `IgnoreParenImpCasts()` 
instead, but it also generally makes sense to have patches that target specific 
situations to match on these situations more precisely. Eg., could you see if 
you can add a check that a constructor is involved, and maybe check for the 
exact cast kind that we want to unwrap?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126534/new/

https://reviews.llvm.org/D126534

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125338: [HLSL] add -D option for dxc mode.

2022-05-31 Thread Xiang Li via Phabricator via cfe-commits
python3kgae updated this revision to Diff 433227.
python3kgae added a comment.

Recover after fixed Mac/arm test fail.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125338/new/

https://reviews.llvm.org/D125338

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/dxc_D.hlsl


Index: clang/test/Driver/dxc_D.hlsl
===
--- /dev/null
+++ clang/test/Driver/dxc_D.hlsl
@@ -0,0 +1,13 @@
+// RUN: %clang_dxc -DTEST=2  -### %s 2>&1 | FileCheck %s
+// RUN: %clang_dxc -DTEST=2  -Tlib_6_7 %s -fcgl -Fo - | FileCheck %s 
--check-prefix=ERROR
+
+// Make sure -D send to cc1.
+// CHECK:"-D" "TEST=2"
+
+#ifndef TEST
+#error "TEST not defined"
+#elif TEST != 2
+#error "TEST defined to wrong value"
+#endif
+
+// ERROR-NOT: error:
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3477,9 +3477,9 @@
 
 static void RenderHLSLOptions(const ArgList , ArgStringList ,
   types::ID InputType) {
-  const unsigned ForwardedArguments[] = {options::OPT_dxil_validator_version,
- options::OPT_S, 
options::OPT_emit_llvm,
- options::OPT_disable_llvm_passes};
+  const unsigned ForwardedArguments[] = {
+  options::OPT_dxil_validator_version, options::OPT_D, options::OPT_S,
+  options::OPT_emit_llvm, options::OPT_disable_llvm_passes};
 
   for (const auto  : ForwardedArguments)
 if (const auto *A = Args.getLastArg(Arg))
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -6804,6 +6804,8 @@
  "lib_6_3, lib_6_4, lib_6_5, lib_6_6, lib_6_7, lib_6_x,"
  "ms_6_5, ms_6_6, ms_6_7,"
  "as_6_5, as_6_6, as_6_7">;
+def dxc_D : Option<["--", "/", "-"], "D", KIND_JOINED_OR_SEPARATE>,
+  Group, Flags<[DXCOption, NoXarchOption]>, Alias;
 def emit_pristine_llvm : DXCFlag<"emit-pristine-llvm">,
   HelpText<"Emit pristine LLVM IR from the frontend by not running any LLVM 
passes at all."
"Same as -S + -emit-llvm + -disable-llvm-passes.">;


Index: clang/test/Driver/dxc_D.hlsl
===
--- /dev/null
+++ clang/test/Driver/dxc_D.hlsl
@@ -0,0 +1,13 @@
+// RUN: %clang_dxc -DTEST=2  -### %s 2>&1 | FileCheck %s
+// RUN: %clang_dxc -DTEST=2  -Tlib_6_7 %s -fcgl -Fo - | FileCheck %s --check-prefix=ERROR
+
+// Make sure -D send to cc1.
+// CHECK:"-D" "TEST=2"
+
+#ifndef TEST
+#error "TEST not defined"
+#elif TEST != 2
+#error "TEST defined to wrong value"
+#endif
+
+// ERROR-NOT: error:
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3477,9 +3477,9 @@
 
 static void RenderHLSLOptions(const ArgList , ArgStringList ,
   types::ID InputType) {
-  const unsigned ForwardedArguments[] = {options::OPT_dxil_validator_version,
- options::OPT_S, options::OPT_emit_llvm,
- options::OPT_disable_llvm_passes};
+  const unsigned ForwardedArguments[] = {
+  options::OPT_dxil_validator_version, options::OPT_D, options::OPT_S,
+  options::OPT_emit_llvm, options::OPT_disable_llvm_passes};
 
   for (const auto  : ForwardedArguments)
 if (const auto *A = Args.getLastArg(Arg))
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -6804,6 +6804,8 @@
  "lib_6_3, lib_6_4, lib_6_5, lib_6_6, lib_6_7, lib_6_x,"
  "ms_6_5, ms_6_6, ms_6_7,"
  "as_6_5, as_6_6, as_6_7">;
+def dxc_D : Option<["--", "/", "-"], "D", KIND_JOINED_OR_SEPARATE>,
+  Group, Flags<[DXCOption, NoXarchOption]>, Alias;
 def emit_pristine_llvm : DXCFlag<"emit-pristine-llvm">,
   HelpText<"Emit pristine LLVM IR from the frontend by not running any LLVM passes at all."
"Same as -S + -emit-llvm + -disable-llvm-passes.">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126498: [clangd] Fix hover crashing on integral or enumeral casts

2022-05-31 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Neat, looks like the pre-merge windows buildbot at least is happy!
I'll land this tomorrow.




Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:3221
+  TestTU TU = TestTU::withCode(T.code());
+  TU.OmitPredefinedMacros = false;
+  auto AST = TU.build();

As an alternative (just to avoid adding this option), I think adding 
"-target=x86_64-pc-linux-gnu" would force intptr_t to be long.
Up to you.



Comment at: clang-tools-extra/clangd/unittests/TestTU.h:63
+  // Omit predefined macros.
+  bool OmitPredefinedMacros = true;
+

If you do add this option, please invert the sense, i.e. `bool PredefineMacros 
= false;`

(The double negative of Omit = false is a bit confusing to read)

And please expand the comment slightly: `"... such as __INTPTR_TYPE__"`


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126498/new/

https://reviews.llvm.org/D126498

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126608: [clangd] Remove a test with a duplicate of FileCacheTests

2022-05-31 Thread Yuki Okushi via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5c1494039491: [clangd] Remove a test with a duplicate of 
FileCacheTests (authored by JohnTitor).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126608/new/

https://reviews.llvm.org/D126608

Files:
  clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp


Index: clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp
@@ -178,44 +178,6 @@
   EXPECT_THAT(getAddedArgs(Cfg), ElementsAre("bar", "baz"));
 }
 
-// FIXME: delete this test, it's covered by FileCacheTests.
-TEST(ProviderTest, Staleness) {
-  MockFS FS;
-
-  auto StartTime = std::chrono::steady_clock::now();
-  Params StaleOK;
-  StaleOK.FreshTime = StartTime;
-  Params MustBeFresh;
-  MustBeFresh.FreshTime = StartTime + std::chrono::hours(1);
-  CapturedDiags Diags;
-  auto P = Provider::fromYAMLFile(testPath("foo.yaml"), /*Directory=*/"", FS);
-
-  // Initial query always reads, regardless of policy.
-  FS.Files["foo.yaml"] = AddFooWithErr;
-  auto Cfg = P->getConfig(StaleOK, Diags.callback());
-  EXPECT_THAT(Diags.Diagnostics,
-  ElementsAre(diagMessage("Unknown CompileFlags key 'Unknown'")));
-  EXPECT_THAT(getAddedArgs(Cfg), ElementsAre("foo"));
-  Diags.clear();
-
-  // Stale value reused by policy.
-  FS.Files["foo.yaml"] = AddBarBaz;
-  Cfg = P->getConfig(StaleOK, Diags.callback());
-  EXPECT_THAT(Diags.Diagnostics, IsEmpty()) << "Cached, not re-parsed";
-  EXPECT_THAT(getAddedArgs(Cfg), ElementsAre("foo"));
-
-  // Cache revalidated by policy.
-  Cfg = P->getConfig(MustBeFresh, Diags.callback());
-  EXPECT_THAT(Diags.Diagnostics, IsEmpty()) << "New config, no errors";
-  EXPECT_THAT(getAddedArgs(Cfg), ElementsAre("bar", "baz"));
-
-  // Cache revalidated by (default) policy.
-  FS.Files.erase("foo.yaml");
-  Cfg = P->getConfig(Params(), Diags.callback());
-  EXPECT_THAT(Diags.Diagnostics, IsEmpty());
-  EXPECT_THAT(getAddedArgs(Cfg), IsEmpty());
-}
-
 TEST(ProviderTest, SourceInfo) {
   MockFS FS;
 


Index: clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp
@@ -178,44 +178,6 @@
   EXPECT_THAT(getAddedArgs(Cfg), ElementsAre("bar", "baz"));
 }
 
-// FIXME: delete this test, it's covered by FileCacheTests.
-TEST(ProviderTest, Staleness) {
-  MockFS FS;
-
-  auto StartTime = std::chrono::steady_clock::now();
-  Params StaleOK;
-  StaleOK.FreshTime = StartTime;
-  Params MustBeFresh;
-  MustBeFresh.FreshTime = StartTime + std::chrono::hours(1);
-  CapturedDiags Diags;
-  auto P = Provider::fromYAMLFile(testPath("foo.yaml"), /*Directory=*/"", FS);
-
-  // Initial query always reads, regardless of policy.
-  FS.Files["foo.yaml"] = AddFooWithErr;
-  auto Cfg = P->getConfig(StaleOK, Diags.callback());
-  EXPECT_THAT(Diags.Diagnostics,
-  ElementsAre(diagMessage("Unknown CompileFlags key 'Unknown'")));
-  EXPECT_THAT(getAddedArgs(Cfg), ElementsAre("foo"));
-  Diags.clear();
-
-  // Stale value reused by policy.
-  FS.Files["foo.yaml"] = AddBarBaz;
-  Cfg = P->getConfig(StaleOK, Diags.callback());
-  EXPECT_THAT(Diags.Diagnostics, IsEmpty()) << "Cached, not re-parsed";
-  EXPECT_THAT(getAddedArgs(Cfg), ElementsAre("foo"));
-
-  // Cache revalidated by policy.
-  Cfg = P->getConfig(MustBeFresh, Diags.callback());
-  EXPECT_THAT(Diags.Diagnostics, IsEmpty()) << "New config, no errors";
-  EXPECT_THAT(getAddedArgs(Cfg), ElementsAre("bar", "baz"));
-
-  // Cache revalidated by (default) policy.
-  FS.Files.erase("foo.yaml");
-  Cfg = P->getConfig(Params(), Diags.callback());
-  EXPECT_THAT(Diags.Diagnostics, IsEmpty());
-  EXPECT_THAT(getAddedArgs(Cfg), IsEmpty());
-}
-
 TEST(ProviderTest, SourceInfo) {
   MockFS FS;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 5c14940 - [clangd] Remove a test with a duplicate of FileCacheTests

2022-05-31 Thread Yuki Okushi via cfe-commits

Author: Yuki Okushi
Date: 2022-06-01T08:15:54+09:00
New Revision: 5c14940394919cbc66cab06103342610af69bc58

URL: 
https://github.com/llvm/llvm-project/commit/5c14940394919cbc66cab06103342610af69bc58
DIFF: 
https://github.com/llvm/llvm-project/commit/5c14940394919cbc66cab06103342610af69bc58.diff

LOG: [clangd] Remove a test with a duplicate of FileCacheTests

FIXME says it should be removed so followed it.

Differential Revision: https://reviews.llvm.org/D126608

Added: 


Modified: 
clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp 
b/clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp
index 22f69143dadfa..36a9c383e058e 100644
--- a/clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp
@@ -178,44 +178,6 @@ TEST(ProviderTest, FromAncestorRelativeYAMLFiles) {
   EXPECT_THAT(getAddedArgs(Cfg), ElementsAre("bar", "baz"));
 }
 
-// FIXME: delete this test, it's covered by FileCacheTests.
-TEST(ProviderTest, Staleness) {
-  MockFS FS;
-
-  auto StartTime = std::chrono::steady_clock::now();
-  Params StaleOK;
-  StaleOK.FreshTime = StartTime;
-  Params MustBeFresh;
-  MustBeFresh.FreshTime = StartTime + std::chrono::hours(1);
-  CapturedDiags Diags;
-  auto P = Provider::fromYAMLFile(testPath("foo.yaml"), /*Directory=*/"", FS);
-
-  // Initial query always reads, regardless of policy.
-  FS.Files["foo.yaml"] = AddFooWithErr;
-  auto Cfg = P->getConfig(StaleOK, Diags.callback());
-  EXPECT_THAT(Diags.Diagnostics,
-  ElementsAre(diagMessage("Unknown CompileFlags key 'Unknown'")));
-  EXPECT_THAT(getAddedArgs(Cfg), ElementsAre("foo"));
-  Diags.clear();
-
-  // Stale value reused by policy.
-  FS.Files["foo.yaml"] = AddBarBaz;
-  Cfg = P->getConfig(StaleOK, Diags.callback());
-  EXPECT_THAT(Diags.Diagnostics, IsEmpty()) << "Cached, not re-parsed";
-  EXPECT_THAT(getAddedArgs(Cfg), ElementsAre("foo"));
-
-  // Cache revalidated by policy.
-  Cfg = P->getConfig(MustBeFresh, Diags.callback());
-  EXPECT_THAT(Diags.Diagnostics, IsEmpty()) << "New config, no errors";
-  EXPECT_THAT(getAddedArgs(Cfg), ElementsAre("bar", "baz"));
-
-  // Cache revalidated by (default) policy.
-  FS.Files.erase("foo.yaml");
-  Cfg = P->getConfig(Params(), Diags.callback());
-  EXPECT_THAT(Diags.Diagnostics, IsEmpty());
-  EXPECT_THAT(getAddedArgs(Cfg), IsEmpty());
-}
-
 TEST(ProviderTest, SourceInfo) {
   MockFS FS;
 



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125291: Introduce @llvm.threadlocal.address intrinsic to access TLS variable (1/3)

2022-05-31 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

So, I've been spending some significant time looking into this. I found that I 
couldn't really review this change for correctness, because I find it basically 
impossible to figure out whether the intrinsic calls have actually been added 
to all the right places in Clang or not. (And my intuition said "not", but then 
couldn't tell me where it's wrong.)

So, I started hacking up a prototype of a change to make the type of a TLS 
global variable be `token` instead of `ptr`. This allows missing calls to 
manifest as IR construction errors.

So far the biggest missing piece that identified in this review is 
function-local thread_locals (although I haven't actually gotten something 
fully working). Sadly, the handling of function-local statics in Clang is 
really rather hairy, what with objc blocks and openmp support both doing things 
that seem rather ill-advised to me. I'm toying with some cleanups there, to see 
if it can be simplified a bit. I don't have a full idea, yet, what changes need 
to be made to this review.

Anyhow -- I think the prototype I'm fiddling with is also along the path to the 
ideal long-term state, but pushing it beyond a prototype seems like it'll be a 
pain in the ass due to the bitcode compatibility requirement. (The bitcode 
upgrader would need to know how to transform all constant expressions using a 
TLS global into non-constant IR instructions, starting with a call to 
llvm.threadlocal.address -- in every function where the "constant" is 
referenced. For uses outside a function body, it transforms to an arbitrary 
address (e.g. null), instead.)




Comment at: clang/lib/CodeGen/CGExpr.cpp:2609-2610
+  if (VD->getTLSKind() != VarDecl::TLS_None &&
+  // We only use @llvm.threadlocal.address if opaque pointers enabled.
+  // Otherwise, we need to pay for many unnecessary bitcasts.
+  //

This should be handled by using an overloaded intrinsic, so you get the entire 
family llvm.threadlocal.address.* with any pointer-type as the argument and the 
same type as the return value (that'll happen when you switch the intrinsic to 
use llvm_anyptr_ty).



Comment at: llvm/include/llvm/IR/Intrinsics.td:1393
 
+def int_threadlocal_address : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty],
+[IntrNoMem, IntrWillReturn]>;

I believe this should be declared exactly like int_ptrmask right above.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125291/new/

https://reviews.llvm.org/D125291

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126731: [pseudo] Eliminate dependencies from clang-pseudo-gen. NFC

2022-05-31 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: hokein.
Herald added a subscriber: mgorny.
Herald added a project: All.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, alextsao1999.
Herald added a project: clang-tools-extra.

ClangBasic dependency eliminated by replacing our usage of
tok::getPunctuatorSpelling etc with direct use of the *.def file.

Implicit dependencies on clang-tablegen-targets removed as we manage to avoid
any transitive tablegen deps.

After these changes, `ninja clean; ninja pseudo-gen` runs 169 actions only
(basically Support and Demangle).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126731

Files:
  clang-tools-extra/pseudo/gen/CMakeLists.txt
  clang-tools-extra/pseudo/lib/grammar/CMakeLists.txt
  clang-tools-extra/pseudo/lib/grammar/Grammar.cpp


Index: clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
===
--- clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
+++ clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
@@ -167,19 +167,16 @@
 }
 
 static llvm::ArrayRef getTerminalNames() {
-  static const std::vector *TerminalNames = []() {
-static std::vector TerminalNames;
-TerminalNames.reserve(NumTerminals);
-for (unsigned I = 0; I < NumTerminals; ++I) {
-  tok::TokenKind K = static_cast(I);
-  if (const auto *Punc = tok::getPunctuatorSpelling(K))
-TerminalNames.push_back(Punc);
-  else
-TerminalNames.push_back(llvm::StringRef(tok::getTokenName(K)).upper());
-}
-return 
+  static const auto  = []() {
+auto  = *new std::array;
+#define PUNCTUATOR(Tok, Spelling) TerminalNames[tok::Tok] = Spelling;
+#define KEYWORD(Keyword, Condition)
\
+  TerminalNames[tok::kw_##Keyword] = llvm::StringRef(#Keyword).upper();
+#define TOK(Tok) TerminalNames[tok::Tok] = llvm::StringRef(#Tok).upper();
+#include "clang/Basic/TokenKinds.def"
+return TerminalNames;
   }();
-  return *TerminalNames;
+  return TerminalNames;
 }
 GrammarTable::GrammarTable() : Terminals(getTerminalNames()) {}
 
Index: clang-tools-extra/pseudo/lib/grammar/CMakeLists.txt
===
--- clang-tools-extra/pseudo/lib/grammar/CMakeLists.txt
+++ clang-tools-extra/pseudo/lib/grammar/CMakeLists.txt
@@ -1,18 +1,15 @@
 set(LLVM_LINK_COMPONENTS Support)
 
-# This library intents to keep as minimal dependencies as possible, it is a 
base
-# library of the cxx generator, to avoid creating long dep paths in the build
-# graph.
+# This library is used by the clang-pseudo-gen tool which runs at build time.
+# Dependencies should be minimal to avoid long dep paths in the build graph.
+# It does use clangBasic headers (tok::TokenKind), but linking is not needed.
+# We have no transitive dependencies on tablegen files.
+list(REMOVE_ITEM LLVM_COMMON_DEPENDS clang-tablegen-targets)
 add_clang_library(clangPseudoGrammar
   Grammar.cpp
   GrammarBNF.cpp
   LRGraph.cpp
   LRTable.cpp
   LRTableBuild.cpp
-
-  # FIXME: can we get rid of the clangBasic dependency? We need it for the
-  # clang::tok::getTokenName and clang::tok::getPunctuatorSpelling functions, 
we
-  # could consider remimplement these functions.
-  LINK_LIBS
-  clangBasic
   )
+
Index: clang-tools-extra/pseudo/gen/CMakeLists.txt
===
--- clang-tools-extra/pseudo/gen/CMakeLists.txt
+++ clang-tools-extra/pseudo/gen/CMakeLists.txt
@@ -1,4 +1,5 @@
 set(LLVM_LINK_COMPONENTS Support)
+list(REMOVE_ITEM LLVM_COMMON_DEPENDS clang-tablegen-targets)
 
 add_clang_executable(pseudo-gen
   Main.cpp


Index: clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
===
--- clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
+++ clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
@@ -167,19 +167,16 @@
 }
 
 static llvm::ArrayRef getTerminalNames() {
-  static const std::vector *TerminalNames = []() {
-static std::vector TerminalNames;
-TerminalNames.reserve(NumTerminals);
-for (unsigned I = 0; I < NumTerminals; ++I) {
-  tok::TokenKind K = static_cast(I);
-  if (const auto *Punc = tok::getPunctuatorSpelling(K))
-TerminalNames.push_back(Punc);
-  else
-TerminalNames.push_back(llvm::StringRef(tok::getTokenName(K)).upper());
-}
-return 
+  static const auto  = []() {
+auto  = *new std::array;
+#define PUNCTUATOR(Tok, Spelling) TerminalNames[tok::Tok] = Spelling;
+#define KEYWORD(Keyword, Condition)\
+  TerminalNames[tok::kw_##Keyword] = llvm::StringRef(#Keyword).upper();
+#define TOK(Tok) TerminalNames[tok::Tok] = llvm::StringRef(#Tok).upper();
+#include "clang/Basic/TokenKinds.def"
+return TerminalNames;
   }();
-  return *TerminalNames;
+  return TerminalNames;
 }
 GrammarTable::GrammarTable() : 

[PATCH] D126498: [clangd] Fix hover crashing on integral or enumeral casts

2022-05-31 Thread Georg Kotheimer via Phabricator via cfe-commits
gkll updated this revision to Diff 433217.
gkll added a comment.

Fixed formatting of `Argv` array.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126498/new/

https://reviews.llvm.org/D126498

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp
  clang-tools-extra/clangd/unittests/TestTU.cpp
  clang-tools-extra/clangd/unittests/TestTU.h

Index: clang-tools-extra/clangd/unittests/TestTU.h
===
--- clang-tools-extra/clangd/unittests/TestTU.h
+++ clang-tools-extra/clangd/unittests/TestTU.h
@@ -59,6 +59,9 @@
   // Extra arguments for the compiler invocation.
   std::vector ExtraArgs;
 
+  // Omit predefined macros.
+  bool OmitPredefinedMacros = true;
+
   TidyProvider ClangTidyProvider = {};
   // Index to use when building AST.
   const SymbolIndex *ExternalIndex = nullptr;
Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -40,9 +40,12 @@
   ParseInputs Inputs;
   Inputs.FeatureModules = FeatureModules;
   auto  = Inputs.CompileCommand.CommandLine;
-  // In tests, omit predefined macros (__GNUC__ etc) for a 25% speedup.
-  // There are hundreds, and we'd generate, parse, serialize, and re-parse them!
-  Argv = {"clang", "-Xclang", "-undef"};
+  Argv = {"clang", "-Xclang"};
+  // In tests, unless explicitly specified otherwise, omit predefined macros
+  // (__GNUC__ etc) for a 25% speedup. There are hundreds, and we'd generate,
+  // parse, serialize, and re-parse them!
+  if (OmitPredefinedMacros)
+Argv.push_back("-undef");
   // FIXME: this shouldn't need to be conditional, but it breaks a
   // GoToDefinition test for some reason (getMacroArgExpandedLocation fails).
   if (!HeaderCode.empty()) {
Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -3206,6 +3206,41 @@
   ASSERT_TRUE(H);
   EXPECT_EQ(H->Definition, "int arr[]");
 }
+
+TEST(Hover, GlobalVarEnumeralCastNoCrash) {
+  Annotations T(R"cpp(
+using uintptr_t = __UINTPTR_TYPE__;
+enum Test : uintptr_t {};
+unsigned global_var;
+void foo() {
+  Test v^al = static_cast(reinterpret_cast(_var));
+}
+  )cpp");
+
+  TestTU TU = TestTU::withCode(T.code());
+  TU.OmitPredefinedMacros = false;
+  auto AST = TU.build();
+  auto HI = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
+  ASSERT_TRUE(HI);
+  EXPECT_EQ(*HI->Value, "_var");
+}
+
+TEST(Hover, GlobalVarIntCastNoCrash) {
+  Annotations T(R"cpp(
+using uintptr_t = __UINTPTR_TYPE__;
+unsigned global_var;
+void foo() {
+  uintptr_t a^ddress = reinterpret_cast(_var);
+}
+  )cpp");
+
+  TestTU TU = TestTU::withCode(T.code());
+  TU.OmitPredefinedMacros = false;
+  auto AST = TU.build();
+  auto HI = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
+  ASSERT_TRUE(HI);
+  EXPECT_EQ(*HI->Value, "_var");
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -429,7 +429,8 @@
 return llvm::None;
 
   // Show enums symbolically, not numerically like APValue::printPretty().
-  if (T->isEnumeralType() && Constant.Val.getInt().getMinSignedBits() <= 64) {
+  if (T->isEnumeralType() && Constant.Val.isInt() &&
+  Constant.Val.getInt().getMinSignedBits() <= 64) {
 // Compare to int64_t to avoid bit-width match requirements.
 int64_t Val = Constant.Val.getInt().getExtValue();
 for (const EnumConstantDecl *ECD :
@@ -440,7 +441,7 @@
 .str();
   }
   // Show hex value of integers if they're at least 10 (or negative!)
-  if (T->isIntegralOrEnumerationType() &&
+  if (T->isIntegralOrEnumerationType() && Constant.Val.isInt() &&
   Constant.Val.getInt().getMinSignedBits() <= 64 &&
   Constant.Val.getInt().uge(10))
 return llvm::formatv("{0} ({1})", Constant.Val.getAsString(Ctx, T),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126084: [Sema] Reject implicit conversions between different scoped enum types in list initialization

2022-05-31 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: clang/lib/Sema/SemaInit.cpp:4506
 !S.Context.hasSameUnqualifiedType(E->getType(), DestType) &&
-(E->getType()->isIntegralOrEnumerationType() ||
+(E->getType()->isIntegralOrUnscopedEnumerationType() ||
  E->getType()->isFloatingType())) {

ahatanak wrote:
> aaron.ballman wrote:
> > ahatanak wrote:
> > > ahatanak wrote:
> > > > aaron.ballman wrote:
> > > > > ahatanak wrote:
> > > > > > aaron.ballman wrote:
> > > > > > > This doesn't match the comments immediately above here and I 
> > > > > > > don't think is the correct fix.
> > > > > > > 
> > > > > > > We're handling this case: http://eel.is/c++draft/dcl.init.list#3.8
> > > > > > > 
> > > > > > > A scoped enumeration has a fixed underlying type 
> > > > > > > (https://eel.is/c++draft/dcl.enum#5.sentence-5). The initializer 
> > > > > > > list has a single element and that element can be implicitly 
> > > > > > > converted to the underlying type (`int` in all of the test cases 
> > > > > > > changed in this patch). And this is a direct initialization case, 
> > > > > > > so I think we should be performing the conversion here rather 
> > > > > > > than skipping to the next bullet.
> > > > > > Can scoped enums be implicitly converted to integer types? Unscoped 
> > > > > > enums can be converted to an integer type, but I don't see any 
> > > > > > mention of scoped enums here: https://eel.is/c++draft/conv.integral
> > > > > > 
> > > > > > It seems that the original paper was trying to change the rules 
> > > > > > about conversions from the underlying type to a scoped enum. It 
> > > > > > doesn't look like it's allowing conversion from a scope enum to 
> > > > > > another scope enum.
> > > > > > 
> > > > > > https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0138r2.pdf
> > > > > > Can scoped enums be implicitly converted to integer types? Unscoped 
> > > > > > enums can be converted to an integer type, but I don't see any 
> > > > > > mention of scoped enums here: https://eel.is/c++draft/conv.integral
> > > > > 
> > > > > Correct, they cannot be implicitly converted to an integer.
> > > > > 
> > > > > > It seems that the original paper was trying to change the rules 
> > > > > > about conversions from the underlying type to a scoped enum. It 
> > > > > > doesn't look like it's allowing conversion from a scope enum to 
> > > > > > another scope enum.
> > > > > 
> > > > > Agreed, however, I think where we want this to fail is below in the 
> > > > > attempt at conversion. "v can be implicitly converted to U" is the 
> > > > > part that should be failing here, and we're now skipping over the bit 
> > > > > of code that's checking whether the implicit conversion is valid.
> > > > Is the code below checking whether the implicit conversion is valid? It 
> > > > looks like it's assuming the implicit conversion is valid and adding an 
> > > > implicit conversion sequence based on that assumption. If the source is 
> > > > an integer, unscoped enum, or floating type, the implicit conversion 
> > > > that is performed later should succeed except when there is narrowing.
> > > > 
> > > > Or are you suggesting we should add a check to 
> > > > `Sema::PerformImplicitConversion` that rejects conversions from scoped 
> > > > enums to other types? It seems to me that it's better to detect the 
> > > > error earlier.
> > > Alternatively, we can emit a diagnostic in the code below that 
> > > specifically calls out conversion from scoped enums to integer types.
> > > Is the code below checking whether the implicit conversion is valid? 
> > 
> > It's forming the conversion sequence as-if it must be valid, but that 
> > causes us to get the right diagnostics. We do the same for narrowing float 
> > conversions: 
> > https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaInit.cpp#L4521
> >  and I would expect us to then need changes so we get to here: 
> > https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaInit.cpp#L8478
> But a conversion from a scoped enum to another scoped enum or its underlying 
> type isn't a narrowing conversion unless the conversion from the underlying 
> type is narrowing. I guess the current code is forming the conversion 
> sequence as if it is valid when the source type is a floating type just to 
> call `DiagnoseNarrowingInInitList`. @rsmith, any comments?
> 
> If we want to detect the invalid conversion while performing conversion, 
> shouldn't the call to `PerformImplicitConversion`, which is called before 
> reaching the call to `DiagnoseNarrowingInInitList`,  fail? Why should it 
> succeed?
> 
> https://github.com/llvm/llvm-project/blob/7689c7fc9e08cc430daca3714bcffdd00fd538bd/clang/lib/Sema/SemaInit.cpp#L8467
> 
> But I think the invalid conversion should be detected at the very beginning 
> of the function before conversion is attempted where it checks whether the 
> initialization sequence is invalid 

[PATCH] D126498: [clangd] Fix hover crashing on integral or enumeral casts

2022-05-31 Thread Georg Kotheimer via Phabricator via cfe-commits
gkll updated this revision to Diff 433211.
gkll added a comment.

Use `uintptr_t` instead of `unsigned long` for the casts, to ensure the pointer 
always fits into the integer type.
For example on Windows x64 that was previously not the case, because there 
`unsigned long` is only 32-bits wide.
Thus the pointer got truncated during the cast, which resulted in `getHover()` 
returning `None` instead of `_var`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126498/new/

https://reviews.llvm.org/D126498

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp
  clang-tools-extra/clangd/unittests/TestTU.cpp
  clang-tools-extra/clangd/unittests/TestTU.h

Index: clang-tools-extra/clangd/unittests/TestTU.h
===
--- clang-tools-extra/clangd/unittests/TestTU.h
+++ clang-tools-extra/clangd/unittests/TestTU.h
@@ -59,6 +59,9 @@
   // Extra arguments for the compiler invocation.
   std::vector ExtraArgs;
 
+  // Omit predefined macros.
+  bool OmitPredefinedMacros = true;
+
   TidyProvider ClangTidyProvider = {};
   // Index to use when building AST.
   const SymbolIndex *ExternalIndex = nullptr;
Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -40,9 +40,12 @@
   ParseInputs Inputs;
   Inputs.FeatureModules = FeatureModules;
   auto  = Inputs.CompileCommand.CommandLine;
-  // In tests, omit predefined macros (__GNUC__ etc) for a 25% speedup.
-  // There are hundreds, and we'd generate, parse, serialize, and re-parse them!
-  Argv = {"clang", "-Xclang", "-undef"};
+  Argv = {"clang", "-Xclang", };
+  // In tests, unless explicitly specified otherwise, omit predefined macros
+  // (__GNUC__ etc) for a 25% speedup. There are hundreds, and we'd generate,
+  // parse, serialize, and re-parse them!
+  if (OmitPredefinedMacros)
+Argv.push_back("-undef");
   // FIXME: this shouldn't need to be conditional, but it breaks a
   // GoToDefinition test for some reason (getMacroArgExpandedLocation fails).
   if (!HeaderCode.empty()) {
Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -3206,6 +3206,41 @@
   ASSERT_TRUE(H);
   EXPECT_EQ(H->Definition, "int arr[]");
 }
+
+TEST(Hover, GlobalVarEnumeralCastNoCrash) {
+  Annotations T(R"cpp(
+using uintptr_t = __UINTPTR_TYPE__;
+enum Test : uintptr_t {};
+unsigned global_var;
+void foo() {
+  Test v^al = static_cast(reinterpret_cast(_var));
+}
+  )cpp");
+
+  TestTU TU = TestTU::withCode(T.code());
+  TU.OmitPredefinedMacros = false;
+  auto AST = TU.build();
+  auto HI = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
+  ASSERT_TRUE(HI);
+  EXPECT_EQ(*HI->Value, "_var");
+}
+
+TEST(Hover, GlobalVarIntCastNoCrash) {
+  Annotations T(R"cpp(
+using uintptr_t = __UINTPTR_TYPE__;
+unsigned global_var;
+void foo() {
+  uintptr_t a^ddress = reinterpret_cast(_var);
+}
+  )cpp");
+
+  TestTU TU = TestTU::withCode(T.code());
+  TU.OmitPredefinedMacros = false;
+  auto AST = TU.build();
+  auto HI = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
+  ASSERT_TRUE(HI);
+  EXPECT_EQ(*HI->Value, "_var");
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -429,7 +429,8 @@
 return llvm::None;
 
   // Show enums symbolically, not numerically like APValue::printPretty().
-  if (T->isEnumeralType() && Constant.Val.getInt().getMinSignedBits() <= 64) {
+  if (T->isEnumeralType() && Constant.Val.isInt() &&
+  Constant.Val.getInt().getMinSignedBits() <= 64) {
 // Compare to int64_t to avoid bit-width match requirements.
 int64_t Val = Constant.Val.getInt().getExtValue();
 for (const EnumConstantDecl *ECD :
@@ -440,7 +441,7 @@
 .str();
   }
   // Show hex value of integers if they're at least 10 (or negative!)
-  if (T->isIntegralOrEnumerationType() &&
+  if (T->isIntegralOrEnumerationType() && Constant.Val.isInt() &&
   Constant.Val.getInt().getMinSignedBits() <= 64 &&
   Constant.Val.getInt().uge(10))
 return llvm::formatv("{0} ({1})", Constant.Val.getAsString(Ctx, T),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126084: [Sema] Reject implicit conversions between different scoped enum types in list initialization

2022-05-31 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: clang/lib/Sema/SemaInit.cpp:4506
 !S.Context.hasSameUnqualifiedType(E->getType(), DestType) &&
-(E->getType()->isIntegralOrEnumerationType() ||
+(E->getType()->isIntegralOrUnscopedEnumerationType() ||
  E->getType()->isFloatingType())) {

aaron.ballman wrote:
> ahatanak wrote:
> > ahatanak wrote:
> > > aaron.ballman wrote:
> > > > ahatanak wrote:
> > > > > aaron.ballman wrote:
> > > > > > This doesn't match the comments immediately above here and I don't 
> > > > > > think is the correct fix.
> > > > > > 
> > > > > > We're handling this case: http://eel.is/c++draft/dcl.init.list#3.8
> > > > > > 
> > > > > > A scoped enumeration has a fixed underlying type 
> > > > > > (https://eel.is/c++draft/dcl.enum#5.sentence-5). The initializer 
> > > > > > list has a single element and that element can be implicitly 
> > > > > > converted to the underlying type (`int` in all of the test cases 
> > > > > > changed in this patch). And this is a direct initialization case, 
> > > > > > so I think we should be performing the conversion here rather than 
> > > > > > skipping to the next bullet.
> > > > > Can scoped enums be implicitly converted to integer types? Unscoped 
> > > > > enums can be converted to an integer type, but I don't see any 
> > > > > mention of scoped enums here: https://eel.is/c++draft/conv.integral
> > > > > 
> > > > > It seems that the original paper was trying to change the rules about 
> > > > > conversions from the underlying type to a scoped enum. It doesn't 
> > > > > look like it's allowing conversion from a scope enum to another scope 
> > > > > enum.
> > > > > 
> > > > > https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0138r2.pdf
> > > > > Can scoped enums be implicitly converted to integer types? Unscoped 
> > > > > enums can be converted to an integer type, but I don't see any 
> > > > > mention of scoped enums here: https://eel.is/c++draft/conv.integral
> > > > 
> > > > Correct, they cannot be implicitly converted to an integer.
> > > > 
> > > > > It seems that the original paper was trying to change the rules about 
> > > > > conversions from the underlying type to a scoped enum. It doesn't 
> > > > > look like it's allowing conversion from a scope enum to another scope 
> > > > > enum.
> > > > 
> > > > Agreed, however, I think where we want this to fail is below in the 
> > > > attempt at conversion. "v can be implicitly converted to U" is the part 
> > > > that should be failing here, and we're now skipping over the bit of 
> > > > code that's checking whether the implicit conversion is valid.
> > > Is the code below checking whether the implicit conversion is valid? It 
> > > looks like it's assuming the implicit conversion is valid and adding an 
> > > implicit conversion sequence based on that assumption. If the source is 
> > > an integer, unscoped enum, or floating type, the implicit conversion that 
> > > is performed later should succeed except when there is narrowing.
> > > 
> > > Or are you suggesting we should add a check to 
> > > `Sema::PerformImplicitConversion` that rejects conversions from scoped 
> > > enums to other types? It seems to me that it's better to detect the error 
> > > earlier.
> > Alternatively, we can emit a diagnostic in the code below that specifically 
> > calls out conversion from scoped enums to integer types.
> > Is the code below checking whether the implicit conversion is valid? 
> 
> It's forming the conversion sequence as-if it must be valid, but that causes 
> us to get the right diagnostics. We do the same for narrowing float 
> conversions: 
> https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaInit.cpp#L4521
>  and I would expect us to then need changes so we get to here: 
> https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaInit.cpp#L8478
But a conversion from a scoped enum to another scoped enum or its underlying 
type isn't a narrowing conversion unless the conversion from the underlying 
type is narrowing. I guess the current code is forming the conversion sequence 
as if it is valid when the source type is a floating type just to call 
`DiagnoseNarrowingInInitList`. @rsmith, any comments?

If we want to detect the invalid conversion while performing conversion, 
shouldn't the call to `PerformImplicitConversion`, which is called before 
reaching the call to `DiagnoseNarrowingInInitList`,  fail? Why should it 
succeed?

https://github.com/llvm/llvm-project/blob/7689c7fc9e08cc430daca3714bcffdd00fd538bd/clang/lib/Sema/SemaInit.cpp#L8467

But I think the invalid conversion should be detected at the very beginning of 
the function before conversion is attempted where it checks whether the 
initialization sequence is invalid 
(https://github.com/llvm/llvm-project/blob/7689c7fc9e08cc430daca3714bcffdd00fd538bd/clang/lib/Sema/SemaInit.cpp#L8020).
 That can be done by calling `Sequence.SetFailed` 

[PATCH] D75277: [WebAssembly] Remove restriction on main name mangling

2022-05-31 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:6360
+  auto *GA = llvm::GlobalAlias::create("__main_void", F);
+  GA->setVisibility(F->getVisibility());
+}

sunfish wrote:
> sbc100 wrote:
> > sunfish wrote:
> > > Can this use `GA->setVisibility(GlobalValue::HiddenVisibility)`? 
> > > `__main_void` is an implementation detail, so in theory users shouldn't 
> > > be setting interesting visibility attributes on it.
> > The caller main / __main_void could live in different shared library the 
> > main function itself.  
> > 
> > IIRC the caller of `main` is normally something like crt1.o and it should 
> > be able to see `__main_void` if, and only if, it can see `main`.  i.e. if 
> > should have the same visibility as main itself, no?
> Typically crt1.o is linked into the same exe/dso as `main`, so it needs 
> `main` to have external linkage, but it doesn't need `main` to have any 
> particular visibility.
> 
> In Emscripten, is `main` being called from a different dso, or from JS 
> following visibility rules for different dsos?
No, emscirpten is not different that respect.   Typically main lives in the 
same DSO as crt1.o.   

But it doesn't have to, and we have a few tests that check it can be in a 
separate dso.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75277/new/

https://reviews.llvm.org/D75277

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75277: [WebAssembly] Remove restriction on main name mangling

2022-05-31 Thread Dan Gohman via Phabricator via cfe-commits
sunfish added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:6360
+  auto *GA = llvm::GlobalAlias::create("__main_void", F);
+  GA->setVisibility(F->getVisibility());
+}

sbc100 wrote:
> sunfish wrote:
> > Can this use `GA->setVisibility(GlobalValue::HiddenVisibility)`? 
> > `__main_void` is an implementation detail, so in theory users shouldn't be 
> > setting interesting visibility attributes on it.
> The caller main / __main_void could live in different shared library the main 
> function itself.  
> 
> IIRC the caller of `main` is normally something like crt1.o and it should be 
> able to see `__main_void` if, and only if, it can see `main`.  i.e. if should 
> have the same visibility as main itself, no?
Typically crt1.o is linked into the same exe/dso as `main`, so it needs `main` 
to have external linkage, but it doesn't need `main` to have any particular 
visibility.

In Emscripten, is `main` being called from a different dso, or from JS 
following visibility rules for different dsos?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75277/new/

https://reviews.llvm.org/D75277

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75277: [WebAssembly] Remove restriction on main name mangling

2022-05-31 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:6360
+  auto *GA = llvm::GlobalAlias::create("__main_void", F);
+  GA->setVisibility(F->getVisibility());
+}

sunfish wrote:
> Can this use `GA->setVisibility(GlobalValue::HiddenVisibility)`? 
> `__main_void` is an implementation detail, so in theory users shouldn't be 
> setting interesting visibility attributes on it.
The caller main / __main_void could live in different shared library the main 
function itself.  

IIRC the caller of `main` is normally something like crt1.o and it should be 
able to see `__main_void` if, and only if, it can see `main`.  i.e. if should 
have the same visibility as main itself, no?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75277/new/

https://reviews.llvm.org/D75277

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126725: [pseudo] rename pseudo-gen -> clang-pseudo-gen. NFC

2022-05-31 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: hokein.
Herald added a subscriber: mgorny.
Herald added a project: All.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, llvm-commits, alextsao1999.
Herald added projects: LLVM, clang-tools-extra.

This name is not namespaced. Requested in D126717 



Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126725

Files:
  clang-tools-extra/pseudo/gen/CMakeLists.txt
  clang-tools-extra/pseudo/include/CMakeLists.txt
  llvm/utils/gn/secondary/clang-tools-extra/pseudo/gen/BUILD.gn


Index: llvm/utils/gn/secondary/clang-tools-extra/pseudo/gen/BUILD.gn
===
--- llvm/utils/gn/secondary/clang-tools-extra/pseudo/gen/BUILD.gn
+++ llvm/utils/gn/secondary/clang-tools-extra/pseudo/gen/BUILD.gn
@@ -1,4 +1,4 @@
-executable("pseudo-gen") {
+executable("clang-pseudo-gen") {
   configs += [ "//llvm/utils/gn/build:clang_code" ]
   deps = [
 "//clang-tools-extra/pseudo/lib/grammar",
Index: clang-tools-extra/pseudo/include/CMakeLists.txt
===
--- clang-tools-extra/pseudo/include/CMakeLists.txt
+++ clang-tools-extra/pseudo/include/CMakeLists.txt
@@ -2,11 +2,11 @@
 set(cxx_bnf ${CMAKE_CURRENT_SOURCE_DIR}/../lib/cxx.bnf)
 
 if(LLVM_USE_HOST_TOOLS)
-  build_native_tool(pseudo-gen pseudo_gen)
+  build_native_tool(clang-pseudo-gen pseudo_gen)
   set(pseudo_gen_target "${pseudo_gen}")
 else()
-  set(pseudo_gen $)
-  set(pseudo_gen_target pseudo-gen)
+  set(pseudo_gen $)
+  set(pseudo_gen_target clang-pseudo-gen)
 endif()
 
 # Generate inc files.
Index: clang-tools-extra/pseudo/gen/CMakeLists.txt
===
--- clang-tools-extra/pseudo/gen/CMakeLists.txt
+++ clang-tools-extra/pseudo/gen/CMakeLists.txt
@@ -1,10 +1,10 @@
 set(LLVM_LINK_COMPONENTS Support)
 
-add_clang_executable(pseudo-gen
+add_clang_executable(clang-pseudo-gen
   Main.cpp
   )
 
-target_link_libraries(pseudo-gen
+target_link_libraries(clang-pseudo-gen
   PRIVATE
   clangPseudoGrammar
   )


Index: llvm/utils/gn/secondary/clang-tools-extra/pseudo/gen/BUILD.gn
===
--- llvm/utils/gn/secondary/clang-tools-extra/pseudo/gen/BUILD.gn
+++ llvm/utils/gn/secondary/clang-tools-extra/pseudo/gen/BUILD.gn
@@ -1,4 +1,4 @@
-executable("pseudo-gen") {
+executable("clang-pseudo-gen") {
   configs += [ "//llvm/utils/gn/build:clang_code" ]
   deps = [
 "//clang-tools-extra/pseudo/lib/grammar",
Index: clang-tools-extra/pseudo/include/CMakeLists.txt
===
--- clang-tools-extra/pseudo/include/CMakeLists.txt
+++ clang-tools-extra/pseudo/include/CMakeLists.txt
@@ -2,11 +2,11 @@
 set(cxx_bnf ${CMAKE_CURRENT_SOURCE_DIR}/../lib/cxx.bnf)
 
 if(LLVM_USE_HOST_TOOLS)
-  build_native_tool(pseudo-gen pseudo_gen)
+  build_native_tool(clang-pseudo-gen pseudo_gen)
   set(pseudo_gen_target "${pseudo_gen}")
 else()
-  set(pseudo_gen $)
-  set(pseudo_gen_target pseudo-gen)
+  set(pseudo_gen $)
+  set(pseudo_gen_target clang-pseudo-gen)
 endif()
 
 # Generate inc files.
Index: clang-tools-extra/pseudo/gen/CMakeLists.txt
===
--- clang-tools-extra/pseudo/gen/CMakeLists.txt
+++ clang-tools-extra/pseudo/gen/CMakeLists.txt
@@ -1,10 +1,10 @@
 set(LLVM_LINK_COMPONENTS Support)
 
-add_clang_executable(pseudo-gen
+add_clang_executable(clang-pseudo-gen
   Main.cpp
   )
 
-target_link_libraries(pseudo-gen
+target_link_libraries(clang-pseudo-gen
   PRIVATE
   clangPseudoGrammar
   )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126719: [clang-cl] Add support for /kernel

2022-05-31 Thread Stephen Long via Phabricator via cfe-commits
steplong added a comment.

In D126719#3548469 , @thakis wrote:

> What does cl do if both `/kernel` and (eg) `/EHsc` is passed (try both 
> orders)? Same question for `/kernel /GR`.

From my experiments, cl doesn't complain and happily compiles the code if 
/kernel /EHsc is passed (both orders), unless the code uses exceptions. Then, 
it complains `error C2980: C++ exception handling is not supported with 
/kernel` (both orders)
For /GR, it complains `Command line error D8016 : '/kernel' and '/GR' 
command-line options are incompatible`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126719/new/

https://reviews.llvm.org/D126719

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75277: [WebAssembly] Remove restriction on main name mangling

2022-05-31 Thread Dan Gohman via Phabricator via cfe-commits
sunfish added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:6360
+  auto *GA = llvm::GlobalAlias::create("__main_void", F);
+  GA->setVisibility(F->getVisibility());
+}

Can this use `GA->setVisibility(GlobalValue::HiddenVisibility)`? `__main_void` 
is an implementation detail, so in theory users shouldn't be setting 
interesting visibility attributes on it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75277/new/

https://reviews.llvm.org/D75277

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126723: [pseudo] GC GSS nodes, reuse them with a freelist

2022-05-31 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 433201.
sammccall added a comment.

remove dead variable


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126723/new/

https://reviews.llvm.org/D126723

Files:
  clang-tools-extra/pseudo/include/clang-pseudo/GLR.h
  clang-tools-extra/pseudo/lib/GLR.cpp
  clang-tools-extra/pseudo/unittests/GLRTest.cpp

Index: clang-tools-extra/pseudo/unittests/GLRTest.cpp
===
--- clang-tools-extra/pseudo/unittests/GLRTest.cpp
+++ clang-tools-extra/pseudo/unittests/GLRTest.cpp
@@ -393,6 +393,29 @@
 "[  0, end) └─IDENTIFIER := tok[0]\n");
 }
 
+TEST(GSSTest, GC) {
+  //  ┌-A-┬-AB
+  //  ├-B-┘
+  // Root-+-C
+  //  ├-D
+  //  └-E
+  GSS GSStack;
+  auto *Root = GSStack.addNode(0, nullptr, {});
+  auto *A = GSStack.addNode(0, nullptr, {Root});
+  auto *B = GSStack.addNode(0, nullptr, {Root});
+  auto *C = GSStack.addNode(0, nullptr, {Root});
+  auto *D = GSStack.addNode(0, nullptr, {Root});
+  auto *AB = GSStack.addNode(0, nullptr, {A, B});
+
+  EXPECT_EQ(1u, GSStack.gc({AB, C})); // destroys D
+  EXPECT_EQ(0u, GSStack.gc({AB, C})); // D is already gone.
+  auto *E = GSStack.addNode(0, nullptr, {Root});
+  EXPECT_EQ(3u, GSStack.gc({A, E})); // destroys B, AB, C
+  EXPECT_EQ(1u, GSStack.gc({E}));// destroys A
+
+  (void)D;
+}
+
 } // namespace
 } // namespace pseudo
 } // namespace clang
Index: clang-tools-extra/pseudo/lib/GLR.cpp
===
--- clang-tools-extra/pseudo/lib/GLR.cpp
+++ clang-tools-extra/pseudo/lib/GLR.cpp
@@ -12,6 +12,7 @@
 #include "clang/Basic/TokenKinds.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -65,6 +66,17 @@
   std::vector NewHeads = {
   GSS.addNode(/*State=*/Params.Table.getStartState(StartSymbol),
   /*ForestNode=*/nullptr, {})};
+  auto MaybeGC = [&, Roots(std::vector{}), I(0u)]() mutable {
+assert(NewHeads.empty() && "Running GC at the wrong time!");
+if (++I != 20) // Run periodically to balance CPU and memory usage.
+  return;
+I = 0;
+Roots.clear();
+for (const auto *Pending : {, , })
+  for (const auto  : *Pending)
+Roots.push_back(E.Head);
+GSS.gc(std::move(Roots));
+  };
   for (const ForestNode  : Terminals) {
 LLVM_DEBUG(llvm::dbgs() << llvm::formatv("Next token {0} (id={1})\n",
  G.symbolName(Terminal.symbol()),
@@ -72,6 +84,7 @@
 for (const auto *Head : NewHeads)
   AddSteps(Head, Terminal.symbol());
 NewHeads.clear();
+MaybeGC();
 glrReduce(PendingReduce, Params,
   [&](const GSS::Node * NewHead) {
 // A reduce will enable more steps.
@@ -373,5 +386,73 @@
   assert(Sequences.empty());
 }
 
+const GSS::Node *GSS::addNode(LRTable::StateID State, const ForestNode *Symbol,
+  llvm::ArrayRef Parents) {
+  ++NodeCount;
+  Node *Result = new (allocate(Parents.size()))
+  Node({State, GCParity, static_cast(Parents.size())});
+  Allocated.push_back(Result);
+  Result->Payload = Symbol;
+  if (!Parents.empty())
+llvm::copy(Parents, reinterpret_cast(Result + 1));
+  return Result;
+}
+
+GSS::Node *GSS::allocate(unsigned Parents) {
+  ++NodeCount;
+  if (FreeList.size() <= Parents)
+FreeList.resize(Parents + 1);
+  auto  = FreeList[Parents];
+  if (!SizedList.empty()) {
+auto *Result = SizedList.back();
+SizedList.pop_back();
+return Result;
+  }
+  return static_cast(
+  Arena.Allocate(sizeof(Node) + Parents * sizeof(Node *), alignof(Node)));
+}
+
+void GSS::destroy(Node *N) {
+  unsigned ParentCount = N->ParentCount;
+  N->~Node();
+  assert(FreeList.size() > ParentCount && "established on construction!");
+  FreeList[ParentCount].push_back(N);
+}
+
+unsigned GSS::gc(std::vector &) {
+#ifndef NDEBUG
+  auto ParityMatches = [&](const Node *N) { return N->GCParity == GCParity; };
+  assert("Before GC" && llvm::all_of(Allocated, ParityMatches));
+  auto Deferred = llvm::make_scope_exit(
+  [&] { assert("After GC" && llvm::all_of(Allocated, ParityMatches)); });
+  assert(llvm::all_of(
+  Queue, [&](const Node *R) { return llvm::is_contained(Allocated, R); }));
+#endif
+  unsigned InitialCount = Allocated.size();
+
+  // Mark
+  GCParity = !GCParity;
+  while (!Queue.empty()) {
+Node *N = const_cast(Queue.back()); // Safe: we created these nodes.
+Queue.pop_back();
+if (N->GCParity != GCParity) { // Not seen yet
+  N->GCParity = GCParity;  // Mark as seen
+  for (const Node *P : N->parents()) // And walk parents
+Queue.push_back(P);
+}
+  }
+  // Sweep
+  llvm::erase_if(Allocated, [&](Node *N) {
+if (N->GCParity == GCParity) // 

[PATCH] D126723: [pseudo] GC GSS nodes, reuse them with a freelist

2022-05-31 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: hokein.
Herald added subscribers: usaxena95, kadircet.
Herald added a project: All.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, alextsao1999, ilya-biryukov.
Herald added a project: clang-tools-extra.

Most GSS nodes have short effective lifetimes, keeping them around until the
end of the parse is wasteful. Mark and sweep them every 20 tokens.

When parsing clangd/AST.cpp, this reduces the GSS memory from 1MB to 20kB.
We pay ~5% performance for this according to the glrParse benchmark.
(Parsing more tokens between GCs doesn't seem to improve this further).

Compared to the refcounting approach in https://reviews.llvm.org/D126337, this
is simpler (at least the complexity is better isolated) and has >2x less
overhead. It doesn't provide death handlers (for error-handling) but we have
an alternative solution in mind.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126723

Files:
  clang-tools-extra/pseudo/include/clang-pseudo/GLR.h
  clang-tools-extra/pseudo/lib/GLR.cpp
  clang-tools-extra/pseudo/unittests/GLRTest.cpp

Index: clang-tools-extra/pseudo/unittests/GLRTest.cpp
===
--- clang-tools-extra/pseudo/unittests/GLRTest.cpp
+++ clang-tools-extra/pseudo/unittests/GLRTest.cpp
@@ -393,6 +393,29 @@
 "[  0, end) └─IDENTIFIER := tok[0]\n");
 }
 
+TEST(GSSTest, GC) {
+  //  ┌-A-┬-AB
+  //  ├-B-┘
+  // Root-+-C
+  //  ├-D
+  //  └-E
+  GSS GSStack;
+  auto *Root = GSStack.addNode(0, nullptr, {});
+  auto *A = GSStack.addNode(0, nullptr, {Root});
+  auto *B = GSStack.addNode(0, nullptr, {Root});
+  auto *C = GSStack.addNode(0, nullptr, {Root});
+  auto *D = GSStack.addNode(0, nullptr, {Root});
+  auto *AB = GSStack.addNode(0, nullptr, {A, B});
+
+  EXPECT_EQ(1u, GSStack.gc({AB, C})); // destroys D
+  EXPECT_EQ(0u, GSStack.gc({AB, C})); // D is already gone.
+  auto *E = GSStack.addNode(0, nullptr, {Root});
+  EXPECT_EQ(3u, GSStack.gc({A, E})); // destroys B, AB, C
+  EXPECT_EQ(1u, GSStack.gc({E}));// destroys A
+
+  (void)D;
+}
+
 } // namespace
 } // namespace pseudo
 } // namespace clang
Index: clang-tools-extra/pseudo/lib/GLR.cpp
===
--- clang-tools-extra/pseudo/lib/GLR.cpp
+++ clang-tools-extra/pseudo/lib/GLR.cpp
@@ -12,6 +12,7 @@
 #include "clang/Basic/TokenKinds.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -65,6 +66,18 @@
   std::vector NewHeads = {
   GSS.addNode(/*State=*/Params.Table.getStartState(StartSymbol),
   /*ForestNode=*/nullptr, {})};
+  auto MaybeGC = [&, Roots(std::vector{}), I(0u)]() mutable {
+assert(NewHeads.empty() && "Running GC at the wrong time!");
+if (++I != 20) // Run periodically to balance CPU and memory usage.
+  return;
+I = 0;
+Roots.clear();
+for (const auto *Pending : {, , })
+  for (const auto  : *Pending)
+Roots.push_back(E.Head);
+GSS.gc(std::move(Roots));
+  };
+  std::vector GCRoots;
   for (const ForestNode  : Terminals) {
 LLVM_DEBUG(llvm::dbgs() << llvm::formatv("Next token {0} (id={1})\n",
  G.symbolName(Terminal.symbol()),
@@ -72,6 +85,7 @@
 for (const auto *Head : NewHeads)
   AddSteps(Head, Terminal.symbol());
 NewHeads.clear();
+MaybeGC();
 glrReduce(PendingReduce, Params,
   [&](const GSS::Node * NewHead) {
 // A reduce will enable more steps.
@@ -373,5 +387,73 @@
   assert(Sequences.empty());
 }
 
+const GSS::Node *GSS::addNode(LRTable::StateID State, const ForestNode *Symbol,
+  llvm::ArrayRef Parents) {
+  ++NodeCount;
+  Node *Result = new (allocate(Parents.size()))
+  Node({State, GCParity, static_cast(Parents.size())});
+  Allocated.push_back(Result);
+  Result->Payload = Symbol;
+  if (!Parents.empty())
+llvm::copy(Parents, reinterpret_cast(Result + 1));
+  return Result;
+}
+
+GSS::Node *GSS::allocate(unsigned Parents) {
+  ++NodeCount;
+  if (FreeList.size() <= Parents)
+FreeList.resize(Parents + 1);
+  auto  = FreeList[Parents];
+  if (!SizedList.empty()) {
+auto *Result = SizedList.back();
+SizedList.pop_back();
+return Result;
+  }
+  return static_cast(
+  Arena.Allocate(sizeof(Node) + Parents * sizeof(Node *), alignof(Node)));
+}
+
+void GSS::destroy(Node *N) {
+  unsigned ParentCount = N->ParentCount;
+  N->~Node();
+  assert(FreeList.size() > ParentCount && "established on construction!");
+  FreeList[ParentCount].push_back(N);
+}
+
+unsigned GSS::gc(std::vector &) {
+#ifndef NDEBUG
+  auto ParityMatches = [&](const Node *N) { return N->GCParity == GCParity; };
+  assert("Before GC" 

[PATCH] D126719: [clang-cl] Add support for /kernel

2022-05-31 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

https://docs.microsoft.com/en-us/cpp/build/reference/kernel-create-kernel-mode-binary?view=msvc-170
 says we should err when `/kernel` is used with various flags (e.g. most 
`/arch:`) flags. Want to add that too?

It also says `/kernel` is passed on to the linker.

What does cl do if both `/kernel` and (eg) `/EHsc` is passed (try both orders)? 
Same question for `/kernel /GR`.




Comment at: clang/lib/Driver/ToolChains/Clang.cpp:7461
 
+  if (Args.hasFlag(options::OPT__SLASH_kernel, options::OPT__SLASH_kernel,
+   false)) {

hasFlag() is for when there's a positive (`/kernel`) and a negative 
(`/kernel-`) form. Is that the case here? Else, use `hasArg` instead.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126719/new/

https://reviews.llvm.org/D126719

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126681: [HIP] Fix static lib name on windows

2022-05-31 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:1788
+for (auto Prefix : {"/libdevice/", "/"}) {
+  if (IsMSVC) {
+AOBFileNames.push_back(Twine(LPath + Prefix + Lib + ".lib").str());

tra wrote:
> style nit: no need for braces here
> https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements
will fix when committing


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126681/new/

https://reviews.llvm.org/D126681

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126651: [clang-diff] Fix getStmtValue when dealing with wide chars

2022-05-31 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes requested changes to this revision.
johannes added a comment.
This revision now requires changes to proceed.

I wonder if clang-diff is useful in its current state, I remember there are 
many edge cases left over.

Anyway, I've left some minor comments. I'm not sure how to download a patch 
that Git can apply so I didn't try it yet.




Comment at: clang/lib/Tooling/ASTDiff/ASTDiff.cpp:468
+  if (auto *String = dyn_cast(S)) {
+if (String->isWide()) {
+  unsigned int wsize = String->getByteLength() / 
String->getCharByteWidth();

I think there are some other cases that need fixing too.
1. isUTF16() (like `u'x'`)
2. isUTF32() (like `U'x'`)

Can you fix them too? Should be quite similar.



Comment at: clang/lib/Tooling/ASTDiff/ASTDiff.cpp:471
+  const wchar_t *temp =
+  reinterpret_cast(String->getBytes().data());
+  std::wstring wstr(temp);

How about using "auto" here to avoid repeating the type?



Comment at: clang/lib/Tooling/ASTDiff/ASTDiff.cpp:474
+  std::string str;
+  if (!convertWideToUTF8(wstr.substr(0, wsize), str))
+return "";

Instead of calling substr() it seems better to move this to the constructor

std::wstring wstr(temp, wsize);

(I think the reason why we need wsize is because strings can have embedded null 
characters)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126651/new/

https://reviews.llvm.org/D126651

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126559: [MSVC] Fix pragma alloc_text failing for C files

2022-05-31 Thread Stephen Long via Phabricator via cfe-commits
steplong updated this revision to Diff 433194.
steplong added a comment.

- Handle static C/C++ functions and C functions in general


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126559/new/

https://reviews.llvm.org/D126559

Files:
  clang/lib/Sema/SemaAttr.cpp
  clang/test/Sema/pragma-ms-alloc-text.c
  clang/test/Sema/pragma-ms-alloc-text.cpp


Index: clang/test/Sema/pragma-ms-alloc-text.cpp
===
--- clang/test/Sema/pragma-ms-alloc-text.cpp
+++ clang/test/Sema/pragma-ms-alloc-text.cpp
@@ -34,3 +34,9 @@
 void foo5();// expected-note {{previous declaration is here}}
 #pragma alloc_text(c, foo5) // expected-error {{'#pragma alloc_text' is 
applicable only to functions with C linkage}}
 extern "C" void foo5() {}   // expected-error {{declaration of 'foo5' has a 
different language linkage}}
+
+extern "C" {
+static void foo6();
+#pragma alloc_text(c, foo6) // no-warning
+void foo6() {}
+}
Index: clang/test/Sema/pragma-ms-alloc-text.c
===
--- /dev/null
+++ clang/test/Sema/pragma-ms-alloc-text.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fms-extensions -fsyntax-only -verify %s
+
+void foo();
+#pragma alloc_text("hello", foo) // expected-no-diagnostics
+void foo() {}
+
+static void foo1();
+#pragma alloc_text("hello", foo1) // expected-no-diagnostics
+void foo1() {}
Index: clang/lib/Sema/SemaAttr.cpp
===
--- clang/lib/Sema/SemaAttr.cpp
+++ clang/lib/Sema/SemaAttr.cpp
@@ -763,7 +763,7 @@
 }
 
 DeclContext *DC = ND->getDeclContext();
-if (!DC->isExternCContext()) {
+if (getLangOpts().CPlusPlus && !DC->isExternCContext()) {
   Diag(Loc, diag::err_pragma_alloc_text_c_linkage);
   return;
 }


Index: clang/test/Sema/pragma-ms-alloc-text.cpp
===
--- clang/test/Sema/pragma-ms-alloc-text.cpp
+++ clang/test/Sema/pragma-ms-alloc-text.cpp
@@ -34,3 +34,9 @@
 void foo5();// expected-note {{previous declaration is here}}
 #pragma alloc_text(c, foo5) // expected-error {{'#pragma alloc_text' is applicable only to functions with C linkage}}
 extern "C" void foo5() {}   // expected-error {{declaration of 'foo5' has a different language linkage}}
+
+extern "C" {
+static void foo6();
+#pragma alloc_text(c, foo6) // no-warning
+void foo6() {}
+}
Index: clang/test/Sema/pragma-ms-alloc-text.c
===
--- /dev/null
+++ clang/test/Sema/pragma-ms-alloc-text.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fms-extensions -fsyntax-only -verify %s
+
+void foo();
+#pragma alloc_text("hello", foo) // expected-no-diagnostics
+void foo() {}
+
+static void foo1();
+#pragma alloc_text("hello", foo1) // expected-no-diagnostics
+void foo1() {}
Index: clang/lib/Sema/SemaAttr.cpp
===
--- clang/lib/Sema/SemaAttr.cpp
+++ clang/lib/Sema/SemaAttr.cpp
@@ -763,7 +763,7 @@
 }
 
 DeclContext *DC = ND->getDeclContext();
-if (!DC->isExternCContext()) {
+if (getLangOpts().CPlusPlus && !DC->isExternCContext()) {
   Diag(Loc, diag::err_pragma_alloc_text_c_linkage);
   return;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75277: [WebAssembly] Remove restriction on main name mangling

2022-05-31 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 updated this revision to Diff 433191.
sbc100 added a comment.

- revert parts


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75277/new/

https://reviews.llvm.org/D75277

Files:
  clang/lib/AST/Mangle.cpp
  clang/lib/CodeGen/CodeGenModule.cpp


Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -555,10 +555,8 @@
 CodeGenFunction(*this).EmitCfiCheckStub();
   }
   emitAtAvailableLinkGuard();
-  if (Context.getTargetInfo().getTriple().isWasm() &&
-  !Context.getTargetInfo().getTriple().isOSEmscripten()) {
+  if (Context.getTargetInfo().getTriple().isWasm())
 EmitMainVoidAlias();
-  }
 
   if (getTriple().isAMDGPU()) {
 // Emit reference of __amdgpu_device_library_preserve_asan_functions to
@@ -6357,8 +6355,10 @@
   // new-style no-argument main is in used.
   if (llvm::Function *F = getModule().getFunction("main")) {
 if (!F->isDeclaration() && F->arg_size() == 0 && !F->isVarArg() &&
-F->getReturnType()->isIntegerTy(Context.getTargetInfo().getIntWidth()))
-  addUsedGlobal(llvm::GlobalAlias::create("__main_void", F));
+
F->getReturnType()->isIntegerTy(Context.getTargetInfo().getIntWidth())) {
+  auto *GA = llvm::GlobalAlias::create("__main_void", F);
+  GA->setVisibility(F->getVisibility());
+}
   }
 }
 
Index: clang/lib/AST/Mangle.cpp
===
--- clang/lib/AST/Mangle.cpp
+++ clang/lib/AST/Mangle.cpp
@@ -70,9 +70,7 @@
 
   // On wasm, the argc/argv form of "main" is renamed so that the startup code
   // can call it with the correct function signature.
-  // On Emscripten, users may be exporting "main" and expecting to call it
-  // themselves, so we can't mangle it.
-  if (Triple.isWasm() && !Triple.isOSEmscripten())
+  if (Triple.isWasm())
 if (const FunctionDecl *FD = dyn_cast(ND))
   if (FD->isMain() && FD->hasPrototype() && FD->param_size() == 2)
 return CCM_WasmMainArgcArgv;


Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -555,10 +555,8 @@
 CodeGenFunction(*this).EmitCfiCheckStub();
   }
   emitAtAvailableLinkGuard();
-  if (Context.getTargetInfo().getTriple().isWasm() &&
-  !Context.getTargetInfo().getTriple().isOSEmscripten()) {
+  if (Context.getTargetInfo().getTriple().isWasm())
 EmitMainVoidAlias();
-  }
 
   if (getTriple().isAMDGPU()) {
 // Emit reference of __amdgpu_device_library_preserve_asan_functions to
@@ -6357,8 +6355,10 @@
   // new-style no-argument main is in used.
   if (llvm::Function *F = getModule().getFunction("main")) {
 if (!F->isDeclaration() && F->arg_size() == 0 && !F->isVarArg() &&
-F->getReturnType()->isIntegerTy(Context.getTargetInfo().getIntWidth()))
-  addUsedGlobal(llvm::GlobalAlias::create("__main_void", F));
+F->getReturnType()->isIntegerTy(Context.getTargetInfo().getIntWidth())) {
+  auto *GA = llvm::GlobalAlias::create("__main_void", F);
+  GA->setVisibility(F->getVisibility());
+}
   }
 }
 
Index: clang/lib/AST/Mangle.cpp
===
--- clang/lib/AST/Mangle.cpp
+++ clang/lib/AST/Mangle.cpp
@@ -70,9 +70,7 @@
 
   // On wasm, the argc/argv form of "main" is renamed so that the startup code
   // can call it with the correct function signature.
-  // On Emscripten, users may be exporting "main" and expecting to call it
-  // themselves, so we can't mangle it.
-  if (Triple.isWasm() && !Triple.isOSEmscripten())
+  if (Triple.isWasm())
 if (const FunctionDecl *FD = dyn_cast(ND))
   if (FD->isMain() && FD->hasPrototype() && FD->param_size() == 2)
 return CCM_WasmMainArgcArgv;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75277: [WebAssembly] Remove restriction on main name mangling

2022-05-31 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added inline comments.



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp:264
-  }
-}
   }

sunfish wrote:
> Why is this code going away? This isn't Emscripten-specific code.
Ah.. I was hoping we could delete these codepaths, but maybe not.. :(


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75277/new/

https://reviews.llvm.org/D75277

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126719: [clang-cl] Add support for /kernel

2022-05-31 Thread Stephen Long via Phabricator via cfe-commits
steplong updated this revision to Diff 433185.
steplong added a comment.

- Test that exceptions aren't enabled with /kernel


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126719/new/

https://reviews.llvm.org/D126719

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/OSTargets.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/cl-zc.cpp


Index: clang/test/Driver/cl-zc.cpp
===
--- clang/test/Driver/cl-zc.cpp
+++ clang/test/Driver/cl-zc.cpp
@@ -24,6 +24,10 @@
 // RUN: %clang_cl /c /std:c++17 -### /Zc:alignedNew- -- %s 2>&1 | FileCheck 
-check-prefix=ALIGNED-NEW-OFF %s
 // ALIGNED-NEW-OFF-NOT: "-faligned-allocation"
 
+// RUN: %clang_cl /c -### /kernel -- %s 2>&1 | FileCheck 
-check-prefixes=KERNEL-NO-RTTI,KERNEL-NO-EXCEPTIONS %s
+// KERNEL-NO-RTTI: "-fno-rtti"
+// KERNEL-NO-EXCEPTIONS-NOT: "-fcxx-exceptions" "-fexceptions"
+
 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck 
-check-prefix=STRICTSTRINGS-DEFAULT %s
 // STRICTSTRINGS-DEFAULT-NOT: -Werror=c++11-compat-deprecated-writable-strings
 // RUN: %clang_cl /c -### /Zc:strictStrings -- %s 2>&1 | FileCheck 
-check-prefix=STRICTSTRINGS-ON %s
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -7458,6 +7458,13 @@
 EH.NoUnwindC = true;
   }
 
+  if (Args.hasFlag(options::OPT__SLASH_kernel, options::OPT__SLASH_kernel,
+   false)) {
+EH.Synch = false;
+EH.NoUnwindC = false;
+EH.Asynch = false;
+  }
+
   return EH;
 }
 
@@ -7602,6 +7609,11 @@
CmdArgs.push_back("-fno-wchar");
  }
 
+ if (Args.hasFlag(options::OPT__SLASH_kernel, options::OPT__SLASH_kernel,
+  false)) {
+   CmdArgs.push_back("-fno-rtti");
+ }
+
   Arg *MostGeneralArg = Args.getLastArg(options::OPT__SLASH_vmg);
   Arg *BestCaseArg = Args.getLastArg(options::OPT__SLASH_vmb);
   if (MostGeneralArg && BestCaseArg)
@@ -7671,6 +7683,9 @@
 CmdArgs.push_back("msvc");
   }
 
+  if (Args.hasArg(options::OPT__SLASH_kernel))
+CmdArgs.push_back("-fms-kernel");
+
   if (Arg *A = Args.getLastArg(options::OPT__SLASH_guard)) {
 StringRef GuardArgs = A->getValue();
 // The only valid options are "cf", "cf,nochecks", "cf-", "ehcont" and
Index: clang/lib/Basic/Targets/OSTargets.cpp
===
--- clang/lib/Basic/Targets/OSTargets.cpp
+++ clang/lib/Basic/Targets/OSTargets.cpp
@@ -215,6 +215,9 @@
 }
   }
 
+  if (Opts.Kernel)
+Builder.defineMacro("_KERNEL_MODE");
+
   Builder.defineMacro("_INTEGRAL_MAX_BITS", "64");
   Builder.defineMacro("__STDC_NO_THREADS__");
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2178,6 +2178,8 @@
   NormalizedValues<["PPTMK_FullGeneralitySingleInheritance", 
"PPTMK_FullGeneralityMultipleInheritance",
 "PPTMK_FullGeneralityVirtualInheritance"]>,
   MarshallingInfoEnum, 
"PPTMK_BestCase">;
+def fms_kernel : Flag<["-"], "fms-kernel">, Group, Flags<[CC1Option, 
NoDriverOption]>,
+  MarshallingInfoFlag>;
 // __declspec is enabled by default for the PS4 by the driver, and also
 // enabled for Microsoft Extensions or Borland Extensions, here.
 //
Index: clang/include/clang/Basic/LangOptions.def
===
--- clang/include/clang/Basic/LangOptions.def
+++ clang/include/clang/Basic/LangOptions.def
@@ -88,6 +88,7 @@
 LANGOPT(C17   , 1, 0, "C17")
 LANGOPT(C2x   , 1, 0, "C2x")
 LANGOPT(MSVCCompat, 1, 0, "Microsoft Visual C++ full compatibility 
mode")
+LANGOPT(Kernel, 1, 0, "Kernel mode")
 LANGOPT(MicrosoftExt  , 1, 0, "Microsoft C++ extensions")
 LANGOPT(AsmBlocks , 1, 0, "Microsoft inline asm blocks")
 LANGOPT(Borland   , 1, 0, "Borland extensions")


Index: clang/test/Driver/cl-zc.cpp
===
--- clang/test/Driver/cl-zc.cpp
+++ clang/test/Driver/cl-zc.cpp
@@ -24,6 +24,10 @@
 // RUN: %clang_cl /c /std:c++17 -### /Zc:alignedNew- -- %s 2>&1 | FileCheck -check-prefix=ALIGNED-NEW-OFF %s
 // ALIGNED-NEW-OFF-NOT: "-faligned-allocation"
 
+// RUN: %clang_cl /c -### /kernel -- %s 2>&1 | FileCheck -check-prefixes=KERNEL-NO-RTTI,KERNEL-NO-EXCEPTIONS %s
+// KERNEL-NO-RTTI: "-fno-rtti"
+// KERNEL-NO-EXCEPTIONS-NOT: "-fcxx-exceptions" "-fexceptions"
+
 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=STRICTSTRINGS-DEFAULT %s
 // STRICTSTRINGS-DEFAULT-NOT: -Werror=c++11-compat-deprecated-writable-strings
 // RUN: %clang_cl /c -### /Zc:strictStrings -- %s 2>&1 | FileCheck 

[PATCH] D125338: [HLSL] add -D option for dxc mode.

2022-05-31 Thread Xiang Li via Phabricator via cfe-commits
python3kgae reopened this revision.
python3kgae added a comment.
This revision is now accepted and ready to land.

Reopen to recover the change after fix Mac/arm test fail.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125338/new/

https://reviews.llvm.org/D125338

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125052: [HLSL] Enable vector types for hlsl.

2022-05-31 Thread Xiang Li via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG13e1a653278b: [HLSL] Enable vector types for hlsl. (authored 
by python3kgae).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125052/new/

https://reviews.llvm.org/D125052

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/LangOptions.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/hlsl.h
  clang/lib/Headers/hlsl/hlsl_basic_types.h
  clang/test/CodeGenHLSL/basic_types.hlsl
  clang/test/Driver/hlsl_no_stdinc.hlsl

Index: clang/test/Driver/hlsl_no_stdinc.hlsl
===
--- /dev/null
+++ clang/test/Driver/hlsl_no_stdinc.hlsl
@@ -0,0 +1,12 @@
+// RUN: %clang_dxc  -Tlib_6_7 -fcgl -Fo - %s -### 2>&1 | FileCheck %s --check-prefix=STDINC
+// RUN: %clang_dxc  -Tlib_6_7 -hlsl-no-stdinc -fcgl -Fo - %s -### 2>&1 | FileCheck %s --check-prefix=NOSTDINC
+
+// RUN: %clang -cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -ast-dump -o - %s -verify
+
+// Make sure hlsl-no-stdinc is translated into finclude-default-header.
+// STDINC:"-finclude-default-header"
+// NOSTDINC-NOT:"-finclude-default-header"
+
+// Make sure uint not work when finclude-default-header is off.
+// expected-error@+1 {{unknown type name 'uint'}}
+uint a;
Index: clang/test/CodeGenHLSL/basic_types.hlsl
===
--- /dev/null
+++ clang/test/CodeGenHLSL/basic_types.hlsl
@@ -0,0 +1,76 @@
+// RUN: %clang_dxc  -Tlib_6_7 -fcgl -Fo - %s | FileCheck %s
+
+// FIXME: check 16bit types once enable-16bit-types is ready.
+
+// CHECK:@uint_Val = global i32 0, align 4
+// CHECK:@uint64_t_Val = global i64 0, align 8
+// CHECK:@int64_t_Val = global i64 0, align 8
+// CHECK:@int2_Val = global <2 x i32> zeroinitializer, align 8
+// CHECK:@int3_Val = global <3 x i32> zeroinitializer, align 16
+// CHECK:@int4_Val = global <4 x i32> zeroinitializer, align 16
+// CHECK:@uint2_Val = global <2 x i32> zeroinitializer, align 8
+// CHECK:@uint3_Val = global <3 x i32> zeroinitializer, align 16
+// CHECK:@uint4_Val = global <4 x i32> zeroinitializer, align 16
+// CHECK:@int64_t2_Val = global <2 x i64> zeroinitializer, align 16
+// CHECK:@int64_t3_Val = global <3 x i64> zeroinitializer, align 32
+// CHECK:@int64_t4_Val = global <4 x i64> zeroinitializer, align 32
+// CHECK:@uint64_t2_Val = global <2 x i64> zeroinitializer, align 16
+// CHECK:@uint64_t3_Val = global <3 x i64> zeroinitializer, align 32
+// CHECK:@uint64_t4_Val = global <4 x i64> zeroinitializer, align 32
+// CHECK:@float2_Val = global <2 x float> zeroinitializer, align 8
+// CHECK:@float3_Val = global <3 x float> zeroinitializer, align 16
+// CHECK:@float4_Val = global <4 x float> zeroinitializer, align 16
+// CHECK:@double2_Val = global <2 x double> zeroinitializer, align 16
+// CHECK:@double3_Val = global <3 x double> zeroinitializer, align 32
+// CHECK:@double4_Val = global <4 x double> zeroinitializer, align 32
+
+#define TYPE_DECL(T)  T T##_Val
+
+#ifdef __HLSL_ENABLE_16_BIT
+TYPE_DECL(uint16_t);
+TYPE_DECL(int16_t);
+#endif
+
+// unsigned 32-bit integer.
+TYPE_DECL(uint);
+
+// 64-bit integer.
+TYPE_DECL(uint64_t);
+TYPE_DECL(int64_t);
+
+// built-in vector data types:
+
+#ifdef __HLSL_ENABLE_16_BIT
+TYPE_DECL(int16_t2   );
+TYPE_DECL(int16_t3   );
+TYPE_DECL(int16_t4   );
+TYPE_DECL( uint16_t2 );
+TYPE_DECL( uint16_t3 );
+TYPE_DECL( uint16_t4 );
+#endif
+
+TYPE_DECL( int2  );
+TYPE_DECL( int3  );
+TYPE_DECL( int4  );
+TYPE_DECL( uint2 );
+TYPE_DECL( uint3 );
+TYPE_DECL( uint4 );
+TYPE_DECL( int64_t2  );
+TYPE_DECL( int64_t3  );
+TYPE_DECL( int64_t4  );
+TYPE_DECL( uint64_t2 );
+TYPE_DECL( uint64_t3 );
+TYPE_DECL( uint64_t4 );
+
+#ifdef __HLSL_ENABLE_16_BIT
+TYPE_DECL(half2 );
+TYPE_DECL(half3 );
+TYPE_DECL(half4 );
+#endif
+
+TYPE_DECL( float2  );
+TYPE_DECL( float3  );
+TYPE_DECL( float4  );
+TYPE_DECL( double2 );
+TYPE_DECL( double3 );
+TYPE_DECL( double4 );
Index: clang/lib/Headers/hlsl/hlsl_basic_types.h
===
--- /dev/null
+++ clang/lib/Headers/hlsl/hlsl_basic_types.h
@@ -0,0 +1,64 @@
+//===- hlsl_basic_types.h - HLSL definitions for basic types --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _HLSL_HLSL_BASIC_TYPES_H_
+#define _HLSL_HLSL_BASIC_TYPES_H_
+
+// built-in scalar data types:
+
+#ifdef __HLSL_ENABLE_16_BIT
+// 16-bit integer.
+typedef unsigned short uint16_t;
+typedef short int16_t;
+#endif
+
+// 

[clang] 13e1a65 - [HLSL] Enable vector types for hlsl.

2022-05-31 Thread Xiang Li via cfe-commits

Author: Xiang Li
Date: 2022-05-31T13:54:17-07:00
New Revision: 13e1a653278ba4a9805f0247c5bc92dad720aab3

URL: 
https://github.com/llvm/llvm-project/commit/13e1a653278ba4a9805f0247c5bc92dad720aab3
DIFF: 
https://github.com/llvm/llvm-project/commit/13e1a653278ba4a9805f0247c5bc92dad720aab3.diff

LOG: [HLSL] Enable vector types for hlsl.

Vector types in hlsl is using clang ext_vector_type.
Declaration of vector types is in builtin header hlsl.h.
hlsl.h will be included by default for hlsl shader.

Reviewed By: Anastasia

Differential Revision: https://reviews.llvm.org/D125052

Added: 
clang/lib/Headers/hlsl.h
clang/lib/Headers/hlsl/hlsl_basic_types.h
clang/test/CodeGenHLSL/basic_types.hlsl
clang/test/Driver/hlsl_no_stdinc.hlsl

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Basic/LangOptions.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Frontend/InitPreprocessor.cpp
clang/lib/Headers/CMakeLists.txt

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 26d003b001a61..fc8bda55c561d 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6055,7 +6055,7 @@ def fdefault_calling_conv_EQ : Joined<["-"], 
"fdefault-calling-conv=">,
 
 // These options cannot be marshalled, because they are used to set up the 
LangOptions defaults.
 def finclude_default_header : Flag<["-"], "finclude-default-header">,
-  HelpText<"Include default header file for OpenCL">;
+  HelpText<"Include default header file for OpenCL and HLSL">;
 def fdeclare_opencl_builtins : Flag<["-"], "fdeclare-opencl-builtins">,
   HelpText<"Add OpenCL builtin function declarations (experimental)">;
 
@@ -6784,6 +6784,8 @@ class DXCJoinedOrSeparate : Option<["/", 
"-"], name,
 def dxc_help : Option<["/", "-", "--"], "help", KIND_JOINED>,
   Group, Flags<[DXCOption, NoXarchOption]>, Alias,
   HelpText<"Display available options">;
+def dxc_no_stdinc : DXCFlag<"hlsl-no-stdinc">,
+  HelpText<"HLSL only. Disables all standard includes containing non-native 
compiler types and functions.">;
 def Fo : DXCJoinedOrSeparate<"Fo">, Alias,
   HelpText<"Output object file">;
 def dxil_validator_version : Option<["/", "-"], "validator-version", 
KIND_SEPARATE>,

diff  --git a/clang/lib/Basic/LangOptions.cpp b/clang/lib/Basic/LangOptions.cpp
index 7791bff388be7..7549f3f2e23b4 100644
--- a/clang/lib/Basic/LangOptions.cpp
+++ b/clang/lib/Basic/LangOptions.cpp
@@ -117,6 +117,8 @@ void LangOptions::setLangDefaults(LangOptions , 
Language Lang,
   Opts.Digraphs = Std.hasDigraphs();
 
   Opts.HLSL = Lang == Language::HLSL;
+  if (Opts.HLSL && Opts.IncludeDefaultHeader)
+Includes.push_back("hlsl.h");
 
   // Set OpenCL Version.
   Opts.OpenCL = Std.isOpenCL();

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 5106c0e327b87..a8706215bf605 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3484,6 +3484,9 @@ static void RenderHLSLOptions(const ArgList , 
ArgStringList ,
   for (const auto  : ForwardedArguments)
 if (const auto *A = Args.getLastArg(Arg))
   A->renderAsInput(Args, CmdArgs);
+  // Add the default headers if dxc_no_stdinc is not set.
+  if (!Args.hasArg(options::OPT_dxc_no_stdinc))
+CmdArgs.push_back("-finclude-default-header");
 }
 
 static void RenderARCMigrateToolOptions(const Driver , const ArgList ,

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 32b084dfedecc..a51d4621ba682 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -4202,6 +4202,10 @@ static void GeneratePreprocessorArgs(PreprocessorOptions 
,
 ((LangOpts.DeclareOpenCLBuiltins && I == "opencl-c-base.h") ||
  I == "opencl-c.h"))
   continue;
+// Don't generate HLSL includes. They are implied by other flags that are
+// generated elsewhere.
+if (LangOpts.HLSL && I == "hlsl.h")
+  continue;
 
 GenerateArg(Args, OPT_include, I, SA);
   }

diff  --git a/clang/lib/Frontend/InitPreprocessor.cpp 
b/clang/lib/Frontend/InitPreprocessor.cpp
index 3921f7949a0a9..4c5e7325d7960 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -377,6 +377,10 @@ static void InitializeStandardPredefinedMacros(const 
TargetInfo ,
 Builder.defineMacro("__HLSL_VERSION",
 Twine((unsigned)LangOpts.getHLSLVersion()));
 
+if (LangOpts.NativeHalfType)
+  Builder.defineMacro("__HLSL_ENABLE_16_BIT",
+  Twine((unsigned)LangOpts.getHLSLVersion()));
+
 // Shader target information
 // "enums" for shader stages
 Builder.defineMacro("__SHADER_STAGE_VERTEX",

diff  --git 

[PATCH] D125052: [HLSL] Enable vector types for hlsl.

2022-05-31 Thread Xiang Li via Phabricator via cfe-commits
python3kgae updated this revision to Diff 433179.
python3kgae added a comment.

Recover after fix Mac/arm test issue.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125052/new/

https://reviews.llvm.org/D125052

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/LangOptions.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/hlsl.h
  clang/lib/Headers/hlsl/hlsl_basic_types.h
  clang/test/CodeGenHLSL/basic_types.hlsl
  clang/test/Driver/hlsl_no_stdinc.hlsl

Index: clang/test/Driver/hlsl_no_stdinc.hlsl
===
--- /dev/null
+++ clang/test/Driver/hlsl_no_stdinc.hlsl
@@ -0,0 +1,12 @@
+// RUN: %clang_dxc  -Tlib_6_7 -fcgl -Fo - %s -### 2>&1 | FileCheck %s --check-prefix=STDINC
+// RUN: %clang_dxc  -Tlib_6_7 -hlsl-no-stdinc -fcgl -Fo - %s -### 2>&1 | FileCheck %s --check-prefix=NOSTDINC
+
+// RUN: %clang -cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -ast-dump -o - %s -verify
+
+// Make sure hlsl-no-stdinc is translated into finclude-default-header.
+// STDINC:"-finclude-default-header"
+// NOSTDINC-NOT:"-finclude-default-header"
+
+// Make sure uint not work when finclude-default-header is off.
+// expected-error@+1 {{unknown type name 'uint'}}
+uint a;
Index: clang/test/CodeGenHLSL/basic_types.hlsl
===
--- /dev/null
+++ clang/test/CodeGenHLSL/basic_types.hlsl
@@ -0,0 +1,76 @@
+// RUN: %clang_dxc  -Tlib_6_7 -fcgl -Fo - %s | FileCheck %s
+
+// FIXME: check 16bit types once enable-16bit-types is ready.
+
+// CHECK:@uint_Val = global i32 0, align 4
+// CHECK:@uint64_t_Val = global i64 0, align 8
+// CHECK:@int64_t_Val = global i64 0, align 8
+// CHECK:@int2_Val = global <2 x i32> zeroinitializer, align 8
+// CHECK:@int3_Val = global <3 x i32> zeroinitializer, align 16
+// CHECK:@int4_Val = global <4 x i32> zeroinitializer, align 16
+// CHECK:@uint2_Val = global <2 x i32> zeroinitializer, align 8
+// CHECK:@uint3_Val = global <3 x i32> zeroinitializer, align 16
+// CHECK:@uint4_Val = global <4 x i32> zeroinitializer, align 16
+// CHECK:@int64_t2_Val = global <2 x i64> zeroinitializer, align 16
+// CHECK:@int64_t3_Val = global <3 x i64> zeroinitializer, align 32
+// CHECK:@int64_t4_Val = global <4 x i64> zeroinitializer, align 32
+// CHECK:@uint64_t2_Val = global <2 x i64> zeroinitializer, align 16
+// CHECK:@uint64_t3_Val = global <3 x i64> zeroinitializer, align 32
+// CHECK:@uint64_t4_Val = global <4 x i64> zeroinitializer, align 32
+// CHECK:@float2_Val = global <2 x float> zeroinitializer, align 8
+// CHECK:@float3_Val = global <3 x float> zeroinitializer, align 16
+// CHECK:@float4_Val = global <4 x float> zeroinitializer, align 16
+// CHECK:@double2_Val = global <2 x double> zeroinitializer, align 16
+// CHECK:@double3_Val = global <3 x double> zeroinitializer, align 32
+// CHECK:@double4_Val = global <4 x double> zeroinitializer, align 32
+
+#define TYPE_DECL(T)  T T##_Val
+
+#ifdef __HLSL_ENABLE_16_BIT
+TYPE_DECL(uint16_t);
+TYPE_DECL(int16_t);
+#endif
+
+// unsigned 32-bit integer.
+TYPE_DECL(uint);
+
+// 64-bit integer.
+TYPE_DECL(uint64_t);
+TYPE_DECL(int64_t);
+
+// built-in vector data types:
+
+#ifdef __HLSL_ENABLE_16_BIT
+TYPE_DECL(int16_t2   );
+TYPE_DECL(int16_t3   );
+TYPE_DECL(int16_t4   );
+TYPE_DECL( uint16_t2 );
+TYPE_DECL( uint16_t3 );
+TYPE_DECL( uint16_t4 );
+#endif
+
+TYPE_DECL( int2  );
+TYPE_DECL( int3  );
+TYPE_DECL( int4  );
+TYPE_DECL( uint2 );
+TYPE_DECL( uint3 );
+TYPE_DECL( uint4 );
+TYPE_DECL( int64_t2  );
+TYPE_DECL( int64_t3  );
+TYPE_DECL( int64_t4  );
+TYPE_DECL( uint64_t2 );
+TYPE_DECL( uint64_t3 );
+TYPE_DECL( uint64_t4 );
+
+#ifdef __HLSL_ENABLE_16_BIT
+TYPE_DECL(half2 );
+TYPE_DECL(half3 );
+TYPE_DECL(half4 );
+#endif
+
+TYPE_DECL( float2  );
+TYPE_DECL( float3  );
+TYPE_DECL( float4  );
+TYPE_DECL( double2 );
+TYPE_DECL( double3 );
+TYPE_DECL( double4 );
Index: clang/lib/Headers/hlsl/hlsl_basic_types.h
===
--- /dev/null
+++ clang/lib/Headers/hlsl/hlsl_basic_types.h
@@ -0,0 +1,64 @@
+//===- hlsl_basic_types.h - HLSL definitions for basic types --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _HLSL_HLSL_BASIC_TYPES_H_
+#define _HLSL_HLSL_BASIC_TYPES_H_
+
+// built-in scalar data types:
+
+#ifdef __HLSL_ENABLE_16_BIT
+// 16-bit integer.
+typedef unsigned short uint16_t;
+typedef short int16_t;
+#endif
+
+// unsigned 32-bit integer.
+typedef unsigned int uint;
+
+// 64-bit integer.
+typedef unsigned long uint64_t;

[PATCH] D125052: [HLSL] Enable vector types for hlsl.

2022-05-31 Thread Xiang Li via Phabricator via cfe-commits
python3kgae reopened this revision.
python3kgae added a comment.
This revision is now accepted and ready to land.

Reopen for the Mac/arm test fail.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125052/new/

https://reviews.llvm.org/D125052

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126719: [clang-cl] Add support for /kernel

2022-05-31 Thread Stephen Long via Phabricator via cfe-commits
steplong created this revision.
Herald added a project: All.
steplong requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

MSVC defines _KERNEL_MODE when /kernel is passed.
Also, /kernel disables RTTI and C++ exception handling.

https://docs.microsoft.com/en-us/cpp/build/reference/kernel-create-kernel-mode-binary?view=msvc-170


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126719

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/OSTargets.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/cl-zc.cpp


Index: clang/test/Driver/cl-zc.cpp
===
--- clang/test/Driver/cl-zc.cpp
+++ clang/test/Driver/cl-zc.cpp
@@ -24,6 +24,9 @@
 // RUN: %clang_cl /c /std:c++17 -### /Zc:alignedNew- -- %s 2>&1 | FileCheck 
-check-prefix=ALIGNED-NEW-OFF %s
 // ALIGNED-NEW-OFF-NOT: "-faligned-allocation"
 
+// RUN: %clang_cl /c -### /kernel -- %s 2>&1 | FileCheck -check-prefix=KERNEL 
%s
+// KERNEL: "-fno-rtti"
+
 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck 
-check-prefix=STRICTSTRINGS-DEFAULT %s
 // STRICTSTRINGS-DEFAULT-NOT: -Werror=c++11-compat-deprecated-writable-strings
 // RUN: %clang_cl /c -### /Zc:strictStrings -- %s 2>&1 | FileCheck 
-check-prefix=STRICTSTRINGS-ON %s
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -7458,6 +7458,13 @@
 EH.NoUnwindC = true;
   }
 
+  if (Args.hasFlag(options::OPT__SLASH_kernel, options::OPT__SLASH_kernel,
+   false)) {
+EH.Synch = false;
+EH.NoUnwindC = false;
+EH.Asynch = false;
+  }
+
   return EH;
 }
 
@@ -7602,6 +7609,11 @@
CmdArgs.push_back("-fno-wchar");
  }
 
+ if (Args.hasFlag(options::OPT__SLASH_kernel, options::OPT__SLASH_kernel,
+  false)) {
+   CmdArgs.push_back("-fno-rtti");
+ }
+
   Arg *MostGeneralArg = Args.getLastArg(options::OPT__SLASH_vmg);
   Arg *BestCaseArg = Args.getLastArg(options::OPT__SLASH_vmb);
   if (MostGeneralArg && BestCaseArg)
@@ -7671,6 +7683,9 @@
 CmdArgs.push_back("msvc");
   }
 
+  if (Args.hasArg(options::OPT__SLASH_kernel))
+CmdArgs.push_back("-fms-kernel");
+
   if (Arg *A = Args.getLastArg(options::OPT__SLASH_guard)) {
 StringRef GuardArgs = A->getValue();
 // The only valid options are "cf", "cf,nochecks", "cf-", "ehcont" and
Index: clang/lib/Basic/Targets/OSTargets.cpp
===
--- clang/lib/Basic/Targets/OSTargets.cpp
+++ clang/lib/Basic/Targets/OSTargets.cpp
@@ -215,6 +215,9 @@
 }
   }
 
+  if (Opts.Kernel)
+Builder.defineMacro("_KERNEL_MODE");
+
   Builder.defineMacro("_INTEGRAL_MAX_BITS", "64");
   Builder.defineMacro("__STDC_NO_THREADS__");
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2178,6 +2178,8 @@
   NormalizedValues<["PPTMK_FullGeneralitySingleInheritance", 
"PPTMK_FullGeneralityMultipleInheritance",
 "PPTMK_FullGeneralityVirtualInheritance"]>,
   MarshallingInfoEnum, 
"PPTMK_BestCase">;
+def fms_kernel : Flag<["-"], "fms-kernel">, Group, Flags<[CC1Option, 
NoDriverOption]>,
+  MarshallingInfoFlag>;
 // __declspec is enabled by default for the PS4 by the driver, and also
 // enabled for Microsoft Extensions or Borland Extensions, here.
 //
Index: clang/include/clang/Basic/LangOptions.def
===
--- clang/include/clang/Basic/LangOptions.def
+++ clang/include/clang/Basic/LangOptions.def
@@ -88,6 +88,7 @@
 LANGOPT(C17   , 1, 0, "C17")
 LANGOPT(C2x   , 1, 0, "C2x")
 LANGOPT(MSVCCompat, 1, 0, "Microsoft Visual C++ full compatibility 
mode")
+LANGOPT(Kernel, 1, 0, "Kernel mode")
 LANGOPT(MicrosoftExt  , 1, 0, "Microsoft C++ extensions")
 LANGOPT(AsmBlocks , 1, 0, "Microsoft inline asm blocks")
 LANGOPT(Borland   , 1, 0, "Borland extensions")


Index: clang/test/Driver/cl-zc.cpp
===
--- clang/test/Driver/cl-zc.cpp
+++ clang/test/Driver/cl-zc.cpp
@@ -24,6 +24,9 @@
 // RUN: %clang_cl /c /std:c++17 -### /Zc:alignedNew- -- %s 2>&1 | FileCheck -check-prefix=ALIGNED-NEW-OFF %s
 // ALIGNED-NEW-OFF-NOT: "-faligned-allocation"
 
+// RUN: %clang_cl /c -### /kernel -- %s 2>&1 | FileCheck -check-prefix=KERNEL %s
+// KERNEL: "-fno-rtti"
+
 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=STRICTSTRINGS-DEFAULT %s
 // STRICTSTRINGS-DEFAULT-NOT: -Werror=c++11-compat-deprecated-writable-strings
 // RUN: %clang_cl /c -### /Zc:strictStrings -- %s 2>&1 | FileCheck 

[PATCH] D126498: [clangd] Fix hover crashing on integral or enumeral casts

2022-05-31 Thread Georg Kotheimer via Phabricator via cfe-commits
gkll updated this revision to Diff 433174.
gkll added a comment.

Changed return type of non-returning function in test code to void.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126498/new/

https://reviews.llvm.org/D126498

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -3206,6 +3206,33 @@
   ASSERT_TRUE(H);
   EXPECT_EQ(H->Definition, "int arr[]");
 }
+
+TEST(Hover, GlobalVarEnumeralCastNoCrash) {
+  Annotations T(R"cpp(
+enum Test : unsigned long {};
+unsigned global_var;
+void foo() { Test v^al = (Test)(unsigned long)_var; }
+  )cpp");
+
+  TestTU TU = TestTU::withCode(T.code());
+  auto AST = TU.build();
+  auto HI = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
+  ASSERT_TRUE(HI);
+  EXPECT_EQ(*HI->Value, "_var");
+}
+
+TEST(Hover, GlobalVarIntCastNoCrash) {
+  Annotations T(R"cpp(
+unsigned global_var;
+void foo() { unsigned long a^ddress = (unsigned long)_var; }
+  )cpp");
+
+  TestTU TU = TestTU::withCode(T.code());
+  auto AST = TU.build();
+  auto HI = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
+  ASSERT_TRUE(HI);
+  EXPECT_EQ(*HI->Value, "_var");
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -429,7 +429,8 @@
 return llvm::None;
 
   // Show enums symbolically, not numerically like APValue::printPretty().
-  if (T->isEnumeralType() && Constant.Val.getInt().getMinSignedBits() <= 64) {
+  if (T->isEnumeralType() && Constant.Val.isInt() &&
+  Constant.Val.getInt().getMinSignedBits() <= 64) {
 // Compare to int64_t to avoid bit-width match requirements.
 int64_t Val = Constant.Val.getInt().getExtValue();
 for (const EnumConstantDecl *ECD :
@@ -440,7 +441,7 @@
 .str();
   }
   // Show hex value of integers if they're at least 10 (or negative!)
-  if (T->isIntegralOrEnumerationType() &&
+  if (T->isIntegralOrEnumerationType() && Constant.Val.isInt() &&
   Constant.Val.getInt().getMinSignedBits() <= 64 &&
   Constant.Val.getInt().uge(10))
 return llvm::formatv("{0} ({1})", Constant.Val.getAsString(Ctx, T),


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -3206,6 +3206,33 @@
   ASSERT_TRUE(H);
   EXPECT_EQ(H->Definition, "int arr[]");
 }
+
+TEST(Hover, GlobalVarEnumeralCastNoCrash) {
+  Annotations T(R"cpp(
+enum Test : unsigned long {};
+unsigned global_var;
+void foo() { Test v^al = (Test)(unsigned long)_var; }
+  )cpp");
+
+  TestTU TU = TestTU::withCode(T.code());
+  auto AST = TU.build();
+  auto HI = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
+  ASSERT_TRUE(HI);
+  EXPECT_EQ(*HI->Value, "_var");
+}
+
+TEST(Hover, GlobalVarIntCastNoCrash) {
+  Annotations T(R"cpp(
+unsigned global_var;
+void foo() { unsigned long a^ddress = (unsigned long)_var; }
+  )cpp");
+
+  TestTU TU = TestTU::withCode(T.code());
+  auto AST = TU.build();
+  auto HI = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
+  ASSERT_TRUE(HI);
+  EXPECT_EQ(*HI->Value, "_var");
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -429,7 +429,8 @@
 return llvm::None;
 
   // Show enums symbolically, not numerically like APValue::printPretty().
-  if (T->isEnumeralType() && Constant.Val.getInt().getMinSignedBits() <= 64) {
+  if (T->isEnumeralType() && Constant.Val.isInt() &&
+  Constant.Val.getInt().getMinSignedBits() <= 64) {
 // Compare to int64_t to avoid bit-width match requirements.
 int64_t Val = Constant.Val.getInt().getExtValue();
 for (const EnumConstantDecl *ECD :
@@ -440,7 +441,7 @@
 .str();
   }
   // Show hex value of integers if they're at least 10 (or negative!)
-  if (T->isIntegralOrEnumerationType() &&
+  if (T->isIntegralOrEnumerationType() && Constant.Val.isInt() &&
   Constant.Val.getInt().getMinSignedBits() <= 64 &&
   Constant.Val.getInt().uge(10))
 return llvm::formatv("{0} ({1})", Constant.Val.getAsString(Ctx, T),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75277: [WebAssembly] Remove restriction on main name mangling

2022-05-31 Thread Dan Gohman via Phabricator via cfe-commits
sunfish added inline comments.



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp:264
-  }
-}
   }

Why is this code going away? This isn't Emscripten-specific code.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75277/new/

https://reviews.llvm.org/D75277

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75277: [WebAssembly] Remove restriction on main name mangling

2022-05-31 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 updated this revision to Diff 433173.
sbc100 added a comment.

- update


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75277/new/

https://reviews.llvm.org/D75277

Files:
  clang/lib/AST/Mangle.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp

Index: llvm/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp
@@ -214,22 +214,9 @@
   return Wrapper;
 }
 
-// Test whether a main function with type FuncTy should be rewritten to have
-// type MainTy.
-static bool shouldFixMainFunction(FunctionType *FuncTy, FunctionType *MainTy) {
-  // Only fix the main function if it's the standard zero-arg form. That way,
-  // the standard cases will work as expected, and users will see signature
-  // mismatches from the linker for non-standard cases.
-  return FuncTy->getReturnType() == MainTy->getReturnType() &&
- FuncTy->getNumParams() == 0 &&
- !FuncTy->isVarArg();
-}
-
 bool FixFunctionBitcasts::runOnModule(Module ) {
   LLVM_DEBUG(dbgs() << "** Fix Function Bitcasts **\n");
 
-  Function *Main = nullptr;
-  CallInst *CallMain = nullptr;
   SmallVector, 0> Uses;
 
   // Collect all the places that need wrappers.
@@ -239,29 +226,6 @@
 if (F.getCallingConv() == CallingConv::Swift)
   continue;
 findUses(, F, Uses);
-
-// If we have a "main" function, and its type isn't
-// "int main(int argc, char *argv[])", create an artificial call with it
-// bitcasted to that type so that we generate a wrapper for it, so that
-// the C runtime can call it.
-if (F.getName() == "main") {
-  Main = 
-  LLVMContext  = M.getContext();
-  Type *MainArgTys[] = {Type::getInt32Ty(C),
-PointerType::get(Type::getInt8PtrTy(C), 0)};
-  FunctionType *MainTy = FunctionType::get(Type::getInt32Ty(C), MainArgTys,
-   /*isVarArg=*/false);
-  if (shouldFixMainFunction(F.getFunctionType(), MainTy)) {
-LLVM_DEBUG(dbgs() << "Found `main` function with incorrect type: "
-  << *F.getFunctionType() << "\n");
-Value *Args[] = {UndefValue::get(MainArgTys[0]),
- UndefValue::get(MainArgTys[1])};
-Value *Casted =
-ConstantExpr::getBitCast(Main, PointerType::get(MainTy, 0));
-CallMain = CallInst::Create(MainTy, Casted, Args, "call_main");
-Uses.push_back(std::make_pair(CallMain, ));
-  }
-}
   }
 
   DenseMap, Function *> Wrappers;
@@ -282,25 +246,5 @@
 CB->setCalledOperand(Wrapper);
   }
 
-  // If we created a wrapper for main, rename the wrapper so that it's the
-  // one that gets called from startup.
-  if (CallMain) {
-Main->setName("__original_main");
-auto *MainWrapper =
-cast(CallMain->getCalledOperand()->stripPointerCasts());
-delete CallMain;
-if (Main->isDeclaration()) {
-  // The wrapper is not needed in this case as we don't need to export
-  // it to anyone else.
-  MainWrapper->eraseFromParent();
-} else {
-  // Otherwise give the wrapper the same linkage as the original main
-  // function, so that it can be called from the same places.
-  MainWrapper->setName("main");
-  MainWrapper->setLinkage(Main->getLinkage());
-  MainWrapper->setVisibility(Main->getVisibility());
-}
-  }
-
   return true;
 }
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -555,10 +555,8 @@
 CodeGenFunction(*this).EmitCfiCheckStub();
   }
   emitAtAvailableLinkGuard();
-  if (Context.getTargetInfo().getTriple().isWasm() &&
-  !Context.getTargetInfo().getTriple().isOSEmscripten()) {
+  if (Context.getTargetInfo().getTriple().isWasm())
 EmitMainVoidAlias();
-  }
 
   if (getTriple().isAMDGPU()) {
 // Emit reference of __amdgpu_device_library_preserve_asan_functions to
@@ -6357,8 +6355,10 @@
   // new-style no-argument main is in used.
   if (llvm::Function *F = getModule().getFunction("main")) {
 if (!F->isDeclaration() && F->arg_size() == 0 && !F->isVarArg() &&
-F->getReturnType()->isIntegerTy(Context.getTargetInfo().getIntWidth()))
-  addUsedGlobal(llvm::GlobalAlias::create("__main_void", F));
+F->getReturnType()->isIntegerTy(Context.getTargetInfo().getIntWidth())) {
+  auto *GA = llvm::GlobalAlias::create("__main_void", F);
+  GA->setVisibility(F->getVisibility());
+}
   }
 }
 
Index: clang/lib/AST/Mangle.cpp
===
--- clang/lib/AST/Mangle.cpp
+++ clang/lib/AST/Mangle.cpp
@@ -70,9 

[PATCH] D126498: [clangd] Fix hover crashing on integral or enumeral casts

2022-05-31 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Landed as ce5ebf0b9113df8ccaec1bcfd6804fb16cdef69d 
 but I had 
to revert due to test failures on windows:

- https://buildkite.com/llvm-project/premerge-checks/builds/94783
- http://45.33.8.238/win/59124/step_9.txt

Unfortunately neither of these give a stack trace, so I'm not yet sure what's 
wrong, beyond "some Optional is null when it shouldn't be".
A wild guess: `long` is shorter than a pointer on 64-bit windows, so that code 
doesn't even parse.
Indeed `(int)_var` doesn't parse for me on a 64-bit linux machine 
(32-bit int, 64-bit pointer).
The mystery in that case, though, is why the test output doesn't show parse 
error before crashing (TestTU is supposed to dump this unless you set ErrorOK).

It's late, but I'll try fixing and re-landing tomorrow.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126498/new/

https://reviews.llvm.org/D126498

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125839: [gmodules] Skip CXXDeductionGuideDecls when visiting FunctionDecls in DebugTypeVisitor

2022-05-31 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl accepted this revision.
aprantl added a comment.
This revision is now accepted and ready to land.

Adding the debug-info group. I don't really know enough about deduction guides 
to comment on the implications, but if it fixes the crash it seems to be a 
strict improvement. Maybe wait another day to see if someone else has an 
opinion on this.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125839/new/

https://reviews.llvm.org/D125839

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 218393f - Revert "[clangd] Fix hover crashing on integral or enumeral casts"

2022-05-31 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-05-31T22:30:20+02:00
New Revision: 218393f44ec903341125b70ce3fbb6dc731a9399

URL: 
https://github.com/llvm/llvm-project/commit/218393f44ec903341125b70ce3fbb6dc731a9399
DIFF: 
https://github.com/llvm/llvm-project/commit/218393f44ec903341125b70ce3fbb6dc731a9399.diff

LOG: Revert "[clangd] Fix hover crashing on integral or enumeral casts"

This reverts commit ce5ebf0b9113df8ccaec1bcfd6804fb16cdef69d.

Fails on bots e.g. 
https://buildkite-cloud.s3.amazonaws.com/logs-by-pipeline/f8ab115f-a384-49e8-a048-0f71ab03c5d0/0181020b-0737-40e5-a05a-ab198347d8ad/0181020b-ecbe-4ac6-ad23-e04c17217893.log?response-content-disposition=inline=text%2Fplain=AWS4-HMAC-SHA256=ASIAQPCP3C7LT7IGTS76%2F20220531%2Fus-east-1%2Fs3%2Faws4_request=20220531T202904Z=600=IQoJb3JpZ2luX2VjEDwaCXVzLWVhc3QtMSJGMEQCIEfw6ocELTUWa2mj4reHKLe5OdUmQqVJpPsdZS2wNDhhAiB7qx6Q17HVVY%2BkJZ5hwTQ6b1MkOG4czysfciD9GghJmCrSBAg1EAAaDDAzMjM3OTcwNTMwMyIMgdUfJT4A6wcP2hl2Kq8EefYtGIt0yaiOSfuq05UzI6WcBY9yOOyYCs3%2FJJDvK3jkpiYQhjA1kgVluePIb3P4yOTXs8lv9U6p8HU555Vzvrv1Wg%2FGvx7U398lH8zg%2BqkvEwnpGuRf0pTInPJftg2bgm%2F7l%2BCM6PtW4mRlzjeQ0IoA3AeENqVM35RYtQdh%2BcAZIfV4l7uAySVgwY1yFu0XznuGAVVryZyYcA2cjKkkNE%2F9n2QTo80%2FbZBvoh1bxJqXRbs5WrSnWlIEj3RPX61ir7lDpRNL5tyVlqsv%2BvV01aS%2F9JbM4cNDXZ%2BDwOR1Q%2By1ajJOomuK9Bqm%2Fq8%2B9%2Byo1t8rFSN7I4X%2BGGuicXFQQnIJAkW3zSQlx9SWrf2uDg7cbXL4MukD9cQB5aN8yX85a%2BRcbb5l4%2BOC%2B8UFKMeemUZyEl5PyyJSBnAnzqvKviJPev9Thj9rZeHGEJD9vOkVM%2FG2tOlC7HUxXAE4kuLlAdeKdIOtHz%2Bx8FzRn%2Bgl6EB2nB4kSVLvfgrsrlHS0L0J1zWbN%2F6prqzum%2FEVIhT7Y5fyZRqtygAX2n7iBjQEM3vpF2GTneUI1FlDeQvGPLADFdq7bXSUOt577YOTw1mW1JzqmZljrJeIM40HdMYnuIg3%2FwW8oK6RKGADdW7URPw%2FoFeGKfrnN%2BuDwJKvrRGCpReseGse2sdYIe28rgGHpc5xsp3pzipQDLfW3hTNtM%2FNNuPJjUWZoBRTMr2eMuk2zs2c6jNvnuBTbgXjcdjCbjCX2dmUBjqqAUalggvk2TGoJzTuqAT%2Fj1kz0vnHdmsHY3B9aR2kY501gISXQMKj7l03E7OfFsu4oPzEgmnyQFKcAolRDI%2F7NRmG8HwtP40iTCjflOHIxkJ1%2FnVNqkeyIznUu6zOr589zIjNqFCm74jOfWjj2%2FO8WU4pc%2FRqeBuGzzpQkAIGGxCwsmd3WG8Z8pyMoJomij7c4LO6ep4O0OUESxbXHcIfzUfR6ajPsKFKS9lb=host=96a132be6f99b5cd5cf29f3226115e480508079047bc8639d69c672f1fe9f0c1

Added: 


Modified: 
clang-tools-extra/clangd/Hover.cpp
clang-tools-extra/clangd/unittests/HoverTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Hover.cpp 
b/clang-tools-extra/clangd/Hover.cpp
index 00fb992876178..fcf3af7561845 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -429,8 +429,7 @@ llvm::Optional printExprValue(const Expr *E,
 return llvm::None;
 
   // Show enums symbolically, not numerically like APValue::printPretty().
-  if (T->isEnumeralType() && Constant.Val.isInt() &&
-  Constant.Val.getInt().getMinSignedBits() <= 64) {
+  if (T->isEnumeralType() && Constant.Val.getInt().getMinSignedBits() <= 64) {
 // Compare to int64_t to avoid bit-width match requirements.
 int64_t Val = Constant.Val.getInt().getExtValue();
 for (const EnumConstantDecl *ECD :
@@ -441,7 +440,7 @@ llvm::Optional printExprValue(const Expr *E,
 .str();
   }
   // Show hex value of integers if they're at least 10 (or negative!)
-  if (T->isIntegralOrEnumerationType() && Constant.Val.isInt() &&
+  if (T->isIntegralOrEnumerationType() &&
   Constant.Val.getInt().getMinSignedBits() <= 64 &&
   Constant.Val.getInt().uge(10))
 return llvm::formatv("{0} ({1})", Constant.Val.getAsString(Ctx, T),

diff  --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp 
b/clang-tools-extra/clangd/unittests/HoverTests.cpp
index 86ecda4e454c4..25ce19b2c580b 100644
--- a/clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -3206,33 +3206,6 @@ TEST(Hover, HideBigInitializers) {
   ASSERT_TRUE(H);
   EXPECT_EQ(H->Definition, "int arr[]");
 }
-
-TEST(Hover, GlobalVarEnumeralCastNoCrash) {
-  Annotations T(R"cpp(
-enum Test : unsigned long {};
-unsigned global_var;
-void foo() { Test v^al = (Test)(unsigned long)_var; }
-  )cpp");
-
-  TestTU TU = TestTU::withCode(T.code());
-  auto AST = TU.build();
-  auto HI = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
-  ASSERT_TRUE(HI);
-  EXPECT_EQ(*HI->Value, "_var");
-}
-
-TEST(Hover, GlobalVarIntCastNoCrash) {
-  Annotations T(R"cpp(
-unsigned global_var;
-int foo() { unsigned long a^ddress = (unsigned long)_var; }
-  )cpp");
-
-  TestTU TU = TestTU::withCode(T.code());
-  auto AST = TU.build();
-  auto HI = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
-  ASSERT_TRUE(HI);
-  EXPECT_EQ(*HI->Value, "_var");
-}
 } // namespace
 } // namespace clangd
 } // namespace clang



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125585: [HLSL][clang][Driver] Parse target profile early to update Driver::TargetTriple.

2022-05-31 Thread Xiang Li via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfde240c9c328: [HLSL][clang][Driver] Parse target profile 
early to update Driver::TargetTriple. (authored by python3kgae).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125585/new/

https://reviews.llvm.org/D125585

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/HLSL.cpp
  clang/lib/Driver/ToolChains/HLSL.h
  clang/test/Driver/dxc_fcgl.hlsl
  clang/unittests/Driver/ToolChainTest.cpp

Index: clang/unittests/Driver/ToolChainTest.cpp
===
--- clang/unittests/Driver/ToolChainTest.cpp
+++ clang/unittests/Driver/ToolChainTest.cpp
@@ -387,6 +387,28 @@
   std::vector> Errors;
 };
 
+static void validateTargetProfile(StringRef TargetProfile,
+  StringRef ExpectTriple, Driver ,
+  DiagnosticsEngine ) {
+  EXPECT_TRUE(TheDriver.BuildCompilation(
+  {"clang", "--driver-mode=dxc", TargetProfile.data(), "foo.hlsl"}));
+  EXPECT_STREQ(TheDriver.getTargetTriple().c_str(), ExpectTriple.data());
+  EXPECT_EQ(Diags.getNumErrors(), 0u);
+}
+
+static void validateTargetProfile(StringRef TargetProfile,
+  StringRef ExpectError, Driver ,
+  DiagnosticsEngine ,
+  SimpleDiagnosticConsumer *DiagConsumer,
+  unsigned NumOfErrors) {
+  EXPECT_TRUE(TheDriver.BuildCompilation(
+  {"clang", "--driver-mode=dxc", TargetProfile.data(), "foo.hlsl"}));
+  EXPECT_EQ(Diags.getNumErrors(), NumOfErrors);
+  EXPECT_STREQ(DiagConsumer->Errors.back().c_str(), ExpectError.data());
+  Diags.Clear();
+  DiagConsumer->clear();
+}
+
 TEST(DxcModeTest, TargetProfileValidation) {
   IntrusiveRefCntPtr DiagID(new DiagnosticIDs());
 
@@ -400,111 +422,40 @@
   IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
   DiagnosticsEngine Diags(DiagID, &*DiagOpts, DiagConsumer);
   Driver TheDriver("/bin/clang", "", Diags, "", InMemoryFileSystem);
-  std::unique_ptr C(
-  TheDriver.BuildCompilation({"clang", "--driver-mode=dxc", "foo.hlsl"}));
-  EXPECT_TRUE(C);
-  EXPECT_TRUE(!C->containsError());
-
-  auto  = C->getDefaultToolChain();
-  bool ContainsError = false;
-  auto Args = TheDriver.ParseArgStrings({"-Tvs_6_0"}, false, ContainsError);
-  EXPECT_FALSE(ContainsError);
-  auto Triple = TC.ComputeEffectiveClangTriple(Args);
-  EXPECT_STREQ(Triple.c_str(), "dxil--shadermodel6.0-vertex");
-  EXPECT_EQ(Diags.getNumErrors(), 0u);
-
-  Args = TheDriver.ParseArgStrings({"-Ths_6_1"}, false, ContainsError);
-  EXPECT_FALSE(ContainsError);
-  Triple = TC.ComputeEffectiveClangTriple(Args);
-  EXPECT_STREQ(Triple.c_str(), "dxil--shadermodel6.1-hull");
-  EXPECT_EQ(Diags.getNumErrors(), 0u);
-
-  Args = TheDriver.ParseArgStrings({"-Tds_6_2"}, false, ContainsError);
-  EXPECT_FALSE(ContainsError);
-  Triple = TC.ComputeEffectiveClangTriple(Args);
-  EXPECT_STREQ(Triple.c_str(), "dxil--shadermodel6.2-domain");
-  EXPECT_EQ(Diags.getNumErrors(), 0u);
-
-  Args = TheDriver.ParseArgStrings({"-Tds_6_2"}, false, ContainsError);
-  EXPECT_FALSE(ContainsError);
-  Triple = TC.ComputeEffectiveClangTriple(Args);
-  EXPECT_STREQ(Triple.c_str(), "dxil--shadermodel6.2-domain");
-  EXPECT_EQ(Diags.getNumErrors(), 0u);
-
-  Args = TheDriver.ParseArgStrings({"-Tgs_6_3"}, false, ContainsError);
-  EXPECT_FALSE(ContainsError);
-  Triple = TC.ComputeEffectiveClangTriple(Args);
-  EXPECT_STREQ(Triple.c_str(), "dxil--shadermodel6.3-geometry");
-  EXPECT_EQ(Diags.getNumErrors(), 0u);
-
-  Args = TheDriver.ParseArgStrings({"-Tps_6_4"}, false, ContainsError);
-  EXPECT_FALSE(ContainsError);
-  Triple = TC.ComputeEffectiveClangTriple(Args);
-  EXPECT_STREQ(Triple.c_str(), "dxil--shadermodel6.4-pixel");
-  EXPECT_EQ(Diags.getNumErrors(), 0u);
-
-  Args = TheDriver.ParseArgStrings({"-Tcs_6_5"}, false, ContainsError);
-  EXPECT_FALSE(ContainsError);
-  Triple = TC.ComputeEffectiveClangTriple(Args);
-  EXPECT_STREQ(Triple.c_str(), "dxil--shadermodel6.5-compute");
-  EXPECT_EQ(Diags.getNumErrors(), 0u);
-
-  Args = TheDriver.ParseArgStrings({"-Tms_6_6"}, false, ContainsError);
-  EXPECT_FALSE(ContainsError);
-  Triple = TC.ComputeEffectiveClangTriple(Args);
-  EXPECT_STREQ(Triple.c_str(), "dxil--shadermodel6.6-mesh");
-  EXPECT_EQ(Diags.getNumErrors(), 0u);
 
-  Args = TheDriver.ParseArgStrings({"-Tas_6_7"}, false, ContainsError);
-  EXPECT_FALSE(ContainsError);
-  Triple = TC.ComputeEffectiveClangTriple(Args);
-  EXPECT_STREQ(Triple.c_str(), "dxil--shadermodel6.7-amplification");
-  EXPECT_EQ(Diags.getNumErrors(), 0u);
-
-  Args = TheDriver.ParseArgStrings({"-Tlib_6_x"}, false, ContainsError);
-  EXPECT_FALSE(ContainsError);
-  Triple = TC.ComputeEffectiveClangTriple(Args);
-  EXPECT_STREQ(Triple.c_str(), 

[clang] fde240c - [HLSL][clang][Driver] Parse target profile early to update Driver::TargetTriple.

2022-05-31 Thread Xiang Li via cfe-commits

Author: Xiang Li
Date: 2022-05-31T13:23:30-07:00
New Revision: fde240c9c328b8a824a064c8ccd91252516e6d41

URL: 
https://github.com/llvm/llvm-project/commit/fde240c9c328b8a824a064c8ccd91252516e6d41
DIFF: 
https://github.com/llvm/llvm-project/commit/fde240c9c328b8a824a064c8ccd91252516e6d41.diff

LOG: [HLSL][clang][Driver] Parse target profile early to update 
Driver::TargetTriple.

This is to avoid err_target_unknown_abi which is caused by use default 
TargetTriple instead of shader model target triple.

Reviewed By: beanz

Differential Revision: https://reviews.llvm.org/D125585

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/HLSL.cpp
clang/lib/Driver/ToolChains/HLSL.h
clang/test/Driver/dxc_fcgl.hlsl
clang/unittests/Driver/ToolChainTest.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 9f4864a33a33b..618e748da4441 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -666,6 +666,8 @@ def err_drv_target_variant_invalid : Error<
 
 def err_drv_invalid_directx_shader_module : Error<
   "invalid profile : %0">;
+def err_drv_dxc_missing_target_profile : Error<
+  "target profile option (-T) is missing">;
 
 def err_drv_invalid_range_dxil_validator_version : Error<
   "invalid validator version : %0\n"

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index aaef2e1ded327..3185ebcd46a4e 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1236,11 +1236,19 @@ Compilation *Driver::BuildCompilation(ArrayRef ArgList) {
 T.setObjectFormat(llvm::Triple::COFF);
 TargetTriple = T.str();
   } else if (IsDXCMode()) {
-// clang-dxc target is build from target_profile option.
-// Just set OS to shader model to select HLSLToolChain.
-llvm::Triple T(TargetTriple);
-T.setOS(llvm::Triple::ShaderModel);
-TargetTriple = T.str();
+// Build TargetTriple from target_profile option for clang-dxc.
+if (const Arg *A = Args.getLastArg(options::OPT_target_profile)) {
+  StringRef TargetProfile = A->getValue();
+  if (auto Triple =
+  toolchains::HLSLToolChain::parseTargetProfile(TargetProfile))
+TargetTriple = Triple.getValue();
+  else
+Diag(diag::err_drv_invalid_directx_shader_module) << TargetProfile;
+
+  A->claim();
+} else {
+  Diag(diag::err_drv_dxc_missing_target_profile);
+}
   }
 
   if (const Arg *A = Args.getLastArg(options::OPT_target))

diff  --git a/clang/lib/Driver/ToolChains/HLSL.cpp 
b/clang/lib/Driver/ToolChains/HLSL.cpp
index b62395b168ea4..c2b55fdde4b4c 100644
--- a/clang/lib/Driver/ToolChains/HLSL.cpp
+++ b/clang/lib/Driver/ToolChains/HLSL.cpp
@@ -64,12 +64,12 @@ bool isLegalShaderModel(Triple ) {
   return false;
 }
 
-std::string tryParseProfile(StringRef Profile) {
+llvm::Optional tryParseProfile(StringRef Profile) {
   // [ps|vs|gs|hs|ds|cs|ms|as]_[major]_[minor]
   SmallVector Parts;
   Profile.split(Parts, "_");
   if (Parts.size() != 3)
-return "";
+return NoneType();
 
   Triple::EnvironmentType Kind =
   StringSwitch(Parts[0])
@@ -84,17 +84,17 @@ std::string tryParseProfile(StringRef Profile) {
   .Case("as", Triple::EnvironmentType::Amplification)
   .Default(Triple::EnvironmentType::UnknownEnvironment);
   if (Kind == Triple::EnvironmentType::UnknownEnvironment)
-return "";
+return NoneType();
 
   unsigned long long Major = 0;
   if (llvm::getAsUnsignedInteger(Parts[1], 0, Major))
-return "";
+return NoneType();
 
   unsigned long long Minor = 0;
   if (Parts[2] == "x" && Kind == Triple::EnvironmentType::Library)
 Minor = OfflineLibMinor;
   else if (llvm::getAsUnsignedInteger(Parts[2], 0, Minor))
-return "";
+return NoneType();
 
   // dxil-unknown-shadermodel-hull
   llvm::Triple T;
@@ -105,7 +105,7 @@ std::string tryParseProfile(StringRef Profile) {
   if (isLegalShaderModel(T))
 return T.getTriple();
   else
-return "";
+return NoneType();
 }
 
 bool isLegalValidatorVersion(StringRef ValVersionStr, const Driver ) {
@@ -138,21 +138,10 @@ HLSLToolChain::HLSLToolChain(const Driver , const 
llvm::Triple ,
  const ArgList )
 : ToolChain(D, Triple, Args) {}
 
-std::string
-HLSLToolChain::ComputeEffectiveClangTriple(const ArgList ,
-   types::ID InputType) const {
-  if (Arg *A = Args.getLastArg(options::OPT_target_profile)) {
-StringRef Profile = A->getValue();
-std::string Triple = tryParseProfile(Profile);
-if (Triple == "") {
-  getDriver().Diag(diag::err_drv_invalid_directx_shader_module) << Profile;
-  Triple = ToolChain::ComputeEffectiveClangTriple(Args, 

[clang-tools-extra] ce5ebf0 - [clangd] Fix hover crashing on integral or enumeral casts

2022-05-31 Thread Sam McCall via cfe-commits

Author: Georg Kotheimer
Date: 2022-05-31T22:05:23+02:00
New Revision: ce5ebf0b9113df8ccaec1bcfd6804fb16cdef69d

URL: 
https://github.com/llvm/llvm-project/commit/ce5ebf0b9113df8ccaec1bcfd6804fb16cdef69d
DIFF: 
https://github.com/llvm/llvm-project/commit/ce5ebf0b9113df8ccaec1bcfd6804fb16cdef69d.diff

LOG: [clangd] Fix hover crashing on integral or enumeral casts

When pretty printing the value of an expression, we cannot infer from
the type of the expression the type of the constant that the expression
evaluates to, as the expression might contain a type cast.

Added: 


Modified: 
clang-tools-extra/clangd/Hover.cpp
clang-tools-extra/clangd/unittests/HoverTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Hover.cpp 
b/clang-tools-extra/clangd/Hover.cpp
index fcf3af7561845..00fb992876178 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -429,7 +429,8 @@ llvm::Optional printExprValue(const Expr *E,
 return llvm::None;
 
   // Show enums symbolically, not numerically like APValue::printPretty().
-  if (T->isEnumeralType() && Constant.Val.getInt().getMinSignedBits() <= 64) {
+  if (T->isEnumeralType() && Constant.Val.isInt() &&
+  Constant.Val.getInt().getMinSignedBits() <= 64) {
 // Compare to int64_t to avoid bit-width match requirements.
 int64_t Val = Constant.Val.getInt().getExtValue();
 for (const EnumConstantDecl *ECD :
@@ -440,7 +441,7 @@ llvm::Optional printExprValue(const Expr *E,
 .str();
   }
   // Show hex value of integers if they're at least 10 (or negative!)
-  if (T->isIntegralOrEnumerationType() &&
+  if (T->isIntegralOrEnumerationType() && Constant.Val.isInt() &&
   Constant.Val.getInt().getMinSignedBits() <= 64 &&
   Constant.Val.getInt().uge(10))
 return llvm::formatv("{0} ({1})", Constant.Val.getAsString(Ctx, T),

diff  --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp 
b/clang-tools-extra/clangd/unittests/HoverTests.cpp
index 25ce19b2c580b..86ecda4e454c4 100644
--- a/clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -3206,6 +3206,33 @@ TEST(Hover, HideBigInitializers) {
   ASSERT_TRUE(H);
   EXPECT_EQ(H->Definition, "int arr[]");
 }
+
+TEST(Hover, GlobalVarEnumeralCastNoCrash) {
+  Annotations T(R"cpp(
+enum Test : unsigned long {};
+unsigned global_var;
+void foo() { Test v^al = (Test)(unsigned long)_var; }
+  )cpp");
+
+  TestTU TU = TestTU::withCode(T.code());
+  auto AST = TU.build();
+  auto HI = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
+  ASSERT_TRUE(HI);
+  EXPECT_EQ(*HI->Value, "_var");
+}
+
+TEST(Hover, GlobalVarIntCastNoCrash) {
+  Annotations T(R"cpp(
+unsigned global_var;
+int foo() { unsigned long a^ddress = (unsigned long)_var; }
+  )cpp");
+
+  TestTU TU = TestTU::withCode(T.code());
+  auto AST = TU.build();
+  auto HI = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
+  ASSERT_TRUE(HI);
+  EXPECT_EQ(*HI->Value, "_var");
+}
 } // namespace
 } // namespace clangd
 } // namespace clang



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126061: [clang] Reject non-declaration C++11 attributes on declarations

2022-05-31 Thread Martin Böhme via Phabricator via cfe-commits
mboehme marked 8 inline comments as done.
mboehme added a comment.

I notice that https://reviews.llvm.org/D111548, which this change is based on, 
has some failing flang tests in the CI. I'm pretty sure these are unrelated and 
stem from the base revision that I happen to be based off. Before rebasing, 
however, I wanted to make sure all of the big comments have been resolved so 
that I don't introduce too much churn into the diffs.




Comment at: clang/include/clang/Sema/DeclSpec.h:1853-1856
   /// Attrs - Attributes.
   ParsedAttributes Attrs;
 
+  ParsedAttributes DeclarationAttrs;

aaron.ballman wrote:
> mboehme wrote:
> > aaron.ballman wrote:
> > > We should probably rename `Attrs` to be less generic and add some 
> > > comments to explain why there are two lists of parsed attributes.
> > I've added some comments to clarify the difference. I'm not sure what a 
> > good alternative name for `Attrs` would be though. The only obvious 
> > candidate that comes to mind is `DeclaratorAttrs`, but that seems pretty 
> > redundant given that this is a field of `Declarator`.
> > 
> > I think there is actually a good case for calling the first list simply 
> > `Attrs` because, unlike `DeclarationAttrs`, it applies directly to the 
> > `Declarator`. This distinction is amplified by the fact that, since your 
> > review, I've changed `DeclarationAttrs` to be a reference, not a by-value 
> > field.
> The new comment actually makes it less clear for me -- that says the 
> attributes are for the `DeclSpec` but they're actually for the `Declatator` 
> (there's no relationship between `Attrs` and `DS`).
> 
> Given that `DeclSpec` uses `Attrs` for its associated attributes, I think 
> it's okay to use `Attrs` here for the ones associated with the `Declarator`, 
> but the comment should be updated in that case.
Sorry, I don't know what I was thinking when I wrote `DeclSpec`. That should 
have read "Attributes attached to the declarator", and I've changed it 
accordingly.

I hope that with this change, this makes sense now?



Comment at: clang/include/clang/Sema/DeclSpec.h:1926-1928
+assert(llvm::all_of(DeclarationAttrs, [](const ParsedAttr ) {
+  return AL.isStandardAttributeSyntax();
+}));

rsmith wrote:
> rsmith wrote:
> > I think I recall seeing OpenMP pragma attributes being parsed as 
> > declaration attributes too. FIXME update this comment after review is 
> > complete
> Oops, forgot to circle back to this. I think I was wrong; please disregard :)
Just making sure I can disregard this comment? Please respond if there's 
something you'd like me to address here.



Comment at: clang/include/clang/Sema/ParsedAttr.h:664
+  /// This may only be called if isStandardAttributeSyntax() returns true.
+  bool slidesFromDeclToDeclSpec() const;
+

aaron.ballman wrote:
> Because this is now specific to standard attributes, and those don't "slide" 
> under normal circumstances, it might be nice to rename this method to make it 
> more clear that this should not be called normally. I don't have a strong 
> opinion on what a *good* name is, but even something like 
> `improperlySlidesFromDeclToDeclSpec()` would make me happy.
I've decided to add `LegacyBehavior` at the end -- WDYT?



Comment at: clang/lib/Parse/ParseDecl.cpp:1854
+ProhibitAttributes(DeclAttrs);
+ProhibitAttributes(OriginalDeclSpecAttrs);
 DeclEnd = Tok.getLocation();

aaron.ballman wrote:
> rsmith wrote:
> > This looks wrong to me (both before and after this patch; you've faithfully 
> > retained an incorrect behavior). If `DeclSpec` attributes aren't allowed, 
> > they should be diagnosed by `ParsedFreeStandingDeclSpec`. Before and after 
> > this patch, we'll diagnose attributes in a free-standing decl-specifier-seq 
> > if we happened to tentatively parse them, not if we happened to parse them 
> > in `ParseDeclarationSpecifiers`. For example:
> > 
> > ```
> > __attribute__(()) struct X; // DeclSpecAttrs will be empty, no error
> > void f() {
> >   __attribute(()) struct X; // DeclSpecAttrs will contain the attribute 
> > specifier, error
> > }
> > ```
> > 
> > Comparing to GCC's behavior for that example (which GCC silently accepts) 
> > and for this one:
> > 
> > ```
> > __attribute__((packed)) struct X; // GCC warns that packed has no meaning 
> > here, clang produces a high-quality warning.
> > void f() {
> >   __attribute((packed)) struct X; // GCC warns that packed has no meaning 
> > here, clang produces a bogus error.
> > }
> > ```
> > 
> > ... I think the right thing to do is to delete this call (along with 
> > `OriginalDeclSpecAttrs`). GNU decl-specifier attributes *are* apparently 
> > syntactically permitted here, but most (maybe even all?) GNU attributes 
> > don't have any meaning in this position.
> Good catch!
Thanks for pointing this out!

I've removed the `ParseAttributes(DeclSpecAttrs)` 

[PATCH] D126717: [pseudo] Add PSEUDO_GEN cmake cache variable to avoid nested CMake invocation

2022-05-31 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D126717#3548184 , @mstorsjo wrote:

> Looks reasonable to me. The variable name feels a bit un-namespaced though, 
> but that's what the tool is called currently. Should we rename the tool and 
> the variable to give it a bit more of a namespace prefix, like 
> clang-pseudo-gen or so?

That makes sense. I'll do that first and rename to CLANG_PSEUDO_GEN.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126717/new/

https://reviews.llvm.org/D126717

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126717: [pseudo] Add PSEUDO_GEN cmake cache variable to avoid nested CMake invocation

2022-05-31 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo accepted this revision.
mstorsjo added a comment.
This revision is now accepted and ready to land.

Looks reasonable to me. The variable name feels a bit un-namespaced though, but 
that's what the tool is called currently. Should we rename the tool and the 
variable to give it a bit more of a namespace prefix, like clang-pseudo-gen or 
so?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126717/new/

https://reviews.llvm.org/D126717

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126498: [clangd] Fix hover crashing on integral or enumeral casts

2022-05-31 Thread Georg Kotheimer via Phabricator via cfe-commits
gkll added a comment.

In D126498#3548168 , @sammccall wrote:

> In D126498#3548132 , @gkll wrote:
>
>> In D126498#3548013 , @sammccall 
>> wrote:
>>
>>> Oh wow, my mental model of these was all wrong.
>>>
>>> Thank you! Do you want me to land this for you?
>>
>> Yeah, that would be great, thank you!
>
> Sorry, can you provide an email address for attribution?
>
> (Normally I can pick this up with `arc patch`, but not this time apparently)

Maybe because I didn't upload the patch with the `arc` tooling.
You can attribute the patch to: g...@mailbox.org


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126498/new/

https://reviews.llvm.org/D126498

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126498: [clangd] Fix hover crashing on integral or enumeral casts

2022-05-31 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D126498#3548132 , @gkll wrote:

> In D126498#3548013 , @sammccall 
> wrote:
>
>> Oh wow, my mental model of these was all wrong.
>>
>> Thank you! Do you want me to land this for you?
>
> Yeah, that would be great, thank you!

Sorry, can you provide an email address for attribution?

(Normally I can pick this up with `arc patch`, but not this time apparently)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126498/new/

https://reviews.llvm.org/D126498

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126664: Expand definition deprecation warning to include constexpr statements.

2022-05-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, but please add a release note about the new diagnostic behavior.

Do you need someone to commit on your behalf? If so, what name and email 
address would you like used for patch attribution?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126664/new/

https://reviews.llvm.org/D126664

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126498: [clangd] Fix hover crashing on integral or enumeral casts

2022-05-31 Thread Georg Kotheimer via Phabricator via cfe-commits
gkll added a comment.

In D126498#3548013 , @sammccall wrote:

> Oh wow, my mental model of these was all wrong.
>
> Thank you! Do you want me to land this for you?

Yeah, that would be great, thank you!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126498/new/

https://reviews.llvm.org/D126498

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126559: [MSVC] Fix pragma alloc_text failing for C files

2022-05-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D126559#3547921 , @steplong wrote:

> It looks like MSVC also accepts
>
>   // foo.c
>   static void foo();
>   #pragma alloc_text("hello", foo)
>   void foo() {}
>
> and
>
>   // foo.cpp
>   extern "C" {
>   static void foo();
>   #pragma alloc_text("hello", foo)
>   void foo() {}
>   }
>
> Do you know of a way I can check whether a function is coming from c or c++? 
> `isExternC()` returns false for the static case

You can look at `!LangOpts.CPlusPlus` to know that you're in C mode (or C++ 
mode)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126559/new/

https://reviews.llvm.org/D126559

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126397: [pseudo] Fix pseudo-gen usage when cross-compiling

2022-05-31 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D126397#3547438 , @sammccall wrote:

> In D126397#3547060 , @thakis wrote:
>
>> Should pseudo-gen honor LLVM_USE_HOST_TOOLS too? It looks like it's 
>> basically the same situation.
>
> Yes, I agree, it should. I'll send a patch.

Committed in 9d991da60df492a191b34aa3e75484ddd27e8930 


>> Regarding building native tools while cross compiling - for other tools so 
>> far, we’ve also had the option to pass an option like 
>> -DLLVM_TABLEGEN=path/to/llvm-tblgen. If all the needed native tools are 
>> provided that way, the build doesn’t need to set up the nested native cmake 
>> build while cross compiling. Should we prove a way to do that for this build 
>> time generation tool too?
>
> Yeah, it seems reasonable to spend a little bit more cmake complexity for 
> this.
> I hope it can be done in a few lines (digging into it) esp given how hard it 
> is to maintain non-bot-covered cmake configs.

Sent D126717  (I verified this locally, but 
want to make sure I'm not misunderstanding what we want here).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126397/new/

https://reviews.llvm.org/D126397

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126717: [pseudo] Add PSEUDO_GEN cmake cache variable to avoid nested CMake invocation

2022-05-31 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: mstorsjo.
Herald added a subscriber: mgorny.
Herald added a project: All.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, alextsao1999.
Herald added a project: clang-tools-extra.

Similar to LLVM_TABLEGEN, CLANG_TABLEGEN variables


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126717

Files:
  clang-tools-extra/pseudo/include/CMakeLists.txt


Index: clang-tools-extra/pseudo/include/CMakeLists.txt
===
--- clang-tools-extra/pseudo/include/CMakeLists.txt
+++ clang-tools-extra/pseudo/include/CMakeLists.txt
@@ -1,7 +1,13 @@
 # The cxx.bnf grammar file
 set(cxx_bnf ${CMAKE_CURRENT_SOURCE_DIR}/../lib/cxx.bnf)
 
-if(LLVM_USE_HOST_TOOLS)
+set(PSEUDO_GEN "pseudo-gen" CACHE
+  STRING "Host pseudo-gen executable. Saves building one if cross-compiling.")
+
+if(NOT PSEUDO_GEN STREQUAL "pseudo-gen")
+  set(pseudo_gen ${PSEUDO_GEN})
+  set(pseudo_gen_target ${PSEUDO_GEN})
+elseif(LLVM_USE_HOST_TOOLS)
   build_native_tool(pseudo-gen pseudo_gen)
   set(pseudo_gen_target "${pseudo_gen}")
 else()


Index: clang-tools-extra/pseudo/include/CMakeLists.txt
===
--- clang-tools-extra/pseudo/include/CMakeLists.txt
+++ clang-tools-extra/pseudo/include/CMakeLists.txt
@@ -1,7 +1,13 @@
 # The cxx.bnf grammar file
 set(cxx_bnf ${CMAKE_CURRENT_SOURCE_DIR}/../lib/cxx.bnf)
 
-if(LLVM_USE_HOST_TOOLS)
+set(PSEUDO_GEN "pseudo-gen" CACHE
+  STRING "Host pseudo-gen executable. Saves building one if cross-compiling.")
+
+if(NOT PSEUDO_GEN STREQUAL "pseudo-gen")
+  set(pseudo_gen ${PSEUDO_GEN})
+  set(pseudo_gen_target ${PSEUDO_GEN})
+elseif(LLVM_USE_HOST_TOOLS)
   build_native_tool(pseudo-gen pseudo_gen)
   set(pseudo_gen_target "${pseudo_gen}")
 else()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126642: [Clang] NFCI: Add a new bit HasExtraBitfields to FunctionType.

2022-05-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM aside from a nit.




Comment at: clang/include/clang/AST/Type.h:3809-3811
 unsigned NumExceptionType;
+
+FunctionTypeExtraBitfields() : NumExceptionType(0) {}




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126642/new/

https://reviews.llvm.org/D126642

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125788: [flang][driver] Rename `flang-new` as `flang`

2022-05-31 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

In D125788#3547494 , @sscalpone wrote:

> I'm fine with removing or renaming the existing flang shell script.



In D125788#3547656 , @rouson wrote:

> On Mon, May 30, 2022 at 2:39 AM Andrzej Warzynski via Phabricator 
>  wrote:
> I support this.

Great, thank you both! "Step 1" merged: https://reviews.llvm.org/D125832. This 
leaves us with `flang` as a symlink pointing to `flang-to-external-fc`, which I 
will be removing once buildbots are reconfigured: 
https://reviews.llvm.org/D125796. I'd like this to happen soon.

In D125788#3547494 , @sscalpone wrote:

> This proposal is not restricted to F95  but to 
> any source that someone might attempt to compile.

I would really appreciate if we could agree on more specific criteria. IMHO, 
"any source" leaves too much room for interpretation.

In D125788#3547656 , @rouson wrote:

> Any news from the call?

Not much - it was a very quiet call (Memorial Day for some folks, ISC 2022 for 
others, unexpected hiccup with Teams for the rest ). We decided to re-visit in 
the next call.

**Next steps**
Just to avoid any confusion:

- `flang`, the bash script, will be renamed as `flang-to-external-fc` (see 
D125832 )
- `flang-new` won't be renamed just yet - perhaps we could discuss more in the 
forthcoming call(s)?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125788/new/

https://reviews.llvm.org/D125788

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 9d991da - [pseudo] Respect LLVM_USE_HOST_TOOLS

2022-05-31 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-05-31T20:47:57+02:00
New Revision: 9d991da60df492a191b34aa3e75484ddd27e8930

URL: 
https://github.com/llvm/llvm-project/commit/9d991da60df492a191b34aa3e75484ddd27e8930
DIFF: 
https://github.com/llvm/llvm-project/commit/9d991da60df492a191b34aa3e75484ddd27e8930.diff

LOG: [pseudo] Respect LLVM_USE_HOST_TOOLS

This is the intended way to request that build-time tools be built in a
distinct configuration.

This is set implicitly by LLVM_OPTIMIZED_TABLEGEN, which may be
surprising, but if undesired this should be fixed elsewhere.

Should fix crbug.com/1330304

Added: 


Modified: 
clang-tools-extra/pseudo/include/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/pseudo/include/CMakeLists.txt 
b/clang-tools-extra/pseudo/include/CMakeLists.txt
index e4265b18c2b2e..3bf9709c2bed8 100644
--- a/clang-tools-extra/pseudo/include/CMakeLists.txt
+++ b/clang-tools-extra/pseudo/include/CMakeLists.txt
@@ -1,9 +1,7 @@
 # The cxx.bnf grammar file
 set(cxx_bnf ${CMAKE_CURRENT_SOURCE_DIR}/../lib/cxx.bnf)
 
-# Using CMAKE_CROSSCOMPILING and not LLVM_USE_HOST_TOOLS because the latter is
-# also set for LLVM_OPTIMIZED_TABLEGEN, which we don't care about here.
-if(CMAKE_CROSSCOMPILING)
+if(LLVM_USE_HOST_TOOLS)
   build_native_tool(pseudo-gen pseudo_gen)
   set(pseudo_gen_target "${pseudo_gen}")
 else()



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125723: [MSVC] Add support for MSVC pragma optimize

2022-05-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Sema/SemaAttr.cpp:1207-1213
+  FD->addAttr(FramePointerAttr::CreateImplicit(Context, Kind));
+}
+
+void Sema::AddOptsize(FunctionDecl *FD, SourceLocation Loc) {
+  FD->dropAttr();
+  OptimizeSizeAttr::Kind Kind = OptimizeSizeAttr::On;
+  FD->addAttr(OptimizeSizeAttr::CreateImplicit(Context, Kind));

steplong wrote:
> aaron.ballman wrote:
> > Rather than creating two new, implicit attributes for this, why not add 
> > support for `__attribute__((optimize(...)))` from GCC and reuse that one?
> > 
> > https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes
> > 
> > It seems like that serves the same function as these implicit attributes, 
> > but then users would get two features for the price of one.
> Hmm that makes sense. So, `pragma optimize(on, "s")` would be equivalent to 
> `__attribute__((optimize("-Os"))`. Could you give me a brief description of 
> what I would have to do to implement the attribute? I'm new to this
> Hmm that makes sense. So, pragma optimize(on, "s") would be equivalent to 
> __attribute__((optimize("-Os")).

Yup, effectively! And in terms of the AST, your pragma can implicitly create an 
`OptimizeAttr` with the appropriate arguments; then everything works off the 
same machinery.

> Could you give me a brief description of what I would have to do to implement 
> the attribute? I'm new to this

Absolutely! 
https://clang.llvm.org/docs/InternalsManual.html#how-to-add-an-attribute has 
most of the information you need. I'm happy to give you more information if 
you'd like it, though.



Comment at: clang/lib/Sema/SemaAttr.cpp:1224
+  FD->dropAttr();
+  FD->addAttr(NeverOptimizeNoneAttr::CreateImplicit(Context));
+}

steplong wrote:
> aaron.ballman wrote:
> > Can you explain why this is needed?
> I added this attr, so we can remove the attr optnone even if -O0 was passed 
> on the cmdline
I think if you add an `OptimizeAttr`, that could be used to carry this 
information instead of using a dedicated attribute for just the "never optnone" 
part.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125723/new/

https://reviews.llvm.org/D125723

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126498: [clangd] Fix hover crashing on integral or enumeral casts

2022-05-31 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Oh wow, my mental model of these was all wrong.

Thank you! Do you want me to land this for you?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126498/new/

https://reviews.llvm.org/D126498

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126536: [pseudo] Add grammar annotations support.

2022-05-31 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Nice!

This has tests for the parsing-the-attribute bits, but I think we're missing 
tests for the actual guards added.




Comment at: clang-tools-extra/pseudo/include/clang-pseudo/GLR.h:114
+using ReduceGuard =
+std::function RHS,
+   const TokenStream , const Grammar )>;

this signature seems a little off to me.

Guard logic is identified by a guard ID and we look it up, but we're not 
passing in the guard ID for some reason. Instead we pass in the rule ID, which 
this function uses to look up the guard ID again. Why not just pass the guard 
ID?

That said, it's a bit surprising that we have the rules declare separate guard 
rules, but then they're all implemented by one function. A map of functions 
seems more natural. (but not a performance advantage I guess)

Naming: it's confusing that this umbrella function is called "guard", but a 
specific rule like "guard=Override" is also called "guard". I'd either call 
this a GuardTester or bypass the issue by making this a DenseMap whose values 
are Guards.

Altogether I might write this as:
```
using Guard = llvm::function_ref RHS, 
const TokenStream &, const Grammar &)>;
...
const DenseMap 
```



Comment at: clang-tools-extra/pseudo/include/clang-pseudo/GLR.h:129
+
+  ReduceGuard Guard; // Guard for reducing.
 };

either a reference, or a lightweight reference type like function_ref, for 
consistency with other fields?



Comment at: clang-tools-extra/pseudo/include/clang-pseudo/Grammar.h:22
 //
+//  Attributes have the syntax form of [guard=value;key=value], they are
+//  associated with a grammar symbol (on the right-hand side of the symbol) or

nit: first "guard" should be "key"?



Comment at: clang-tools-extra/pseudo/include/clang-pseudo/Grammar.h:87
+// Defines the built-in attribute keys.
+enum class AttributeKey : uint8_t {
+  // A guard controls whether a reduction of a rule will be conducted by the 
GLR

hokein wrote:
> new names are welcome. Attribute is the name I came up with (I think it is 
> clearer than the original `Hook`), 
I don't understand why we need AttributeKey, and to parse things into it, 
rather than just using StringRef.

(Also here you've put it in the header, but it's not used in any interfaces)



Comment at: clang-tools-extra/pseudo/include/clang-pseudo/Grammar.h:94
+// It is the index into a table of attribute values.
+// NOTE: value among attributes must be unique even within different keys!
+using AttributeID = uint16_t;

hokein wrote:
> I'm not quite happy with using the value as the ID, I think we can encode the 
> Key into the ID as well (ID := Key | Value). 
> 
> Similar to the generated enum name, currently we just use the name of Value 
> (`Override`), it will be more confusing when we add more keys/values, one 
> idea is to add key as well (`GuardOverride` etc?).
Packing all the possible values into a single unstructured enum is weird, but 
the problem (if it's a problem) is _redundancy_ and packing the attribute name 
in there as well just makes that worse.

If we want to fix this, I think a sounder fix is something like:
```
// Grammar.h
using AttributeEnum = uint8_t;
struct Rule { ...; AttributeEnum Guard = 0; }
// CXX.h
enum class GuardID : AttributeEnum { Override = 1; };
enum class RecoveryID : AttributeEnum { Parens = 1; };
```

i.e. we keep track of the unique values per attribute name and emit an enum for 
each attribute. This probably means emitting the actual enum definitions in 
tablegen, rather than a generic .inc file.

(But I'm also fine with not fixing it at this point, and keeping one flat enum 
for the values) 



Comment at: clang-tools-extra/pseudo/include/clang-pseudo/Grammar.h:95
+// NOTE: value among attributes must be unique even within different keys!
+using AttributeID = uint16_t;
+// A sentinel attributeID indicating no attributes, by default.

I agree HookID is an unfortunately vague name, but I did consider and reject 
AttributeID which I think is actively confusing.
In the plain-english meaning, "guard" is an attribute, and "override" is its 
value. So assigning "override" an "attribute ID" is very confusing.

The difficulty of naming this is that we can't refer to the semantics (e.g. 
"Guard") as we want a single namespace for all of them, and all they have in 
common is syntax. However referring to "attribute values" makes for confusing 
internal data structures, as we don't model the whole attribute generically.

So we're left with names that suggest "this is some kind of anchor to attach 
custom code to". Maybe `ExtensionID` is a little clearer than `HookID`?



Comment at: clang-tools-extra/pseudo/include/clang-pseudo/Grammar.h:97
+// A sentinel attributeID indicating no attributes, by default.
+static constexpr AttributeID 

[PATCH] D125585: [HLSL][clang][Driver] Parse target profile early to update Driver::TargetTriple.

2022-05-31 Thread Chris Bieneman via Phabricator via cfe-commits
beanz accepted this revision.
beanz added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125585/new/

https://reviews.llvm.org/D125585

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126642: [Clang] NFCI: Add a new bit HasExtraBitfields to FunctionType.

2022-05-31 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

I think I'm Ok with this as a 1st step for the cleanup.  I think we should 
probably evaluate what amount of work is necessary to extract the ExtInfo out 
into trailing storage, depending on whether it saves us room in the 
FunctionProtoType and FunctionNoProtoType types.




Comment at: clang/include/clang/AST/Type.h:4103
   bool hasExtraBitfields() const {
-return hasExtraBitfields(getExceptionSpecType());
+assert((getExceptionSpecType() != EST_Dynamic ||
+FunctionTypeBits.HasExtraBitfields) &&

sdesmalen wrote:
> sdesmalen wrote:
> > erichkeane wrote:
> > > Why is asking if we DO have extra bitfields an assert here?  I would 
> > > think this is a valid question...
> > > 
> > > Why would 'dynamic' and extra-bitfields be exclusive here?
> > This assert is merely confirming that HasExtraBitfields **must** be true if 
> > the ExceptionSpecType is `EST_Dynamic`, because that was the old behaviour 
> > (and I wanted to avoid introducing failures if some code still assumed that 
> > hasExtraBitfields == true, but for some reason HasExtraBitfields had not 
> > yet been set to `true`).
> I've marked the comment as done hoping that my above explanation clarified 
> it, but let me know if you're not happy with it.
Ah, that makes sense, thanks.  


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126642/new/

https://reviews.llvm.org/D126642

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126522: Create specialization of `-Wgnu-statement-expression` for expressions found in macros.

2022-05-31 Thread Michael Wyman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7689c7fc9e08: Create specialization of 
-Wgnu-statement-expression for expressions found in… (authored by mwyman).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126522/new/

https://reviews.llvm.org/D126522

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/Parse/ParseExpr.cpp
  clang/test/Sema/gnu-flags.c


Index: clang/test/Sema/gnu-flags.c
===
--- clang/test/Sema/gnu-flags.c
+++ clang/test/Sema/gnu-flags.c
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s -DNONE -Wno-gnu
-// RUN: %clang_cc1 -fsyntax-only -verify %s -DALL -Wgnu 
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DALL -Wgnu
 // RUN: %clang_cc1 -fsyntax-only -verify %s -DALL -Wno-gnu \
 // RUN:   -Wgnu-alignof-expression -Wgnu-case-range -Wgnu-complex-integer 
-Wgnu-conditional-omitted-operand \
 // RUN:   -Wgnu-empty-initializer -Wgnu-label-as-value 
-Wgnu-statement-expression \
@@ -20,6 +20,7 @@
 // %clang_cc1 -fsyntax-only -verify %s -DEMPTYINIT -Wno-gnu 
-Wgnu-empty-initializer
 // %clang_cc1 -fsyntax-only -verify %s -DLABELVALUE -Wno-gnu 
-Wgnu-label-as-value
 // %clang_cc1 -fsyntax-only -verify %s -DSTATEMENTEXP -Wno-gnu 
-Wgnu-statement-expression
+// %clang_cc1 -fsyntax-only -verify %s -DSTATEMENTEXPMACRO -Wno-gnu 
-Wgnu-statement-expression-from-macro-expansion
 // %clang_cc1 -fsyntax-only -verify %s -DCOMPOUNDLITERALINITIALIZER -Wno-gnu 
-Wgnu-compound-literal-initializer
 // %clang_cc1 -fsyntax-only -verify %s -DFLEXIBLEARRAYINITIALIZER -Wno-gnu 
-Wgnu-flexible-array-initializer
 // %clang_cc1 -fsyntax-only -verify %s -DREDECLAREDENUM -Wno-gnu 
-Wgnu-redeclared-enum
@@ -95,6 +96,14 @@
int a = ({ 1; });
 }
 
+#if ALL || STATEMENTEXP || STATEMENTEXPMACRO
+// expected-warning@+5 {{use of GNU statement expression extension from macro 
expansion}}
+#endif
+
+#define STMT_EXPR_MACRO(a) ({ (a); })
+void statementexprmacro(void) {
+  int a = STMT_EXPR_MACRO(1);
+}
 
 #if ALL || COMPOUNDLITERALINITIALIZER
 // expected-warning@+4 {{initialization of an array of type 'int[5]' from a 
compound literal of type 'int[5]' is a GNU extension}}
Index: clang/lib/Parse/ParseExpr.cpp
===
--- clang/lib/Parse/ParseExpr.cpp
+++ clang/lib/Parse/ParseExpr.cpp
@@ -2870,7 +2870,8 @@
   // None of these cases should fall through with an invalid Result
   // unless they've already reported an error.
   if (ExprType >= CompoundStmt && Tok.is(tok::l_brace)) {
-Diag(Tok, diag::ext_gnu_statement_expr);
+Diag(Tok, OpenLoc.isMacroID() ? diag::ext_gnu_statement_expr_macro
+  : diag::ext_gnu_statement_expr);
 
 checkCompoundToken(OpenLoc, tok::l_paren, CompoundToken::StmtExprBegin);
 
Index: clang/include/clang/Basic/DiagnosticParseKinds.td
===
--- clang/include/clang/Basic/DiagnosticParseKinds.td
+++ clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -174,6 +174,9 @@
   "statement expression not allowed at file scope">;
 def ext_gnu_statement_expr : Extension<
   "use of GNU statement expression extension">, 
InGroup;
+def ext_gnu_statement_expr_macro : Extension<
+  "use of GNU statement expression extension from macro expansion">,
+  InGroup;
 def ext_gnu_conditional_expr : Extension<
   "use of GNU ?: conditional expression extension, omitting middle operand">, 
InGroup;
 def ext_gnu_empty_initializer : Extension<
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -611,7 +611,12 @@
 def StaticLocalInInline : DiagGroup<"static-local-in-inline">;
 def GNUStaticFloatInit : DiagGroup<"gnu-static-float-init">;
 def StaticFloatInit : DiagGroup<"static-float-init", [GNUStaticFloatInit]>;
-def GNUStatementExpression : DiagGroup<"gnu-statement-expression">;
+// Allow differentiation between GNU statement expressions in a macro versus
+// written directly in source.
+def GNUStatementExpressionFromMacroExpansion :
+  DiagGroup<"gnu-statement-expression-from-macro-expansion">;
+def GNUStatementExpression : DiagGroup<"gnu-statement-expression",
+   
[GNUStatementExpressionFromMacroExpansion]>;
 def StringConcatation : DiagGroup<"string-concatenation">;
 def StringCompare : DiagGroup<"string-compare">;
 def StringPlusInt : DiagGroup<"string-plus-int">;


Index: clang/test/Sema/gnu-flags.c
===
--- clang/test/Sema/gnu-flags.c
+++ clang/test/Sema/gnu-flags.c
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s -DNONE -Wno-gnu
-// RUN: %clang_cc1 

[clang] 7689c7f - Create specialization of -Wgnu-statement-expression for expressions found in macros.

2022-05-31 Thread Michael Wyman via cfe-commits

Author: Michael Wyman
Date: 2022-05-31T11:13:08-07:00
New Revision: 7689c7fc9e08cc430daca3714bcffdd00fd538bd

URL: 
https://github.com/llvm/llvm-project/commit/7689c7fc9e08cc430daca3714bcffdd00fd538bd
DIFF: 
https://github.com/llvm/llvm-project/commit/7689c7fc9e08cc430daca3714bcffdd00fd538bd.diff

LOG: Create specialization of -Wgnu-statement-expression for expressions found 
in macros.

-Wgnu-statement-expression currently warns for both direct source uses of 
statement expressions but also macro expansions; since they may be used by 
macros to avoid multiple evaluation of macro arguments, engineers might want to 
suppress warnings when statement expressions are expanded from macros but see 
them if introduced directly in source code.

Differential Revision: https://reviews.llvm.org/D126522

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/lib/Parse/ParseExpr.cpp
clang/test/Sema/gnu-flags.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index a7c34038ba3f..81ab2e494976 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -611,7 +611,12 @@ def StaticInInline : DiagGroup<"static-in-inline">;
 def StaticLocalInInline : DiagGroup<"static-local-in-inline">;
 def GNUStaticFloatInit : DiagGroup<"gnu-static-float-init">;
 def StaticFloatInit : DiagGroup<"static-float-init", [GNUStaticFloatInit]>;
-def GNUStatementExpression : DiagGroup<"gnu-statement-expression">;
+// Allow 
diff erentiation between GNU statement expressions in a macro versus
+// written directly in source.
+def GNUStatementExpressionFromMacroExpansion :
+  DiagGroup<"gnu-statement-expression-from-macro-expansion">;
+def GNUStatementExpression : DiagGroup<"gnu-statement-expression",
+   
[GNUStatementExpressionFromMacroExpansion]>;
 def StringConcatation : DiagGroup<"string-concatenation">;
 def StringCompare : DiagGroup<"string-compare">;
 def StringPlusInt : DiagGroup<"string-plus-int">;

diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 74930a4690d7..dd6bba720ce2 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -174,6 +174,9 @@ def err_stmtexpr_file_scope : Error<
   "statement expression not allowed at file scope">;
 def ext_gnu_statement_expr : Extension<
   "use of GNU statement expression extension">, 
InGroup;
+def ext_gnu_statement_expr_macro : Extension<
+  "use of GNU statement expression extension from macro expansion">,
+  InGroup;
 def ext_gnu_conditional_expr : Extension<
   "use of GNU ?: conditional expression extension, omitting middle operand">, 
InGroup;
 def ext_gnu_empty_initializer : Extension<

diff  --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index 54ba115a65f9..1002a0e11c0f 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -2870,7 +2870,8 @@ Parser::ParseParenExpression(ParenParseOption , 
bool stopIfCastExpr,
   // None of these cases should fall through with an invalid Result
   // unless they've already reported an error.
   if (ExprType >= CompoundStmt && Tok.is(tok::l_brace)) {
-Diag(Tok, diag::ext_gnu_statement_expr);
+Diag(Tok, OpenLoc.isMacroID() ? diag::ext_gnu_statement_expr_macro
+  : diag::ext_gnu_statement_expr);
 
 checkCompoundToken(OpenLoc, tok::l_paren, CompoundToken::StmtExprBegin);
 

diff  --git a/clang/test/Sema/gnu-flags.c b/clang/test/Sema/gnu-flags.c
index b454549ba945..8389cb6055bc 100644
--- a/clang/test/Sema/gnu-flags.c
+++ b/clang/test/Sema/gnu-flags.c
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s -DNONE -Wno-gnu
-// RUN: %clang_cc1 -fsyntax-only -verify %s -DALL -Wgnu 
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DALL -Wgnu
 // RUN: %clang_cc1 -fsyntax-only -verify %s -DALL -Wno-gnu \
 // RUN:   -Wgnu-alignof-expression -Wgnu-case-range -Wgnu-complex-integer 
-Wgnu-conditional-omitted-operand \
 // RUN:   -Wgnu-empty-initializer -Wgnu-label-as-value 
-Wgnu-statement-expression \
@@ -20,6 +20,7 @@
 // %clang_cc1 -fsyntax-only -verify %s -DEMPTYINIT -Wno-gnu 
-Wgnu-empty-initializer
 // %clang_cc1 -fsyntax-only -verify %s -DLABELVALUE -Wno-gnu 
-Wgnu-label-as-value
 // %clang_cc1 -fsyntax-only -verify %s -DSTATEMENTEXP -Wno-gnu 
-Wgnu-statement-expression
+// %clang_cc1 -fsyntax-only -verify %s -DSTATEMENTEXPMACRO -Wno-gnu 
-Wgnu-statement-expression-from-macro-expansion
 // %clang_cc1 -fsyntax-only -verify %s -DCOMPOUNDLITERALINITIALIZER -Wno-gnu 
-Wgnu-compound-literal-initializer
 // %clang_cc1 -fsyntax-only -verify %s -DFLEXIBLEARRAYINITIALIZER -Wno-gnu 

[PATCH] D126642: [Clang] NFCI: Add a new bit HasExtraBitfields to FunctionType.

2022-05-31 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D126642#3547905 , @sdesmalen wrote:

> In D126642#3547526 , @erichkeane 
> wrote:
>
>> Right, yeah.  One thing to consider: `ExtInfo` was 'first', and so it got to 
>> keep the 'in bitfield bits'. However, much of what is in there is, IMO, not 
>> something that is used often enough to be worth having in there.  Of the 
>> bits being used there, I think 'NoReturn' is the only one used with any 
>> regularity (other than perhaps 'this call' in Windows-32-bit machines).  I 
>> wonder if we should consider moving as much of that as possible over.
>
> That sounds sensible. Some of the fields there are also valid in 
> FunctionNoProtoType though, and I don't believe I saw an equivalent to 
> ExtProtoInfo for FunctionNoProtoType, is that because it's uncommon enough 
> that it only requires changing in a handful of places? I'm not too familiar 
> with Clang code, so I didn't look to deep into this.

Ah, hrmph, yeah, those have to be available anywhere that a function type is 
defined, since they are part of the no-prototype type of the function.  So we'd 
likely need to extract that at the "FunctionType" level, and put it into 
trailing storage in BOTH places (that is, FunctionNoProtoType would have 
trailing storage for it if necessary, and FunctionProtoType would as well).  
ExtProtoInfo doesn't exist for FunctionNoProtoType because it is 
C++/parameter-specific stuff (prototypeless function types aren't permitted in 
C++).

>>> so perhaps incorrectly I assumed I couldn't add any new bits to 
>>> FunctionType and thought I'd repurpose this one bit, because it's only ever 
>>> used for FunctionProtoType (never for FunctionNoProtoType).
>>>
>>> But I now realised I can just add an extra bit, so that we can leave this 
>>> bit as-is. What do you think?
>>
>> I think there is probably value to that, yes.
>
> Great, thanks, I've updated that now!




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126642/new/

https://reviews.llvm.org/D126642

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125585: [HLSL][clang][Driver] Parse target profile early to update Driver::TargetTriple.

2022-05-31 Thread Xiang Li via Phabricator via cfe-commits
python3kgae updated this revision to Diff 433143.
python3kgae added a comment.

Add check for no -T option.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125585/new/

https://reviews.llvm.org/D125585

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/HLSL.cpp
  clang/lib/Driver/ToolChains/HLSL.h
  clang/test/Driver/dxc_fcgl.hlsl
  clang/unittests/Driver/ToolChainTest.cpp

Index: clang/unittests/Driver/ToolChainTest.cpp
===
--- clang/unittests/Driver/ToolChainTest.cpp
+++ clang/unittests/Driver/ToolChainTest.cpp
@@ -387,6 +387,28 @@
   std::vector> Errors;
 };
 
+static void validateTargetProfile(StringRef TargetProfile,
+  StringRef ExpectTriple, Driver ,
+  DiagnosticsEngine ) {
+  EXPECT_TRUE(TheDriver.BuildCompilation(
+  {"clang", "--driver-mode=dxc", TargetProfile.data(), "foo.hlsl"}));
+  EXPECT_STREQ(TheDriver.getTargetTriple().c_str(), ExpectTriple.data());
+  EXPECT_EQ(Diags.getNumErrors(), 0u);
+}
+
+static void validateTargetProfile(StringRef TargetProfile,
+  StringRef ExpectError, Driver ,
+  DiagnosticsEngine ,
+  SimpleDiagnosticConsumer *DiagConsumer,
+  unsigned NumOfErrors) {
+  EXPECT_TRUE(TheDriver.BuildCompilation(
+  {"clang", "--driver-mode=dxc", TargetProfile.data(), "foo.hlsl"}));
+  EXPECT_EQ(Diags.getNumErrors(), NumOfErrors);
+  EXPECT_STREQ(DiagConsumer->Errors.back().c_str(), ExpectError.data());
+  Diags.Clear();
+  DiagConsumer->clear();
+}
+
 TEST(DxcModeTest, TargetProfileValidation) {
   IntrusiveRefCntPtr DiagID(new DiagnosticIDs());
 
@@ -400,111 +422,40 @@
   IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
   DiagnosticsEngine Diags(DiagID, &*DiagOpts, DiagConsumer);
   Driver TheDriver("/bin/clang", "", Diags, "", InMemoryFileSystem);
-  std::unique_ptr C(
-  TheDriver.BuildCompilation({"clang", "--driver-mode=dxc", "foo.hlsl"}));
-  EXPECT_TRUE(C);
-  EXPECT_TRUE(!C->containsError());
-
-  auto  = C->getDefaultToolChain();
-  bool ContainsError = false;
-  auto Args = TheDriver.ParseArgStrings({"-Tvs_6_0"}, false, ContainsError);
-  EXPECT_FALSE(ContainsError);
-  auto Triple = TC.ComputeEffectiveClangTriple(Args);
-  EXPECT_STREQ(Triple.c_str(), "dxil--shadermodel6.0-vertex");
-  EXPECT_EQ(Diags.getNumErrors(), 0u);
-
-  Args = TheDriver.ParseArgStrings({"-Ths_6_1"}, false, ContainsError);
-  EXPECT_FALSE(ContainsError);
-  Triple = TC.ComputeEffectiveClangTriple(Args);
-  EXPECT_STREQ(Triple.c_str(), "dxil--shadermodel6.1-hull");
-  EXPECT_EQ(Diags.getNumErrors(), 0u);
-
-  Args = TheDriver.ParseArgStrings({"-Tds_6_2"}, false, ContainsError);
-  EXPECT_FALSE(ContainsError);
-  Triple = TC.ComputeEffectiveClangTriple(Args);
-  EXPECT_STREQ(Triple.c_str(), "dxil--shadermodel6.2-domain");
-  EXPECT_EQ(Diags.getNumErrors(), 0u);
-
-  Args = TheDriver.ParseArgStrings({"-Tds_6_2"}, false, ContainsError);
-  EXPECT_FALSE(ContainsError);
-  Triple = TC.ComputeEffectiveClangTriple(Args);
-  EXPECT_STREQ(Triple.c_str(), "dxil--shadermodel6.2-domain");
-  EXPECT_EQ(Diags.getNumErrors(), 0u);
-
-  Args = TheDriver.ParseArgStrings({"-Tgs_6_3"}, false, ContainsError);
-  EXPECT_FALSE(ContainsError);
-  Triple = TC.ComputeEffectiveClangTriple(Args);
-  EXPECT_STREQ(Triple.c_str(), "dxil--shadermodel6.3-geometry");
-  EXPECT_EQ(Diags.getNumErrors(), 0u);
-
-  Args = TheDriver.ParseArgStrings({"-Tps_6_4"}, false, ContainsError);
-  EXPECT_FALSE(ContainsError);
-  Triple = TC.ComputeEffectiveClangTriple(Args);
-  EXPECT_STREQ(Triple.c_str(), "dxil--shadermodel6.4-pixel");
-  EXPECT_EQ(Diags.getNumErrors(), 0u);
-
-  Args = TheDriver.ParseArgStrings({"-Tcs_6_5"}, false, ContainsError);
-  EXPECT_FALSE(ContainsError);
-  Triple = TC.ComputeEffectiveClangTriple(Args);
-  EXPECT_STREQ(Triple.c_str(), "dxil--shadermodel6.5-compute");
-  EXPECT_EQ(Diags.getNumErrors(), 0u);
-
-  Args = TheDriver.ParseArgStrings({"-Tms_6_6"}, false, ContainsError);
-  EXPECT_FALSE(ContainsError);
-  Triple = TC.ComputeEffectiveClangTriple(Args);
-  EXPECT_STREQ(Triple.c_str(), "dxil--shadermodel6.6-mesh");
-  EXPECT_EQ(Diags.getNumErrors(), 0u);
 
-  Args = TheDriver.ParseArgStrings({"-Tas_6_7"}, false, ContainsError);
-  EXPECT_FALSE(ContainsError);
-  Triple = TC.ComputeEffectiveClangTriple(Args);
-  EXPECT_STREQ(Triple.c_str(), "dxil--shadermodel6.7-amplification");
-  EXPECT_EQ(Diags.getNumErrors(), 0u);
-
-  Args = TheDriver.ParseArgStrings({"-Tlib_6_x"}, false, ContainsError);
-  EXPECT_FALSE(ContainsError);
-  Triple = TC.ComputeEffectiveClangTriple(Args);
-  EXPECT_STREQ(Triple.c_str(), "dxil--shadermodel6.15-library");
-  EXPECT_EQ(Diags.getNumErrors(), 0u);
+  validateTargetProfile("-Tvs_6_0", 

[PATCH] D126559: [MSVC] Fix pragma alloc_text failing for C files

2022-05-31 Thread Stephen Long via Phabricator via cfe-commits
steplong added a comment.

It looks like MSVC also accepts

  // foo.c
  static void foo();
  #pragma alloc_text("hello", foo)
  void foo() {}

and

  // foo.cpp
  extern "C" {
  static void foo();
  #pragma alloc_text("hello", foo)
  void foo() {}
  }

Do you know of a way I can check whether a function is coming from c or c++? 
`isExternC()` returns false for the static case


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126559/new/

https://reviews.llvm.org/D126559

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >