[PATCH] D124504: Remove --no-opaque-pointers in test/cxx2a-thread-local-constinit.cpp

2022-04-27 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu created this revision.
ChuanqiXu added a reviewer: nikic.
ChuanqiXu added a project: clang.
Herald added a project: All.
ChuanqiXu requested review of this revision.
Herald added a subscriber: cfe-commits.

The option `--no-opaque-pointers` in test/cxx2a-thread-local-constinit.cpp 
blocks my current works. I feel it should be good to remove 
`--no-opaque-pointers` in clang tests. But I want to consult experts to be sure 
about this.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124504

Files:
  clang/test/CodeGenCXX/cxx2a-thread-local-constinit.cpp


Index: clang/test/CodeGenCXX/cxx2a-thread-local-constinit.cpp
===
--- clang/test/CodeGenCXX/cxx2a-thread-local-constinit.cpp
+++ clang/test/CodeGenCXX/cxx2a-thread-local-constinit.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-linux-gnu -std=c++2a %s 
-emit-llvm -o - | FileCheck --check-prefix=CHECK --check-prefix=LINUX %s
-// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-apple-darwin12  
-std=c++2a %s -emit-llvm -o - | FileCheck --check-prefix=CHECK 
--check-prefix=DARWIN %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++2a %s -emit-llvm -o - | 
FileCheck --check-prefix=CHECK --check-prefix=LINUX %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin12  -std=c++2a %s -emit-llvm -o 
- | FileCheck --check-prefix=CHECK --check-prefix=DARWIN %s
 
 // Check variable definitions/declarations. Note that on Darwin, typically the
 // variable's symbol is marked internal, and only the _ZTW function is
@@ -19,7 +19,7 @@
 extern thread_local constinit int b;
 
 // CHECK-LABEL: define{{.*}} i32 @_Z5get_av()
-// CHECK: call {{(cxx_fast_tlscc )?}}i32* @_ZTW1a()
+// CHECK: call {{(cxx_fast_tlscc )?}}ptr @_ZTW1a()
 // CHECK: }
 int get_a() { return a; }
 
@@ -31,7 +31,7 @@
 
 // CHECK-LABEL: define{{.*}} i32 @_Z5get_bv()
 // CHECK-NOT: call
-// CHECK: load i32, i32* @b
+// CHECK: load i32, ptr @b
 // CHECK-NOT: call
 // CHECK: }
 int get_b() { return b; }
@@ -41,8 +41,8 @@
 extern thread_local int c;
 
 // CHECK-LABEL: define{{.*}} i32 @_Z5get_cv()
-// LINUX: call {{(cxx_fast_tlscc )?}}i32* @_ZTW1c()
-// CHECK: load i32, i32* %
+// LINUX: call {{(cxx_fast_tlscc )?}}ptr @_ZTW1c()
+// CHECK: load i32, ptr %
 // CHECK: }
 int get_c() { return c; }
 
@@ -52,7 +52,7 @@
 // LINUX-LABEL: define weak_odr {{.*}} @_ZTW1c()
 // CHECK-NOT: br i1
 // CHECK-NOT: call
-// CHECK: ret i32* @c
+// CHECK: ret ptr @c
 // CHECK: }
 
 thread_local int c = 0;
@@ -61,7 +61,7 @@
 // destruction, and so speculatively call the thread wrapper.
 
 // CHECK-LABEL: define {{.*}} @_Z6get_e3v(
-// CHECK: call {{.*}}* @_ZTW2e3()
+// CHECK: call {{.*}}ptr @_ZTW2e3()
 // CHECK-LABEL: }
 extern thread_local constinit struct DestructedFwdDecl e3;
 DestructedFwdDecl &get_e3() { return e3; }
@@ -79,13 +79,13 @@
 
 extern thread_local constinit Destructed e;
 // CHECK-LABEL: define{{.*}} i32 @_Z5get_ev()
-// CHECK: call {{.*}}* @_ZTW1e()
+// CHECK: call {{.*}}ptr @_ZTW1e()
 // CHECK: }
 int get_e() { return e.n; }
 
 // CHECK: define {{.*}}[[E2_INIT:@__cxx_global_var_init[^(]*]](
-// LINUX: call {{.*}} @__cxa_thread_atexit({{.*}} @_ZN10DestructedD1Ev {{.*}} 
@e2
-// DARWIN: call {{.*}} @_tlv_atexit({{.*}} @_ZN10DestructedD1Ev {{.*}} @e2
+// LINUX: call {{.*}} @__cxa_thread_atexit({{.*}} @_ZN10DestructedD1Ev, {{.*}} 
@e2
+// DARWIN: call {{.*}} @_tlv_atexit({{.*}} @_ZN10DestructedD1Ev, {{.*}} @e2
 thread_local constinit Destructed e2;
 
 thread_local constinit int f = 4;


Index: clang/test/CodeGenCXX/cxx2a-thread-local-constinit.cpp
===
--- clang/test/CodeGenCXX/cxx2a-thread-local-constinit.cpp
+++ clang/test/CodeGenCXX/cxx2a-thread-local-constinit.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-linux-gnu -std=c++2a %s -emit-llvm -o - | FileCheck --check-prefix=CHECK --check-prefix=LINUX %s
-// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-apple-darwin12  -std=c++2a %s -emit-llvm -o - | FileCheck --check-prefix=CHECK --check-prefix=DARWIN %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++2a %s -emit-llvm -o - | FileCheck --check-prefix=CHECK --check-prefix=LINUX %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin12  -std=c++2a %s -emit-llvm -o - | FileCheck --check-prefix=CHECK --check-prefix=DARWIN %s
 
 // Check variable definitions/declarations. Note that on Darwin, typically the
 // variable's symbol is marked internal, and only the _ZTW function is
@@ -19,7 +19,7 @@
 extern thread_local constinit int b;
 
 // CHECK-LABEL: define{{.*}} i32 @_Z5get_av()
-// CHECK: call {{(cxx_fast_tlscc )?}}i32* @_ZTW1a()
+// CHECK: call {{(cxx_fast_tlscc )?}}ptr @_ZTW1a()
 // CHECK: }
 int get_a() { return a; }
 
@@ -31,7 +31,7 @@
 
 // CHECK-LABEL: define{{.*}} i32 @_Z5get_bv()
 // CHECK-NOT: call
-// CHECK: load i32, i32* @b
+// CHECK: load i32, ptr @b
 // CHECK-NOT: call
 // CHECK: }
 int get_b() { 

[PATCH] D124435: [X86] Always extend the integer parameters in callee

2022-04-27 Thread LiuChen via Phabricator via cfe-commits
LiuChen3 updated this revision to Diff 425427.
LiuChen3 added a comment.

Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124435

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/CodeGen/CGFunctionInfo.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/2007-06-18-SextAttrAggregate.c
  clang/test/CodeGen/X86/integer_argument_passing.c
  clang/test/CodeGen/X86/x86_32-arguments-darwin.c
  clang/test/CodeGen/X86/x86_32-arguments-linux.c
  clang/test/CodeGen/X86/x86_64-arguments-nacl.c
  clang/test/CodeGen/X86/x86_64-arguments.c
  clang/test/CodeGen/attr-noundef.cpp
  clang/test/CodeGen/builtin-align.c
  clang/test/CodeGen/catch-implicit-integer-sign-changes.c
  clang/test/CodeGen/ext-int-cc.c
  clang/test/CodeGen/function-attributes.c
  clang/test/CodeGen/mangle-windows.c
  clang/test/CodeGen/matrix-type-builtins.c
  clang/test/CodeGen/matrix-type-operators.c
  clang/test/CodeGen/ms-inline-asm.c
  clang/test/CodeGen/regcall.c
  clang/test/CodeGen/vectorcall.c
  clang/test/CodeGenCXX/exceptions.cpp
  clang/test/CodeGenCXX/ext-int.cpp
  clang/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
  clang/test/CodeGenCXX/new-overflow.cpp
  clang/test/CodeGenCXX/virtual-bases.cpp
  clang/test/CodeGenObjC/property-atomic-bool.m
  clang/test/OpenMP/target_codegen_global_capture.cpp

Index: clang/test/OpenMP/target_codegen_global_capture.cpp
===
--- clang/test/OpenMP/target_codegen_global_capture.cpp
+++ clang/test/OpenMP/target_codegen_global_capture.cpp
@@ -2051,7 +2051,7 @@
 //
 //
 // CHECK3-LABEL: define {{[^@]+}}@_Z3foo
-// CHECK3-SAME: (i16 noundef signext [[A:%.*]], i16 noundef signext [[B:%.*]], i16 noundef signext [[C:%.*]], i16 noundef signext [[D:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK3-SAME: (i16 noundef [[A:%.*]], i16 noundef [[B:%.*]], i16 noundef [[C:%.*]], i16 noundef [[D:%.*]]) #[[ATTR0:[0-9]+]] {
 // CHECK3-NEXT:  entry:
 // CHECK3-NEXT:[[A_ADDR:%.*]] = alloca i16, align 2
 // CHECK3-NEXT:[[B_ADDR:%.*]] = alloca i16, align 2
@@ -2335,7 +2335,7 @@
 //
 //
 // CHECK3-LABEL: define {{[^@]+}}@_Z3bar
-// CHECK3-SAME: (i16 noundef signext [[A:%.*]], i16 noundef signext [[B:%.*]], i16 noundef signext [[C:%.*]], i16 noundef signext [[D:%.*]]) #[[ATTR0]] {
+// CHECK3-SAME: (i16 noundef [[A:%.*]], i16 noundef [[B:%.*]], i16 noundef [[C:%.*]], i16 noundef [[D:%.*]]) #[[ATTR0]] {
 // CHECK3-NEXT:  entry:
 // CHECK3-NEXT:[[A_ADDR:%.*]] = alloca i16, align 2
 // CHECK3-NEXT:[[B_ADDR:%.*]] = alloca i16, align 2
@@ -2642,7 +2642,7 @@
 //
 //
 // CHECK3-LABEL: define {{[^@]+}}@_Z5tbar2
-// CHECK3-SAME: (i16 noundef signext [[A:%.*]], i16 noundef signext [[B:%.*]], i16 noundef signext [[C:%.*]], i16 noundef signext [[D:%.*]]) #[[ATTR0]] {
+// CHECK3-SAME: (i16 noundef [[A:%.*]], i16 noundef [[B:%.*]], i16 noundef [[C:%.*]], i16 noundef [[D:%.*]]) #[[ATTR0]] {
 // CHECK3-NEXT:  entry:
 // CHECK3-NEXT:[[A_ADDR:%.*]] = alloca i16, align 2
 // CHECK3-NEXT:[[B_ADDR:%.*]] = alloca i16, align 2
@@ -2661,7 +2661,7 @@
 //
 //
 // CHECK3-LABEL: define {{[^@]+}}@_Z4tbarIsEiT_S0_S0_S0_
-// CHECK3-SAME: (i16 noundef signext [[A:%.*]], i16 noundef signext [[B:%.*]], i16 noundef signext [[C:%.*]], i16 noundef signext [[D:%.*]]) #[[ATTR0]] comdat {
+// CHECK3-SAME: (i16 noundef [[A:%.*]], i16 noundef [[B:%.*]], i16 noundef [[C:%.*]], i16 noundef [[D:%.*]]) #[[ATTR0]] comdat {
 // CHECK3-NEXT:  entry:
 // CHECK3-NEXT:[[A_ADDR:%.*]] = alloca i16, align 2
 // CHECK3-NEXT:[[B_ADDR:%.*]] = alloca i16, align 2
@@ -2975,7 +2975,7 @@
 //
 //
 // CHECK4-LABEL: define {{[^@]+}}@_Z3foo
-// CHECK4-SAME: (i16 noundef signext [[A:%.*]], i16 noundef signext [[B:%.*]], i16 noundef signext [[C:%.*]], i16 noundef signext [[D:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK4-SAME: (i16 noundef [[A:%.*]], i16 noundef [[B:%.*]], i16 noundef [[C:%.*]], i16 noundef [[D:%.*]]) #[[ATTR0:[0-9]+]] {
 // CHECK4-NEXT:  entry:
 // CHECK4-NEXT:[[A_ADDR:%.*]] = alloca i16, align 2
 // CHECK4-NEXT:[[B_ADDR:%.*]] = alloca i16, align 2
@@ -3259,7 +3259,7 @@
 //
 //
 // CHECK4-LABEL: define {{[^@]+}}@_Z3bar
-// CHECK4-SAME: (i16 noundef signext [[A:%.*]], i16 noundef signext [[B:%.*]], i16 noundef signext [[C:%.*]], i16 noundef signext [[D:%.*]]) #[[ATTR0]] {
+// CHECK4-SAME: (i16 noundef [[A:%.*]], i16 noundef [[B:%.*]], i16 noundef [[C:%.*]], i16 noundef [[D:%.*]]) #[[ATTR0]] {
 // CHECK4-NEXT:  entry:
 // CHECK4-NEXT:[[A_ADDR:%.*]] = alloca i16, align 2
 // CHECK4-NEXT:[[B_ADDR:%.*]] = alloca i16, align 2
@@ -3566,7 +3566,7 @@
 //
 //
 // CHECK4-LABEL: define {{[^@]+}}@_Z5tbar2
-// CHECK4-SAME: (i16 noundef signext [[A:%.*]], i16 noundef signext [[B:%.*]], i16 noundef 

[PATCH] D124435: [X86] Always extend the integer parameters in callee

2022-04-27 Thread LiuChen via Phabricator via cfe-commits
LiuChen3 marked 9 inline comments as done.
LiuChen3 added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:2310
   case ABIArgInfo::Extend:
+  case ABIArgInfo::ConservativeExtend:
 if (RetAI.isSignExt())

At present, `ConservativeExtend` has no specific definition for return value, 
so I just make it follow the behavior of `Extend` .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124435

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


[PATCH] D124341: [clang-tidy][NFC] Replace many instances of std::string where a StringRef would suffice.

2022-04-27 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D124341#3475083 , @aaron.ballman 
wrote:

> I went through the changes and they look correct to me... yet I'm still 
> mildly terrified. :-D Have you tried running clang-tidy through its paces 
> with ASan/MSan enabled to see if the change introduces any use-after-free 
> issues in practice?

I can't seem to build LLVM with msan at all. But ASan, which checks things like 
use after free, ran all clang tools tests without a hitch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124341

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


[PATCH] D124435: [X86] Always extend the integer parameters in callee

2022-04-27 Thread LiuChen via Phabricator via cfe-commits
LiuChen3 updated this revision to Diff 425428.
LiuChen3 added a comment.

add one missing comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124435

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/CodeGen/CGFunctionInfo.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/2007-06-18-SextAttrAggregate.c
  clang/test/CodeGen/X86/integer_argument_passing.c
  clang/test/CodeGen/X86/x86_32-arguments-darwin.c
  clang/test/CodeGen/X86/x86_32-arguments-linux.c
  clang/test/CodeGen/X86/x86_64-arguments-nacl.c
  clang/test/CodeGen/X86/x86_64-arguments.c
  clang/test/CodeGen/attr-noundef.cpp
  clang/test/CodeGen/builtin-align.c
  clang/test/CodeGen/catch-implicit-integer-sign-changes.c
  clang/test/CodeGen/ext-int-cc.c
  clang/test/CodeGen/function-attributes.c
  clang/test/CodeGen/mangle-windows.c
  clang/test/CodeGen/matrix-type-builtins.c
  clang/test/CodeGen/matrix-type-operators.c
  clang/test/CodeGen/ms-inline-asm.c
  clang/test/CodeGen/regcall.c
  clang/test/CodeGen/vectorcall.c
  clang/test/CodeGenCXX/exceptions.cpp
  clang/test/CodeGenCXX/ext-int.cpp
  clang/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
  clang/test/CodeGenCXX/new-overflow.cpp
  clang/test/CodeGenCXX/virtual-bases.cpp
  clang/test/CodeGenObjC/property-atomic-bool.m
  clang/test/OpenMP/target_codegen_global_capture.cpp

Index: clang/test/OpenMP/target_codegen_global_capture.cpp
===
--- clang/test/OpenMP/target_codegen_global_capture.cpp
+++ clang/test/OpenMP/target_codegen_global_capture.cpp
@@ -2051,7 +2051,7 @@
 //
 //
 // CHECK3-LABEL: define {{[^@]+}}@_Z3foo
-// CHECK3-SAME: (i16 noundef signext [[A:%.*]], i16 noundef signext [[B:%.*]], i16 noundef signext [[C:%.*]], i16 noundef signext [[D:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK3-SAME: (i16 noundef [[A:%.*]], i16 noundef [[B:%.*]], i16 noundef [[C:%.*]], i16 noundef [[D:%.*]]) #[[ATTR0:[0-9]+]] {
 // CHECK3-NEXT:  entry:
 // CHECK3-NEXT:[[A_ADDR:%.*]] = alloca i16, align 2
 // CHECK3-NEXT:[[B_ADDR:%.*]] = alloca i16, align 2
@@ -2335,7 +2335,7 @@
 //
 //
 // CHECK3-LABEL: define {{[^@]+}}@_Z3bar
-// CHECK3-SAME: (i16 noundef signext [[A:%.*]], i16 noundef signext [[B:%.*]], i16 noundef signext [[C:%.*]], i16 noundef signext [[D:%.*]]) #[[ATTR0]] {
+// CHECK3-SAME: (i16 noundef [[A:%.*]], i16 noundef [[B:%.*]], i16 noundef [[C:%.*]], i16 noundef [[D:%.*]]) #[[ATTR0]] {
 // CHECK3-NEXT:  entry:
 // CHECK3-NEXT:[[A_ADDR:%.*]] = alloca i16, align 2
 // CHECK3-NEXT:[[B_ADDR:%.*]] = alloca i16, align 2
@@ -2642,7 +2642,7 @@
 //
 //
 // CHECK3-LABEL: define {{[^@]+}}@_Z5tbar2
-// CHECK3-SAME: (i16 noundef signext [[A:%.*]], i16 noundef signext [[B:%.*]], i16 noundef signext [[C:%.*]], i16 noundef signext [[D:%.*]]) #[[ATTR0]] {
+// CHECK3-SAME: (i16 noundef [[A:%.*]], i16 noundef [[B:%.*]], i16 noundef [[C:%.*]], i16 noundef [[D:%.*]]) #[[ATTR0]] {
 // CHECK3-NEXT:  entry:
 // CHECK3-NEXT:[[A_ADDR:%.*]] = alloca i16, align 2
 // CHECK3-NEXT:[[B_ADDR:%.*]] = alloca i16, align 2
@@ -2661,7 +2661,7 @@
 //
 //
 // CHECK3-LABEL: define {{[^@]+}}@_Z4tbarIsEiT_S0_S0_S0_
-// CHECK3-SAME: (i16 noundef signext [[A:%.*]], i16 noundef signext [[B:%.*]], i16 noundef signext [[C:%.*]], i16 noundef signext [[D:%.*]]) #[[ATTR0]] comdat {
+// CHECK3-SAME: (i16 noundef [[A:%.*]], i16 noundef [[B:%.*]], i16 noundef [[C:%.*]], i16 noundef [[D:%.*]]) #[[ATTR0]] comdat {
 // CHECK3-NEXT:  entry:
 // CHECK3-NEXT:[[A_ADDR:%.*]] = alloca i16, align 2
 // CHECK3-NEXT:[[B_ADDR:%.*]] = alloca i16, align 2
@@ -2975,7 +2975,7 @@
 //
 //
 // CHECK4-LABEL: define {{[^@]+}}@_Z3foo
-// CHECK4-SAME: (i16 noundef signext [[A:%.*]], i16 noundef signext [[B:%.*]], i16 noundef signext [[C:%.*]], i16 noundef signext [[D:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK4-SAME: (i16 noundef [[A:%.*]], i16 noundef [[B:%.*]], i16 noundef [[C:%.*]], i16 noundef [[D:%.*]]) #[[ATTR0:[0-9]+]] {
 // CHECK4-NEXT:  entry:
 // CHECK4-NEXT:[[A_ADDR:%.*]] = alloca i16, align 2
 // CHECK4-NEXT:[[B_ADDR:%.*]] = alloca i16, align 2
@@ -3259,7 +3259,7 @@
 //
 //
 // CHECK4-LABEL: define {{[^@]+}}@_Z3bar
-// CHECK4-SAME: (i16 noundef signext [[A:%.*]], i16 noundef signext [[B:%.*]], i16 noundef signext [[C:%.*]], i16 noundef signext [[D:%.*]]) #[[ATTR0]] {
+// CHECK4-SAME: (i16 noundef [[A:%.*]], i16 noundef [[B:%.*]], i16 noundef [[C:%.*]], i16 noundef [[D:%.*]]) #[[ATTR0]] {
 // CHECK4-NEXT:  entry:
 // CHECK4-NEXT:[[A_ADDR:%.*]] = alloca i16, align 2
 // CHECK4-NEXT:[[B_ADDR:%.*]] = alloca i16, align 2
@@ -3566,7 +3566,7 @@
 //
 //
 // CHECK4-LABEL: define {{[^@]+}}@_Z5tbar2
-// CHECK4-SAME: (i16 noundef signext [[A:%.*]], i16 noundef signext [[B:%.*]], i16 n

[PATCH] D124435: [X86] Always extend the integer parameters in callee

2022-04-27 Thread LiuChen via Phabricator via cfe-commits
LiuChen3 added a comment.

In D124435#3474130 , @skan wrote:

> Should we update the `clang/docs/ReleaseNotes.rst` for this?

The ReleaseNotes says "written by LLVM Team". So I am not sure if I can update 
this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124435

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


[PATCH] D124504: Remove --no-opaque-pointers in test/cxx2a-thread-local-constinit.cpp

2022-04-27 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a reviewer: opaque-pointers.
nikic added a comment.

How does it block your work? Tests currently still use `-no-opaque-pointers` to 
avoid breaking this mode. I think it's generally okay to drop the option, but 
I'm a bit unclear about the motivation in this case -- do you want to make a 
change that would be incompatible with typed pointers?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124504

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


[PATCH] D124435: [X86] Always extend the integer parameters in callee

2022-04-27 Thread LiuChen via Phabricator via cfe-commits
LiuChen3 added inline comments.



Comment at: clang/docs/ClangCommandLineReference.rst:2988-2992
+.. option:: -mconservative-extend
+Always extend the integer parameter both in the callee and caller.
+
+.. option:: -mno-conservative-extend
+Keep the original integer parameter passing behavior.

LiuChen3 wrote:
> rjmccall wrote:
> > pengfei wrote:
> > > Combine like others?
> > How about:
> > 
> > ```
> > In the past, Clang passed small integer arguments on certain targets using a
> > parameter convention in which the caller was assumed to have sign-extended
> > or zero-extended the argument to a certain width.  This convention was not
> > conformant with the documented ABI on these platforms, which does not
> > require the caller to perform this extension.  Clang no longer assumes that
> > callers perform this extension, but for compatibility with code compiled by
> > previous releases of Clang, Clang defaults to still extending the argument 
> > in the
> > caller.  `-mno-conservative-extend` disables this, which may improve
> > performance and code size if compatibility with old versions of Clang is not
> > required.
> > 
> > This affects most 32-bit and 64-bit x86 targets, except:
> > - Windows, which Clang has never assumed extension on
> > - Apple platforms, which use a non-standard ABI that unconditionally 
> > assumes extension
> > ```
> > 
> > Note that I need to check that that's what Apple actually wants to do.  You 
> > should also reach out to the Sony folks to see what they want to do, but I 
> > expect that it's to assume extension unconditionally.
> Thanks a lot! It's much clearer.
> Just a small correction for windows: only windows64 is not affected.
Hi, @RKSimon , @probinson.  This patch will extend the integer parameters in 
the caller.  Is there any concern about this for Sony?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124435

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


[PATCH] D124504: Remove --no-opaque-pointers in test/cxx2a-thread-local-constinit.cpp

2022-04-27 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D124504#3476537 , @nikic wrote:

> How does it block your work? Tests currently still use `-no-opaque-pointers` 
> to avoid breaking this mode. I think it's generally okay to drop the option, 
> but I'm a bit unclear about the motivation in this case -- do you want to 
> make a change that would be incompatible with typed pointers?

The motivation is that I want to insert an intrinsic for TLS variable. The 
whole background could be found at: 
https://discourse.llvm.org/t/address-thread-identification-problems-with-coroutine/62015

The signature of the intrinsic is `ptr @intrinsic.name(ptr)`. And I must add 
one bitcast if I can't use opaque-pointer. It looks like opaque pointer is 
enabled by default now: 
https://github.com/llvm/llvm-project/blob/86c770346c26ce4c9abf5a5b7ab4b5bbfdcf9d78/clang/include/clang/Driver/Options.td#L5567-L5573

So I feel like it is better to remove the `--no-opaque-pointers` option. I 
could add a bitcast to workaround if this is not wanted. Maybe the word `block` 
is not suitable here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124504

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


[PATCH] D124462: [Analyzer] Fix clang::ento::taint::dumpTaint definition

2022-04-27 Thread Marco Antognini via Phabricator via cfe-commits
mantognini created this revision.
Herald added subscribers: manas, steakhal, ASDenysPetrov, martong, dkrupp, 
donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, 
xazax.hun.
Herald added a project: All.
mantognini published this revision for review.
mantognini added reviewers: NoQ, xazax.hun.
mantognini added a comment.
Herald added subscribers: cfe-commits, rnkovacs.
Herald added a project: clang.

I'd appreciate reviews for this small patch. Thanks.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124462

Files:
  clang/lib/StaticAnalyzer/Checkers/Taint.cpp


Index: clang/lib/StaticAnalyzer/Checkers/Taint.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/Taint.cpp
+++ clang/lib/StaticAnalyzer/Checkers/Taint.cpp
@@ -37,7 +37,9 @@
 Out << I.first << " : " << I.second << NL;
 }
 
-void dumpTaint(ProgramStateRef State) { printTaint(State, llvm::errs()); }
+LLVM_DUMP_METHOD void taint::dumpTaint(ProgramStateRef State) {
+  printTaint(State, llvm::errs());
+}
 
 ProgramStateRef taint::addTaint(ProgramStateRef State, const Stmt *S,
 const LocationContext *LCtx,


Index: clang/lib/StaticAnalyzer/Checkers/Taint.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/Taint.cpp
+++ clang/lib/StaticAnalyzer/Checkers/Taint.cpp
@@ -37,7 +37,9 @@
 Out << I.first << " : " << I.second << NL;
 }
 
-void dumpTaint(ProgramStateRef State) { printTaint(State, llvm::errs()); }
+LLVM_DUMP_METHOD void taint::dumpTaint(ProgramStateRef State) {
+  printTaint(State, llvm::errs());
+}
 
 ProgramStateRef taint::addTaint(ProgramStateRef State, const Stmt *S,
 const LocationContext *LCtx,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D124359: [clangd] Add inlay hints for mutable reference parameters

2022-04-27 Thread Tobias Ribizel via Phabricator via cfe-commits
upsj updated this revision to Diff 425432.
upsj added a comment.

add tests for reference inlay hints


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124359

Files:
  clang-tools-extra/clangd/InlayHints.cpp
  clang-tools-extra/clangd/unittests/InlayHintTests.cpp

Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -138,6 +138,39 @@
   )cpp");
 }
 
+TEST(ParameterHints, NoNameConstReference) {
+  // No hint for anonymous const l-value ref parameter.
+  assertParameterHints(R"cpp(
+void foo(const int&);
+void bar() {
+  foo(42);
+}
+  )cpp");
+}
+
+TEST(ParameterHints, NoNameReference) {
+  // Reference hint for anonymous l-value ref parameter.
+  assertParameterHints(R"cpp(
+void foo(int&);
+void bar() {
+  int i;
+  foo($param[[i]]);
+}
+  )cpp",
+   ExpectedHint{"&", "param"});
+}
+
+TEST(ParameterHints, NoNameRValueReference) {
+  // Reference hint for anonymous r-value ref parameter.
+  assertParameterHints(R"cpp(
+void foo(int&&);
+void bar() {
+  foo($param[[42]]);
+}
+  )cpp",
+   ExpectedHint{"&&", "param"});
+}
+
 TEST(ParameterHints, NameInDefinition) {
   // Parameter name picked up from definition if necessary.
   assertParameterHints(R"cpp(
@@ -162,6 +195,40 @@
ExpectedHint{"good: ", "good"});
 }
 
+TEST(ParameterHints, NameConstReference) {
+  // Only name hint for const l-value ref parameter.
+  assertParameterHints(R"cpp(
+void foo(const int& param);
+void bar() {
+  foo($param[[42]]);
+}
+  )cpp",
+   ExpectedHint{"param: ", "param"});
+}
+
+TEST(ParameterHints, NameReference) {
+  // Reference and name hint for l-value ref parameter.
+  assertParameterHints(R"cpp(
+void foo(int& param);
+void bar() {
+  int i;
+  foo($param[[i]]);
+}
+  )cpp",
+   ExpectedHint{"param: &", "param"});
+}
+
+TEST(ParameterHints, NameRValueReference) {
+  // Reference and name hint for r-value ref parameter.
+  assertParameterHints(R"cpp(
+void foo(int&& param);
+void bar() {
+  foo($param[[42]]);
+}
+  )cpp",
+   ExpectedHint{"param: &&", "param"});
+}
+
 TEST(ParameterHints, Operator) {
   // No hint for operator call with operator syntax.
   assertParameterHints(R"cpp(
@@ -301,6 +368,21 @@
ExpectedHint{"param: ", "param"});
 }
 
+TEST(ParameterHints, ArgMatchesParamReference) {
+  assertParameterHints(R"cpp(
+void foo(int& param);
+void foo2(const int& param);
+void bar() {
+  int param;
+  // show reference hint on mutable reference
+  foo($param[[param]]);
+  // but not on const reference
+  foo2(param);
+}
+  )cpp",
+   ExpectedHint{"&", "param"});
+}
+
 TEST(ParameterHints, LeadingUnderscore) {
   assertParameterHints(R"cpp(
 void foo(int p1, int _p2, int __p3);
Index: clang-tools-extra/clangd/InlayHints.cpp
===
--- clang-tools-extra/clangd/InlayHints.cpp
+++ clang-tools-extra/clangd/InlayHints.cpp
@@ -10,6 +10,7 @@
 #include "Config.h"
 #include "HeuristicResolver.h"
 #include "ParsedAST.h"
+#include "clang/AST/Decl.h"
 #include "clang/AST/DeclarationName.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/RecursiveASTVisitor.h"
@@ -392,6 +393,7 @@
 // Don't show hints for variadic parameters.
 size_t FixedParamCount = getFixedParamCount(Callee);
 size_t ArgCount = std::min(FixedParamCount, Args.size());
+auto Params = Callee->parameters();
 
 NameVec ParameterNames = chooseParameterNames(Callee, ArgCount);
 
@@ -402,12 +404,18 @@
 
 for (size_t I = 0; I < ArgCount; ++I) {
   StringRef Name = ParameterNames[I];
-  if (!shouldHint(Args[I], Name))
-continue;
+  bool NameHint = shouldNameHint(Args[I], Name);
+  std::string Suffix = ": ";
+  if (!NameHint) {
+Name = "";
+Suffix = "";
+  }
+  Suffix += getRefSuffix(Params[I]);
 
-  addInlayHint(Args[I]->getSourceRange(), HintSide::Left,
-   InlayHintKind::ParameterHint, /*Prefix=*/"", Name,
-   /*Suffix=*/": ");
+  if (!Name.empty() || !Suffix.empty()) {
+addInlayHint(Args[I]->getSourceRange(), HintSide::Left,
+ InlayHintKind::ParameterHint, /*Prefix=*/"", Name, Suffix);
+  }
 }
   }
 
@@ -434,12 +442,21 @@
 return WhatItIsSetting.equals_insensitive(ParamNames[0]);
   }
 
-  bool shouldHint(const Expr *Arg, StringRef ParamName) {
+  StringRef getRefSuffix(const ParmVarDecl *Param) {
+// If the parameter is a non-const reference type, print an inlay hi

[PATCH] D124462: [Analyzer] Fix clang::ento::taint::dumpTaint definition

2022-04-27 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a reviewer: steakhal.
steakhal added a comment.

Could you please elaborate whats the motivation for this change?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124462

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


[clang] c1e9459 - Revert "[asan] Enable detect_stack_use_after_return=1 by default"

2022-04-27 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2022-04-27T00:43:39-07:00
New Revision: c1e94591bcc95f36da0372080c455b09af8c46fd

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

LOG: Revert "[asan] Enable detect_stack_use_after_return=1 by default"

Temporarily revert the option to fix
https://bugs.chromium.org/p/chromium/issues/detail?id=1319387

This reverts option default and documentation of the commit. Test
changes are not being reverted as they are improvement and break
reliance on option defaults.

Additional memory usage is a problem on mobile devices with low memory.
Even heavy thread desktop programs may need some FakeStack tunning.

This reverts commit 4b4437c084e2b8a2643e97e7aef125c438635a4d.

Added: 


Modified: 
clang/docs/AddressSanitizer.rst
clang/docs/ReleaseNotes.rst
compiler-rt/lib/asan/asan_flags.inc

Removed: 




diff  --git a/clang/docs/AddressSanitizer.rst b/clang/docs/AddressSanitizer.rst
index ca5c052b615f5..cc51a8d8a34fd 100644
--- a/clang/docs/AddressSanitizer.rst
+++ b/clang/docs/AddressSanitizer.rst
@@ -15,7 +15,7 @@ following types of bugs:
 * Out-of-bounds accesses to heap, stack and globals
 * Use-after-free
 * Use-after-return (clang flag 
``-fsanitize-address-use-after-return=(never|runtime|always)`` default: 
``runtime``)
-* Disable ``runtime`` with: 
``ASAN_OPTIONS=detect_stack_use_after_return=0``
+* Enable ``runtime`` with: ``ASAN_OPTIONS=detect_stack_use_after_return=1``
 * Use-after-scope (clang flag ``-fsanitize-address-use-after-scope``)
 * Double-free, invalid free
 * Memory leaks (experimental)

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index e78167bad589e..2dacf3a94cdff 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -178,9 +178,7 @@ Non-comprehensive list of changes in this release
   - Improve the dump format, dump both bitwidth(if its a bitfield) and field 
value.
   - Remove anonymous tag locations.
   - Beautify dump format, add indent for nested struct and struct members.
-- Previously disabled sanitizer options now enabled by default:
-  - ASAN_OPTIONS=detect_stack_use_after_return=1 (except Windows).
-  - MSAN_OPTIONS=poison_in_dtor=1.
+- Enable MSAN_OPTIONS=poison_in_dtor=1 by default.
 
 New Compiler Flags
 --

diff  --git a/compiler-rt/lib/asan/asan_flags.inc 
b/compiler-rt/lib/asan/asan_flags.inc
index 04023234bc945..514b225c40731 100644
--- a/compiler-rt/lib/asan/asan_flags.inc
+++ b/compiler-rt/lib/asan/asan_flags.inc
@@ -49,7 +49,7 @@ ASAN_FLAG(
 "to find more errors.")
 ASAN_FLAG(bool, replace_intrin, true,
   "If set, uses custom wrappers for memset/memcpy/memmove intrinsics.")
-ASAN_FLAG(bool, detect_stack_use_after_return, !SANITIZER_WINDOWS,
+ASAN_FLAG(bool, detect_stack_use_after_return, false,
   "Enables stack-use-after-return checking at run-time.")
 ASAN_FLAG(int, min_uar_stack_size_log, 16, // We can't do smaller anyway.
   "Minimum fake stack size log.")



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


[PATCH] D112921: [clang] Enable sized deallocation by default in C++14 onwards

2022-04-27 Thread Wang Pengcheng via Phabricator via cfe-commits
pcwang-thead added a comment.

In D112921#3474964 , @rjmccall wrote:

> Hmm.  Allowing a version on `-stdlib` is intuitively appealing, but I'm not 
> sure it actually gives us the information we need.  As I recall, `-stdlib` 
> selects the high-level stdlib and not the low-level one, and those are 
> related in code but not necessarily at runtime; for example, you can (or at 
> least could, historically) use libstdc++ on macOS, but the underlying 
> low-level stdlib is going to be libc++abi, not libsupc++.  And the low-level 
> runtime is the one that actually provides global `operator new` functions.  
> Is there a way to bridge that gap?

Hmm, that's really a tough nut. We have high-level standard libraries like 
`libc++` and `libstdc++`, and low-level runtimes like `libc++abi`, `libsupc++` 
and libcxxrt . There could be a lot of 
situations and we haven't think about MSVC yet.
I don't know if adding an option `-cxxabilib=libsupc++-v4.8` or something like 
this would make sense, but I think we should make another revision to do it. I 
will appy @ldionne 's solution first.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112921

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


[PATCH] D124504: Remove --no-opaque-pointers in test/cxx2a-thread-local-constinit.cpp

2022-04-27 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

In D124504#3476562 , @ChuanqiXu wrote:

> In D124504#3476537 , @nikic wrote:
>
>> How does it block your work? Tests currently still use `-no-opaque-pointers` 
>> to avoid breaking this mode. I think it's generally okay to drop the option, 
>> but I'm a bit unclear about the motivation in this case -- do you want to 
>> make a change that would be incompatible with typed pointers?
>
> The motivation is that I want to insert an intrinsic for TLS variable. The 
> whole background could be found at: 
> https://discourse.llvm.org/t/address-thread-identification-problems-with-coroutine/62015
>
> The signature of the intrinsic is `ptr @intrinsic.name(ptr)`. And I must add 
> one bitcast if I can't use opaque-pointer. It looks like opaque pointer is 
> enabled by default now: 
> https://github.com/llvm/llvm-project/blob/86c770346c26ce4c9abf5a5b7ab4b5bbfdcf9d78/clang/include/clang/Driver/Options.td#L5567-L5573
>
> So I feel like it is better to remove the `--no-opaque-pointers` option. I 
> could add a bitcast to workaround if this is not wanted. Maybe the word 
> `block` is not suitable here.

In that case, I'd recommend inserting the bitcast for now, if it's not too much 
complication. Also, you might want to consider using an overloaded intrinsic, 
in which case a bitcast is not necessary (using an overloaded intrinsic would 
also allow pointers of different address spaces, not sure if that's relevant 
here).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124504

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


[PATCH] D124461: [Analyzer] Remove undefined function

2022-04-27 Thread Marco Antognini via Phabricator via cfe-commits
mantognini created this revision.
Herald added subscribers: manas, steakhal, ASDenysPetrov, dkrupp, donat.nagy, 
Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Herald added a project: All.
mantognini added reviewers: NoQ, baloghadamsoftware.
mantognini published this revision for review.
mantognini added a comment.
Herald added subscribers: cfe-commits, rnkovacs.
Herald added a project: clang.

I'd appreciate reviews for this small patch. Thanks.


This getLValue function was declared in 98db1f990fc2 
 
([Analyzer] [NFC]
Parameter Regions, 2020-05-11) but was never implemented.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124461

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h


Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
@@ -306,10 +306,6 @@
   Loc getLValue(const CXXRecordDecl *BaseClass, const SubRegion *Super,
 bool IsVirtual) const;
 
-  /// Get the lvalue for a parameter.
-  Loc getLValue(const Expr *Call, unsigned Index,
-const LocationContext *LC) const;
-
   /// Get the lvalue for a variable reference.
   Loc getLValue(const VarDecl *D, const LocationContext *LC) const;
 


Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
@@ -306,10 +306,6 @@
   Loc getLValue(const CXXRecordDecl *BaseClass, const SubRegion *Super,
 bool IsVirtual) const;
 
-  /// Get the lvalue for a parameter.
-  Loc getLValue(const Expr *Call, unsigned Index,
-const LocationContext *LC) const;
-
   /// Get the lvalue for a variable reference.
   Loc getLValue(const VarDecl *D, const LocationContext *LC) const;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D124057: [asan] Enable detect_stack_use_after_return=1 by default

2022-04-27 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka updated this revision to Diff 425433.
vitalybuka added a comment.

redo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124057

Files:
  clang/docs/AddressSanitizer.rst
  clang/docs/ReleaseNotes.rst
  compiler-rt/lib/asan/asan_flags.inc


Index: compiler-rt/lib/asan/asan_flags.inc
===
--- compiler-rt/lib/asan/asan_flags.inc
+++ compiler-rt/lib/asan/asan_flags.inc
@@ -49,7 +49,7 @@
 "to find more errors.")
 ASAN_FLAG(bool, replace_intrin, true,
   "If set, uses custom wrappers for memset/memcpy/memmove intrinsics.")
-ASAN_FLAG(bool, detect_stack_use_after_return, false,
+ASAN_FLAG(bool, detect_stack_use_after_return, !SANITIZER_WINDOWS,
   "Enables stack-use-after-return checking at run-time.")
 ASAN_FLAG(int, min_uar_stack_size_log, 16, // We can't do smaller anyway.
   "Minimum fake stack size log.")
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -178,7 +178,9 @@
   - Improve the dump format, dump both bitwidth(if its a bitfield) and field 
value.
   - Remove anonymous tag locations.
   - Beautify dump format, add indent for nested struct and struct members.
-- Enable MSAN_OPTIONS=poison_in_dtor=1 by default.
+- Previously disabled sanitizer options now enabled by default:
+  - ASAN_OPTIONS=detect_stack_use_after_return=1 (except Windows).
+  - MSAN_OPTIONS=poison_in_dtor=1.
 
 New Compiler Flags
 --
Index: clang/docs/AddressSanitizer.rst
===
--- clang/docs/AddressSanitizer.rst
+++ clang/docs/AddressSanitizer.rst
@@ -15,7 +15,7 @@
 * Out-of-bounds accesses to heap, stack and globals
 * Use-after-free
 * Use-after-return (clang flag 
``-fsanitize-address-use-after-return=(never|runtime|always)`` default: 
``runtime``)
-* Enable ``runtime`` with: ``ASAN_OPTIONS=detect_stack_use_after_return=1``
+* Disable ``runtime`` with: 
``ASAN_OPTIONS=detect_stack_use_after_return=0``
 * Use-after-scope (clang flag ``-fsanitize-address-use-after-scope``)
 * Double-free, invalid free
 * Memory leaks (experimental)


Index: compiler-rt/lib/asan/asan_flags.inc
===
--- compiler-rt/lib/asan/asan_flags.inc
+++ compiler-rt/lib/asan/asan_flags.inc
@@ -49,7 +49,7 @@
 "to find more errors.")
 ASAN_FLAG(bool, replace_intrin, true,
   "If set, uses custom wrappers for memset/memcpy/memmove intrinsics.")
-ASAN_FLAG(bool, detect_stack_use_after_return, false,
+ASAN_FLAG(bool, detect_stack_use_after_return, !SANITIZER_WINDOWS,
   "Enables stack-use-after-return checking at run-time.")
 ASAN_FLAG(int, min_uar_stack_size_log, 16, // We can't do smaller anyway.
   "Minimum fake stack size log.")
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -178,7 +178,9 @@
   - Improve the dump format, dump both bitwidth(if its a bitfield) and field value.
   - Remove anonymous tag locations.
   - Beautify dump format, add indent for nested struct and struct members.
-- Enable MSAN_OPTIONS=poison_in_dtor=1 by default.
+- Previously disabled sanitizer options now enabled by default:
+  - ASAN_OPTIONS=detect_stack_use_after_return=1 (except Windows).
+  - MSAN_OPTIONS=poison_in_dtor=1.
 
 New Compiler Flags
 --
Index: clang/docs/AddressSanitizer.rst
===
--- clang/docs/AddressSanitizer.rst
+++ clang/docs/AddressSanitizer.rst
@@ -15,7 +15,7 @@
 * Out-of-bounds accesses to heap, stack and globals
 * Use-after-free
 * Use-after-return (clang flag ``-fsanitize-address-use-after-return=(never|runtime|always)`` default: ``runtime``)
-* Enable ``runtime`` with: ``ASAN_OPTIONS=detect_stack_use_after_return=1``
+* Disable ``runtime`` with: ``ASAN_OPTIONS=detect_stack_use_after_return=0``
 * Use-after-scope (clang flag ``-fsanitize-address-use-after-scope``)
 * Double-free, invalid free
 * Memory leaks (experimental)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D124504: Remove --no-opaque-pointers in test/cxx2a-thread-local-constinit.cpp

2022-04-27 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu abandoned this revision.
ChuanqiXu added a comment.

In D124504#3476585 , @nikic wrote:

> In D124504#3476562 , @ChuanqiXu 
> wrote:
>
>> In D124504#3476537 , @nikic wrote:
>>
>>> How does it block your work? Tests currently still use 
>>> `-no-opaque-pointers` to avoid breaking this mode. I think it's generally 
>>> okay to drop the option, but I'm a bit unclear about the motivation in this 
>>> case -- do you want to make a change that would be incompatible with typed 
>>> pointers?
>>
>> The motivation is that I want to insert an intrinsic for TLS variable. The 
>> whole background could be found at: 
>> https://discourse.llvm.org/t/address-thread-identification-problems-with-coroutine/62015
>>
>> The signature of the intrinsic is `ptr @intrinsic.name(ptr)`. And I must add 
>> one bitcast if I can't use opaque-pointer. It looks like opaque pointer is 
>> enabled by default now: 
>> https://github.com/llvm/llvm-project/blob/86c770346c26ce4c9abf5a5b7ab4b5bbfdcf9d78/clang/include/clang/Driver/Options.td#L5567-L5573
>>
>> So I feel like it is better to remove the `--no-opaque-pointers` option. I 
>> could add a bitcast to workaround if this is not wanted. Maybe the word 
>> `block` is not suitable here.
>
> In that case, I'd recommend inserting the bitcast for now, if it's not too 
> much complication. Also, you might want to consider using an overloaded 
> intrinsic, in which case a bitcast is not necessary (using an overloaded 
> intrinsic would also allow pointers of different address spaces, not sure if 
> that's relevant here).

Thanks, I would give it a try.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124504

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


[PATCH] D121370: [clang-format] SortIncludes should support "@import" lines in Objective-C

2022-04-27 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

> @krasimir I'm on sick leave and will have a look as soon as I'm back. Can it 
> wait that long?

I'm planning to revert this temporarily and add a regression test, you can 
proceed with this work without time pressure. We aim to release a new 
clang-format version weekly to ease the process of finding and reporting 
regressions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121370

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


[PATCH] D123300: [Clang] Enable opaque pointers by default

2022-04-27 Thread Dawid Jurczak via Phabricator via cfe-commits
yurai007 added a comment.

In D123300#3474834 , @nikic wrote:

> @yurai007 I've put up https://reviews.llvm.org/D124459 to fix this 
> optimization failure.

@nikic: I can confirm that patch fix regression and makes coroutines snippet 
great again. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123300

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


[PATCH] D124158: [Clang][Attr] Skip adding noundef attribute to arguments when function has convergent attribute

2022-04-27 Thread krishna chaitanya sankisa via Phabricator via cfe-commits
skc7 updated this revision to Diff 425442.
skc7 added a comment.

fix failing tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124158

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGen/PowerPC/ppc64le-varargs-f128.c
  clang/test/CodeGenCUDA/address-spaces.cu
  clang/test/CodeGenCUDA/builtins-amdgcn.cu
  clang/test/CodeGenCUDA/cuda-builtin-vars.cu
  clang/test/CodeGenCUDA/kernel-args-alignment.cu
  clang/test/CodeGenCUDA/kernel-args.cu
  clang/test/CodeGenCUDA/redux-builtins.cu
  clang/test/CodeGenCUDA/surface.cu
  clang/test/CodeGenCUDA/usual-deallocators.cu
  clang/test/CodeGenCUDA/vtbl.cu
  clang/test/CodeGenCUDASPIRV/kernel-argument.cu
  clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
  clang/test/CodeGenOpenCL/address-spaces.cl
  clang/test/CodeGenOpenCL/amdgcn-automatic-variable.cl
  clang/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl
  clang/test/CodeGenOpenCL/amdgpu-call-kernel.cl
  clang/test/CodeGenOpenCL/amdgpu-printf.cl
  clang/test/CodeGenOpenCL/as_type.cl
  clang/test/CodeGenOpenCL/atomic-ops-libcall.cl
  clang/test/CodeGenOpenCL/blocks.cl
  clang/test/CodeGenOpenCL/byval.cl
  clang/test/CodeGenOpenCL/const-str-array-decay.cl
  clang/test/CodeGenOpenCL/constant-addr-space-globals.cl
  clang/test/CodeGenOpenCL/convergent.cl
  clang/test/CodeGenOpenCL/fpmath.cl
  clang/test/CodeGenOpenCL/half.cl
  clang/test/CodeGenOpenCL/kernel-param-alignment.cl
  clang/test/CodeGenOpenCL/kernels-have-spir-cc-by-default.cl
  clang/test/CodeGenOpenCL/no-half.cl
  clang/test/CodeGenOpenCL/overload.cl
  clang/test/CodeGenOpenCL/size_t.cl
  clang/test/CodeGenOpenCL/spir-calling-conv.cl
  clang/test/CodeGenOpenCLCXX/address-space-deduction.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-of-this.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-operators.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-references.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-with-class.clcpp
  clang/test/CodeGenSYCL/address-space-conversions.cpp
  clang/test/CodeGenSYCL/address-space-mangling.cpp
  clang/test/CodeGenSYCL/functionptr-addrspace.cpp
  clang/test/CodeGenSYCL/unique_stable_name.cpp
  clang/test/OpenMP/amdgcn-attributes.cpp
  clang/test/OpenMP/amdgcn_target_global_constructor.cpp
  clang/test/OpenMP/assumes_include_nvptx.cpp
  clang/test/OpenMP/declare_target_codegen.cpp
  clang/test/OpenMP/declare_target_codegen_globalization.cpp
  clang/test/OpenMP/declare_target_link_codegen.cpp
  clang/test/OpenMP/declare_variant_mixed_codegen.c
  clang/test/OpenMP/distribute_codegen.cpp
  clang/test/OpenMP/distribute_simd_codegen.cpp
  clang/test/OpenMP/nvptx_allocate_codegen.cpp
  clang/test/OpenMP/nvptx_data_sharing.cpp
  clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
  clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_lambda_capturing.cpp
  clang/test/OpenMP/nvptx_multi_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_nested_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_target_printf_codegen.c
  clang/test/OpenMP/nvptx_target_teams_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  
clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/nvptx_teams_codegen.cpp
  clang/test/OpenMP/nvptx_teams_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_unsupported_type_codegen.cpp
  clang/test/OpenMP/openmp_offload_codegen.cpp
  clang/test/OpenMP/reduction_implicit_map.cpp
  clang/test/OpenMP/target_firstprivate_codegen.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_debug_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_debug_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_parallel_if_codegen.cpp
  clang/test/OpenMP/target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/target_private_codegen.cpp
  clang/test/OpenMP/target_reduction_codegen.cpp
  clang/test/OpenMP/target_teams_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_private_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_codegen.cpp
  
clang/test/OpenMP/target_teams_dist

[PATCH] D112921: [clang] Enable sized deallocation by default in C++14 onwards

2022-04-27 Thread Wang Pengcheng via Phabricator via cfe-commits
pcwang-thead updated this revision to Diff 425443.
pcwang-thead added a comment.
Herald added subscribers: dexonsmith, arichardson.

- Add handling of Apple targets.
- Update libc++ tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112921

Files:
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc-new-delete-overloads.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/SizedDeallocation.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/Darwin.h
  clang/lib/Driver/ToolChains/ZOS.cpp
  clang/test/AST/ast-dump-expr-json.cpp
  clang/test/AST/ast-dump-expr.cpp
  clang/test/AST/ast-dump-stmt-json.cpp
  clang/test/CodeGenCXX/cxx1y-sized-deallocation.cpp
  clang/test/CodeGenCXX/cxx2a-destroying-delete.cpp
  clang/test/CodeGenCXX/delete-two-arg.cpp
  clang/test/CodeGenCXX/dllimport.cpp
  clang/test/CodeGenCXX/new.cpp
  clang/test/CodeGenCoroutines/coro-alloc-exp-namespace.cpp
  clang/test/CodeGenCoroutines/coro-alloc.cpp
  clang/test/CodeGenCoroutines/coro-cleanup-exp-namespace.cpp
  clang/test/CodeGenCoroutines/coro-cleanup.cpp
  clang/test/CodeGenCoroutines/coro-gro-exp-namespace.cpp
  clang/test/CodeGenCoroutines/coro-gro.cpp
  clang/test/SemaCXX/MicrosoftExtensions.cpp
  clang/test/SemaCXX/builtin-operator-new-delete.cpp
  clang/test/SemaCXX/unavailable_aligned_allocation.cpp
  clang/unittests/StaticAnalyzer/CallEventTest.cpp
  clang/www/cxx_status.html
  
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp
  libcxx/utils/ci/buildkite-pipeline.yml

Index: libcxx/utils/ci/buildkite-pipeline.yml
===
--- libcxx/utils/ci/buildkite-pipeline.yml
+++ libcxx/utils/ci/buildkite-pipeline.yml
@@ -1,4 +1,5 @@
 #===--===##
+#===--===##
 #
 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 # See https://llvm.org/LICENSE.txt for license information.
@@ -144,7 +145,7 @@
   #
   # All other supported configurations of libc++.
   #
-  - wait
+  # - wait
 
   - label: "C++20"
 command: "libcxx/utils/ci/run-buildbot generic-cxx20"
Index: libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp
===
--- libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp
+++ libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp
@@ -9,10 +9,11 @@
 // test sized operator delete[] replacement.
 
 // UNSUPPORTED: sanitizer-new-delete, c++03, c++11
+// XFAIL: clang-13, clang-14
+// XFAIL: apple-clang
 
-// NOTE: Clang does not enable sized-deallocation in C++14 and beyond by
-// default. It is only enabled when -fsized-deallocation is given.
-// XFAIL: clang, apple-clang
+// Sized deallocation was added in macOS 10.12 and aligned OSes.
+// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11}}
 
 #include 
 #include 
Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -578,12 +578,11 @@
 
 
 
-(7): In Clang 3.7 and later, sized deallocation is only enabled
-if the user passes the -fsized-deallocation flag. The user must
-supply definitions of the sized deallocation functions, either by providing them
-explicitly or by using a C++ standard library that does. libstdc++
-added these functions in version 5.0, and libc++ added them in
-version 3.7.
+(7): The user must supply definitions of the sized deallocation
+functions, either by providing them explicitly or by using a C++ standard library
+that does. libstdc++ added these functions in version 5.0, and
+libc++ added them in version 3.7. The user can also use the
+-fno-sized-deallocation option to disable sized deallocation.
 
 
 
Index: clang/unittests/StaticAnalyzer/CallEventTest.cpp
===
--- clang/unittests/StaticAnalyzer/CallEventTest.cpp
+++ clang/unittests/StaticAnalyzer/CallEventTest.cpp
@@ -81,7 +81,7 @@
 }
   )",
  Diags));
-  EXPECT_EQ(Diags, "test.CXXDeallocator: NumArgs: 1\n");
+  EXPECT_EQ(Diags, "test.CXXDeallocator: NumArgs: 2\n");
 }
 
 } // namespace
Index: clang/test/SemaCXX/unavailable_aligned_allocation.cpp
===
--- clang/test/SemaCXX/unavailable_aligned_allocation.cpp
+++ clang/test/SemaCXX/unavailable_aligned_allocation.c

[PATCH] D124435: [X86] Always extend the integer parameters in callee

2022-04-27 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/docs/ClangCommandLineReference.rst:2988-2992
+.. option:: -mconservative-extend
+Always extend the integer parameter both in the callee and caller.
+
+.. option:: -mno-conservative-extend
+Keep the original integer parameter passing behavior.

LiuChen3 wrote:
> LiuChen3 wrote:
> > rjmccall wrote:
> > > pengfei wrote:
> > > > Combine like others?
> > > How about:
> > > 
> > > ```
> > > In the past, Clang passed small integer arguments on certain targets 
> > > using a
> > > parameter convention in which the caller was assumed to have sign-extended
> > > or zero-extended the argument to a certain width.  This convention was not
> > > conformant with the documented ABI on these platforms, which does not
> > > require the caller to perform this extension.  Clang no longer assumes 
> > > that
> > > callers perform this extension, but for compatibility with code compiled 
> > > by
> > > previous releases of Clang, Clang defaults to still extending the 
> > > argument in the
> > > caller.  `-mno-conservative-extend` disables this, which may improve
> > > performance and code size if compatibility with old versions of Clang is 
> > > not
> > > required.
> > > 
> > > This affects most 32-bit and 64-bit x86 targets, except:
> > > - Windows, which Clang has never assumed extension on
> > > - Apple platforms, which use a non-standard ABI that unconditionally 
> > > assumes extension
> > > ```
> > > 
> > > Note that I need to check that that's what Apple actually wants to do.  
> > > You should also reach out to the Sony folks to see what they want to do, 
> > > but I expect that it's to assume extension unconditionally.
> > Thanks a lot! It's much clearer.
> > Just a small correction for windows: only windows64 is not affected.
> Hi, @RKSimon , @probinson.  This patch will extend the integer parameters in 
> the caller.  Is there any concern about this for Sony?
Slight revision:

In the past, on certain targets, Clang passed promotable integer arguments
(arguments with types smaller than `int`) using a parameter convention in
which the caller was assumed to have sign-extended or zero-extended the
argument to the width of an `int`.  This convention did not conform to the
documented ABI for these targets, which does not require the caller to
perform this extension.





Comment at: clang/lib/CodeGen/TargetInfo.cpp:1938
+return IsConservativeExtend ? ABIArgInfo::getConservativeExtend(Ty)
+: ABIArgInfo::getExtend(Ty);
   }

LiuChen3 wrote:
> rjmccall wrote:
> > This looks wrong.  In non-`ConservativeExtend` mode, we don't get to assume 
> > extension at all and should use `Direct`, right?
> As I understand it, `Direct` means do nothing with the parameters. Caller 
> won't do the extension and callee can't assume the parameter is correct. This 
> makes new clang behave in the opposite way to currently clang behavior, which 
> will cause incompatibility issue. e.g:
> https://godbolt.org/z/d3Peq4nsG
Oh, I see, you're thinking that `-mno-conservative-extend` means "do what old 
versions of clang did" rather than "break compatibility with old versions of 
clang and just follow the x86_64 ABI".  That's definitely different from the 
documentation I suggested, so something's got to change.

I think these are the possibilities here:

1. Some platforms, like Apple's, are probably going to define Clang's current 
behavior as the platform ABI.  So those platforms need to continue to use 
`Extend`.  My previous comment about using `Direct` wasn't paying due attention 
to this case.

2. On other platforms, we need to maintain compatibility by default with both 
the platform ABI and old Clang behavior.  Those platforms will need to use 
`ConservativeExtend`.

3. Some people may want to opt out of (2) and just be compatible with the 
platform ABI, which has minor code-size and performance wins.  If we support 
that with an option, I believe it should cause us to emit `Direct`.  This is 
what I was thinking `-mno-conservative-extend` would mean.

4. Some people may want to force the use of (1) even on platforms where that 
isn't the platform ABI.  I don't know if this is really something we should 
support in the long term, but it might be valuable for people staging this 
change in.  This is what you seem to be thinking `-mno-conservative-extend` 
would mean.

I would suggest these spellings for the argument, instead of making it boolean:

```
-mextend-small-integers=none// Force the use of Direct
-mextend-small-integers=conservative // Force the use of ConservativeExtend
-mextend-small-integers=assumed // Force the use of Extend
-mextend-small-integers=default // Use the default rule for the target
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124435


[PATCH] D124509: [RISCV] Fix int16 -> __fp16 conversion code gen

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

clang emit wrong code sequence for int16(short) to __fp16 conversion,
and that should fix the code gen directly is the right way I think,
but I found there is a FIXME comment in clang/Basic/TargetInfo.h say
that's should be removed in future so I think just let swich to using
generic LLVM IR rather than llvm.convert.to.fp16 intrinsics code gen
path is enough, and the code gen apperantly more concise for __fp16 to
int16 conversion.

  /// Check whether llvm intrinsics such as llvm.convert.to.fp16 should be used
  /// to convert to and from __fp16.
  /// FIXME: This function should be removed once all targets stop using the
  /// conversion intrinsics.
  virtual bool useFP16ConversionIntrinsics() const {
return true;
  }


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124509

Files:
  clang/lib/Basic/Targets/RISCV.h
  clang/test/CodeGen/RISCV/__fp16-convert.c


Index: clang/test/CodeGen/RISCV/__fp16-convert.c
===
--- clang/test/CodeGen/RISCV/__fp16-convert.c
+++ clang/test/CodeGen/RISCV/__fp16-convert.c
@@ -6,10 +6,10 @@
 short z;
 // CHECK-LABEL: @bar1(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = load i16, ptr @y, align 2
-// CHECK-NEXT:[[TMP1:%.*]] = call float @llvm.convert.from.fp16.f32(i16 
[[TMP0]])
-// CHECK-NEXT:[[CONV:%.*]] = fptosi float [[TMP1]] to i16
-// CHECK-NEXT:store i16 [[CONV]], ptr @z, align 2
+// CHECK-NEXT:[[TMP0:%.*]] = load half, ptr @y, align 2
+// CHECK-NEXT:[[CONV:%.*]] = fpext half [[TMP0]] to float
+// CHECK-NEXT:[[CONV1:%.*]] = fptosi float [[CONV]] to i16
+// CHECK-NEXT:store i16 [[CONV1]], ptr @z, align 2
 // CHECK-NEXT:ret void
 //
 void bar1(){
@@ -18,7 +18,9 @@
 // CHECK-LABEL: @bar2(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = load i16, ptr @z, align 2
-// CHECK-NEXT:store i16 [[TMP0]], ptr @y, align 2
+// CHECK-NEXT:[[CONV:%.*]] = sitofp i16 [[TMP0]] to float
+// CHECK-NEXT:[[CONV1:%.*]] = fptrunc float [[CONV]] to half
+// CHECK-NEXT:store half [[CONV1]], ptr @y, align 2
 // CHECK-NEXT:ret void
 //
 void bar2(){
Index: clang/lib/Basic/Targets/RISCV.h
===
--- clang/lib/Basic/Targets/RISCV.h
+++ clang/lib/Basic/Targets/RISCV.h
@@ -96,6 +96,10 @@
 DiagnosticsEngine &Diags) override;
 
   bool hasBitIntType() const override { return true; }
+
+  bool useFP16ConversionIntrinsics() const override {
+return false;
+  }
 };
 class LLVM_LIBRARY_VISIBILITY RISCV32TargetInfo : public RISCVTargetInfo {
 public:


Index: clang/test/CodeGen/RISCV/__fp16-convert.c
===
--- clang/test/CodeGen/RISCV/__fp16-convert.c
+++ clang/test/CodeGen/RISCV/__fp16-convert.c
@@ -6,10 +6,10 @@
 short z;
 // CHECK-LABEL: @bar1(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = load i16, ptr @y, align 2
-// CHECK-NEXT:[[TMP1:%.*]] = call float @llvm.convert.from.fp16.f32(i16 [[TMP0]])
-// CHECK-NEXT:[[CONV:%.*]] = fptosi float [[TMP1]] to i16
-// CHECK-NEXT:store i16 [[CONV]], ptr @z, align 2
+// CHECK-NEXT:[[TMP0:%.*]] = load half, ptr @y, align 2
+// CHECK-NEXT:[[CONV:%.*]] = fpext half [[TMP0]] to float
+// CHECK-NEXT:[[CONV1:%.*]] = fptosi float [[CONV]] to i16
+// CHECK-NEXT:store i16 [[CONV1]], ptr @z, align 2
 // CHECK-NEXT:ret void
 //
 void bar1(){
@@ -18,7 +18,9 @@
 // CHECK-LABEL: @bar2(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = load i16, ptr @z, align 2
-// CHECK-NEXT:store i16 [[TMP0]], ptr @y, align 2
+// CHECK-NEXT:[[CONV:%.*]] = sitofp i16 [[TMP0]] to float
+// CHECK-NEXT:[[CONV1:%.*]] = fptrunc float [[CONV]] to half
+// CHECK-NEXT:store half [[CONV1]], ptr @y, align 2
 // CHECK-NEXT:ret void
 //
 void bar2(){
Index: clang/lib/Basic/Targets/RISCV.h
===
--- clang/lib/Basic/Targets/RISCV.h
+++ clang/lib/Basic/Targets/RISCV.h
@@ -96,6 +96,10 @@
 DiagnosticsEngine &Diags) override;
 
   bool hasBitIntType() const override { return true; }
+
+  bool useFP16ConversionIntrinsics() const override {
+return false;
+  }
 };
 class LLVM_LIBRARY_VISIBILITY RISCV32TargetInfo : public RISCVTargetInfo {
 public:
___
cfe-commits mailing list
cfe-commits@lists.llv

[PATCH] D124510: [RISCV] Precommit test for D124509

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

Test case to show the wrong code gen for `int16` -> `__fp16` conversion,
clang just emit a load and store without did conversion in the case,

and another case used for demonstrate the code gen improvement of `__fp16`
-> `int16`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124510

Files:
  clang/test/CodeGen/RISCV/__fp16-convert.c


Index: clang/test/CodeGen/RISCV/__fp16-convert.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/__fp16-convert.c
@@ -0,0 +1,26 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple riscv64 -emit-llvm %s -o - \
+// RUN:   | FileCheck %s
+
+__fp16 y;
+short z;
+// CHECK-LABEL: @bar1(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = load i16, ptr @y, align 2
+// CHECK-NEXT:[[TMP1:%.*]] = call float @llvm.convert.from.fp16.f32(i16 
[[TMP0]])
+// CHECK-NEXT:[[CONV:%.*]] = fptosi float [[TMP1]] to i16
+// CHECK-NEXT:store i16 [[CONV]], ptr @z, align 2
+// CHECK-NEXT:ret void
+//
+void bar1(){
+z = y;
+}
+// CHECK-LABEL: @bar2(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = load i16, ptr @z, align 2
+// CHECK-NEXT:store i16 [[TMP0]], ptr @y, align 2
+// CHECK-NEXT:ret void
+//
+void bar2(){
+y = z;
+}


Index: clang/test/CodeGen/RISCV/__fp16-convert.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/__fp16-convert.c
@@ -0,0 +1,26 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple riscv64 -emit-llvm %s -o - \
+// RUN:   | FileCheck %s
+
+__fp16 y;
+short z;
+// CHECK-LABEL: @bar1(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = load i16, ptr @y, align 2
+// CHECK-NEXT:[[TMP1:%.*]] = call float @llvm.convert.from.fp16.f32(i16 [[TMP0]])
+// CHECK-NEXT:[[CONV:%.*]] = fptosi float [[TMP1]] to i16
+// CHECK-NEXT:store i16 [[CONV]], ptr @z, align 2
+// CHECK-NEXT:ret void
+//
+void bar1(){
+z = y;
+}
+// CHECK-LABEL: @bar2(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = load i16, ptr @z, align 2
+// CHECK-NEXT:store i16 [[TMP0]], ptr @y, align 2
+// CHECK-NEXT:ret void
+//
+void bar2(){
+y = z;
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D124060: [PowerPC] Enable CR bits support for Power8 and above.

2022-04-27 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added inline comments.



Comment at: clang/lib/Basic/Targets/PPC.cpp:519
 .Default(false);
+  Features["crbits"] = llvm::StringSwitch(CPU)
+.Case("ppc64le", true)

shchenz wrote:
> amyk wrote:
> > shchenz wrote:
> > > If we set the `+crbits` by the arch name, do we still need the 
> > > customization (Turn on crbits for O2 and above) in 
> > > `computeFSAdditions()`? 
> > Yeah, that's a good point. I looked into this previously, and it appears 
> > that addition of `-mcrbits` inside `computeFSAdditions()` may still be 
> > necessary. 
> > 
> > In particular, we have test cases that test pre-POWER8 with optimizations 
> > on (or, if no optimization level is provided, then -O2 is assumed the 
> > default). In these cases, much of the code changes if the customization 
> > inside `computeFSAdditions()` is removed because we would no longer be 
> > using crbits pre-P8.
> hmm, OK, then we still have the same issue that this patch fixes for 
> pre-POWER8. I'm ok with leaving it for now as IMO Power7/Power6 should not be 
> major versions for PowerPC.
Up until Power8, the only instructions we had that require `crbits` were 
CR-logicals (which existed since the POWER architecture - i.e. before PowerPC). 
In Power8, we added BCD instructions that also require `crbits`. So that's why 
we turn it on for Power8 and up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124060

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


[PATCH] D124512: Revert "[clang-format] SortIncludes should support "@import" lines in Objective-C"

2022-04-27 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.
Herald added a project: All.
krasimir requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This reverts commit d46fa023caa2db5a9f1e21dd038bcb626261d958 
.

Regressed include order in some cases with trailing comments, see the
comments on https://reviews.llvm.org/D121370.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124512

Files:
  clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
  clang/lib/Format/Format.cpp
  clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
  clang/unittests/Format/SortIncludesTest.cpp

Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -458,103 +458,6 @@
  "#include \"b.h\"\n"));
 }
 
-TEST_F(SortIncludesTest, SupportAtImportLines) {
-  // Test from https://github.com/llvm/llvm-project/issues/38995
-  EXPECT_EQ("#import \"a.h\"\n"
-"#import \"b.h\"\n"
-"#import \"c.h\"\n"
-"#import \n"
-"@import Foundation;\n",
-sort("#import \"b.h\"\n"
- "#import \"c.h\"\n"
- "#import \n"
- "@import Foundation;\n"
- "#import \"a.h\"\n"));
-
-  // Slightly more complicated test that shows sorting in each priorities still
-  // works.
-  EXPECT_EQ("#import \"a.h\"\n"
-"#import \"b.h\"\n"
-"#import \"c.h\"\n"
-"#import \n"
-"@import Base;\n"
-"@import Foundation;\n"
-"@import base;\n"
-"@import foundation;\n",
-sort("#import \"b.h\"\n"
- "#import \"c.h\"\n"
- "@import Base;\n"
- "#import \n"
- "@import foundation;\n"
- "@import Foundation;\n"
- "@import base;\n"
- "#import \"a.h\"\n"));
-
-  // Test that shows main headers in two groups are still found and sorting
-  // still works. The @import's are kept in their respective group but are
-  // put at the end of each group.
-  FmtStyle.IncludeStyle.IncludeBlocks = tooling::IncludeStyle::IBS_Preserve;
-  EXPECT_EQ("#import \"foo.hpp\"\n"
-"#import \"b.h\"\n"
-"#import \"c.h\"\n"
-"#import \n"
-"@import Base;\n"
-"@import Foundation;\n"
-"@import foundation;\n"
-"\n"
-"#import \"foo.h\"\n"
-"#include \"foobar\"\n"
-"#import \n"
-"@import ;\n"
-"@import ;\n",
-sort("#import \"b.h\"\n"
- "@import Foundation;\n"
- "@import foundation;\n"
- "#import \"c.h\"\n"
- "#import \n"
- "@import Base;\n"
- "#import \"foo.hpp\"\n"
- "\n"
- "@import ;\n"
- "#import \n"
- "@import ;\n"
- "#include \"foobar\"\n"
- "#import \"foo.h\"\n",
- "foo.c", 2));
-
-  // Regrouping and putting @import's in the very last group
-  FmtStyle.IncludeStyle.IncludeBlocks = tooling::IncludeStyle::IBS_Regroup;
-  EXPECT_EQ("#import \"foo.hpp\"\n"
-"\n"
-"#import \"b.h\"\n"
-"#import \"c.h\"\n"
-"#import \"foo.h\"\n"
-"#include \"foobar\"\n"
-"\n"
-"#import \n"
-"#import \n"
-"\n"
-"@import ;\n"
-"@import Base;\n"
-"@import Foundation;\n"
-"@import ;\n"
-"@import foundation;\n",
-sort("#import \"b.h\"\n"
- "@import Foundation;\n"
- "@import foundation;\n"
- "#import \"c.h\"\n"
- "#import \n"
- "@import Base;\n"
- "#import \"foo.hpp\"\n"
- "\n"
- "@import ;\n"
- "#import \n"
- "@import ;\n"
- "#include \"foobar\"\n"
- "#import \"foo.h\"\n",
- "foo.c"));
-}
-
 TEST_F(SortIncludesTest, LeavesMainHeaderFirst) {
   Style.IncludeIsMainRegex = "([-_](test|unittest))?$";
   EXPECT_EQ("#include \"llvm/a.h\"\n"
Index: clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
===
--- clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
+++ clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
@@ -169,6 +169,13 @@
   });
 }
 
+inline StringRef trimInclude(StringRef IncludeName) {
+  return IncludeName.trim("\"<>");
+}
+
+const char IncludeRegexPattern[] =
+R"(^[\t\ ]*#[\t\ ]*(import|include)[^"<]*(["<][^

[PATCH] D124513: [clang-format] add a regression test for include sorting

2022-04-27 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.
Herald added a project: All.
krasimir requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This adds a regression test from the comments
on https://reviews.llvm.org/D121370.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124513

Files:
  clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
  clang/lib/Format/Format.cpp
  clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
  clang/unittests/Format/SortIncludesTest.cpp

Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -458,101 +458,18 @@
  "#include \"b.h\"\n"));
 }
 
-TEST_F(SortIncludesTest, SupportAtImportLines) {
-  // Test from https://github.com/llvm/llvm-project/issues/38995
-  EXPECT_EQ("#import \"a.h\"\n"
-"#import \"b.h\"\n"
-"#import \"c.h\"\n"
-"#import \n"
-"@import Foundation;\n",
-sort("#import \"b.h\"\n"
- "#import \"c.h\"\n"
- "#import \n"
- "@import Foundation;\n"
- "#import \"a.h\"\n"));
-
-  // Slightly more complicated test that shows sorting in each priorities still
-  // works.
-  EXPECT_EQ("#import \"a.h\"\n"
-"#import \"b.h\"\n"
-"#import \"c.h\"\n"
-"#import \n"
-"@import Base;\n"
-"@import Foundation;\n"
-"@import base;\n"
-"@import foundation;\n",
-sort("#import \"b.h\"\n"
- "#import \"c.h\"\n"
- "@import Base;\n"
- "#import \n"
- "@import foundation;\n"
- "@import Foundation;\n"
- "@import base;\n"
- "#import \"a.h\"\n"));
-
-  // Test that shows main headers in two groups are still found and sorting
-  // still works. The @import's are kept in their respective group but are
-  // put at the end of each group.
-  FmtStyle.IncludeStyle.IncludeBlocks = tooling::IncludeStyle::IBS_Preserve;
-  EXPECT_EQ("#import \"foo.hpp\"\n"
-"#import \"b.h\"\n"
-"#import \"c.h\"\n"
-"#import \n"
-"@import Base;\n"
-"@import Foundation;\n"
-"@import foundation;\n"
-"\n"
-"#import \"foo.h\"\n"
-"#include \"foobar\"\n"
-"#import \n"
-"@import ;\n"
-"@import ;\n",
-sort("#import \"b.h\"\n"
- "@import Foundation;\n"
- "@import foundation;\n"
- "#import \"c.h\"\n"
- "#import \n"
- "@import Base;\n"
- "#import \"foo.hpp\"\n"
- "\n"
- "@import ;\n"
- "#import \n"
- "@import ;\n"
- "#include \"foobar\"\n"
- "#import \"foo.h\"\n",
- "foo.c", 2));
-
-  // Regrouping and putting @import's in the very last group
-  FmtStyle.IncludeStyle.IncludeBlocks = tooling::IncludeStyle::IBS_Regroup;
-  EXPECT_EQ("#import \"foo.hpp\"\n"
-"\n"
-"#import \"b.h\"\n"
-"#import \"c.h\"\n"
-"#import \"foo.h\"\n"
-"#include \"foobar\"\n"
-"\n"
-"#import \n"
-"#import \n"
+TEST_F(SortIncludesTest, HandlesTrailingCommentsWithAngleBrackets) {
+  // Regression test from the discussion at https://reviews.llvm.org/D121370.
+  EXPECT_EQ("#include \n"
 "\n"
-"@import ;\n"
-"@import Base;\n"
-"@import Foundation;\n"
-"@import ;\n"
-"@import foundation;\n",
-sort("#import \"b.h\"\n"
- "@import Foundation;\n"
- "@import foundation;\n"
- "#import \"c.h\"\n"
- "#import \n"
- "@import Base;\n"
- "#import \"foo.hpp\"\n"
+"#include \"util/bar.h\"\n"
+"#include \"util/foo/foo.h\" // foo\n",
+sort("#include \n"
  "\n"
- "@import ;\n"
- "#import \n"
- "@import ;\n"
- "#include \"foobar\"\n"
- "#import \"foo.h\"\n",
- "foo.c"));
+ "#include \"util/bar.h\"\n"
+ "#include \"util/foo/foo.h\" // foo\n",
+ /*FileName=*/"input.cc",
+ /*ExpectedNumRanges=*/0));
 }
 
 TEST_F(SortIncludesTest, LeavesMainHeaderFirst) {
Index: clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
===
--- clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
+++ clang/lib/Tooling/Inclusions/HeaderInc

[PATCH] D124513: [clang-format] add a regression test for include sorting

2022-04-27 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 425456.
krasimir added a comment.

- update with just the last commit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124513

Files:
  clang/unittests/Format/SortIncludesTest.cpp


Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -458,6 +458,20 @@
  "#include \"b.h\"\n"));
 }
 
+TEST_F(SortIncludesTest, HandlesTrailingCommentsWithAngleBrackets) {
+  // Regression test from the discussion at https://reviews.llvm.org/D121370.
+  EXPECT_EQ("#include \n"
+"\n"
+"#include \"util/bar.h\"\n"
+"#include \"util/foo/foo.h\" // foo\n",
+sort("#include \n"
+ "\n"
+ "#include \"util/bar.h\"\n"
+ "#include \"util/foo/foo.h\" // foo\n",
+ /*FileName=*/"input.cc",
+ /*ExpectedNumRanges=*/0));
+}
+
 TEST_F(SortIncludesTest, LeavesMainHeaderFirst) {
   Style.IncludeIsMainRegex = "([-_](test|unittest))?$";
   EXPECT_EQ("#include \"llvm/a.h\"\n"


Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -458,6 +458,20 @@
  "#include \"b.h\"\n"));
 }
 
+TEST_F(SortIncludesTest, HandlesTrailingCommentsWithAngleBrackets) {
+  // Regression test from the discussion at https://reviews.llvm.org/D121370.
+  EXPECT_EQ("#include \n"
+"\n"
+"#include \"util/bar.h\"\n"
+"#include \"util/foo/foo.h\" // foo\n",
+sort("#include \n"
+ "\n"
+ "#include \"util/bar.h\"\n"
+ "#include \"util/foo/foo.h\" // foo\n",
+ /*FileName=*/"input.cc",
+ /*ExpectedNumRanges=*/0));
+}
+
 TEST_F(SortIncludesTest, LeavesMainHeaderFirst) {
   Style.IncludeIsMainRegex = "([-_](test|unittest))?$";
   EXPECT_EQ("#include \"llvm/a.h\"\n"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D124158: [Clang][Attr] Skip adding noundef attribute to arguments when function has convergent attribute

2022-04-27 Thread krishna chaitanya sankisa via Phabricator via cfe-commits
skc7 updated this revision to Diff 425458.
skc7 added a comment.

skip adding noundef to return type


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124158

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGen/PowerPC/ppc64le-varargs-f128.c
  clang/test/CodeGenCUDA/address-spaces.cu
  clang/test/CodeGenCUDA/builtins-amdgcn.cu
  clang/test/CodeGenCUDA/cuda-builtin-vars.cu
  clang/test/CodeGenCUDA/kernel-args-alignment.cu
  clang/test/CodeGenCUDA/kernel-args.cu
  clang/test/CodeGenCUDA/lambda.cu
  clang/test/CodeGenCUDA/redux-builtins.cu
  clang/test/CodeGenCUDA/surface.cu
  clang/test/CodeGenCUDA/unnamed-types.cu
  clang/test/CodeGenCUDA/usual-deallocators.cu
  clang/test/CodeGenCUDA/vtbl.cu
  clang/test/CodeGenCUDASPIRV/kernel-argument.cu
  clang/test/CodeGenHIP/hipspv-addr-spaces.cpp
  clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
  clang/test/CodeGenOpenCL/address-spaces.cl
  clang/test/CodeGenOpenCL/amdgcn-automatic-variable.cl
  clang/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl
  clang/test/CodeGenOpenCL/amdgpu-call-kernel.cl
  clang/test/CodeGenOpenCL/amdgpu-printf.cl
  clang/test/CodeGenOpenCL/as_type.cl
  clang/test/CodeGenOpenCL/atomic-ops-libcall.cl
  clang/test/CodeGenOpenCL/blocks.cl
  clang/test/CodeGenOpenCL/byval.cl
  clang/test/CodeGenOpenCL/const-str-array-decay.cl
  clang/test/CodeGenOpenCL/constant-addr-space-globals.cl
  clang/test/CodeGenOpenCL/convergent.cl
  clang/test/CodeGenOpenCL/fpmath.cl
  clang/test/CodeGenOpenCL/half.cl
  clang/test/CodeGenOpenCL/kernel-param-alignment.cl
  clang/test/CodeGenOpenCL/kernels-have-spir-cc-by-default.cl
  clang/test/CodeGenOpenCL/no-half.cl
  clang/test/CodeGenOpenCL/overload.cl
  clang/test/CodeGenOpenCL/size_t.cl
  clang/test/CodeGenOpenCL/spir-calling-conv.cl
  clang/test/CodeGenOpenCLCXX/address-space-deduction.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-derived-base.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-new-delete.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-of-this.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-operators.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-references.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-with-class.clcpp
  clang/test/CodeGenOpenCLCXX/template-address-spaces.clcpp
  clang/test/CodeGenSYCL/address-space-conversions.cpp
  clang/test/CodeGenSYCL/address-space-mangling.cpp
  clang/test/CodeGenSYCL/functionptr-addrspace.cpp
  clang/test/CodeGenSYCL/unique_stable_name.cpp
  clang/test/OpenMP/amdgcn-attributes.cpp
  clang/test/OpenMP/amdgcn_target_global_constructor.cpp
  clang/test/OpenMP/assumes_include_nvptx.cpp
  clang/test/OpenMP/declare_target_codegen.cpp
  clang/test/OpenMP/declare_target_codegen_globalization.cpp
  clang/test/OpenMP/declare_target_link_codegen.cpp
  clang/test/OpenMP/declare_variant_mixed_codegen.c
  clang/test/OpenMP/distribute_codegen.cpp
  clang/test/OpenMP/distribute_simd_codegen.cpp
  clang/test/OpenMP/nvptx_allocate_codegen.cpp
  clang/test/OpenMP/nvptx_data_sharing.cpp
  clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
  clang/test/OpenMP/nvptx_declare_variant_name_mangling.cpp
  clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_lambda_capturing.cpp
  clang/test/OpenMP/nvptx_multi_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_nested_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_target_printf_codegen.c
  clang/test/OpenMP/nvptx_target_teams_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  
clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/nvptx_teams_codegen.cpp
  clang/test/OpenMP/nvptx_teams_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_unsupported_type_codegen.cpp
  clang/test/OpenMP/openmp_offload_codegen.cpp
  clang/test/OpenMP/reduction_implicit_map.cpp
  clang/test/OpenMP/target_firstprivate_codegen.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_debug_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_debug_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_parallel_if_codegen.cpp
  clang/test/OpenMP/target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/target_private_codegen.cpp
  clang/test/OpenMP/target_reduction_codegen.cpp
  clang/test/OpenMP/target_teams_codegen.cpp
  clang/test/OpenMP/

[PATCH] D124158: [Clang][Attr] Skip adding noundef attribute to arguments when function has convergent attribute

2022-04-27 Thread krishna chaitanya sankisa via Phabricator via cfe-commits
skc7 updated this revision to Diff 425463.
skc7 added a comment.

update test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124158

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGen/PowerPC/ppc64le-varargs-f128.c
  clang/test/CodeGenCUDA/address-spaces.cu
  clang/test/CodeGenCUDA/builtins-amdgcn.cu
  clang/test/CodeGenCUDA/cuda-builtin-vars.cu
  clang/test/CodeGenCUDA/kernel-args-alignment.cu
  clang/test/CodeGenCUDA/kernel-args.cu
  clang/test/CodeGenCUDA/lambda.cu
  clang/test/CodeGenCUDA/redux-builtins.cu
  clang/test/CodeGenCUDA/surface.cu
  clang/test/CodeGenCUDA/unnamed-types.cu
  clang/test/CodeGenCUDA/usual-deallocators.cu
  clang/test/CodeGenCUDA/vtbl.cu
  clang/test/CodeGenCUDASPIRV/kernel-argument.cu
  clang/test/CodeGenHIP/hipspv-addr-spaces.cpp
  clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
  clang/test/CodeGenOpenCL/address-spaces.cl
  clang/test/CodeGenOpenCL/amdgcn-automatic-variable.cl
  clang/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl
  clang/test/CodeGenOpenCL/amdgpu-call-kernel.cl
  clang/test/CodeGenOpenCL/amdgpu-printf.cl
  clang/test/CodeGenOpenCL/as_type.cl
  clang/test/CodeGenOpenCL/atomic-ops-libcall.cl
  clang/test/CodeGenOpenCL/blocks.cl
  clang/test/CodeGenOpenCL/byval.cl
  clang/test/CodeGenOpenCL/const-str-array-decay.cl
  clang/test/CodeGenOpenCL/constant-addr-space-globals.cl
  clang/test/CodeGenOpenCL/convergent.cl
  clang/test/CodeGenOpenCL/fpmath.cl
  clang/test/CodeGenOpenCL/half.cl
  clang/test/CodeGenOpenCL/kernel-param-alignment.cl
  clang/test/CodeGenOpenCL/kernels-have-spir-cc-by-default.cl
  clang/test/CodeGenOpenCL/no-half.cl
  clang/test/CodeGenOpenCL/overload.cl
  clang/test/CodeGenOpenCL/size_t.cl
  clang/test/CodeGenOpenCL/spir-calling-conv.cl
  clang/test/CodeGenOpenCLCXX/address-space-deduction.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-derived-base.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-new-delete.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-of-this.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-operators.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-references.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-with-class.clcpp
  clang/test/CodeGenOpenCLCXX/template-address-spaces.clcpp
  clang/test/CodeGenSYCL/address-space-conversions.cpp
  clang/test/CodeGenSYCL/address-space-mangling.cpp
  clang/test/CodeGenSYCL/functionptr-addrspace.cpp
  clang/test/CodeGenSYCL/unique_stable_name.cpp
  clang/test/OpenMP/amdgcn-attributes.cpp
  clang/test/OpenMP/amdgcn_target_global_constructor.cpp
  clang/test/OpenMP/assumes_include_nvptx.cpp
  clang/test/OpenMP/declare_target_codegen.cpp
  clang/test/OpenMP/declare_target_codegen_globalization.cpp
  clang/test/OpenMP/declare_target_link_codegen.cpp
  clang/test/OpenMP/declare_variant_mixed_codegen.c
  clang/test/OpenMP/distribute_codegen.cpp
  clang/test/OpenMP/distribute_simd_codegen.cpp
  clang/test/OpenMP/nvptx_allocate_codegen.cpp
  clang/test/OpenMP/nvptx_data_sharing.cpp
  clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
  clang/test/OpenMP/nvptx_declare_variant_name_mangling.cpp
  clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_lambda_capturing.cpp
  clang/test/OpenMP/nvptx_multi_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_nested_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_target_printf_codegen.c
  clang/test/OpenMP/nvptx_target_teams_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  
clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/nvptx_teams_codegen.cpp
  clang/test/OpenMP/nvptx_teams_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_unsupported_type_codegen.cpp
  clang/test/OpenMP/openmp_offload_codegen.cpp
  clang/test/OpenMP/reduction_implicit_map.cpp
  clang/test/OpenMP/target_firstprivate_codegen.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_debug_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_debug_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_parallel_if_codegen.cpp
  clang/test/OpenMP/target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/target_private_codegen.cpp
  clang/test/OpenMP/target_reduction_codegen.cpp
  clang/test/OpenMP/target_teams_codegen.cpp
  clang/test/OpenMP/target_teams_distribute

[PATCH] D124158: [Clang][Attr] Skip adding noundef attribute to arguments when function has convergent attribute

2022-04-27 Thread krishna chaitanya sankisa via Phabricator via cfe-commits
skc7 added inline comments.



Comment at: 
llvm/test/Transforms/SimplifyCFG/tautological-conditional-branch-convergent-noundef.ll:26
+  %i3 = phi double [%i2, %bb2], [undef, %bb1] 
+  %i4 = call noundef double @two(double %i3, i1 %i1) 
+  ret void

skc7 wrote:
> arsenm wrote:
> > Aren't the cases with defined handling of undef lanes still defined for the 
> > result?
> ret double %i4? 
Updated patch to skip adding noundef attribute to return types aswell


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124158

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


[PATCH] D124435: [X86] Always extend the integer parameters in callee

2022-04-27 Thread LiuChen via Phabricator via cfe-commits
LiuChen3 added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:1938
+return IsConservativeExtend ? ABIArgInfo::getConservativeExtend(Ty)
+: ABIArgInfo::getExtend(Ty);
   }

rjmccall wrote:
> LiuChen3 wrote:
> > rjmccall wrote:
> > > This looks wrong.  In non-`ConservativeExtend` mode, we don't get to 
> > > assume extension at all and should use `Direct`, right?
> > As I understand it, `Direct` means do nothing with the parameters. Caller 
> > won't do the extension and callee can't assume the parameter is correct. 
> > This makes new clang behave in the opposite way to currently clang 
> > behavior, which will cause incompatibility issue. e.g:
> > https://godbolt.org/z/d3Peq4nsG
> Oh, I see, you're thinking that `-mno-conservative-extend` means "do what old 
> versions of clang did" rather than "break compatibility with old versions of 
> clang and just follow the x86_64 ABI".  That's definitely different from the 
> documentation I suggested, so something's got to change.
> 
> I think these are the possibilities here:
> 
> 1. Some platforms, like Apple's, are probably going to define Clang's current 
> behavior as the platform ABI.  So those platforms need to continue to use 
> `Extend`.  My previous comment about using `Direct` wasn't paying due 
> attention to this case.
> 
> 2. On other platforms, we need to maintain compatibility by default with both 
> the platform ABI and old Clang behavior.  Those platforms will need to use 
> `ConservativeExtend`.
> 
> 3. Some people may want to opt out of (2) and just be compatible with the 
> platform ABI, which has minor code-size and performance wins.  If we support 
> that with an option, I believe it should cause us to emit `Direct`.  This is 
> what I was thinking `-mno-conservative-extend` would mean.
> 
> 4. Some people may want to force the use of (1) even on platforms where that 
> isn't the platform ABI.  I don't know if this is really something we should 
> support in the long term, but it might be valuable for people staging this 
> change in.  This is what you seem to be thinking `-mno-conservative-extend` 
> would mean.
> 
> I would suggest these spellings for the argument, instead of making it 
> boolean:
> 
> ```
> -mextend-small-integers=none// Force the use of Direct
> -mextend-small-integers=conservative // Force the use of ConservativeExtend
> -mextend-small-integers=assumed // Force the use of Extend
> -mextend-small-integers=default // Use the default rule for the target
> ```
Yes. That's what I mean. I totally misunderstood your meaning before. 
I agree with your method. I will work on that. Just one concern about the 
'default': the default behavior is 'conservative' instead of 'default'. 
Wouldn't that be a little weird? But with my limited English I can't think of a 
better word. 'default' is ok for me. :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124435

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


[PATCH] D124349: [analyzer] Get direct binding for specific punned case

2022-04-27 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers added a comment.

polite ping to @NoQ and/or @martong. @steakhal is ok with this change, are you 
ok if I land this? Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124349

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


[PATCH] D124462: [Analyzer] Fix clang::ento::taint::dumpTaint definition

2022-04-27 Thread Marco Antognini via Phabricator via cfe-commits
mantognini added a comment.

In D124462#3476581 , @steakhal wrote:

> Could you please elaborate whats the motivation for this change?

Right, I could have been more explicit. Sorry about that.

`dumpTaint` is declared inside the `taint` namespace in the header file, hence 
why I'm adding `taint::`.  I believe `LLVM_DUMP_METHOD` should also be applied 
to the function definition too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124462

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


[clang] 31ff400 - Revert "[Driver] Support for compressed debug info on Fuchsia"

2022-04-27 Thread Tom Weaver via cfe-commits

Author: Tom Weaver
Date: 2022-04-27T12:29:04+01:00
New Revision: 31ff40042d0504a37b443a8e8d5edfd90d54e228

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

LOG: Revert "[Driver] Support for compressed debug info on Fuchsia"

This reverts commit 19190cc651ef153c308d23fb56f064223b144488.

Causes test failures on following build bot:

http://lab.llvm.org:8011/#/builders/216

Added: 


Modified: 
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/test/Driver/fuchsia.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp 
b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index 6fe6f7f82feb..9e0b259dfcae 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -127,7 +127,6 @@ void fuchsia::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   D.getLTOMode() == LTOK_Thin);
   }
 
-  addLinkerCompressDebugSectionsOption(ToolChain, Args, CmdArgs);
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,

diff  --git a/clang/test/Driver/fuchsia.c b/clang/test/Driver/fuchsia.c
index 09bbf5d20b54..888f6b1a2c4b 100644
--- a/clang/test/Driver/fuchsia.c
+++ b/clang/test/Driver/fuchsia.c
@@ -253,13 +253,6 @@
 // CHECK-THINLTO: "-plugin-opt=thinlto"
 // CHECK-THINLTO: "-plugin-opt=jobs=8"
 
-// RUN: %clang %s -### --target=x86_64-unknown-fuchsia \
-// RUN: --sysroot=%S/platform \
-// RUN: -Og -gz 2>&1 \
-// RUN: | FileCheck %s -check-prefix=CHECK-GZ
-// CHECK-GZ: {{.*}}clang{{.*}}" "--compress-debug-sections=zlib"
-// CHECK-GZ: {{.*}}ld.lld{{.*}}" "--compress-debug-sections=zlib"
-
 // RUN: %clang %s -### --target=x86_64-unknown-fuchsia \
 // RUN: -gsplit-dwarf -g -c %s 2>&1 \
 // RUN: | FileCheck %s -check-prefix=CHECK-SPLIT-DWARF



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


[PATCH] D114115: [Driver] Support for compressed debug info on Fuchsia

2022-04-27 Thread Tom Weaver via Phabricator via cfe-commits
TWeaver added a comment.

Hello all,

really sorry but I've had to revert this patch due to failures on windows build 
bots:

http://lab.llvm.org:8011/#/builders/216


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114115

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


[PATCH] D124437: [AST] Consider QualifiedTemplateName in TemplateName::getAsUsingDecl().

2022-04-27 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 425481.
hokein added a comment.

Fix the broken test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124437

Files:
  clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
  clang/lib/AST/TemplateName.cpp
  clang/unittests/AST/TemplateNameTest.cpp


Index: clang/unittests/AST/TemplateNameTest.cpp
===
--- clang/unittests/AST/TemplateNameTest.cpp
+++ clang/unittests/AST/TemplateNameTest.cpp
@@ -82,6 +82,7 @@
   const auto *USD = QTN->getUnderlyingTemplate().getAsUsingShadowDecl();
   EXPECT_TRUE(USD);
   EXPECT_EQ(USD->getTargetDecl(), TN.getAsTemplateDecl());
+  EXPECT_EQ(TN.getAsUsingShadowDecl(), USD);
 }
 
 TEST(TemplateName, UsingTemplate) {
Index: clang/lib/AST/TemplateName.cpp
===
--- clang/lib/AST/TemplateName.cpp
+++ clang/lib/AST/TemplateName.cpp
@@ -172,6 +172,8 @@
   if (Decl *D = Storage.dyn_cast())
 if (UsingShadowDecl *USD = dyn_cast(D))
   return USD;
+  if (QualifiedTemplateName *QTN = getAsQualifiedTemplateName())
+return QTN->getUnderlyingTemplate().getAsUsingShadowDecl();
   return nullptr;
 }
 
Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -90,6 +90,14 @@
   template  class T> class X {};
   X x;
 )cpp"},
+  {R"cpp(
+  namespace ns { template class A {}; }
+  namespace absl {using ns::^A;}
+   )cpp",
+   R"cpp(
+  template  class T> class X {};
+  X x;
+   )cpp"},
   {R"cpp(
   namespace ns { template struct ^A { ^A(T); }; }
   using ns::^A;


Index: clang/unittests/AST/TemplateNameTest.cpp
===
--- clang/unittests/AST/TemplateNameTest.cpp
+++ clang/unittests/AST/TemplateNameTest.cpp
@@ -82,6 +82,7 @@
   const auto *USD = QTN->getUnderlyingTemplate().getAsUsingShadowDecl();
   EXPECT_TRUE(USD);
   EXPECT_EQ(USD->getTargetDecl(), TN.getAsTemplateDecl());
+  EXPECT_EQ(TN.getAsUsingShadowDecl(), USD);
 }
 
 TEST(TemplateName, UsingTemplate) {
Index: clang/lib/AST/TemplateName.cpp
===
--- clang/lib/AST/TemplateName.cpp
+++ clang/lib/AST/TemplateName.cpp
@@ -172,6 +172,8 @@
   if (Decl *D = Storage.dyn_cast())
 if (UsingShadowDecl *USD = dyn_cast(D))
   return USD;
+  if (QualifiedTemplateName *QTN = getAsQualifiedTemplateName())
+return QTN->getUnderlyingTemplate().getAsUsingShadowDecl();
   return nullptr;
 }
 
Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -90,6 +90,14 @@
   template  class T> class X {};
   X x;
 )cpp"},
+  {R"cpp(
+  namespace ns { template class A {}; }
+  namespace absl {using ns::^A;}
+   )cpp",
+   R"cpp(
+  template  class T> class X {};
+  X x;
+   )cpp"},
   {R"cpp(
   namespace ns { template struct ^A { ^A(T); }; }
   using ns::^A;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8052f4d - [AST] Consider QualifiedTemplateName in TemplateName::getAsUsingDecl().

2022-04-27 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2022-04-27T14:16:19+02:00
New Revision: 8052f4d22a12f1baa949c7a04f029e231faae90a

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

LOG: [AST] Consider QualifiedTemplateName in TemplateName::getAsUsingDecl().

If the underlying template name of a qualified template name is a using
decl, TemplateName::getAsUsingDecl() will return it.

This will make the UsingTemplateName consumer life easier.

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

Added: 


Modified: 
clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
clang/lib/AST/TemplateName.cpp
clang/unittests/AST/TemplateNameTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp 
b/clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
index 8df292cd28a9..77d4e289cf26 100644
--- a/clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ b/clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -90,6 +90,14 @@ TEST(IncludeCleaner, ReferencedLocations) {
   template  class T> class X {};
   X x;
 )cpp"},
+  {R"cpp(
+  namespace ns { template class A {}; }
+  namespace absl {using ns::^A;}
+   )cpp",
+   R"cpp(
+  template  class T> class X {};
+  X x;
+   )cpp"},
   {R"cpp(
   namespace ns { template struct ^A { ^A(T); }; }
   using ns::^A;

diff  --git a/clang/lib/AST/TemplateName.cpp b/clang/lib/AST/TemplateName.cpp
index f0f64cd5a516..11dc3d2e1985 100644
--- a/clang/lib/AST/TemplateName.cpp
+++ b/clang/lib/AST/TemplateName.cpp
@@ -172,6 +172,8 @@ UsingShadowDecl *TemplateName::getAsUsingShadowDecl() const 
{
   if (Decl *D = Storage.dyn_cast())
 if (UsingShadowDecl *USD = dyn_cast(D))
   return USD;
+  if (QualifiedTemplateName *QTN = getAsQualifiedTemplateName())
+return QTN->getUnderlyingTemplate().getAsUsingShadowDecl();
   return nullptr;
 }
 

diff  --git a/clang/unittests/AST/TemplateNameTest.cpp 
b/clang/unittests/AST/TemplateNameTest.cpp
index 5844af6cc957..fb9061053ea5 100644
--- a/clang/unittests/AST/TemplateNameTest.cpp
+++ b/clang/unittests/AST/TemplateNameTest.cpp
@@ -82,6 +82,7 @@ TEST(TemplateName, QualifiedUsingTemplate) {
   const auto *USD = QTN->getUnderlyingTemplate().getAsUsingShadowDecl();
   EXPECT_TRUE(USD);
   EXPECT_EQ(USD->getTargetDecl(), TN.getAsTemplateDecl());
+  EXPECT_EQ(TN.getAsUsingShadowDecl(), USD);
 }
 
 TEST(TemplateName, UsingTemplate) {



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


[PATCH] D124437: [AST] Consider QualifiedTemplateName in TemplateName::getAsUsingDecl().

2022-04-27 Thread Haojian Wu 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 rG8052f4d22a12: [AST] Consider QualifiedTemplateName in 
TemplateName::getAsUsingDecl(). (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124437

Files:
  clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
  clang/lib/AST/TemplateName.cpp
  clang/unittests/AST/TemplateNameTest.cpp


Index: clang/unittests/AST/TemplateNameTest.cpp
===
--- clang/unittests/AST/TemplateNameTest.cpp
+++ clang/unittests/AST/TemplateNameTest.cpp
@@ -82,6 +82,7 @@
   const auto *USD = QTN->getUnderlyingTemplate().getAsUsingShadowDecl();
   EXPECT_TRUE(USD);
   EXPECT_EQ(USD->getTargetDecl(), TN.getAsTemplateDecl());
+  EXPECT_EQ(TN.getAsUsingShadowDecl(), USD);
 }
 
 TEST(TemplateName, UsingTemplate) {
Index: clang/lib/AST/TemplateName.cpp
===
--- clang/lib/AST/TemplateName.cpp
+++ clang/lib/AST/TemplateName.cpp
@@ -172,6 +172,8 @@
   if (Decl *D = Storage.dyn_cast())
 if (UsingShadowDecl *USD = dyn_cast(D))
   return USD;
+  if (QualifiedTemplateName *QTN = getAsQualifiedTemplateName())
+return QTN->getUnderlyingTemplate().getAsUsingShadowDecl();
   return nullptr;
 }
 
Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -90,6 +90,14 @@
   template  class T> class X {};
   X x;
 )cpp"},
+  {R"cpp(
+  namespace ns { template class A {}; }
+  namespace absl {using ns::^A;}
+   )cpp",
+   R"cpp(
+  template  class T> class X {};
+  X x;
+   )cpp"},
   {R"cpp(
   namespace ns { template struct ^A { ^A(T); }; }
   using ns::^A;


Index: clang/unittests/AST/TemplateNameTest.cpp
===
--- clang/unittests/AST/TemplateNameTest.cpp
+++ clang/unittests/AST/TemplateNameTest.cpp
@@ -82,6 +82,7 @@
   const auto *USD = QTN->getUnderlyingTemplate().getAsUsingShadowDecl();
   EXPECT_TRUE(USD);
   EXPECT_EQ(USD->getTargetDecl(), TN.getAsTemplateDecl());
+  EXPECT_EQ(TN.getAsUsingShadowDecl(), USD);
 }
 
 TEST(TemplateName, UsingTemplate) {
Index: clang/lib/AST/TemplateName.cpp
===
--- clang/lib/AST/TemplateName.cpp
+++ clang/lib/AST/TemplateName.cpp
@@ -172,6 +172,8 @@
   if (Decl *D = Storage.dyn_cast())
 if (UsingShadowDecl *USD = dyn_cast(D))
   return USD;
+  if (QualifiedTemplateName *QTN = getAsQualifiedTemplateName())
+return QTN->getUnderlyingTemplate().getAsUsingShadowDecl();
   return nullptr;
 }
 
Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -90,6 +90,14 @@
   template  class T> class X {};
   X x;
 )cpp"},
+  {R"cpp(
+  namespace ns { template class A {}; }
+  namespace absl {using ns::^A;}
+   )cpp",
+   R"cpp(
+  template  class T> class X {};
+  X x;
+   )cpp"},
   {R"cpp(
   namespace ns { template struct ^A { ^A(T); }; }
   using ns::^A;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D124373: [clang] add parameter pack/pack expansion matchers

2022-04-27 Thread Tobias Ribizel via Phabricator via cfe-commits
upsj updated this revision to Diff 425487.
upsj added a comment.

formatting


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124373

Files:
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/lib/ASTMatchers/Dynamic/Registry.cpp


Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -446,6 +446,7 @@
   REGISTER_MATCHER(isNoThrow);
   REGISTER_MATCHER(isNoneKind);
   REGISTER_MATCHER(isOverride);
+  REGISTER_MATCHER(isParameterPack);
   REGISTER_MATCHER(isPrivate);
   REGISTER_MATCHER(isProtected);
   REGISTER_MATCHER(isPublic);
@@ -513,6 +514,7 @@
   REGISTER_MATCHER(onImplicitObjectArgument);
   REGISTER_MATCHER(opaqueValueExpr);
   REGISTER_MATCHER(optionally);
+  REGISTER_MATCHER(packExpansionExpr);
   REGISTER_MATCHER(parameterCountIs);
   REGISTER_MATCHER(parenExpr);
   REGISTER_MATCHER(parenListExpr);
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -981,6 +981,8 @@
 predefinedExpr;
 const internal::VariadicDynCastAllOfMatcher
 designatedInitExpr;
+const internal::VariadicDynCastAllOfMatcher
+packExpansionExpr;
 const internal::VariadicOperatorMatcherFunc<
 2, std::numeric_limits::max()>
 eachOf = {internal::DynTypedMatcher::VO_EachOf};
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -731,6 +731,27 @@
   InnerMatcher.matches(*Initializer, Finder, Builder));
 }
 
+/// Determines whether a declaration is a parameter pack.
+///
+/// Given
+/// \code
+/// template  class C,
+///   template  class... Ds>
+/// void foo(A param, Bs... params);
+/// \endcode
+/// templateTypeParmDecl(isParameterPack())
+///   matches 'typename... Bs', but not 'typename A'.
+/// nonTypeTemplateParmDecl(isParameterPack())
+///   matches 'int... js', but not 'int i'.
+/// templateTemplateParmDecl(isParameterPack())
+///   matches 'template  class... Ds', but not
+///   'template  class C'
+/// varDecl(isParameterPack())
+///   matches 'Bs... params', but not 'A param'.
+AST_MATCHER(Decl, isParameterPack) { return Node.isParameterPack(); }
+
 /// Determines whether the function is "main", which is the entry point
 /// into an executable program.
 AST_MATCHER(FunctionDecl, isMain) {
@@ -2699,6 +2720,21 @@
   return Node.size() == N;
 }
 
+/// Matches pack expansion expressions.
+///
+/// Given
+/// \code
+/// void bar(int, int);
+/// template 
+/// void foo(T arg, Args args...) {
+/// bar(arg + 1, (args + 1)...);
+/// }
+/// \endcode
+/// packExpansionExpr()
+///   matches '(args + 1)...', but not 'arg + 1'.
+extern const internal::VariadicDynCastAllOfMatcher
+packExpansionExpr;
+
 /// Matches \c QualTypes in the clang AST.
 extern const internal::VariadicAllOfMatcher qualType;
 


Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -446,6 +446,7 @@
   REGISTER_MATCHER(isNoThrow);
   REGISTER_MATCHER(isNoneKind);
   REGISTER_MATCHER(isOverride);
+  REGISTER_MATCHER(isParameterPack);
   REGISTER_MATCHER(isPrivate);
   REGISTER_MATCHER(isProtected);
   REGISTER_MATCHER(isPublic);
@@ -513,6 +514,7 @@
   REGISTER_MATCHER(onImplicitObjectArgument);
   REGISTER_MATCHER(opaqueValueExpr);
   REGISTER_MATCHER(optionally);
+  REGISTER_MATCHER(packExpansionExpr);
   REGISTER_MATCHER(parameterCountIs);
   REGISTER_MATCHER(parenExpr);
   REGISTER_MATCHER(parenListExpr);
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -981,6 +981,8 @@
 predefinedExpr;
 const internal::VariadicDynCastAllOfMatcher
 designatedInitExpr;
+const internal::VariadicDynCastAllOfMatcher
+packExpansionExpr;
 const internal::VariadicOperatorMatcherFunc<
 2, std::numeric_limits::max()>
 eachOf = {internal::DynTypedMatcher::VO_EachOf};
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -731,6 +731,27 @@
   InnerMatcher.matches(*Initializer, Finder, Builder));
 }
 
+/// Determines whether a declaration is a parameter pack.
+///
+/// Given
+/// \code
+/// template 

[PATCH] D124164: [include-cleaner] Include-cleaner library structure, and simplistic AST walking.

2022-04-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks, as discussed offline. this mostly LG. there are concerns about more 
code re-use, especially around handling pragmas but we should probably address 
them as we go rather than now.




Comment at: clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp:42
+  for (Decl *D : AST.context().getTranslationUnitDecl()->decls()) {
+if (ReferencingFile == 
SM.getDecomposedExpansionLoc(D->getLocation()).first)
+  walkAST(*D, [&](SourceLocation Loc, NamedDecl &ND) {

nit: early exit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124164

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


[PATCH] D124462: [Analyzer] Fix clang::ento::taint::dumpTaint definition

2022-04-27 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

Although gcc (and probably clang too) allows specifying 
`__attribute__((noinline))` at any declaration (by merging //compatible// 
attributes), I would prefer not to repeat ourselves.
The attribute must be present at the header to force all usages not to inline 
it, hence I would rather drop such attributes from the definition files.

Aside from that, looks good. Please update the summary of this patch 
accordingly.




Comment at: clang/lib/StaticAnalyzer/Checkers/Taint.cpp:40
 
-void dumpTaint(ProgramStateRef State) { printTaint(State, llvm::errs()); }
+LLVM_DUMP_METHOD void taint::dumpTaint(ProgramStateRef State) {
+  printTaint(State, llvm::errs());




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124462

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


[PATCH] D123605: [WIP][Sema][SVE] Move/simplify Sema testing for SVE ACLE builtins

2022-04-27 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen accepted this revision.
sdesmalen added a comment.
This revision is now accepted and ready to land.

Thanks for this @RosieSumpter. If you remove the 'WIP' and s/SVE/SVE2/ from the 
title and description, I'm happy to accept. The negative tests for the SVE(1) 
intrinsics can be added as a separate patch.




Comment at: 
clang/test/Sema/aarch64-sve2-intrinsics/acle_sve2_imm_lane.cpp:151-152
+{
+  // expected-error-re@+1 {{argument value {{[0-9]+}} is outside the valid 
range [0, 1]}}
+  SVE_ACLE_FUNC(svcdot_lane,_s64,,)(svundef_s64(), svundef_s16(), 
svundef_s16(), -1, 0);
+  // expected-error-re@+1 {{argument value {{[0-9]+}} is outside the valid 
range [0, 1]}}

nit: there is also a svcdot_lane,_s32


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

https://reviews.llvm.org/D123605

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


[PATCH] D117829: [Clang] Add integer add/mul reduction builtins

2022-04-27 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117829

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


[PATCH] D124525: [OpenMP][ClangLinkerWrapper] Extending linker wrapper to embed metadata for multi-arch fat binaries

2022-04-27 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam created this revision.
saiislam added reviewers: jdoerfert, JonChesterfield, jhuber6, yaxunl.
Herald added a subscriber: guansong.
Herald added a project: All.
saiislam requested review of this revision.
Herald added subscribers: openmp-commits, cfe-commits, sstefan1.
Herald added projects: clang, OpenMP.

This patch adds "__tgt_image_info" field for each of the images
embedded in a multi-arch image. Required changes in libomptarget
are also shown.

The information in "__tgt_image_info" struct is provided in the 
clang-linker-wrapper
as a call to __tgt_register_image_info for each image in the library
of images also created by the clang-linker-wrapper.
__tgt_register_image_info is called for each image BEFORE the single
call to __tgt_register_lib so that image information is available
before they are loaded. clang-linker-wrapper gets this image information
from command line arguments provided by the clang driver when it creates
the call to the __clang-linker-wrapper command.
This architecture allows the binary image (pointed to by ImageStart and
ImageEnd in __tgt_device_image) to remain architecture indenendent.
That is, the architecture independent part of the libomptarget runtime
does not need to peer inside the image to determine if it is loadable
even though in most cases the image is an elf object.
There is one __tgt_image_info for each __tgt_device_image. For backward
compabibility, no changes are allowed to either __tgt_device_image or
__tgt_bin_desc. The absense of __tgt_image_info is the indication that
the runtime is being used on a binary created by an old version of
the compiler.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124525

Files:
  clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
  clang/tools/clang-linker-wrapper/OffloadWrapper.cpp
  clang/tools/clang-linker-wrapper/OffloadWrapper.h
  openmp/libomptarget/include/omptarget.h
  openmp/libomptarget/src/exports
  openmp/libomptarget/src/interface.cpp
  openmp/libomptarget/src/rtl.cpp

Index: openmp/libomptarget/src/rtl.cpp
===
--- openmp/libomptarget/src/rtl.cpp
+++ openmp/libomptarget/src/rtl.cpp
@@ -13,6 +13,7 @@
 #include "rtl.h"
 #include "device.h"
 #include "private.h"
+#include "llvm/OffloadArch/OffloadArch.h"
 
 #include 
 #include 
@@ -20,6 +21,8 @@
 #include 
 #include 
 #include 
+// It's strange we do not have llvm tools for openmp runtime, so we use stat
+#include 
 
 // List of all plugins that can support offloading.
 static const char *RTLNames[] = {
@@ -351,18 +354,109 @@
 initRTLonce(R);
 }
 
+/// Query runtime capabilities of this system by calling offload-arch -c
+/// offload_arch_output_buffer is persistant storage returned by this
+/// __tgt_get_active_offload_env.
+static void
+__tgt_get_active_offload_env(__tgt_active_offload_env *active_env,
+ char *offload_arch_output_buffer,
+ size_t offload_arch_output_buffer_size) {
+
+  // If OFFLOAD_ARCH_OVERRIDE env varible is present then use its value instead of
+  // querying it using LLVMOffloadArch library.
+  if (char *OffloadArchEnvVar = getenv("OFFLOAD_ARCH_OVERRIDE")) {
+if (OffloadArchEnvVar) {
+  active_env->capabilities = OffloadArchEnvVar;
+  return;
+}
+  }
+  // Qget runtime capabilities of this system with libLLVMOffloadArch.a
+  if (int rc = getRuntimeCapabilities(offload_arch_output_buffer,
+  offload_arch_output_buffer_size))
+return;
+  active_env->capabilities = offload_arch_output_buffer;
+  return;
+}
+
+std::vector _splitstrings(char *input, const char *sep) {
+  std::vector split_strings;
+  std::string s(input);
+  std::string delimiter(sep);
+  size_t pos = 0;
+  while ((pos = s.find(delimiter)) != std::string::npos) {
+if (pos != 0)
+  split_strings.push_back(s.substr(0, pos));
+s.erase(0, pos + delimiter.length());
+  }
+  if (s.length() > 1)
+split_strings.push_back(s.substr(0, s.length()));
+  return split_strings;
+}
+
+static bool _ImageIsCompatibleWithEnv(__tgt_image_info *img_info,
+  __tgt_active_offload_env *active_env) {
+  // get_image_info will return null if no image information was registered.
+  // If no image information, assume application built with old compiler and
+  // check each image.
+  if (!img_info)
+return true;
+
+  if (!active_env->capabilities)
+return false;
+
+  // Each runtime requirement for the compiled image is stored in
+  // the img_info->offload_arch (TargetID) string.
+  // Each runtime capability obtained from "offload-arch -c" is stored in
+  // actvie_env->capabilities (TargetID) string.
+  // If every requirement has a matching capability, then the image
+  // is compatible with active environment
+
+  std::vector reqs = _splitstrings(img_info->offload_arch, ":");
+  std::vector caps = _splitstrings(active_env->capabilities, ":");

[clang] 0a4a43c - [OpenMP] Properly handle the `-f/-fno` veraints for the new driver

2022-04-27 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2022-04-27T09:58:55-04:00
New Revision: 0a4a43cf138b929b5280dbe4fcf5f219ca18ae43

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

LOG: [OpenMP] Properly handle the `-f/-fno` veraints for the new driver

Summary:
We provide the `-f(no-)openmp-new-driver` option to allow users to use
the old or new driver. Previously this wasn't handled in the expected
way and only `-fno-openmp-new-driver` was checked. This patch fixes that
by using the `hasFlag` method as is standard.

Added: 


Modified: 
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/Clang.cpp

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 2bb6680cf596..487e2e1e0b3f 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -3984,7 +3984,8 @@ void Driver::BuildActions(Compilation &C, DerivedArgList 
&Args,
 
   bool UseNewOffloadingDriver =
   C.isOffloadingHostKind(Action::OFK_OpenMP) &&
-  !Args.hasArg(options::OPT_fno_openmp_new_driver);
+  Args.hasFlag(options::OPT_fopenmp_new_driver,
+   options::OPT_fno_openmp_new_driver, true);
 
   for (auto &I : Inputs) {
 types::ID InputType = I.first;

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 6e4eadd3ab0e..01380f9e1985 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4675,7 +4675,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
 if (IsUsingLTO) {
   // Only AMDGPU supports device-side LTO.
   if (IsDeviceOffloadAction &&
-  Args.hasArg(options::OPT_fno_openmp_new_driver) &&
+  !Args.hasFlag(options::OPT_fopenmp_new_driver,
+options::OPT_fno_openmp_new_driver, true) &&
   !Triple.isAMDGPU()) {
 D.Diag(diag::err_drv_unsupported_opt_for_target)
 << Args.getLastArg(options::OPT_foffload_lto,



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


[PATCH] D124158: [Clang][Attr] Skip adding noundef attribute to arguments when function has convergent attribute

2022-04-27 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

> For Ex: SimplifyCFG pass removes the branch leading to a BB which has an 
> incoming value that will always trigger undefined behavior. This basically 
> modifies the CFG and combines the basic blocks. This works for CPU execution. 
> But on a GPU, there are intrinsics like "__shfl_sync(unsigned mask, T var, 
> int srcLane, int width=warpSize)", Where the exchange of variable occurs 
> simultaneously for all active threads within the warp. So, here in the 
> cuda/hip kernel, variable var in shuffl_sync may not be initialised, and LLVM 
> IR treats it as undef. Currently all the arguments are tagged with noundef 
> attribute and the above mentioned optimization by SimplifyCFG gets applied 
> and the kernel execution becomes ambiguous. So, the proposed change is to 
> skip adding noundef attribute to arguments when a function has been tagged 
> with convergent attribute.

Can we please have an example for this. I don't know what would be broken w/ 
noundef + convergent and I somewhat doubt noundef is the problem.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124158

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


[PATCH] D124060: [PowerPC] Enable CR bits support for Power8 and above.

2022-04-27 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added inline comments.



Comment at: clang/docs/ClangCommandLineReference.rst:3566
 
+Control the CR-bit tracking feature on PowerPC. ``-mcrbits`` (the enablement 
of CR-bit tracking support) is the default for POWER8 and above.
+

```
... is the default for POWER8 and above as well as for all other CPUs when 
optimization is applied (-O2 and above).
```
But please check if it is also applied at -O1 and correct that statement 
accordingly.



Comment at: llvm/test/CodeGen/PowerPC/fast-isel-fcmp-nan.ll:5
 ; CHECK-LABEL: TestULT:
-; CHECK: xscmpudp
+; CHECK: fcmpu
 ; CHECK: blr

Why do we not emit the VSX instructions here any longer? How are crbits related?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124060

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


[PATCH] D124525: [OpenMP][ClangLinkerWrapper] Extending linker wrapper to embed metadata for multi-arch fat binaries

2022-04-27 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: openmp/libomptarget/include/omptarget.h:163
+  int32_t image_number;  // Image number in image library starting from 0
+  int32_t number_images; // Number of images, used for initial allocation
+  char *offload_arch;// e.g. sm_30, sm_70, gfx906, includes features

I doubt we want/need to number and count them. This seems fragile and 
unhelpful. "initial allocation" is not expensive, image numbers should be 
implicit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124525

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


[PATCH] D119544: Deferred Concept Instantiation Implementation

2022-04-27 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 425516.
erichkeane added a comment.

Correct the caching behavior to make the FriendFunc example work.

I THINK this is ready to review!  I'd like to do the lambda examples in a 
followup patch as I believe that is a pre-existing issue, and this patch has 
gotten large enough.


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

https://reviews.llvm.org/D119544

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/Template.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/DeclBase.cpp
  clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/CXX/temp/temp.constr/temp.constr.constr/non-function-templates.cpp
  clang/test/SemaTemplate/concepts.cpp
  clang/test/SemaTemplate/deferred-concept-inst.cpp
  clang/test/SemaTemplate/instantiate-requires-clause.cpp
  clang/test/SemaTemplate/trailing-return-short-circuit.cpp

Index: clang/test/SemaTemplate/trailing-return-short-circuit.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/trailing-return-short-circuit.cpp
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -std=c++20 -verify %s
+
+template 
+  requires(sizeof(T) > 2) || T::value // #FOO_REQ
+void Foo(T){};// #FOO
+
+template 
+void TrailingReturn(T)   // #TRAILING
+  requires(sizeof(T) > 2) || // #TRAILING_REQ
+  T::value   // #TRAILING_REQ_VAL
+{};
+template 
+struct HasValue {
+  static constexpr bool value = B;
+};
+static_assert(sizeof(HasValue) <= 2);
+
+template 
+struct HasValueLarge {
+  static constexpr bool value = B;
+  int I;
+};
+static_assert(sizeof(HasValueLarge) > 2);
+
+void usage() {
+  // Passes the 1st check, short-circuit so the 2nd ::value is not evaluated.
+  Foo(1.0);
+  TrailingReturn(1.0);
+
+  // Fails the 1st check, but has a ::value, so the check happens correctly.
+  Foo(HasValue{});
+  TrailingReturn(HasValue{});
+
+  // Passes the 1st check, but would have passed the 2nd one.
+  Foo(HasValueLarge{});
+  TrailingReturn(HasValueLarge{});
+
+  // Fails the 1st check, fails 2nd because there is no ::value.
+  Foo(true);
+  // expected-error@-1{{no matching function for call to 'Foo'}}
+  // expected-note@#FOO{{candidate template ignored: constraints not satisfied [with T = bool]}}
+  // expected-note@#FOO_REQ{{because 'sizeof(_Bool) > 2' (1 > 2) evaluated to false}}
+  // expected-note@#FOO_REQ{{because substituted constraint expression is ill-formed: type 'bool' cannot be used prior to '::' because it has no members}}
+
+  TrailingReturn(true);
+  // expected-error@-1{{no matching function for call to 'TrailingReturn'}}
+  // expected-note@#TRAILING{{candidate template ignored: constraints not satisfied [with T = bool]}}
+  // expected-note@#TRAILING_REQ{{because 'sizeof(_Bool) > 2' (1 > 2) evaluated to false}}
+  // expected-note@#TRAILING_REQ_VAL{{because substituted constraint expression is ill-formed: type 'bool' cannot be used prior to '::' because it has no members}}
+
+  // Fails the 1st check, fails 2nd because ::value is false.
+  Foo(HasValue{});
+  // expected-error@-1 {{no matching function for call to 'Foo'}}
+  // expected-note@#FOO{{candidate template ignored: constraints not satisfied [with T = HasValue]}}
+  // expected-note@#FOO_REQ{{because 'sizeof(HasValue) > 2' (1 > 2) evaluated to false}}
+  // expected-note@#FOO_REQ{{and 'HasValue::value' evaluated to false}}
+  TrailingReturn(HasValue{});
+  // expected-error@-1 {{no matching function for call to 'TrailingReturn'}}
+  // expected-note@#TRAILING{{candidate template ignored: constraints not satisfied [with T = HasValue]}}
+  // expected-note@#TRAILING_REQ{{because 'sizeof(HasValue) > 2' (1 > 2) evaluated to false}}
+  // expected-note@#TRAILING_REQ_VAL{{and 'HasValue::value' evaluated to false}}
+}
Index: clang/test/SemaTemplate/instantiate-requires-clause.cpp
===
--- clang/test/SemaTemplate/instantiate-requires-clause.cpp
+++ clang/test/SemaTemplate/instantiate-requires-clause.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++2a -x c++ %s -verify
+// RUN: %clang_cc1 -std=c++2a -x c++ %s -Wno-unused-value -verify
 
 template  requires ((sizeof(Args) == 1), ...)
 // expected-note@-1 {{because '(sizeof(int) == 1) , (sizeof(char) == 1) , (sizeof(int) == 1)' evaluated to false}}
@@ -40,6 +40,20 @@
 
 static_assert(S::f(1));
 
+// Similar to the 'S' test, but tries to use 'U' in the requires clause.
+template 
+struct S1 {
+  // expected-note@+3 

[PATCH] D124486: [clangd] ExtractVariable support for C and Objective-C

2022-04-27 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp:165
+std::string
+ExtractionContext::computeExprType(const clang::Expr *E) const {
+  if (Ctx.getLangOpts().CPlusPlus)

(does this need to be a method?)



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp:166
+ExtractionContext::computeExprType(const clang::Expr *E) const {
+  if (Ctx.getLangOpts().CPlusPlus)
+return "auto";

CPlusPlus11



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp:169
+  QualType ExprType = E->getType();
+  if (E->hasPlaceholderType(BuiltinType::PseudoObject)) {
+if (const auto *PR = dyn_cast(E)) {

if it has pseudo-object type and *isn't* handled by the ObjCPropertyRef case, 
we should disallow extraction right?



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp:170
+  if (E->hasPlaceholderType(BuiltinType::PseudoObject)) {
+if (const auto *PR = dyn_cast(E)) {
+  if (PR->isMessagingSetter()) {

E->getObjCProperty()?



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp:176
+// it returns nil (setter method must have a void return type).
+return "";
+  } else if (PR->isMessagingGetter()) {

please don't use "" as a sentinel value, it will lead to bugs

Why are we checking this here rather than in eligibleForExtraction?



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp:187
+  AttributedType::stripOuterNullability(ExprType);
+  return ExprType.getAsString();
+}

prefer printType from AST.h, which will get qualifiers, anonymous namespaces 
etc right



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp:208
+  std::string ExtractedVarDecl =
+  Type + " " + VarName.str() + " = " + ExtractionCode.str() + "; ";
   return tooling::Replacement(SM, InsertionLoc, 0, ExtractedVarDecl);

Type + Varname isn't correct for types in general, particularly those that use 
declarator syntax.
printType with varname as the placeholder should do what you want.

Can you add a testcase where the variable has function pointer type?



Comment at: 
clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp:324
+  // We don't preserve types through typedefs.
+  // FIXME: Ideally we could preserve the non-canonical type.
+  {R"cpp(typedef long NSInteger;

I'd drop the FIXME here: the fully-sugared type type of NSInteger * long is 
long, not NSInteger.

(Unless you're suggesting changing this in clang)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124486

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


[PATCH] D124525: [OpenMP][ClangLinkerWrapper] Extending linker wrapper to embed metadata for multi-arch fat binaries

2022-04-27 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added inline comments.



Comment at: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp:1161
 
-LinkedImages.push_back(*ImageOrErr);
+LinkedImages.emplace_back(TheArch, *ImageOrErr);
   }

I'm doing something similar in D123810, I just used the existing `DeviceFile` 
because I needed the `Arch` and `Kind` fields to dispatch the appropriate 
wrapping job for CUDA / HIP.



Comment at: clang/tools/clang-linker-wrapper/OffloadWrapper.cpp:246
   IRBuilder<> Builder(BasicBlock::Create(C, "entry", Func));
+  // Create calls to __tgt_register_image_info for each image
+  auto *NullPtr = llvm::ConstantPointerNull::get(Builder.getInt8PtrTy());

I'm wondering if it would be better to create a new `__tgt_bin_desc` and call a 
new `__tgt_register_lib` with it here so we don't need multiple calls here. 
Inside that new runtime function we could just widen or shrink the existing 
structs as needed. That way each device image would have this metadata 
associated with it and the target plugin can handle it as-needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124525

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


[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-04-27 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added inline comments.



Comment at: clang-tools-extra/unittests/clang-tidy/ModernizeModuleTest.cpp:1
+#include "ClangTidyTest.h"
+#include "modernize/IntegralLiteralExpressionMatcher.h"

Needs a file header


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

https://reviews.llvm.org/D124500

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


[PATCH] D124493: [symbolizer] Parse DW_TAG_variable DIs to show line info for globals

2022-04-27 Thread Filipe Cabecinhas via Phabricator via cfe-commits
filcab added a comment.

Hi @hctim, thanks for the patch.
I have one question, though. Do you really need to remove the information you 
removed?
Some people might be testing ASan binaries without access to debug info 
(because it's been stripped or it's not been loaded and is not available for 
the sanitizers to get symbols from, etc), and having the full global 
information would be useful for those reports.

Can this be done by having a flag to make clang not emit the source information 
+ the sanitizer patch to get the line and column?
That way we could keep the current behaviour of emitting more info, and you'd 
still get your savings + use of debuginfo.

Thank you,
Filipe


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124493

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


[PATCH] D123534: [dwarf] Emit a DIGlobalVariable for constant strings.

2022-04-27 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D123534#3475790 , @hctim wrote:

>> summary of DWARF:
>> & how many of these descriptions get added to the debug info?
>
> afaict, there is now:
>  1x .debug_addr entry for each string
>  1x. debug_info DW_TAG_variable for each string
>  1x. DW_TAG_array_type + DW_TAG_subrange_type for each unique sizeof(string)

& you ran an experiment where the type was omitted, but it didn't save much 
space?

> i tried to measure if there's other bits laying around that could be 
> optimised. i thought briefly about diffing the llvm-dwarfdump for the 
> before/after for clang, but as the dumpfiles reached 20gb, rethought that 
> decision. the dwarfdump for the clang/test/CodeGen/debug-info-variables.c dwo 
> is below.

Yeah, diffing DWARF isn't super practical with all the offsets, etc.

>> Numbers for Split DWARF may be helpful too - given this'll add an extra 
>> address/relocation for every string literal, it might make object size 
>> (specifically unlinked object size where relocations are 
>> expensive/plentiful) significantly larger in problematic ways.
>
> sorry, i don't understand why split-dwarf means this requires an additional 
> relocation (i'm not really sure what split-dwarf is outside of just putting 
> the dwarf in a separate file, but don't see why that would change 
> relocations).

Sorry, to expound more: Split DWARF is intended to reduce the size of object 
files processed by the linker, and the resulting linked binary. Doing things 
like adding more pure type information which only goes in the .dwo file has no 
impact on .o/executable size - but this change adds another relocation for 
every string literal in the binary, which does grow the debug info that remains 
in the .o file (the .debug_addr table in particular) and relocations in 
particular are quite expensive (since they aren't compressed by -gz and take 3x 
the bytes of the actual address entry)

We should probably do some measurements inside google on these things, since 
the object size metrics are quite important to linkability in bazel/blaze 
(go/binary-size-analysis internally has some info - happy to help with 
measurements, etc).

> i made a quick dwarfdump diff on clang/test/CodeGen/debug-info-variables.c 
> (with split-dwarf):
>
> sections old:
>
>   [Nr] Name  TypeAddress  OffSize   ES 
> Flg Lk Inf Al
>   [ 2] .debug_str.dwoPROGBITS 40 eb 01 
> MSE  0   0  1
>   [ 3] .debug_str_offsets.dwo PROGBITS    00012b 2c 00   
> E  0   0  1
>   [ 4] .debug_info.dwo   PROGBITS 000157 77 00   
> E  0   0  1
>   [ 5] .debug_abbrev.dwo PROGBITS 0001ce 91 00   
> E  0   0  1
>
> sections new:
>
>   [Nr] Name  TypeAddress  OffSize   ES 
> Flg Lk Inf Al
>   [ 3] .debug_str.dwoPROGBITS 78 ff 01 
> MSE  0   0  1
>   [ 2] .debug_str_offsets.dwo PROGBITS    40 38 00   
> E  0   0  1
>   [ 4] .debug_info.dwo   PROGBITS 000177 92 00   
> E  0   0  1
>   [ 5] .debug_abbrev.dwo PROGBITS 000209 aa 00   
> E  0   0  1
>
> so `.debug_string += 0x14`, `.debug_str_offsets += 0xc`, `.debug_info += 
> 0x1b` and `.debug_abbrev += 0x19`.

This data, but for Clang, might be informative - for this small sample it's 
hard to separate the constant overheads from the linear ones. (eg: the 
debug_str growth I'd expect to be constant (just the name of the char type and 
the name of the size type), but the debug_info growth is presumably not 
constant)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123534

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


[PATCH] D123436: [Clang] Use std::move in GlobalModuleIndex::readIndex. NFC

2022-04-27 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D123436#3475858 , @junaire wrote:

> In D123436#3475002 , @dblaikie 
> wrote:
>
>> In D123436#3462567 , @dblaikie 
>> wrote:
>>
>>> Perhaps GlobalModuleIndex should create the cursor itself - it's being 
>>> handed the buffer anyway?
>>
>> Ping on this ^ - would this be a better direction that addresses the 
>> concerns?
>
> Sorry about missing this! :(
> However, I'm not sure that I understand your idea. Do you mean we can simply 
> pass the buffer to the `GlobalModuleIndex` then we can construct the cursor 
> in the constructor itself?

That's what I meant, yeah - since the buffer is actually already being passed.

> IMHO, we can't. that's because we need to use the cursor to sniff for the 
> signature of the buffer, and we will return an error if it is failed. Please 
> let me know if I understand you wrong :)

Ah, right ,I missed that usage before the call. Makes sense then - thanks for 
helping me understand!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123436

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


[PATCH] D124532: [AST] Improve traversal of concept requirements

2022-04-27 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman.
Herald added a project: All.
ilya-biryukov requested review of this revision.
Herald added projects: clang, clang-tools-extra.

- Do not visit implicit AST node the relevant traversal mode.
- Add traversal extension points for concept requirements.
- Renamed `TraverseConceptReference` to mark as helper to share the code. 
Having an extension point there seems confusing given that there are many 
concept refences in the AST that do not call the helper. Those are `AutoType`, 
`AutoTypeLoc` and constraint requirements.

Only clangd code requires an update.

There is really no use-case for concept requirements traversals yet, but
I added them in the earlier version of the patch and decided to keep
them for completeness.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124532

Files:
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/lib/Index/IndexBody.cpp
  clang/unittests/Tooling/RecursiveASTVisitorTests/Concept.cpp

Index: clang/unittests/Tooling/RecursiveASTVisitorTests/Concept.cpp
===
--- clang/unittests/Tooling/RecursiveASTVisitorTests/Concept.cpp
+++ clang/unittests/Tooling/RecursiveASTVisitorTests/Concept.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "TestVisitor.h"
+#include "clang/AST/ASTConcept.h"
 #include "clang/AST/ExprConcepts.h"
 
 using namespace clang;
@@ -18,28 +19,55 @@
 ++ConceptSpecializationExprsVisited;
 return true;
   }
-  bool TraverseConceptReference(const ConceptReference &R) {
-++ConceptReferencesTraversed;
-return true;
+  bool TraverseTypeConstraint(const TypeConstraint *C) {
+++TypeConstraintsTraversed;
+return ExpectedLocationVisitor::TraverseTypeConstraint(C);
+  }
+  bool TraverseConceptRequirement(concepts::Requirement *R) {
+++ConceptRequirementsTraversed;
+return ExpectedLocationVisitor::TraverseConceptRequirement(R);
   }
 
+  bool shouldVisitImplicitCode() { return ShouldVisitImplicitCode; }
+
   int ConceptSpecializationExprsVisited = 0;
-  int ConceptReferencesTraversed = 0;
+  int TypeConstraintsTraversed = 0;
+  int ConceptRequirementsTraversed = 0;
+  bool ShouldVisitImplicitCode = false;
 };
 
-TEST(RecursiveASTVisitor, ConstrainedParameter) {
+TEST(RecursiveASTVisitor, Concepts) {
   ConceptVisitor Visitor;
+  Visitor.ShouldVisitImplicitCode = true;
   EXPECT_TRUE(Visitor.runOver("template  concept Fooable = true;\n"
   "template  void bar(T);",
   ConceptVisitor::Lang_CXX2a));
-  // Check that we visit the "Fooable T" template parameter's TypeConstraint's
-  // ImmediatelyDeclaredConstraint, which is a ConceptSpecializationExpr.
+  // Check that we traverse the "Fooable T" template parameter's
+  // TypeConstraint's ImmediatelyDeclaredConstraint, which is a
+  // ConceptSpecializationExpr.
   EXPECT_EQ(1, Visitor.ConceptSpecializationExprsVisited);
-  // There are two ConceptReference objects in the AST: the base subobject
-  // of the ConceptSpecializationExpr, and the base subobject of the
-  // TypeConstraint itself. To avoid traversing the concept and arguments
-  // multiple times, we only traverse one.
-  EXPECT_EQ(1, Visitor.ConceptReferencesTraversed);
+  // Also check we traversed the TypeConstraint that produced the expr.
+  EXPECT_EQ(1, Visitor.TypeConstraintsTraversed);
+
+  Visitor = {}; // Don't visit implicit code now.
+  EXPECT_TRUE(Visitor.runOver("template  concept Fooable = true;\n"
+  "template  void bar(T);",
+  ConceptVisitor::Lang_CXX2a));
+  // Check that we only visit the TypeConstraint, but not the implicitly
+  // generated immediately declared expression.
+  EXPECT_EQ(0, Visitor.ConceptSpecializationExprsVisited);
+  EXPECT_EQ(1, Visitor.TypeConstraintsTraversed);
+
+  Visitor = {};
+  EXPECT_TRUE(Visitor.runOver("template  concept A = true;\n"
+  "template  struct vector {};\n"
+  "template  concept B = requires(T x) {\n"
+  "  typename vector;\n"
+  "  {x} -> A;\n"
+  "  requires true;\n"
+  "};",
+  ConceptVisitor::Lang_CXX2a));
+  EXPECT_EQ(3, Visitor.ConceptRequirementsTraversed);
 }
 
 } // end anonymous namespace
Index: clang/lib/Index/IndexBody.cpp
===
--- clang/lib/Index/IndexBody.cpp
+++ clang/lib/Index/IndexBody.cpp
@@ -483,13 +483,10 @@
 return true;
   }
 
-  bool VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) {
-// This handles referen

[PATCH] D124534: Add a warning diagnostic for line directive of a gnu extension

2022-04-27 Thread Ken Matsui via Phabricator via cfe-commits
ken-matsui created this revision.
Herald added a project: All.
ken-matsui requested review of this revision.
Herald added projects: clang, clang-tools-extra.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124534

Files:
  clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp
  clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp.expected
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/lib/Lex/PPDirectives.cpp
  clang/test/Misc/warning-flags.c
  clang/test/Preprocessor/line-directive.c
  clang/test/Preprocessor/warn-gnu-ext-line-directive.c

Index: clang/test/Preprocessor/warn-gnu-ext-line-directive.c
===
--- /dev/null
+++ clang/test/Preprocessor/warn-gnu-ext-line-directive.c
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -fsyntax-only %s -verify
+
+#1 // expected-warning {{style of line directive is a GNU extension}}
Index: clang/test/Preprocessor/line-directive.c
===
--- clang/test/Preprocessor/line-directive.c
+++ clang/test/Preprocessor/line-directive.c
@@ -27,7 +27,7 @@
 #define A 42 "foo"
 #line A
 
-# 42
+# 42 // expected-warning {{style of line directive is a GNU extension}}
 # 42 "foo"
 # 42 "foo" 2 // expected-error {{invalid line marker flag '2': cannot pop empty include stack}}
 # 42 "foo" 1 3  // enter
@@ -97,7 +97,7 @@
 #line 010  // expected-warning {{#line directive interprets number as decimal, not octal}}
 extern int array[__LINE__ == 10 ? 1:-1];
 
-# 020  // expected-warning {{GNU line marker directive interprets number as decimal, not octal}}
+# 020  // expected-warning {{GNU line marker directive interprets number as decimal, not octal}} expected-warning {{style of line directive is a GNU extension}}
 extern int array_gnuline[__LINE__ == 20 ? 1:-1];
 
 /* PR3917 */
@@ -106,7 +106,7 @@
 _\
 _LINE__ == 42 ? 1: -1];  /* line marker is location of first _ */
 
-# 51
+# 51 // expected-warning {{style of line directive is a GNU extension}}
 extern char array2_gnuline[\
 _\
 _LINE__ == 52 ? 1: -1];  /* line marker is location of first _ */
Index: clang/test/Misc/warning-flags.c
===
--- clang/test/Misc/warning-flags.c
+++ clang/test/Misc/warning-flags.c
@@ -18,7 +18,7 @@
 
 The list of warnings below should NEVER grow.  It should gradually shrink to 0.
 
-CHECK: Warnings without flags (67):
+CHECK: Warnings without flags (68):
 
 CHECK-NEXT:   ext_expected_semi_decl_list
 CHECK-NEXT:   ext_explicit_specialization_storage_class
@@ -71,6 +71,7 @@
 CHECK-NEXT:   warn_on_superclass_use
 CHECK-NEXT:   warn_pp_convert_to_positive
 CHECK-NEXT:   warn_pp_expr_overflow
+CHECK-NEXT:   warn_pp_gnu_ext_line_directive
 CHECK-NEXT:   warn_pp_line_decimal
 CHECK-NEXT:   warn_pragma_pack_pop_identifier_and_alignment
 CHECK-NEXT:   warn_pragma_pack_show
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -1432,6 +1432,7 @@
   // string followed by eod.
   if (StrTok.is(tok::eod)) {
 // Treat this like "#line NN", which doesn't change file characteristics.
+Diag(StrTok, diag::warn_pp_gnu_ext_line_directive);
 FileKind = SourceMgr.getFileCharacteristic(DigitTok.getLocation());
   } else if (StrTok.isNot(tok::string_literal)) {
 Diag(StrTok, diag::err_pp_linemarker_invalid_filename);
Index: clang/include/clang/Basic/DiagnosticLexKinds.td
===
--- clang/include/clang/Basic/DiagnosticLexKinds.td
+++ clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -427,6 +427,8 @@
 def ext_pp_opencl_variadic_macros : Extension<
   "variadic macros are a Clang extension in OpenCL">;
 
+def warn_pp_gnu_ext_line_directive : Warning<"style of line directive is a GNU extension">;
+
 def err_pp_invalid_directive : Error<"invalid preprocessing directive">;
 def err_pp_directive_required : Error<
   "%0 must be used within a preprocessing directive">;
Index: clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp.expected
===
--- clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp.expected
+++ clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp.expected
@@ -1,6 +1,6 @@
-
-// This file intentionally uses a CRLF newlines!
-
-void foo() {
-  int *x = nullptr;
-}
+
+// This file intentionally uses a CRLF newlines!
+
+void foo() {
+  int *x = nullptr;
+}
Index: clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp
===
--- clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp
+++ clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp
@@ -1,6 +1

[PATCH] D124534: Add a warning diagnostic for line directive of a gnu extension

2022-04-27 Thread Ken Matsui via Phabricator via cfe-commits
ken-matsui added a comment.

This change is related to: https://github.com/llvm/llvm-project/issues/55067


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124534

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


[PATCH] D124158: [Clang][Attr] Skip adding noundef attribute to arguments when function has convergent attribute

2022-04-27 Thread krishna chaitanya sankisa via Phabricator via cfe-commits
skc7 added a comment.

In D124158#3477281 , @jdoerfert wrote:

>> For Ex: SimplifyCFG pass removes the branch leading to a BB which has an 
>> incoming value that will always trigger undefined behavior. This basically 
>> modifies the CFG and combines the basic blocks. This works for CPU 
>> execution. But on a GPU, there are intrinsics like "__shfl_sync(unsigned 
>> mask, T var, int srcLane, int width=warpSize)", Where the exchange of 
>> variable occurs simultaneously for all active threads within the warp. So, 
>> here in the cuda/hip kernel, variable var in shuffl_sync may not be 
>> initialised, and LLVM IR treats it as undef. Currently all the arguments are 
>> tagged with noundef attribute and the above mentioned optimization by 
>> SimplifyCFG gets applied and the kernel execution becomes ambiguous. So, the 
>> proposed change is to skip adding noundef attribute to arguments when a 
>> function has been tagged with convergent attribute.
>
> Can we please have an example for this. I don't know what would be broken w/ 
> noundef + convergent and I somewhat doubt noundef is the problem.

For the below source kernel from hypre, the optimisation by simplifyCFG pass 
caused issue with kernel execution on GPU.
We figured out that enabling noudef analysis by default is triggering this 
optimization.

**source kernel:**
Note: variable t is uninitialised intially and gets initialiazed when lane is 0.
void kernel{

  double t, measure_row;
  int lane = hypre_cuda_get_lane_id<1>();

...

  if (lane == 0) {t = read_only_load(measure_diag + row);}
  measure_row = __shfl_sync(HYPRE_WARP_FULL_MASK, t, 0);

...
}

**Example LLVM IR for a similar scenario:**
define void @func(i32 noundef %arg17) {
bb1:

  %i1 = icmp eq i32 %arg17, 0
  br i1 %i1, label %bb2, label %bb3

bb2:  ; preds = %bb1

  %i2 = call noundef double @read_only_load()
  br label %bb3

bb3:  ; preds = %bb2, %bb1

  %i3 = phi double [ %i2, %bb2 ], [ undef, %bb1 ]
  %i4 = call noundef double @__shfl_sync(double noundef %i3)
  ret void

}

declare double @read_only_load()
declare double @__shfl_sync(double noundef) convergent

**IR Dump After SimplifyCFGPass on func:**
define void @func(i32 noundef %arg17) {
bb1:

  %i1 = icmp eq i32 %arg17, 0
  call void @llvm.assume(i1 %i1)
  %i2 = call noundef double @read_only_load()
  %i4 = call noundef double @__shfl_sync(double noundef %i2)
  ret void

}


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124158

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


[PATCH] D124091: [clang][AArch64][SVE] Implement conditional operator for SVE vectors

2022-04-27 Thread David Truby via Phabricator via cfe-commits
DavidTruby updated this revision to Diff 425541.
DavidTruby added a comment.

Fix crash where condition and splatted result don't have the same width


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124091

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/CodeGenCXX/aarch64-sve-vector-conditional-op.cpp
  clang/test/SemaCXX/aarch64-sve-vector-conditional-op.cpp

Index: clang/test/SemaCXX/aarch64-sve-vector-conditional-op.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/aarch64-sve-vector-conditional-op.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -verify -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only %s
+
+// REQUIRES: aarch64-registered-target
+
+#include 
+
+void cond(svint8_t i8, svint16_t i16, svint32_t i32, svint64_t i64,
+  svuint8_t u8, svuint16_t u16, svuint32_t u32, svuint64_t u64,
+  svfloat16_t f16, svfloat32_t f32, svfloat64_t f64,
+  svbool_t b) {
+  (void)(i8 ? i16 : i16);  // expected-error{{vector condition type 'svint8_t' (aka '__SVInt8_t') and result type 'svint16_t' (aka '__SVInt16_t') do not have the same number of elements}}
+  (void)(i8 ? i32 : i32);  // expected-error{{vector condition type 'svint8_t' (aka '__SVInt8_t') and result type 'svint32_t' (aka '__SVInt32_t') do not have the same number of elements}}
+  (void)(i8 ? i64 : i64);  // expected-error{{vector condition type 'svint8_t' (aka '__SVInt8_t') and result type 'svint64_t' (aka '__SVInt64_t') do not have the same number of elements}}
+
+  (void)(i16 ? i16 : i8);   // expected-error{{vector operands to the vector conditional must be the same type}}
+  (void)(i16 ? i16 : i32);  // expected-error{{vector operands to the vector conditional must be the same type}}
+  (void)(i16 ? i16 : i64);  // expected-error{{vector operands to the vector conditional must be the same type}}
+
+  (void)(i16 ? i8 : i16);   // expected-error{{vector operands to the vector conditional must be the same type}}
+  (void)(i16 ? i32 : i16);  // expected-error{{vector operands to the vector conditional must be the same type}}
+  (void)(i16 ? i64 : i16);  // expected-error{{vector operands to the vector conditional must be the same type}}
+
+  (void)(f32 < 0.f ? 1. : 0.);   // expected-error {{vector condition type '__SVInt32_t' and result type 'double' do not have elements of the same size}}
+  (void)(f64 < 0. ? 1.f : 0.f); // expected-error {{vector condition type '__SVInt64_t' and result type 'float' do not have elements of the same size}}
+}
Index: clang/test/CodeGenCXX/aarch64-sve-vector-conditional-op.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/aarch64-sve-vector-conditional-op.cpp
@@ -0,0 +1,224 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve \
+// RUN: -fallow-half-arguments-and-returns -disable-O0-optnone \
+// RUN:  -emit-llvm -o - %s | opt -S -sroa | FileCheck %s
+
+// REQUIRES: aarch64-registered-target
+
+#include 
+
+// CHECK-LABEL: @_Z9cond_boolu10__SVBool_tu10__SVBool_t(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[CMP:%.*]] = icmp ult  [[A:%.*]], [[B:%.*]]
+// CHECK-NEXT:[[VECTOR_COND:%.*]] = icmp ne  [[CMP]], zeroinitializer
+// CHECK-NEXT:[[VECTOR_SELECT:%.*]] = select  [[VECTOR_COND]],  [[A]],  [[B]]
+// CHECK-NEXT:ret  [[VECTOR_SELECT]]
+//
+svbool_t cond_bool(svbool_t a, svbool_t b) {
+return a < b ? a : b;
+}
+
+// CHECK-LABEL: @_Z7cond_i8u10__SVInt8_tu10__SVInt8_t(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[CMP:%.*]] = icmp ult  [[A:%.*]], [[B:%.*]]
+// CHECK-NEXT:[[CONV:%.*]] = zext  [[CMP]] to 
+// CHECK-NEXT:[[VECTOR_COND:%.*]] = icmp ne  [[CONV]], zeroinitializer
+// CHECK-NEXT:[[VECTOR_SELECT:%.*]] = select  [[VECTOR_COND]],  [[A]],  [[B]]
+// CHECK-NEXT:ret  [[VECTOR_SELECT]]
+//
+svint8_t cond_i8(svint8_t a, svint8_t b) {
+return a < b ? a : b;
+}
+
+// CHECK-LABEL: @_Z7cond_u8u11__SVUint8_tu11__SVUint8_t(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[CMP:%.*]] = icmp ult  [[A:%.*]], [[B:%.*]]
+// CHECK-NEXT:[[CONV:%.*]] = zext  [[CMP]] to 
+// CHECK-NEXT:[[VECTOR_COND:%.*]] = icmp ne  [[CONV]], zeroinitializer
+// CHECK-NEXT:[[VECTOR_SELECT:%.*]] = select  [[VECTOR_COND]],  [[A]],  [[B]]
+// CHECK-NEXT:ret  [[VECTOR_SELECT]]
+//
+svuint8_t cond_u8(svuint8_t a, svuint8_t b) {
+return a < b ? a : b;
+}
+
+// CHECK-LABEL: @_Z8cond_i16u11__SVInt16_tu11__SVInt16_t(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[CMP:%.*]] = icmp ult  [[A:%.*]], [[B:%.*]]
+// CHECK-NEXT:[[CONV:%.*]] = zext  [[CMP]] to 
+// CHECK-NEXT:[[VECTOR_COND:%.*]] = icmp ne  [[CONV]], zeroinitializer
+// CHECK-NEXT:[[VECTOR_SELECT:%

[PATCH] D123958: [randstruct] Randomize all elements of a record

2022-04-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Can you also add a test specifically for an enumeration declaration, as that 
was something we found bugs with?




Comment at: clang/lib/AST/Randstruct.cpp:201
+dyn_cast(RandomizedFields.back()->getType()))
+  if (CA->getSize().sle(2) || CA->isIncompleteArrayType())
+FlexibleArray = RandomizedFields.pop_back_val();

CA->isIncompleteArrayType() looks to be at the wrong spot. An incomplete array 
type is one of type `IncompleteArrayType`, which a `ConstantArrayType` is not. 
Are we missing test coverage, or does the `hasFlexibleArrayMember()` make it so 
that we just need to remove this check entirely?



Comment at: clang/unittests/AST/RandstructTest.cpp:368
+int h;
+char name[0];
+} __attribute__((randomize_layout));

Can you add a test where the last field is `char name[1];` and another one for 
`char name[];` so that we have full coverage there?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123958

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


[PATCH] D124158: [Clang][Attr] Skip adding noundef attribute to arguments when function has convergent attribute

2022-04-27 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

The issue you're describing sounds like it's specific to @__shfl_sync.  In 
general, in C++, you aren't allowed to read from an uninitialized variable; see 
[basic.indet] in the standard.  But if your testcase doesn't have undefined 
behavior, CUDA language rules must somehow allow this particular builtin 
function to take undef variables as input.  (Is this documented somewhere?)

That isn't related to the "convergent" attribute; the transform you're 
describing doesn't break convergence rules.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124158

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


[PATCH] D124536: [AMDGPU] Add gfx11 subtarget ELF definition

2022-04-27 Thread Joe Nash via Phabricator via cfe-commits
Joe_Nash created this revision.
Herald added subscribers: hsmhsm, foad, dexonsmith, kerbowa, rupprecht, 
hiraditya, t-tye, tpr, dstuttard, yaxunl, nhaehnle, jvesely, kzhuravl, emaste, 
arsenm.
Herald added a reviewer: jhenderson.
Herald added a project: All.
Joe_Nash requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, MaskRay, wdng.
Herald added projects: clang, LLVM.

This is the first patch of a series to upstream support for the new
subtarget.

Contributors:
Jay Foad 
Konstantin Zhuravlyov 

Patch 1/N for upstreaming AMDGPU gfx11 architectures.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124536

Files:
  clang/test/Misc/target-invalid-cpu-note.c
  llvm/include/llvm/BinaryFormat/ELF.h
  llvm/include/llvm/Support/TargetParser.h
  llvm/lib/Object/ELFObjectFile.cpp
  llvm/lib/ObjectYAML/ELFYAML.cpp
  llvm/lib/Support/TargetParser.cpp
  llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp
  llvm/test/Object/AMDGPU/elf-header-flags-mach.yaml
  llvm/test/tools/llvm-readobj/ELF/amdgpu-elf-headers.test
  llvm/tools/llvm-readobj/ELFDumper.cpp

Index: llvm/tools/llvm-readobj/ELFDumper.cpp
===
--- llvm/tools/llvm-readobj/ELFDumper.cpp
+++ llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -1539,6 +1539,10 @@
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1034),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1035),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1036),
+  LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1100),
+  LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1101),
+  LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1102),
+  LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1103),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_FEATURE_XNACK_V3),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_FEATURE_SRAMECC_V3)
 };
@@ -1595,6 +1599,10 @@
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1034),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1035),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1036),
+  LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1100),
+  LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1101),
+  LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1102),
+  LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1103),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_FEATURE_XNACK_ANY_V4),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_FEATURE_XNACK_OFF_V4),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_FEATURE_XNACK_ON_V4),
Index: llvm/test/tools/llvm-readobj/ELF/amdgpu-elf-headers.test
===
--- llvm/test/tools/llvm-readobj/ELF/amdgpu-elf-headers.test
+++ llvm/test/tools/llvm-readobj/ELF/amdgpu-elf-headers.test
@@ -337,6 +337,42 @@
 # RUN: yaml2obj %s -o %t -DABI_VERSION=16 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX90A
 # RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,UNKNOWN-ABI-VERSION --match-full-lines -DABI_VERSION=16 -DFILE=%t -DFLAG_VALUE=0x3F
 
+# RUN: yaml2obj %s -o %t -DABI_VERSION=0 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX1100
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,KNOWN-ABI-VERSION,SINGLE-FLAG --match-full-lines -DABI_VERSION=0 -DFILE=%t -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX1100 -DFLAG_VALUE=0x41
+
+# RUN: yaml2obj %s -o %t -DABI_VERSION=1 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX1100
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,KNOWN-ABI-VERSION,SINGLE-FLAG --match-full-lines -DABI_VERSION=1 -DFILE=%t -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX1100 -DFLAG_VALUE=0x41
+
+# RUN: yaml2obj %s -o %t -DABI_VERSION=2 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX1100
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,KNOWN-ABI-VERSION,SINGLE-FLAG --match-full-lines -DABI_VERSION=2 -DFILE=%t -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX1100 -DFLAG_VALUE=0x41
+
+# RUN: yaml2obj %s -o %t -DABI_VERSION=0 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX1101
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,KNOWN-ABI-VERSION,SINGLE-FLAG --match-full-lines -DABI_VERSION=0 -DFILE=%t -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX1101 -DFLAG_VALUE=0x46
+
+# RUN: yaml2obj %s -o %t -DABI_VERSION=1 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX1101
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,KNOWN-ABI-VERSION,SINGLE-FLAG --match-full-lines -DABI_VERSION=1 -DFILE=%t -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX1101 -DFLAG_VALUE=0x46
+
+# RUN: yaml2obj %s -o %t -DABI_VERSION=2 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX1101
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,KNOWN-ABI-VERSION,SINGLE-FLAG --match-full-lines -DABI_VERSION=2 -DFILE=%t -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX1101 -DFLAG_VALUE=0x46
+
+# RUN: yaml2obj %s -o %t -DABI_VERSION=0 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX1102
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,KNOWN-ABI-VERSION,SINGLE-FLAG --match-full-lines -DABI_VERSION=0 -DFILE=%t -DFLAG_NAME=EF_AMDGPU_M

[PATCH] D124537: [AMDGPU][clang] Definition of gfx11 subtarget

2022-04-27 Thread Joe Nash via Phabricator via cfe-commits
Joe_Nash created this revision.
Herald added subscribers: mattd, gchakrabarti, asavonic, dexonsmith, kerbowa, 
t-tye, tpr, dstuttard, yaxunl, jvesely, kzhuravl, jholewinski.
Herald added a project: All.
Joe_Nash requested review of this revision.
Herald added subscribers: cfe-commits, wdng.
Herald added a project: clang.

Contributors:
Jay Foad 
Konstantin Zhuravlyov 

Patch 2/N for upstreaming of AMDGPU gfx11 architecture

Depends on D124536 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124537

Files:
  clang/include/clang/Basic/Cuda.h
  clang/lib/Basic/Cuda.cpp
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/NVPTX.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/test/CodeGenOpenCL/amdgpu-features.cl
  clang/test/Driver/amdgpu-macros.cl
  clang/test/Driver/amdgpu-mcpu.cl
  clang/test/Misc/target-invalid-cpu-note.c

Index: clang/test/Misc/target-invalid-cpu-note.c
===
--- clang/test/Misc/target-invalid-cpu-note.c
+++ clang/test/Misc/target-invalid-cpu-note.c
@@ -29,7 +29,7 @@
 
 // RUN: not %clang_cc1 -triple nvptx--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix NVPTX
 // NVPTX: error: unknown target CPU 'not-a-cpu'
-// NVPTX-NEXT: note: valid target CPU values are: sm_20, sm_21, sm_30, sm_32, sm_35, sm_37, sm_50, sm_52, sm_53, sm_60, sm_61, sm_62, sm_70, sm_72, sm_75, sm_80, sm_86, gfx600, gfx601, gfx602, gfx700, gfx701, gfx702, gfx703, gfx704, gfx705, gfx801, gfx802, gfx803, gfx805, gfx810, gfx900, gfx902, gfx904, gfx906, gfx908, gfx909, gfx90a, gfx90c, gfx940, gfx1010, gfx1011, gfx1012, gfx1013, gfx1030, gfx1031, gfx1032, gfx1033, gfx1034, gfx1035, gfx1036{{$}}
+// NVPTX-NEXT: note: valid target CPU values are: sm_20, sm_21, sm_30, sm_32, sm_35, sm_37, sm_50, sm_52, sm_53, sm_60, sm_61, sm_62, sm_70, sm_72, sm_75, sm_80, sm_86, gfx600, gfx601, gfx602, gfx700, gfx701, gfx702, gfx703, gfx704, gfx705, gfx801, gfx802, gfx803, gfx805, gfx810, gfx900, gfx902, gfx904, gfx906, gfx908, gfx909, gfx90a, gfx90c, gfx940, gfx1010, gfx1011, gfx1012, gfx1013, gfx1030, gfx1031, gfx1032, gfx1033, gfx1034, gfx1035, gfx1036, gfx1100, gfx1101, gfx1102, gfx1103{{$}}
 
 // RUN: not %clang_cc1 -triple r600--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix R600
 // R600: error: unknown target CPU 'not-a-cpu'
Index: clang/test/Driver/amdgpu-mcpu.cl
===
--- clang/test/Driver/amdgpu-mcpu.cl
+++ clang/test/Driver/amdgpu-mcpu.cl
@@ -104,6 +104,10 @@
 // RUN: %clang -### -target amdgcn -mcpu=gfx1034 %s 2>&1 | FileCheck --check-prefix=GFX1034 %s
 // RUN: %clang -### -target amdgcn -mcpu=gfx1035 %s 2>&1 | FileCheck --check-prefix=GFX1035 %s
 // RUN: %clang -### -target amdgcn -mcpu=gfx1036 %s 2>&1 | FileCheck --check-prefix=GFX1036 %s
+// RUN: %clang -### -target amdgcn -mcpu=gfx1100 %s 2>&1 | FileCheck --check-prefix=GFX1100 %s
+// RUN: %clang -### -target amdgcn -mcpu=gfx1101 %s 2>&1 | FileCheck --check-prefix=GFX1101 %s
+// RUN: %clang -### -target amdgcn -mcpu=gfx1102 %s 2>&1 | FileCheck --check-prefix=GFX1102 %s
+// RUN: %clang -### -target amdgcn -mcpu=gfx1103 %s 2>&1 | FileCheck --check-prefix=GFX1103 %s
 
 // GCNDEFAULT-NOT: -target-cpu
 // GFX600:"-target-cpu" "gfx600"
@@ -140,3 +144,7 @@
 // GFX1034:   "-target-cpu" "gfx1034"
 // GFX1035:   "-target-cpu" "gfx1035"
 // GFX1036:   "-target-cpu" "gfx1036"
+// GFX1100:   "-target-cpu" "gfx1100"
+// GFX1101:   "-target-cpu" "gfx1101"
+// GFX1102:   "-target-cpu" "gfx1102"
+// GFX1103:   "-target-cpu" "gfx1103"
Index: clang/test/Driver/amdgpu-macros.cl
===
--- clang/test/Driver/amdgpu-macros.cl
+++ clang/test/Driver/amdgpu-macros.cl
@@ -120,6 +120,10 @@
 // RUN: %clang -E -dM -target amdgcn -mcpu=gfx1034 %s 2>&1 | FileCheck --check-prefixes=ARCH-GCN,FAST_FMAF %s -DWAVEFRONT_SIZE=32 -DCPU=gfx1034
 // RUN: %clang -E -dM -target amdgcn -mcpu=gfx1035 %s 2>&1 | FileCheck --check-prefixes=ARCH-GCN,FAST_FMAF %s -DWAVEFRONT_SIZE=32 -DCPU=gfx1035
 // RUN: %clang -E -dM -target amdgcn -mcpu=gfx1036 %s 2>&1 | FileCheck --check-prefixes=ARCH-GCN,FAST_FMAF %s -DWAVEFRONT_SIZE=32 -DCPU=gfx1036
+// RUN: %clang -E -dM -target amdgcn -mcpu=gfx1100 %s 2>&1 | FileCheck --check-prefixes=ARCH-GCN,FAST_FMAF %s -DWAVEFRONT_SIZE=32 -DCPU=gfx1100
+// RUN: %clang -E -dM -target amdgcn -mcpu=gfx1101 %s 2>&1 | FileCheck --check-prefixes=ARCH-GCN,FAST_FMAF %s -DWAVEFRONT_SIZE=32 -DCPU=gfx1101
+// RUN: %clang -E -dM -target amdgcn -mcpu=gfx1102 %s 2>&1 | FileCheck --check-prefixes=ARCH-GCN,FAST_FMAF %s -DWAVEFRONT_SIZE=32 -DCPU=gfx1102
+// RUN: %clang -E -dM -target amdgcn -mcpu=gfx1103 %s 2>&1 | FileCheck --check-prefixes=ARCH-GCN,FAST_FMAF %s -DWAVEFRONT_SIZE=32 -DCPU=gfx1103
 
 // ARCH-GCN-DAG: #define FP_FAST_FMA 1
 
Index: clang/test/CodeGenOpenCL/amdgpu-features.cl
=

[PATCH] D124341: [clang-tidy][NFC] Replace many instances of std::string where a StringRef would suffice.

2022-04-27 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added inline comments.



Comment at: clang-tools-extra/clang-tidy/ClangTidyCheck.cpp:51
 ClangTidyContext *Context)
-: NamePrefix(CheckName.str() + "."), CheckOptions(CheckOptions),
+: NamePrefix((CheckName + ".").str()), CheckOptions(CheckOptions),
   Context(Context) {}

Why is `StringRef::operator+` considered "better" than `std::string::operator+`?



Comment at: clang-tools-extra/clang-tidy/ClangTidyCheck.cpp:56
 ClangTidyCheck::OptionsView::get(StringRef LocalName) const {
-  const auto &Iter = CheckOptions.find(NamePrefix + LocalName.str());
+  const auto &Iter = CheckOptions.find((NamePrefix + LocalName).str());
   if (Iter != CheckOptions.end())

`find` takes a `StringRef` so why convert to `std::string` here?



Comment at: clang-tools-extra/clang-tidy/ClangTidyCheck.cpp:123
 StringRef Value) const {
-  Options[NamePrefix + LocalName.str()] = Value;
+  Options[(NamePrefix + LocalName).str()] = Value;
 }

`operator[]` takes a `StringRef` so why convert to `std::string` here?



Comment at: clang-tools-extra/clang-tidy/ClangTidyCheck.h:158
 /// ``None``.
-llvm::Optional get(StringRef LocalName) const;
+llvm::Optional get(StringRef LocalName) const;
 

I think I would feel safer if the changes to the infrastructure were pushed 
separately from the changes to the checks, with some "bake time" in between so 
we have more confidence in the changes.

While debugging my own checks, I've seen that there are surprises with the 
lifetimes of `StringRef`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124341

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


[PATCH] D124537: [AMDGPU][clang] Definition of gfx11 subtarget

2022-04-27 Thread Brian Sumner via Phabricator via cfe-commits
b-sumner added a comment.

t-tye should review this too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124537

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


[PATCH] D124540: [clang][dataflow] Perform structural comparison of indirection values in `join`.

2022-04-27 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added reviewers: xazax.hun, sgatev.
Herald added subscribers: tschuett, steakhal, rnkovacs.
Herald added a project: All.
ymandel requested review of this revision.
Herald added a project: clang.

This patch changes `Environment::join`, in the case that two values at the same
location are not (pointer) equal, to structurally compare indirection values
(pointers and references) for equivalence (that is, equivalent pointees) before
resorting to merging.

This change makes join consistent with equivalence, which also performs
structural comparison. It also fixes a bug where the values are `ReferenceValue`
but the merge creates a non-reference value. This case arises when the
`ReferenceValue`s were created to represent an lvalue, so the "reference-ness"
is not reflected in the type. In this case, the pointees will always be
equivalent, because lvalues at the same code location point to the location of a
fixed declaration, whose location is itself stable across blocks.

We were unable to reproduce a unit test for this latter bug, but have verified
the fix in the context of a larger piece of code that triggers the bug.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124540

Files:
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp


Index: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
===
--- clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -21,6 +21,7 @@
 #include "clang/Analysis/FlowSensitive/Value.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/ErrorHandling.h"
 #include 
 #include 
@@ -353,6 +354,16 @@
   continue;
 }
 
+// FIXME: add unit tests that cover this statement.
+if (auto *IndVal1 = dyn_cast(Val)) {
+  auto *IndVal2 = cast(It->second);
+  assert(IndVal1->getKind() == IndVal2->getKind());
+  if (&IndVal1->getPointeeLoc() == &IndVal2->getPointeeLoc()) {
+JoinedEnv.LocToVal.insert({Loc, Val});
+continue;
+  }
+}
+
 if (Value *MergedVal = mergeDistinctValues(
 Loc->getType(), Val, *this, It->second, Other, JoinedEnv, Model))
   JoinedEnv.LocToVal.insert({Loc, MergedVal});


Index: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
===
--- clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -21,6 +21,7 @@
 #include "clang/Analysis/FlowSensitive/Value.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/ErrorHandling.h"
 #include 
 #include 
@@ -353,6 +354,16 @@
   continue;
 }
 
+// FIXME: add unit tests that cover this statement.
+if (auto *IndVal1 = dyn_cast(Val)) {
+  auto *IndVal2 = cast(It->second);
+  assert(IndVal1->getKind() == IndVal2->getKind());
+  if (&IndVal1->getPointeeLoc() == &IndVal2->getPointeeLoc()) {
+JoinedEnv.LocToVal.insert({Loc, Val});
+continue;
+  }
+}
+
 if (Value *MergedVal = mergeDistinctValues(
 Loc->getType(), Val, *this, It->second, Other, JoinedEnv, Model))
   JoinedEnv.LocToVal.insert({Loc, MergedVal});
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D124532: [AST] Improve traversal of concept requirements

2022-04-27 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Nice!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124532

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


[PATCH] D124435: [X86] Always extend the integer parameters in callee

2022-04-27 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:1938
+return IsConservativeExtend ? ABIArgInfo::getConservativeExtend(Ty)
+: ABIArgInfo::getExtend(Ty);
   }

LiuChen3 wrote:
> rjmccall wrote:
> > LiuChen3 wrote:
> > > rjmccall wrote:
> > > > This looks wrong.  In non-`ConservativeExtend` mode, we don't get to 
> > > > assume extension at all and should use `Direct`, right?
> > > As I understand it, `Direct` means do nothing with the parameters. Caller 
> > > won't do the extension and callee can't assume the parameter is correct. 
> > > This makes new clang behave in the opposite way to currently clang 
> > > behavior, which will cause incompatibility issue. e.g:
> > > https://godbolt.org/z/d3Peq4nsG
> > Oh, I see, you're thinking that `-mno-conservative-extend` means "do what 
> > old versions of clang did" rather than "break compatibility with old 
> > versions of clang and just follow the x86_64 ABI".  That's definitely 
> > different from the documentation I suggested, so something's got to change.
> > 
> > I think these are the possibilities here:
> > 
> > 1. Some platforms, like Apple's, are probably going to define Clang's 
> > current behavior as the platform ABI.  So those platforms need to continue 
> > to use `Extend`.  My previous comment about using `Direct` wasn't paying 
> > due attention to this case.
> > 
> > 2. On other platforms, we need to maintain compatibility by default with 
> > both the platform ABI and old Clang behavior.  Those platforms will need to 
> > use `ConservativeExtend`.
> > 
> > 3. Some people may want to opt out of (2) and just be compatible with the 
> > platform ABI, which has minor code-size and performance wins.  If we 
> > support that with an option, I believe it should cause us to emit `Direct`. 
> >  This is what I was thinking `-mno-conservative-extend` would mean.
> > 
> > 4. Some people may want to force the use of (1) even on platforms where 
> > that isn't the platform ABI.  I don't know if this is really something we 
> > should support in the long term, but it might be valuable for people 
> > staging this change in.  This is what you seem to be thinking 
> > `-mno-conservative-extend` would mean.
> > 
> > I would suggest these spellings for the argument, instead of making it 
> > boolean:
> > 
> > ```
> > -mextend-small-integers=none// Force the use of Direct
> > -mextend-small-integers=conservative // Force the use of ConservativeExtend
> > -mextend-small-integers=assumed // Force the use of Extend
> > -mextend-small-integers=default // Use the default rule for the target
> > ```
> Yes. That's what I mean. I totally misunderstood your meaning before. 
> I agree with your method. I will work on that. Just one concern about the 
> 'default': the default behavior is 'conservative' instead of 'default'. 
> Wouldn't that be a little weird? But with my limited English I can't think of 
> a better word. 'default' is ok for me. :-)
The default will be platform-specific.  For example, the de facto macOS x86_64 
ABI is to extend in the caller, because clang is the system compiler, and 
that's what clang does.  Apple just needs to update its documentation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124435

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


[PATCH] D124487: [HLSL] Adjust access specifier behavior

2022-04-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticParseKinds.td:1603
+def ext_hlsl_access_specifiers : ExtWarn<
+  "access specifiers are a clang HLSL extension">;
 

This also needs to go into a warning group.



Comment at: clang/lib/Parse/ParseDeclCXX.cpp:3517-3519
+  // HLSL: In HLSL members of a class are public by default.
   AccessSpecifier CurAS;
+  if (TagType == DeclSpec::TST_class && !getLangOpts().HLSL)

Gross. 🤮



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:2504-2507
+  // In HLSL, unspecified class access is public rather than private.
+  if (getLangOpts().HLSL && Class->getTagKind() == TTK_Class &&
+  Access == AS_none)
+Access = AS_public;

🤮



Comment at: clang/test/ParserHLSL/access_specifiers.hlsl:4-5
+class Doggo {
+  // expected-note@+1 {{member is declared here}}
+  int legs;
+// expected-warning@+1 {{access specifiers are a clang HLSL extension}}

(It's generally easier to maintain tests when the expected check lines are 
directly on the impacted line rather than using offsets to it. Same applies 
through the rest of the test. NB: we don't care about 80 col limits in tests.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124487

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


[PATCH] D124373: [clang] add parameter pack/pack expansion matchers

2022-04-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Due to how expensive it is to instantiate all the templates from ASTMatchers.h, 
we typically don't add new matchers unless there's a need for them in-tree or 
they're expected to be generally useful to a number of out-of-tree matchers. 
Are you planning to make use of these matchers for a clang-tidy check you're 
working on or something along those lines? Or are they mostly to add missing 
coverage?

On the technical side (feel free to ignore this until we know we're going to 
add the matchers to Clang if you'd like), you should add test coverage for the 
new matchers to clang/unittests/ASTMatchers and you should regenerate the 
documentation by running clang/docs/tools/dump_ast_matchers.py.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124373

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


[PATCH] D124461: [Analyzer] Remove undefined function

2022-04-27 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124461

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


[PATCH] D122920: [Clang][CodeGen]Fix __builtin_dump_struct missing record type field name

2022-04-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D122920#3476388 , @yihanaa wrote:

> In D122920#3472379 , @asoffer wrote:
>
>> In D122920#3471865 , @yihanaa 
>> wrote:
>>
>>> In D122920#3471654 , @erichkeane 
>>> wrote:
>>>
 @yihanaa : I'd suggest seeing the conversation that @rsmith @aaron.ballman 
 and I are having about this builtin here: https://reviews.llvm.org/D124221

 In general it looks like the three of us think that this builtin needs an 
 overhaul in implementation/functionality in order to be further useful. 
 While we very much appreciate your attempts to try to improve it, we 
 believe there needs to be larger-scale changes.
>>>
>>> Thanks for your reply, I would like to get involved and help if needed
>>
>> While I eagerly await `__builtin_reflect_struct`, this change still provides 
>> significant value in fixing a regression with `__builtin_dump_struct`. 
>> Should we proceed with this change and that proposal independently?
>
> Agree

While we'd usually be happy to take the fix-in-hand and apply it, part of the 
discussion on the other thread is whether to remove `__builtin_dump_struct` 
entirely. Because of that, I don't think we should make substantial changes in 
this area until it's clear we're keeping the builtin.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122920

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


[clang] 2d0c897 - [Driver] Support for compressed debug info on Fuchsia

2022-04-27 Thread Petr Hosek via cfe-commits

Author: Petr Hosek
Date: 2022-04-27T11:24:41-07:00
New Revision: 2d0c897212d0551966b26eae986209ea31c4f032

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

LOG: [Driver] Support for compressed debug info on Fuchsia

Pass the --compress-debug-sections=zlib argument to the linker when
the use of compressed debug info is requested.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/test/Driver/fuchsia.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp 
b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index 9e0b259dfcae7..6fe6f7f82feb2 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -127,6 +127,7 @@ void fuchsia::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   D.getLTOMode() == LTOK_Thin);
   }
 
+  addLinkerCompressDebugSectionsOption(ToolChain, Args, CmdArgs);
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,

diff  --git a/clang/test/Driver/fuchsia.c b/clang/test/Driver/fuchsia.c
index 888f6b1a2c4b7..07bb12b547ddf 100644
--- a/clang/test/Driver/fuchsia.c
+++ b/clang/test/Driver/fuchsia.c
@@ -253,6 +253,15 @@
 // CHECK-THINLTO: "-plugin-opt=thinlto"
 // CHECK-THINLTO: "-plugin-opt=jobs=8"
 
+// RUN: %clang %s -### --target=x86_64-unknown-fuchsia \
+// RUN: --sysroot=%S/platform \
+// RUN: -Og -gz 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-GZ
+// CHECK-GZ: "{{[^"]*}}clang{{[^"]*}}"
+// CHECK-GZ: "--compress-debug-sections=zlib"
+// CHECK-GZ: "{{[^"]*}}ld.lld{{[^"]*}}"
+// CHECK-GZ: "--compress-debug-sections=zlib"
+
 // RUN: %clang %s -### --target=x86_64-unknown-fuchsia \
 // RUN: -gsplit-dwarf -g -c %s 2>&1 \
 // RUN: | FileCheck %s -check-prefix=CHECK-SPLIT-DWARF



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


[PATCH] D124545: [HIP] Add HIP runtime library arguments for linker

2022-04-27 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: tra.
Herald added a project: All.
yaxunl requested review of this revision.
Herald added a subscriber: MaskRay.

Add -L -l options for linker.


https://reviews.llvm.org/D124545

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChains/Linux.h
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/lib/Driver/ToolChains/MSVC.h
  clang/test/Driver/hip-runtime-libs-linux.hip
  clang/test/Driver/hip-runtime-libs-msvc.hip

Index: clang/test/Driver/hip-runtime-libs-msvc.hip
===
--- /dev/null
+++ clang/test/Driver/hip-runtime-libs-msvc.hip
@@ -0,0 +1,10 @@
+// REQUIRES: system-windows
+
+// RUN:  touch %t.o
+
+// Test HIP runtime lib args specified by --rocm-path.
+// RUN: %clang -### --hip-link -target x86_64-pc-windows-msvc \
+// RUN:   --rocm-path=%S/Inputs/rocm %t.o 2>&1 \
+// RUN:   | FileCheck %s
+
+// CHECK: "-libpath:{{.*Inputs.*rocm.*lib}}" "amdhip64.lib"
Index: clang/test/Driver/hip-runtime-libs-linux.hip
===
--- /dev/null
+++ clang/test/Driver/hip-runtime-libs-linux.hip
@@ -0,0 +1,43 @@
+// UNSUPPORTED: system-windows
+
+// RUN:  touch %t.o
+
+// Test HIP runtime lib args specified by --rocm-path.
+// RUN: %clang -### --hip-link -target x86_64-linux-gnu \
+// RUN:   --rocm-path=%S/Inputs/rocm %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefixes=ROCM-PATH %s
+
+// Test HIP runtime lib args specified by environment variable ROCM_PATH.
+// RUN: env ROCM_PATH=%S/Inputs/rocm %clang -### --hip-link \
+// RUN:   -target x86_64-linux-gnu %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefixes=ROCM-PATH %s
+
+// Test detecting latest /opt/rocm-{release} directory.
+// RUN: rm -rf %T/opt
+// RUN: mkdir -p %T/opt
+// RUN: cp -r %S/Inputs/rocm %T/opt/rocm-3.9.0-1234
+// RUN: cp -r %S/Inputs/rocm %T/opt/rocm-3.10.0
+// RUN: %clang -### --hip-link -target x86_64-linux-gnu \
+// RUN:   --sysroot=%T %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefixes=ROCM-REL %s
+
+// Test HIP runtime lib is not linked without --hip-link.
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   --rocm-path=%S/Inputs/rocm %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefixes=NOHIPRT %s
+
+// Test HIP runtime lib is not linked with -nostdlib.
+// RUN: %clang -### --hip-link -nostdlib -target x86_64-linux-gnu \
+// RUN:   --rocm-path=%S/Inputs/rocm %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefixes=NOHIPRT %s
+
+// Test HIP runtime lib is not linked with -no-hip-rt.
+// RUN: %clang -### --hip-link -no-hip-rt -target x86_64-linux-gnu \
+// RUN:   --rocm-path=%S/Inputs/rocm %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefixes=NOHIPRT %s
+
+// ROCM-PATH: "-L[[HIPRT:.*/Inputs/rocm/lib]]" "-rpath" "[[HIPRT]]" "-lamdhip64"
+// ROCM-REL: "-L[[HIPRT:.*/opt/rocm-3.10.0/lib]]" "-rpath" "[[HIPRT]]" "-lamdhip64"
+// NOHIPRT-NOT: "-L{{.*/Inputs/rocm/lib}}"
+// NOHIPRT-NOT: "-rpath" "{{.*/Inputs/rocm/lib}}"
+// NOHIPRT-NOT: "-lamdhip64"
Index: clang/lib/Driver/ToolChains/MSVC.h
===
--- clang/lib/Driver/ToolChains/MSVC.h
+++ clang/lib/Driver/ToolChains/MSVC.h
@@ -96,6 +96,9 @@
   void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs,
  llvm::opt::ArgStringList &CC1Args) const override;
 
+  void AddHIPRuntimeLibArgs(const llvm::opt::ArgList &Args,
+llvm::opt::ArgStringList &CmdArgs) const override;
+
   bool getWindowsSDKLibraryPath(
   const llvm::opt::ArgList &Args, std::string &path) const;
   bool getUniversalCRTLibraryPath(const llvm::opt::ArgList &Args,
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -286,6 +286,8 @@
 A.renderAsInput(Args, CmdArgs);
   }
 
+  addHIPRuntimeLibArgs(TC, Args, CmdArgs);
+
   TC.addProfileRTLibs(Args, CmdArgs);
 
   std::vector Environment;
@@ -475,6 +477,13 @@
   RocmInstallation.AddHIPIncludeArgs(DriverArgs, CC1Args);
 }
 
+void MSVCToolChain::AddHIPRuntimeLibArgs(const ArgList &Args,
+ ArgStringList &CmdArgs) const {
+  CmdArgs.push_back(Args.MakeArgString(StringRef("-libpath:") +
+   RocmInstallation.getLibPath()));
+  CmdArgs.push_back("amdhip64.lib");
+}
+
 void MSVCToolChain::printVerboseInfo(raw_ostream &OS) const {
   CudaInstallation.print(OS);
   RocmInstallation.print(OS);
Index: clang/lib/Driver/ToolChains/Linux.h
===
--- clang/lib/Driver/ToolChains/Linux.h
+++ clang/lib/Driver/ToolChains/Linux.h
@@ -37,6 +37,8

[clang] 82aa5e2 - Revert "[Driver] Support for compressed debug info on Fuchsia"

2022-04-27 Thread Petr Hosek via cfe-commits

Author: Petr Hosek
Date: 2022-04-27T11:41:41-07:00
New Revision: 82aa5e2c6fe9ffbd637d421a799deffa0d90d7bf

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

LOG: Revert "[Driver] Support for compressed debug info on Fuchsia"

This reverts commit 2d0c897212d0551966b26eae986209ea31c4f032 which
is still breaking on the sanitizer bots.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/test/Driver/fuchsia.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp 
b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index 6fe6f7f82feb2..9e0b259dfcae7 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -127,7 +127,6 @@ void fuchsia::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   D.getLTOMode() == LTOK_Thin);
   }
 
-  addLinkerCompressDebugSectionsOption(ToolChain, Args, CmdArgs);
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,

diff  --git a/clang/test/Driver/fuchsia.c b/clang/test/Driver/fuchsia.c
index 07bb12b547ddf..888f6b1a2c4b7 100644
--- a/clang/test/Driver/fuchsia.c
+++ b/clang/test/Driver/fuchsia.c
@@ -253,15 +253,6 @@
 // CHECK-THINLTO: "-plugin-opt=thinlto"
 // CHECK-THINLTO: "-plugin-opt=jobs=8"
 
-// RUN: %clang %s -### --target=x86_64-unknown-fuchsia \
-// RUN: --sysroot=%S/platform \
-// RUN: -Og -gz 2>&1 \
-// RUN: | FileCheck %s -check-prefix=CHECK-GZ
-// CHECK-GZ: "{{[^"]*}}clang{{[^"]*}}"
-// CHECK-GZ: "--compress-debug-sections=zlib"
-// CHECK-GZ: "{{[^"]*}}ld.lld{{[^"]*}}"
-// CHECK-GZ: "--compress-debug-sections=zlib"
-
 // RUN: %clang %s -### --target=x86_64-unknown-fuchsia \
 // RUN: -gsplit-dwarf -g -c %s 2>&1 \
 // RUN: | FileCheck %s -check-prefix=CHECK-SPLIT-DWARF



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


[PATCH] D114115: [Driver] Support for compressed debug info on Fuchsia

2022-04-27 Thread Douglas Yung via Phabricator via cfe-commits
dyung added a comment.

I think the problem here is that if zlib is not available, you won't get the 
clang command line you expect:

https://lab.llvm.org/buildbot/#/builders/216/builds/3519

  Input was:
  <<
   1: clang version 15.0.0 
(https://github.com/llvm/llvm-project.git 
2d0c897212d0551966b26eae986209ea31c4f032) 
   2: Target: x86_64-unknown-fuchsia 
   3: Thread model: posix 
   4: InstalledDir: 
c:\buildbot-root\llvm-clang-x86_64-sie-win\build\bin 
   5: clang: warning: cannot compress debug sections (zlib not 
installed) [-Wdebug-compression-unavailable] 
   6:  
"c:\\buildbot-root\\llvm-clang-x86_64-sie-win\\build\\bin\\clang.exe" "-cc1" 
"-triple" "x86_64-unknown-fuchsia" "-emit-obj" "--mrelax-relocations" 
"-disable-free" "-clear-ast-before-backend" "-main-file-name" "fuchsia.c" 
"-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mframe-pointer=all" 
"-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" 
"-funwind-tables=2" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-mllvm" 
"-treat-scalable-fixed-error-as-warning" "-debugger-tuning=gdb" 
"-fcoverage-compilation-dir=C:\\buildbot-root\\llvm-clang-x86_64-sie-win\\build\\tools\\clang\\test\\Driver"
 "-resource-dir" 
"c:\\buildbot-root\\llvm-clang-x86_64-sie-win\\build\\lib\\clang\\15.0.0" 
"-isysroot" 
"C:\\buildbot-root\\llvm-clang-x86_64-sie-win\\llvm-project\\clang\\test\\Driver/platform"
 "-internal-isystem" 
"c:\\buildbot-root\\llvm-clang-x86_64-sie-win\\build\\lib\\clang\\15.0.0\\include"
 "-internal-externc-isystem" 
"C:\\buildbot-root\\llvm-clang-x86_64-sie-win\\llvm-project\\clang\\test\\Driver/platform\\include"
 "-Og" 
"-fdebug-compilation-dir=C:\\buildbot-root\\llvm-clang-x86_64-sie-win\\build\\tools\\clang\\test\\Driver"
 "-ferror-limit" "19" "-fsanitize=safe-stack" "-stack-protector" "2" 
"-fgnuc-version=4.2.1" "-faddrsig" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o" 
"C:\\Users\\BUILDB~1\\AppData\\Local\\Temp\\lit-tmp-f3r87ykv\\fuchsia-9a49da.o" 
"-x" "c" 
"C:\\buildbot-root\\llvm-clang-x86_64-sie-win\\llvm-project\\clang\\test\\Driver\\fuchsia.c"
 
   7:  
"c:\\buildbot-root\\llvm-clang-x86_64-sie-win\\build\\bin\\ld.lld" "-z" 
"max-page-size=4096" "-z" "now" "-z" "rodynamic" "-z" 
"separate-loadable-segments" "-z" "rel" "--pack-dyn-relocs=relr" 
"--sysroot=C:\\buildbot-root\\llvm-clang-x86_64-sie-win\\llvm-project\\clang\\test\\Driver/platform"
 "-pie" "--build-id" "--hash-style=gnu" "--eh-frame-hdr" "-dynamic-linker" 
"ld.so.1" "-o" "a.out" "Scrt1.o" 
"-LC:\\buildbot-root\\llvm-clang-x86_64-sie-win\\llvm-project\\clang\\test\\Driver/platform\\lib"
 "--compress-debug-sections=zlib" 
"C:\\Users\\BUILDB~1\\AppData\\Local\\Temp\\lit-tmp-f3r87ykv\\fuchsia-9a49da.o" 
"c:\\buildbot-root\\llvm-clang-x86_64-sie-win\\build\\lib\\clang\\15.0.0\\lib\\fuchsia\\libclang_rt.builtins-x86_64.a"
 "-lc" 
  >>

Since lld does produce the expected argument, it suggests that maybe LLD isn't 
doing any detection of whether zlib is available like the compiler is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114115

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


[PATCH] D124534: Add a warning diagnostic for line directive of a gnu extension

2022-04-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added a comment.

Thank you for working on this new diagnostic!




Comment at: 
clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp:1
-
-// This file intentionally uses a CRLF newlines!
-
-void foo() {
-  int *x = 0;
-}
+
+// This file intentionally uses a CRLF newlines!

I think this file (and the next one) are making unintended line ending changes 
and should be reverted.



Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:430
 
+def warn_pp_gnu_ext_line_directive : Warning<"style of line directive is a GNU 
extension">;
+

Tweaking for grammar, but mostly, this should be marked as an `Extension` 
rather than a `Warning` so that it's controlled only via `-pedantic` rather 
than another warning group.



Comment at: clang/test/Misc/warning-flags.c:21
 
-CHECK: Warnings without flags (67):
+CHECK: Warnings without flags (68):
 

Once you make the diagnostic an extension, the changes to this file can be 
reverted. (It's worth noting that two lines above we document that this list 
should not grow.)



Comment at: clang/test/Preprocessor/line-directive.c:31
+# 42 // expected-warning {{style of line directive is a GNU extension}}
 # 42 "foo"
 # 42 "foo" 2 // expected-error {{invalid line marker flag '2': cannot pop 
empty include stack}}

This should get the same diagnostic.



Comment at: clang/test/Preprocessor/line-directive.c:33
 # 42 "foo" 2 // expected-error {{invalid line marker flag '2': cannot pop 
empty include stack}}
 # 42 "foo" 1 3  // enter
 # 42 "foo" 2 3  // exit

As should this form.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124534

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


[PATCH] D124545: [HIP] Add HIP runtime library arguments for linker

2022-04-27 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Driver/ToolChains/Linux.cpp:681
+ ArgStringList &CmdArgs) const {
+  CmdArgs.push_back(
+  Args.MakeArgString(StringRef("-L") + RocmInstallation.getLibPath()));

Nit: `CmdArgs.append({ ... })` to add all arguments at once would be a bit more 
readable (no `CmdArgs.push_back` littering space between args).


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

https://reviews.llvm.org/D124545

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


[PATCH] D124545: [HIP] Add HIP runtime library arguments for linker

2022-04-27 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/Linux.cpp:681
+ ArgStringList &CmdArgs) const {
+  CmdArgs.push_back(
+  Args.MakeArgString(StringRef("-L") + RocmInstallation.getLibPath()));

tra wrote:
> Nit: `CmdArgs.append({ ... })` to add all arguments at once would be a bit 
> more readable (no `CmdArgs.push_back` littering space between args).
will do when committing


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

https://reviews.llvm.org/D124545

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


[PATCH] D114115: [Driver] Support for compressed debug info on Fuchsia

2022-04-27 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

Lit is aware of zlib's presence or absence, you could use `REQUIRES: zlib` (or 
you might factor that bit out into its own test with the REQUIRES).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114115

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


[PATCH] D124220: [OpenMP] Add options to only compile the host or device when offloading

2022-04-27 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/include/clang/Driver/Options.td:2527
   HelpText<"Use the static host OpenMP runtime while linking.">;
+def offload_device_only : Flag<["-"], "offload-device-only">,
+  HelpText<"Only compile for the offloading device.">;

jhuber6 wrote:
> tra wrote:
> > We should be using "--" for the new options.
> What's the reason for preferring `--` over `-`? Is it just because `-o` can 
> bind to output?
Convention, I guess. Legacy (e.g. `-nostdlib` )  and single-letter options 
(e.g. `-o` `-m`, `-f` ) use single dash. Long options typically use double-dash.



Comment at: clang/lib/Driver/Driver.cpp:4215
Action *HostAction) const {
-  if (!isa(HostAction))
+  if (Args.hasArg(options::OPT_offload_host_only))
 return HostAction;

jhuber6 wrote:
> tra wrote:
> > This will not always be correct. E.g. `--offload-host-only 
> > --offload-host-device` would be true here, but we would still want to 
> > compile for both and device.
> > 
> > Is there a reason we can no longer rely on `HostAction`?
> Guess I should just use the last argument. Host action is used below, can 
> probably merge these if statements.
I guess the general idea is to avoid the ambiguity about what controls the 
behavior of the function. Is that the `Args`, or the `HostAction`?
Ideally I'd prefer to parse command line options once, save results somewhere 
we could use them and then use those flargs to control the behavior, regardless 
of which options were used to specify it. E.g. CUDA/HIPActionBuilder classes 
have these member fields:
```
  bool CompileHostOnly = false;
  bool CompileDeviceOnly = false;

...
  Arg *PartialCompilationArg = Args.getLastArg(
  options::OPT_cuda_host_only, options::OPT_cuda_device_only,
  options::OPT_cuda_compile_host_device);
  CompileHostOnly = PartialCompilationArg &&
PartialCompilationArg->getOption().matches(
options::OPT_cuda_host_only);
  CompileDeviceOnly = PartialCompilationArg &&
  PartialCompilationArg->getOption().matches(
  options::OPT_cuda_device_only);
...
```



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124220

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


[PATCH] D124221: Add new builtin __builtin_reflect_struct.

2022-04-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:420
+auto *FD = IFD ? IFD->getAnonField() : dyn_cast(D);
+if (!FD || (FD->isUnnamedBitfield() || FD->isAnonymousStructOrUnion()))
+  continue;

rsmith wrote:
> yihanaa wrote:
> > erichkeane wrote:
> > > rsmith wrote:
> > > > erichkeane wrote:
> > > > > rsmith wrote:
> > > > > > erichkeane wrote:
> > > > > > > rsmith wrote:
> > > > > > > > erichkeane wrote:
> > > > > > > > > Losing the unnamed bitfield is unfortunate, and I the 'dump 
> > > > > > > > > struct' handles.  As is losing the anonymous struct/union.
> > > > > > > > > 
> > > > > > > > > Also, how does this handle 'record type' members?  Does the 
> > > > > > > > > user have to know the inner type already?  If they already 
> > > > > > > > > know that much information about the type, they wouldn't 
> > > > > > > > > really need this, right?
> > > > > > > > If `__builtin_dump_struct` includes unnamed bitfields, that's a 
> > > > > > > > bug in that builtin.
> > > > > > > > 
> > > > > > > > In general, the user function gets given the bases and members 
> > > > > > > > with the right types, so they can use an overload set or a 
> > > > > > > > template to dispatch based on that type. See the SemaCXX test 
> > > > > > > > for a basic example of that.
> > > > > > > I thought it did?  For the use case I see `__builtin_dump_struct` 
> > > > > > > having, I would think printing the existence of unnamed bitfields 
> > > > > > > to be quite useful.
> > > > > > > 
> > > > > > > 
> > > > > > Why? They're not part of the value, they're just padding.
> > > > > They are lexically part of the type and are part of what makes up the 
> > > > > 'size' of the thing. I would expect something dumping the type to be 
> > > > > as consistent lexically as possible.
> > > > Looks like `__builtin_dump_struct` currently includes them *and* prints 
> > > > a value (whatever garbage happens to be in those padding bits). That's 
> > > > obviously a bug.
> > > O.o! Yeah, printing the value is nonsense.
> > I think the user should be informed somehow that there is an unnamed 
> > bitfield here
> It seems to me that `__builtin_dump_struct` is displaying the value of a 
> struct object, not the representation of the object, and unnamed bitfields 
> are not a part of the value, so should not be included. And I think it makes 
> sense for that builtin to be value-oriented: someone using it presumably 
> already knows whatever they want to know about the representation, to the 
> extent that it matters, or can look it up; what they don't know is the 
> information that varies from one instance to another. If we want a builtin 
> that's more oriented around showing the struct's memory representation, I 
> think we'd want quite a different output format, including offsets for fields 
> -- and even then I don't think it makes sense to include unnamed bit-fields 
> because they're not different from any other kind of padding in the object. 
> If we still want to print unnamed bit-fields for some reason, presumably we 
> should also print alignment and packing attributes and pragmas, because they 
> too can change the padding within a struct.
I tend to agree that `__builtin_dump_struct` should be focused on the values in 
the structure and not the representation.

However, keeping in mind that the original builtin was for kernel folks and the 
kernel tends to do some pretty interesting things (that aren't always supported 
by the standard), there's a part of me that wonders if they have a use case for 
unnamed bit-fields where they expect data to be squirreled away in those bits 
(through `memcpy()` or some other means) that they'd like to be able to read.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124221

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


[PATCH] D124373: [clang] add parameter pack/pack expansion matchers

2022-04-27 Thread Tobias Ribizel via Phabricator via cfe-commits
upsj added a comment.

This is part of my long-term goal to add support for forwarding parameters and 
documentation for make_unique-like functions to clangd. To be fair, the details 
are not entirely fleshed out - for inlay hints (displaying parameter names 
inline), the entire function template is already available in an instantiated 
form, so I can work with existing matchers. For signature help (displaying 
which parameters are available, which one is active while typing), IIRC you 
only have the template instantiation pattern available, so I need to find the 
necessary parts of the AST myself.

My thought was to try and move towards this goal in small steps, but if this is 
an important build time/size consideration, I can also see whether both of them 
are actually necessary (I suspect isParameterPack might not be) before moving 
forward?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124373

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


[PATCH] D124220: [OpenMP] Add options to only compile the host or device when offloading

2022-04-27 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:4215
Action *HostAction) const {
-  if (!isa(HostAction))
+  if (Args.hasArg(options::OPT_offload_host_only))
 return HostAction;

tra wrote:
> jhuber6 wrote:
> > tra wrote:
> > > This will not always be correct. E.g. `--offload-host-only 
> > > --offload-host-device` would be true here, but we would still want to 
> > > compile for both and device.
> > > 
> > > Is there a reason we can no longer rely on `HostAction`?
> > Guess I should just use the last argument. Host action is used below, can 
> > probably merge these if statements.
> I guess the general idea is to avoid the ambiguity about what controls the 
> behavior of the function. Is that the `Args`, or the `HostAction`?
> Ideally I'd prefer to parse command line options once, save results somewhere 
> we could use them and then use those flargs to control the behavior, 
> regardless of which options were used to specify it. E.g. 
> CUDA/HIPActionBuilder classes have these member fields:
> ```
>   bool CompileHostOnly = false;
>   bool CompileDeviceOnly = false;
> 
> ...
>   Arg *PartialCompilationArg = Args.getLastArg(
>   options::OPT_cuda_host_only, options::OPT_cuda_device_only,
>   options::OPT_cuda_compile_host_device);
>   CompileHostOnly = PartialCompilationArg &&
> PartialCompilationArg->getOption().matches(
> options::OPT_cuda_host_only);
>   CompileDeviceOnly = PartialCompilationArg &&
>   PartialCompilationArg->getOption().matches(
>   options::OPT_cuda_device_only);
> ...
> ```
> 
I more or less copied that below, but I suppose we are recalculating them each 
phase. We don't have a monolithic class with my new implementation, but I 
suppose I could add these to the Compilation or something if we don't want to 
recalculate it. Beside that, does anything else seem amiss?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124220

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


[clang] 5e096ce - Update PGO and 3-stage cache files

2022-04-27 Thread Chris Bieneman via cfe-commits

Author: Chris Bieneman
Date: 2022-04-27T14:41:56-05:00
New Revision: 5e096ce6c84fe80a15158dd10d3a23fb7135aa6d

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

LOG: Update PGO and 3-stage cache files

These files are out of date and haven't been updated to work within the
monorepo. This change updates them appropriately so that they build
using the monorepo build infrastructure.

Added: 


Modified: 
clang/cmake/caches/3-stage-base.cmake
clang/cmake/caches/PGO-stage2.cmake
clang/cmake/caches/PGO.cmake

Removed: 




diff  --git a/clang/cmake/caches/3-stage-base.cmake 
b/clang/cmake/caches/3-stage-base.cmake
index 31391aa4defce..63a1c21528dc9 100644
--- a/clang/cmake/caches/3-stage-base.cmake
+++ b/clang/cmake/caches/3-stage-base.cmake
@@ -1,6 +1,8 @@
 set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "")
 set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
-set(LLVM_BUILD_EXTERNAL_COMPILER_RT ON CACHE BOOL "")
+
+set(LLVM_ENABLE_PROJECTS "clang;lld" CACHE STRING "")
+set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi" CACHE STRING "")
 
 if(APPLE)
   # Use LLD to have fewer requirements on system linker, unless we're on an 
apple

diff  --git a/clang/cmake/caches/PGO-stage2.cmake 
b/clang/cmake/caches/PGO-stage2.cmake
index 2080cd405f2a6..b9b2f62e9cae4 100644
--- a/clang/cmake/caches/PGO-stage2.cmake
+++ b/clang/cmake/caches/PGO-stage2.cmake
@@ -1,2 +1,3 @@
 set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "")
-set(LLVM_BUILD_EXTERNAL_COMPILER_RT ON CACHE BOOL "")
+set(LLVM_ENABLE_PROJECTS "clang;lld" CACHE STRING "")
+set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi" CACHE STRING "")

diff  --git a/clang/cmake/caches/PGO.cmake b/clang/cmake/caches/PGO.cmake
index 7e4a001129cb9..e1d0585e453f8 100644
--- a/clang/cmake/caches/PGO.cmake
+++ b/clang/cmake/caches/PGO.cmake
@@ -1,8 +1,10 @@
 set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "")
 set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
-set(LLVM_BUILD_EXTERNAL_COMPILER_RT ON CACHE BOOL "")
 
-set(LLVM_TARGETS_TO_BUILD X86 CACHE STRING "")
+set(LLVM_ENABLE_PROJECTS "clang;lld" CACHE STRING "")
+set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi" CACHE STRING "")
+
+set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
 set(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED ON CACHE BOOL "")
 set(CLANG_BOOTSTRAP_TARGETS
   generate-profdata



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


[PATCH] D124373: [clang] add parameter pack/pack expansion matchers

2022-04-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D124373#3477996 , @upsj wrote:

> This is part of my long-term goal to add support for forwarding parameters 
> and documentation for make_unique-like functions to clangd. To be fair, the 
> details are not entirely fleshed out - for inlay hints (displaying parameter 
> names inline), the entire function template is already available in an 
> instantiated form, so I can work with existing matchers. For signature help 
> (displaying which parameters are available, which one is active while 
> typing), IIRC you only have the template instantiation pattern available, so 
> I need to find the necessary parts of the AST myself.

Ah, thank you for the background information!

> My thought was to try and move towards this goal in small steps, but if this 
> is an important build time/size consideration, I can also see whether both of 
> them are actually necessary (I suspect isParameterPack might not be) before 
> moving forward?

We support locally defined matchers so that you can still use all the AST 
matching awesomeness, but without increasing the compile times for everyone for 
one-off matchers. e.g,., 
https://github.com/llvm/llvm-project/blob/c874dd53628db8170d4c5ba3878817abc385a695/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStatic.cpp#L23
  My recommendation is to do something similar for clangd, but once we find a 
second use for the matcher, we can go ahead and hoist it into ASTMatchers.h at 
that point. WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124373

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


[PATCH] D124373: [clang] add parameter pack/pack expansion matchers

2022-04-27 Thread Tobias Ribizel via Phabricator via cfe-commits
upsj planned changes to this revision.
upsj added a comment.

I wasn't aware of that, sounds perfect, thanks! Then I'll put this on hold 
until I figure out if it's really necessary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124373

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


[PATCH] D123958: [randstruct] Randomize all elements of a record

2022-04-27 Thread Bill Wendling via Phabricator via cfe-commits
void updated this revision to Diff 425593.
void marked 2 inline comments as done.
void added a comment.

Add a few more tests and remove a dead check.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123958

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/Randstruct.h
  clang/lib/AST/Decl.cpp
  clang/lib/AST/Randstruct.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/test/Sema/init-randomized-struct.c
  clang/unittests/AST/RandstructTest.cpp

Index: clang/unittests/AST/RandstructTest.cpp
===
--- clang/unittests/AST/RandstructTest.cpp
+++ clang/unittests/AST/RandstructTest.cpp
@@ -132,6 +132,12 @@
 namespace clang {
 namespace ast_matchers {
 
+long declCount(const RecordDecl *RD) {
+  return llvm::count_if(RD->decls(), [&](const Decl *D) {
+return isa(D) || isa(D);
+  });
+}
+
 #define RANDSTRUCT_TEST_SUITE_TEST RecordLayoutRandomizationTestSuiteTest
 
 TEST(RANDSTRUCT_TEST_SUITE_TEST, CanDetermineIfSubsequenceExists) {
@@ -159,9 +165,11 @@
   EXPECT_FALSE(AST->getDiagnostics().hasErrorOccurred());
 
   const RecordDecl *RD = getRecordDeclFromAST(AST->getASTContext(), "test");
+  long OriginalDeclCount = declCount(RD);
 
   EXPECT_FALSE(RD->hasAttr());
   EXPECT_FALSE(RD->isRandomized());
+  EXPECT_EQ(OriginalDeclCount, declCount(RD));
 }
 
 TEST(RANDSTRUCT_TEST, MarkedNoRandomize) {
@@ -177,9 +185,11 @@
   EXPECT_FALSE(AST->getDiagnostics().hasErrorOccurred());
 
   const RecordDecl *RD = getRecordDeclFromAST(AST->getASTContext(), "test");
+  long OriginalDeclCount = declCount(RD);
 
   EXPECT_TRUE(RD->hasAttr());
   EXPECT_FALSE(RD->isRandomized());
+  EXPECT_EQ(OriginalDeclCount, declCount(RD));
 }
 
 TEST(RANDSTRUCT_TEST, MarkedRandomize) {
@@ -195,9 +205,11 @@
   EXPECT_FALSE(AST->getDiagnostics().hasErrorOccurred());
 
   const RecordDecl *RD = getRecordDeclFromAST(AST->getASTContext(), "test");
+  long OriginalDeclCount = declCount(RD);
 
   EXPECT_TRUE(RD->hasAttr());
   EXPECT_TRUE(RD->isRandomized());
+  EXPECT_EQ(OriginalDeclCount, declCount(RD));
 }
 
 TEST(RANDSTRUCT_TEST, MismatchedAttrsDeclVsDef) {
@@ -280,19 +292,27 @@
   EXPECT_FALSE(AST->getDiagnostics().hasErrorOccurred());
 
   const RecordDecl *RD = getRecordDeclFromAST(AST->getASTContext(), "test");
+  long OriginalDeclCount = declCount(RD);
+
   const field_names Actual = getFieldNamesFromRecord(RD);
   const field_names Subseq = {"x", "y", "z"};
 
   EXPECT_TRUE(RD->isRandomized());
   EXPECT_TRUE(isSubsequence(Actual, Subseq));
+  EXPECT_EQ(OriginalDeclCount, declCount(RD));
 }
 
-TEST(RANDSTRUCT_TEST, CheckVariableLengthArrayMemberRemainsAtEndOfStructure) {
+TEST(RANDSTRUCT_TEST, CheckFlexibleArrayMemberRemainsAtEndOfStructure1) {
   std::unique_ptr AST = makeAST(R"c(
 struct test {
 int a;
-double b;
-short c;
+int b;
+int c;
+int d;
+int e;
+int f;
+int g;
+int h;
 char name[];
 } __attribute__((randomize_layout));
   )c");
@@ -300,8 +320,64 @@
   EXPECT_FALSE(AST->getDiagnostics().hasErrorOccurred());
 
   const RecordDecl *RD = getRecordDeclFromAST(AST->getASTContext(), "test");
+  long OriginalDeclCount = declCount(RD);
 
+  EXPECT_TRUE(RD->hasFlexibleArrayMember());
   EXPECT_TRUE(RD->isRandomized());
+  EXPECT_EQ(OriginalDeclCount, declCount(RD));
+  EXPECT_EQ(getFieldNamesFromRecord(RD).back(), "name");
+}
+
+TEST(RANDSTRUCT_TEST, CheckFlexibleArrayMemberRemainsAtEndOfStructure2) {
+  std::unique_ptr AST = makeAST(R"c(
+struct test {
+int a;
+int b;
+int c;
+int d;
+int e;
+int f;
+int g;
+int h;
+char name[0];
+} __attribute__((randomize_layout));
+  )c");
+
+  EXPECT_FALSE(AST->getDiagnostics().hasErrorOccurred());
+
+  const RecordDecl *RD = getRecordDeclFromAST(AST->getASTContext(), "test");
+  long OriginalDeclCount = declCount(RD);
+
+  EXPECT_FALSE(RD->hasFlexibleArrayMember());
+  EXPECT_TRUE(RD->isRandomized());
+  EXPECT_EQ(OriginalDeclCount, declCount(RD));
+  EXPECT_EQ(getFieldNamesFromRecord(RD).back(), "name");
+}
+
+TEST(RANDSTRUCT_TEST, CheckFlexibleArrayMemberRemainsAtEndOfStructure3) {
+  std::unique_ptr AST = makeAST(R"c(
+struct test {
+int a;
+int b;
+int c;
+int d;
+int e;
+int f;
+int g;
+int h;
+char name[1];
+} __attribute__((randomize_layout));
+  )c");
+
+  EXPECT_FALSE(AST->getDiagnostics().hasErrorOccurred());
+
+  const RecordDecl *RD = getRecordDeclFromAST(AST->getASTContext(), "test");
+  long OriginalDeclCount = declCount(RD);
+
+  EXPECT_FALSE(RD->hasFlexibleArrayMember());
+  EXPECT_TRUE(RD->isRandomized());
+  EXPECT_EQ(OriginalDeclCount, declCount(RD));
+  EXPECT_EQ(getFieldNamesFromRecord(RD).back(), "name");
 }
 
 TEST(RANDSTRUCT_TEST, Randstr

[PATCH] D123958: [randstruct] Randomize all elements of a record

2022-04-27 Thread Bill Wendling via Phabricator via cfe-commits
void added inline comments.



Comment at: clang/lib/AST/Randstruct.cpp:201
+dyn_cast(RandomizedFields.back()->getType()))
+  if (CA->getSize().sle(2) || CA->isIncompleteArrayType())
+FlexibleArray = RandomizedFields.pop_back_val();

aaron.ballman wrote:
> CA->isIncompleteArrayType() looks to be at the wrong spot. An incomplete 
> array type is one of type `IncompleteArrayType`, which a `ConstantArrayType` 
> is not. Are we missing test coverage, or does the `hasFlexibleArrayMember()` 
> make it so that we just need to remove this check entirely?
It looks like if it's an `IncompleteArrayType`, then it will be captured by 
`hasFlexibleArrayMember`. I think we can do without the check here. (It doesn't 
hurt, because it should always return `false`.)



Comment at: clang/unittests/AST/RandstructTest.cpp:368
+int h;
+char name[0];
+} __attribute__((randomize_layout));

aaron.ballman wrote:
> Can you add a test where the last field is `char name[1];` and another one 
> for `char name[];` so that we have full coverage there?
The `name[]` is above this test. The `name[1]` is due to a copy-paste error 
(oops). Fixed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123958

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


[PATCH] D124551: [Driver] Add f16 support to -mrecip parsing.

2022-04-27 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: spatel, efriedma, RKSimon.
Herald added a subscriber: StephenFan.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added a subscriber: MaskRay.
Herald added a project: clang.

This is a followup to D120158  which added an 
'h' suffix to the
backend handling.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124551

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/attr-mrecip.c
  clang/test/Driver/mrecip.c

Index: clang/test/Driver/mrecip.c
===
--- clang/test/Driver/mrecip.c
+++ clang/test/Driver/mrecip.c
@@ -37,6 +37,9 @@
 // RUN: %clang -### -S %s -mrecip=divf,sqrtd,vec-divd,vec-sqrtf  2>&1 | FileCheck --check-prefix=RECIP8 %s
 // RECIP8: "-mrecip=divf,sqrtd,vec-divd,vec-sqrtf"
 
+// RUN: %clang -### -S %s -mrecip=vec-sqrth  2>&1 | FileCheck --check-prefix=RECIP18 %s
+// RECIP18: "-mrecip=vec-sqrth"
+
  Check optional refinement step specifiers.
 
 // RUN: %clang -### -S %s -mrecip=all:1  2>&1 | FileCheck --check-prefix=RECIP9 %s
@@ -51,6 +54,9 @@
 // RUN: %clang -### -S %s -mrecip=divd:1,!sqrtf:2,vec-divf:9,vec-sqrtd:0  2>&1 | FileCheck --check-prefix=RECIP12 %s
 // RECIP12: "-mrecip=divd:1,!sqrtf:2,vec-divf:9,vec-sqrtd:0"
 
+// RUN: %clang -### -S %s -mrecip=sqrth:2  2>&1 | FileCheck --check-prefix=RECIP19 %s
+// RECIP19: "-mrecip=sqrth:2"
+
  Check invalid parameters.
 
 // RUN: %clang -### -S %s -mrecip=bogus  2>&1 | FileCheck --check-prefix=RECIP13 %s
@@ -68,3 +74,11 @@
 // RUN: %clang -### -S %s -mrecip=!vec-divd:  2>&1 | FileCheck --check-prefix=RECIP17 %s
 // RECIP17: error: invalid value 
 
+// RUN: %clang -### -S %s -mrecip=divh:1,divh  2>&1 | FileCheck --check-prefix=RECIP20 %s
+// RECIP20: error: invalid value 
+
+// RUN: %clang -### -S %s -mrecip=divh,div  2>&1 | FileCheck --check-prefix=RECIP21 %s
+// RECIP21: error: invalid value 
+
+// RUN: %clang -### -S %s -mrecip=sqrt,sqrth  2>&1 | FileCheck --check-prefix=RECIP22 %s
+// RECIP22: error: invalid value 
Index: clang/test/CodeGen/attr-mrecip.c
===
--- clang/test/CodeGen/attr-mrecip.c
+++ clang/test/CodeGen/attr-mrecip.c
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -mrecip=!sqrtf,vec-divf:3 -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -mrecip=!sqrtf,vec-divf:3,divh -emit-llvm %s -o - | FileCheck %s
 
 int baz(int a) { return 4; }
 
 // CHECK: baz{{.*}} #0
-// CHECK: #0 = {{.*}}"reciprocal-estimates"="!sqrtf,vec-divf:3"
+// CHECK: #0 = {{.*}}"reciprocal-estimates"="!sqrtf,vec-divf:3,divh"
 
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -226,12 +226,16 @@
   llvm::StringMap OptionStrings;
   OptionStrings.insert(std::make_pair("divd", false));
   OptionStrings.insert(std::make_pair("divf", false));
+  OptionStrings.insert(std::make_pair("divh", false));
   OptionStrings.insert(std::make_pair("vec-divd", false));
   OptionStrings.insert(std::make_pair("vec-divf", false));
+  OptionStrings.insert(std::make_pair("vec-divh", false));
   OptionStrings.insert(std::make_pair("sqrtd", false));
   OptionStrings.insert(std::make_pair("sqrtf", false));
+  OptionStrings.insert(std::make_pair("sqrth", false));
   OptionStrings.insert(std::make_pair("vec-sqrtd", false));
   OptionStrings.insert(std::make_pair("vec-sqrtf", false));
+  OptionStrings.insert(std::make_pair("vec-sqrth", false));
 
   for (unsigned i = 0; i != NumOptions; ++i) {
 StringRef Val = A->getValue(i);
@@ -255,10 +259,11 @@
 D.Diag(diag::err_drv_unknown_argument) << Val;
 return;
   }
-  // The option was specified without a float or double suffix.
-  // Make sure that the double entry was not already specified.
+  // The option was specified without a half or float or double suffix.
+  // Make sure that the double or half entry was not already specified.
   // The float entry will be checked below.
-  if (OptionStrings[ValBase.str() + 'd']) {
+  if (OptionStrings[ValBase.str() + 'd'] ||
+  OptionStrings[ValBase.str() + 'h']) {
 D.Diag(diag::err_drv_invalid_value) << A->getOption().getName() << Val;
 return;
   }
@@ -273,9 +278,12 @@
 // Mark the matched option as found. Do not allow duplicate specifiers.
 OptionIter->second = true;
 
-// If the precision was not specified, also mark the double entry as found.
-if (ValBase.back() != 'f' && ValBase.back() != 'd')
+// If the precision was not specified, also mark the double and half entry
+// as found.
+if (ValBase.back() != 'f' && ValBase.back() != 'd' && ValBase.back() != 'h') {
   OptionStrings[ValBase.str() + 'd'] = true;
+  OptionStrings[ValBase.str() + 'h'] = true;
+

[PATCH] D123958: [randstruct] Randomize all elements of a record

2022-04-27 Thread Bill Wendling via Phabricator via cfe-commits
void updated this revision to Diff 425595.
void added a comment.

Fix test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123958

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/Randstruct.h
  clang/lib/AST/Decl.cpp
  clang/lib/AST/Randstruct.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/test/Sema/init-randomized-struct.c
  clang/unittests/AST/RandstructTest.cpp

Index: clang/unittests/AST/RandstructTest.cpp
===
--- clang/unittests/AST/RandstructTest.cpp
+++ clang/unittests/AST/RandstructTest.cpp
@@ -132,6 +132,12 @@
 namespace clang {
 namespace ast_matchers {
 
+long declCount(const RecordDecl *RD) {
+  return llvm::count_if(RD->decls(), [&](const Decl *D) {
+return isa(D) || isa(D);
+  });
+}
+
 #define RANDSTRUCT_TEST_SUITE_TEST RecordLayoutRandomizationTestSuiteTest
 
 TEST(RANDSTRUCT_TEST_SUITE_TEST, CanDetermineIfSubsequenceExists) {
@@ -159,9 +165,11 @@
   EXPECT_FALSE(AST->getDiagnostics().hasErrorOccurred());
 
   const RecordDecl *RD = getRecordDeclFromAST(AST->getASTContext(), "test");
+  long OriginalDeclCount = declCount(RD);
 
   EXPECT_FALSE(RD->hasAttr());
   EXPECT_FALSE(RD->isRandomized());
+  EXPECT_EQ(OriginalDeclCount, declCount(RD));
 }
 
 TEST(RANDSTRUCT_TEST, MarkedNoRandomize) {
@@ -177,9 +185,11 @@
   EXPECT_FALSE(AST->getDiagnostics().hasErrorOccurred());
 
   const RecordDecl *RD = getRecordDeclFromAST(AST->getASTContext(), "test");
+  long OriginalDeclCount = declCount(RD);
 
   EXPECT_TRUE(RD->hasAttr());
   EXPECT_FALSE(RD->isRandomized());
+  EXPECT_EQ(OriginalDeclCount, declCount(RD));
 }
 
 TEST(RANDSTRUCT_TEST, MarkedRandomize) {
@@ -195,9 +205,11 @@
   EXPECT_FALSE(AST->getDiagnostics().hasErrorOccurred());
 
   const RecordDecl *RD = getRecordDeclFromAST(AST->getASTContext(), "test");
+  long OriginalDeclCount = declCount(RD);
 
   EXPECT_TRUE(RD->hasAttr());
   EXPECT_TRUE(RD->isRandomized());
+  EXPECT_EQ(OriginalDeclCount, declCount(RD));
 }
 
 TEST(RANDSTRUCT_TEST, MismatchedAttrsDeclVsDef) {
@@ -280,19 +292,27 @@
   EXPECT_FALSE(AST->getDiagnostics().hasErrorOccurred());
 
   const RecordDecl *RD = getRecordDeclFromAST(AST->getASTContext(), "test");
+  long OriginalDeclCount = declCount(RD);
+
   const field_names Actual = getFieldNamesFromRecord(RD);
   const field_names Subseq = {"x", "y", "z"};
 
   EXPECT_TRUE(RD->isRandomized());
   EXPECT_TRUE(isSubsequence(Actual, Subseq));
+  EXPECT_EQ(OriginalDeclCount, declCount(RD));
 }
 
-TEST(RANDSTRUCT_TEST, CheckVariableLengthArrayMemberRemainsAtEndOfStructure) {
+TEST(RANDSTRUCT_TEST, CheckFlexibleArrayMemberRemainsAtEndOfStructure1) {
   std::unique_ptr AST = makeAST(R"c(
 struct test {
 int a;
-double b;
-short c;
+int b;
+int c;
+int d;
+int e;
+int f;
+int g;
+int h;
 char name[];
 } __attribute__((randomize_layout));
   )c");
@@ -300,8 +320,64 @@
   EXPECT_FALSE(AST->getDiagnostics().hasErrorOccurred());
 
   const RecordDecl *RD = getRecordDeclFromAST(AST->getASTContext(), "test");
+  long OriginalDeclCount = declCount(RD);
 
+  EXPECT_TRUE(RD->hasFlexibleArrayMember());
   EXPECT_TRUE(RD->isRandomized());
+  EXPECT_EQ(OriginalDeclCount, declCount(RD));
+  EXPECT_EQ(getFieldNamesFromRecord(RD).back(), "name");
+}
+
+TEST(RANDSTRUCT_TEST, CheckFlexibleArrayMemberRemainsAtEndOfStructure2) {
+  std::unique_ptr AST = makeAST(R"c(
+struct test {
+int a;
+int b;
+int c;
+int d;
+int e;
+int f;
+int g;
+int h;
+char name[0];
+} __attribute__((randomize_layout));
+  )c");
+
+  EXPECT_FALSE(AST->getDiagnostics().hasErrorOccurred());
+
+  const RecordDecl *RD = getRecordDeclFromAST(AST->getASTContext(), "test");
+  long OriginalDeclCount = declCount(RD);
+
+  EXPECT_FALSE(RD->hasFlexibleArrayMember());
+  EXPECT_TRUE(RD->isRandomized());
+  EXPECT_EQ(OriginalDeclCount, declCount(RD));
+  EXPECT_EQ(getFieldNamesFromRecord(RD).back(), "name");
+}
+
+TEST(RANDSTRUCT_TEST, CheckFlexibleArrayMemberRemainsAtEndOfStructure3) {
+  std::unique_ptr AST = makeAST(R"c(
+struct test {
+int a;
+int b;
+int c;
+int d;
+int e;
+int f;
+int g;
+int h;
+char name[1];
+} __attribute__((randomize_layout));
+  )c");
+
+  EXPECT_FALSE(AST->getDiagnostics().hasErrorOccurred());
+
+  const RecordDecl *RD = getRecordDeclFromAST(AST->getASTContext(), "test");
+  long OriginalDeclCount = declCount(RD);
+
+  EXPECT_FALSE(RD->hasFlexibleArrayMember());
+  EXPECT_TRUE(RD->isRandomized());
+  EXPECT_EQ(OriginalDeclCount, declCount(RD));
+  EXPECT_EQ(getFieldNamesFromRecord(RD).back(), "name");
 }
 
 TEST(RANDSTRUCT_TEST, RandstructDoesNotOverrideThePackedAttr) {
@@ -340,9 +416,11 @@
 getRecordD

[PATCH] D95063: AMDGPU: Use optimization remarks for register usage

2022-04-27 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm abandoned this revision.
arsenm added a comment.
Herald added subscribers: hsmhsm, foad.
Herald added a project: All.

Obsoleted by D123878 


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

https://reviews.llvm.org/D95063

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


[clang] fd0e60d - [PS5] Test sanitizer options/lib names

2022-04-27 Thread Paul Robinson via cfe-commits

Author: Paul Robinson
Date: 2022-04-27T13:45:41-07:00
New Revision: fd0e60d7874363a641e35a862b05d8dfabab77ef

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

LOG: [PS5] Test sanitizer options/lib names

The functionality was added in 7726ad0, catching up on the tests now.

Added: 


Modified: 
clang/test/Driver/fsanitize.c
clang/test/Driver/sanitizer-ld.c

Removed: 




diff  --git a/clang/test/Driver/fsanitize.c b/clang/test/Driver/fsanitize.c
index f31e6156120fd..c6135f88541b6 100644
--- a/clang/test/Driver/fsanitize.c
+++ b/clang/test/Driver/fsanitize.c
@@ -783,6 +783,29 @@
 // RUN: %clang -target x86_64-scei-ps4 -fsanitize=address -nodefaultlibs 
-nostdlib  %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-NOLIB-PS4
 // CHECK-ASAN-NOLIB-PS4-NOT: SceDbgAddressSanitizer_stub_weak
 
+// RUN: %clang -target x86_64-sie-ps5 -fsanitize=address %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-ASAN-PS5
+// Make sure there are no *.{o,bc} or -l passed before the ASan library.
+// CHECK-ASAN-PS5-NOT: {{(\.(o|bc)"? 
|-l).*-lSceAddressSanitizer_nosubmission_stub_weak}}
+// CHECK-ASAN-PS5: 
--dependent-lib=libSceAddressSanitizer_nosubmission_stub_weak.a
+// CHECK-ASAN-PS5-NOT: {{(\.(o|bc)"? 
|-l).*-lSceAddressSanitizer_nosubmission_stub_weak}}
+// CHECK-ASAN-PS5: -lSceAddressSanitizer_nosubmission_stub_weak
+// RUN: %clang -target x86_64-sie-ps5 -fsanitize=address -nostdlib %s -### 
2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-NOLIB-PS5
+// RUN: %clang -target x86_64-sie-ps5 -fsanitize=address -nodefaultlibs %s 
-### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-NOLIB-PS5
+// RUN: %clang -target x86_64-sie-ps5 -fsanitize=address -nodefaultlibs 
-nostdlib  %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-NOLIB-PS5
+// CHECK-ASAN-NOLIB-PS5-NOT: SceAddressSanitizer_nosubmission_stub_weak
+
+// RUN: %clang -target x86_64-sie-ps5 -fsanitize=thread %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-TSAN-PS5
+// Make sure there are no *.{o,bc} or -l passed before the TSan library.
+// CHECK-TSAN-PS5-NOT: {{(\.(o|bc)"? 
|-l).*-lSceThreadSanitizer_nosubmission_stub_weak}}
+// CHECK-TSAN-PS5: 
--dependent-lib=libSceThreadSanitizer_nosubmission_stub_weak.a
+// CHECK-TSAN-PS5-NOT: {{(\.(o|bc)"? 
|-l).*-lSceThreadSanitizer_nosubmission_stub_weak}}
+// CHECK-TSAN-PS5: -lSceThreadSanitizer_nosubmission_stub_weak
+// RUN: %clang -target x86_64-sie-ps5 -fsanitize=thread -nostdlib %s -### 2>&1 
| FileCheck %s --check-prefix=CHECK-TSAN-NOLIB-PS5
+// RUN: %clang -target x86_64-sie-ps5 -fsanitize=thread -nodefaultlibs %s -### 
2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-NOLIB-PS5
+// RUN: %clang -target x86_64-sie-ps5 -fsanitize=thread -nodefaultlibs 
-nostdlib  %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-NOLIB-PS5
+// CHECK-TSAN-NOLIB-PS5-NOT: SceThreadSanitizer_nosubmission_stub_weak
+
+
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-minimal-runtime %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-ASAN-MINIMAL
 // CHECK-ASAN-MINIMAL: error: invalid argument '-fsanitize-minimal-runtime' 
not allowed with '-fsanitize=address'
 

diff  --git a/clang/test/Driver/sanitizer-ld.c 
b/clang/test/Driver/sanitizer-ld.c
index 966edbd7d038b..def3ef967a46e 100644
--- a/clang/test/Driver/sanitizer-ld.c
+++ b/clang/test/Driver/sanitizer-ld.c
@@ -759,6 +759,14 @@
 // CHECK-UBSAN-PS4: "{{.*}}ld{{(.gold)?(.exe)?}}"
 // CHECK-UBSAN-PS4: -lSceDbgUBSanitizer_stub_weak
 
+// RUN: %clang -fsanitize=undefined %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-sie-ps5 -fuse-ld=ld \
+// RUN: -shared \
+// RUN:   | FileCheck --check-prefix=CHECK-UBSAN-PS5 %s
+// CHECK-UBSAN-PS5: --dependent-lib=libSceUBSanitizer_nosubmission_stub_weak.a
+// CHECK-UBSAN-PS5: "{{.*}}ld{{(.gold)?(.exe)?}}"
+// CHECK-UBSAN-PS5: -lSceUBSanitizer_nosubmission_stub_weak
+
 // RUN: %clang -fsanitize=address %s -### -o %t.o 2>&1 \
 // RUN: -target x86_64-scei-ps4 -fuse-ld=ld \
 // RUN: -shared \
@@ -767,6 +775,14 @@
 // CHECK-ASAN-PS4: "{{.*}}ld{{(.gold)?(.exe)?}}"
 // CHECK-ASAN-PS4: -lSceDbgAddressSanitizer_stub_weak
 
+// RUN: %clang -fsanitize=address %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-sie-ps5 -fuse-ld=ld \
+// RUN: -shared \
+// RUN:   | FileCheck --check-prefix=CHECK-ASAN-PS5 %s
+// CHECK-ASAN-PS5: 
--dependent-lib=libSceAddressSanitizer_nosubmission_stub_weak.a
+// CHECK-ASAN-PS5: "{{.*}}ld{{(.gold)?(.exe)?}}"
+// CHECK-ASAN-PS5: -lSceAddressSanitizer_nosubmission_stub_weak
+
 // RUN: %clang -fsanitize=address,undefined %s -### -o %t.o 2>&1 \
 // RUN: -target x86_64-scei-ps4 -fuse-ld=ld \
 // RUN: -shared \
@@ -777,6 +793,16 @@
 // CHECK-AUBSAN-PS4: "{{.*}}ld{{(.gold)?(.exe)?}}"
 // CHECK-AUBSAN-PS4: -lSceDbgAddressSanitizer_stub_weak
 
+// RUN: %clang -fsaniti

[PATCH] D124534: Add a warning diagnostic for line directive of a gnu extension

2022-04-27 Thread Ken Matsui via Phabricator via cfe-commits
ken-matsui updated this revision to Diff 425601.
ken-matsui added a comment.

Add a diagnostic for line directive of a gnu extension


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124534

Files:
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/lib/Lex/PPDirectives.cpp
  clang/test/Misc/warning-flags.c
  clang/test/Preprocessor/line-directive.c


Index: clang/test/Preprocessor/line-directive.c
===
--- clang/test/Preprocessor/line-directive.c
+++ clang/test/Preprocessor/line-directive.c
@@ -27,8 +27,8 @@
 #define A 42 "foo"
 #line A
 
-# 42
-# 42 "foo"
+# 42 // expected-warning {{this style of line directive is a GNU extension}}
+# 42 "foo" // expected-warning {{this style of line directive is a GNU 
extension}}
 # 42 "foo" 2 // expected-error {{invalid line marker flag '2': cannot pop 
empty include stack}}
 # 42 "foo" 1 3  // enter
 # 42 "foo" 2 3  // exit
@@ -97,7 +97,7 @@
 #line 010  // expected-warning {{#line directive interprets number as decimal, 
not octal}}
 extern int array[__LINE__ == 10 ? 1:-1];
 
-# 020  // expected-warning {{GNU line marker directive interprets number 
as decimal, not octal}}
+# 020  // expected-warning {{GNU line marker directive interprets number 
as decimal, not octal}} expected-warning {{this style of line directive is a 
GNU extension}}
 extern int array_gnuline[__LINE__ == 20 ? 1:-1];
 
 /* PR3917 */
@@ -106,7 +106,7 @@
 _\
 _LINE__ == 42 ? 1: -1];  /* line marker is location of first _ */
 
-# 51
+# 51 // expected-warning {{this style of line directive is a GNU extension}}
 extern char array2_gnuline[\
 _\
 _LINE__ == 52 ? 1: -1];  /* line marker is location of first _ */
@@ -115,7 +115,7 @@
 #line 0 "line-directive.c" // expected-warning {{#line directive with zero 
argument is a GNU extension}}
 undefined t; // expected-error {{unknown type name 'undefined'}}
 
-# 115 "main"
+# 115 "main" // expected-warning {{this style of line directive is a GNU 
extension}}
 # 116 "enter-1" 1
 # 117 "enter-2" 1
 # 118 "" 2 // pop to enter-1
Index: clang/test/Misc/warning-flags.c
===
--- clang/test/Misc/warning-flags.c
+++ clang/test/Misc/warning-flags.c
@@ -90,4 +90,4 @@
 
 The list of warnings in -Wpedantic should NEVER grow.
 
-CHECK: Number in -Wpedantic (not covered by other -W flags): 27
+CHECK: Number in -Wpedantic (not covered by other -W flags): 28
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -1335,7 +1335,10 @@
   unsigned FlagVal;
   Token FlagTok;
   PP.Lex(FlagTok);
-  if (FlagTok.is(tok::eod)) return false;
+  if (FlagTok.is(tok::eod)) {
+PP.Diag(FlagTok, diag::ext_pp_gnu_line_directive);
+return false;
+  }
   if (GetLineValue(FlagTok, FlagVal, diag::err_pp_linemarker_invalid_flag, PP))
 return true;
 
@@ -1431,6 +1434,7 @@
   // If the StrTok is "eod", then it wasn't present.  Otherwise, it must be a
   // string followed by eod.
   if (StrTok.is(tok::eod)) {
+Diag(StrTok, diag::ext_pp_gnu_line_directive);
 // Treat this like "#line NN", which doesn't change file characteristics.
 FileKind = SourceMgr.getFileCharacteristic(DigitTok.getLocation());
   } else if (StrTok.isNot(tok::string_literal)) {
Index: clang/include/clang/Basic/DiagnosticLexKinds.td
===
--- clang/include/clang/Basic/DiagnosticLexKinds.td
+++ clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -427,6 +427,9 @@
 def ext_pp_opencl_variadic_macros : Extension<
   "variadic macros are a Clang extension in OpenCL">;
 
+def ext_pp_gnu_line_directive : Extension<
+  "this style of line directive is a GNU extension">;
+
 def err_pp_invalid_directive : Error<"invalid preprocessing directive">;
 def err_pp_directive_required : Error<
   "%0 must be used within a preprocessing directive">;


Index: clang/test/Preprocessor/line-directive.c
===
--- clang/test/Preprocessor/line-directive.c
+++ clang/test/Preprocessor/line-directive.c
@@ -27,8 +27,8 @@
 #define A 42 "foo"
 #line A
 
-# 42
-# 42 "foo"
+# 42 // expected-warning {{this style of line directive is a GNU extension}}
+# 42 "foo" // expected-warning {{this style of line directive is a GNU extension}}
 # 42 "foo" 2 // expected-error {{invalid line marker flag '2': cannot pop empty include stack}}
 # 42 "foo" 1 3  // enter
 # 42 "foo" 2 3  // exit
@@ -97,7 +97,7 @@
 #line 010  // expected-warning {{#line directive interprets number as decimal, not octal}}
 extern int array[__LINE__ == 10 ? 1:-1];
 
-# 020  // expected-warning {{GNU line marker directive interprets number as decimal, not octal}}
+# 020  // expected-warning {{GNU line marker di

[PATCH] D124534: Add a warning diagnostic for line directive of a gnu extension

2022-04-27 Thread Ken Matsui via Phabricator via cfe-commits
ken-matsui added a comment.

Hi @aaron.ballman,

Thank you for your review! I updated the code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124534

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


[PATCH] D124474: Honor COMPILER_RT_INCLUDE_TESTS when using LLVM_BUILD_EXTERNAL_COMPILER_RT=ON

2022-04-27 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

I posted a PR to swift that migrates build-script to use 
`LLVM_ENABLE_RUNTIMES`: https://github.com/apple/swift/pull/58465

Obviously I can't test this against your internal infrastructure, but the 
change here is pretty trivial.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124474

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


[PATCH] D124556: Prevent shadowing a variable declared in `if`

2022-04-27 Thread Ken Matsui via Phabricator via cfe-commits
ken-matsui created this revision.
Herald added a project: All.
ken-matsui requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124556

Files:
  clang/lib/Basic/Diagnostic.cpp


Index: clang/lib/Basic/Diagnostic.cpp
===
--- clang/lib/Basic/Diagnostic.cpp
+++ clang/lib/Basic/Diagnostic.cpp
@@ -983,13 +983,13 @@
   if (const char *S = tok::getPunctuatorSpelling(Kind))
 // Quoted token spelling for punctuators.
 Out << '\'' << S << '\'';
-  else if (const char *S = tok::getKeywordSpelling(Kind))
+  else if ((S = tok::getKeywordSpelling(Kind)))
 // Unquoted token spelling for keywords.
 Out << S;
-  else if (const char *S = getTokenDescForDiagnostic(Kind))
+  else if ((S = getTokenDescForDiagnostic(Kind)))
 // Unquoted translatable token name.
 Out << S;
-  else if (const char *S = tok::getTokenName(Kind))
+  else if ((S = tok::getTokenName(Kind)))
 // Debug name, shouldn't appear in user-facing diagnostics.
 Out << '<' << S << '>';
   else


Index: clang/lib/Basic/Diagnostic.cpp
===
--- clang/lib/Basic/Diagnostic.cpp
+++ clang/lib/Basic/Diagnostic.cpp
@@ -983,13 +983,13 @@
   if (const char *S = tok::getPunctuatorSpelling(Kind))
 // Quoted token spelling for punctuators.
 Out << '\'' << S << '\'';
-  else if (const char *S = tok::getKeywordSpelling(Kind))
+  else if ((S = tok::getKeywordSpelling(Kind)))
 // Unquoted token spelling for keywords.
 Out << S;
-  else if (const char *S = getTokenDescForDiagnostic(Kind))
+  else if ((S = getTokenDescForDiagnostic(Kind)))
 // Unquoted translatable token name.
 Out << S;
-  else if (const char *S = tok::getTokenName(Kind))
+  else if ((S = tok::getTokenName(Kind)))
 // Debug name, shouldn't appear in user-facing diagnostics.
 Out << '<' << S << '>';
   else
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >