[PATCH] D153235: [RISCV] Change the type of argument to clz and ctz from ZiZi/WiWi to iUi/iULi

2023-06-19 Thread Jim Lin via Phabricator via cfe-commits
Jim updated this revision to Diff 532790.
Jim added a comment.

Address comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153235

Files:
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c


Index: clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
===
--- clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
+++ clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
@@ -34,7 +34,7 @@
 // RV64ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.ctlz.i32(i32 [[TMP0]], i1 
false)
 // RV64ZBB-NEXT:ret i32 [[TMP1]]
 //
-int clz_32(int a) {
+int clz_32(unsigned int a) {
   return __builtin_riscv_clz_32(a);
 }
 
@@ -46,7 +46,7 @@
 // RV64ZBB-NEXT:[[TMP1:%.*]] = call i64 @llvm.ctlz.i64(i64 [[TMP0]], i1 
false)
 // RV64ZBB-NEXT:ret i64 [[TMP1]]
 //
-long clz_64(long a) {
+int clz_64(unsigned long a) {
   return __builtin_riscv_clz_64(a);
 }
 
@@ -58,7 +58,7 @@
 // RV64ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.cttz.i32(i32 [[TMP0]], i1 
false)
 // RV64ZBB-NEXT:ret i32 [[TMP1]]
 //
-int ctz_32(int a) {
+int ctz_32(unsigned int a) {
   return __builtin_riscv_ctz_32(a);
 }
 
@@ -70,6 +70,6 @@
 // RV64ZBB-NEXT:[[TMP1:%.*]] = call i64 @llvm.cttz.i64(i64 [[TMP0]], i1 
false)
 // RV64ZBB-NEXT:ret i64 [[TMP1]]
 //
-long ctz_64(long a) {
+int ctz_64(unsigned long a) {
   return __builtin_riscv_ctz_64(a);
 }
\ No newline at end of file
Index: clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
===
--- clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
+++ clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
@@ -22,7 +22,7 @@
 // RV32ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.ctlz.i32(i32 [[TMP0]], i1 
false)
 // RV32ZBB-NEXT:ret i32 [[TMP1]]
 //
-int clz_32(int a) {
+int clz_32(unsigned int a) {
   return __builtin_riscv_clz_32(a);
 }
 
@@ -34,6 +34,6 @@
 // RV32ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.cttz.i32(i32 [[TMP0]], i1 
false)
 // RV32ZBB-NEXT:ret i32 [[TMP1]]
 //
-int ctz_32(int a) {
+int ctz_32(unsigned int a) {
   return __builtin_riscv_ctz_32(a);
 }
\ No newline at end of file
Index: clang/include/clang/Basic/BuiltinsRISCV.def
===
--- clang/include/clang/Basic/BuiltinsRISCV.def
+++ clang/include/clang/Basic/BuiltinsRISCV.def
@@ -18,10 +18,10 @@
 // Zbb extension
 TARGET_BUILTIN(__builtin_riscv_orc_b_32, "ZiZi", "nc", "zbb")
 TARGET_BUILTIN(__builtin_riscv_orc_b_64, "WiWi", "nc", "zbb,64bit")
-TARGET_BUILTIN(__builtin_riscv_clz_32, "ZiZi", "nc", "zbb|xtheadbb")
-TARGET_BUILTIN(__builtin_riscv_clz_64, "WiWi", "nc", "zbb|xtheadbb,64bit")
-TARGET_BUILTIN(__builtin_riscv_ctz_32, "ZiZi", "nc", "zbb")
-TARGET_BUILTIN(__builtin_riscv_ctz_64, "WiWi", "nc", "zbb,64bit")
+TARGET_BUILTIN(__builtin_riscv_clz_32, "iUZi", "nc", "zbb|xtheadbb")
+TARGET_BUILTIN(__builtin_riscv_clz_64, "iUWi", "nc", "zbb|xtheadbb,64bit")
+TARGET_BUILTIN(__builtin_riscv_ctz_32, "iUZi", "nc", "zbb")
+TARGET_BUILTIN(__builtin_riscv_ctz_64, "iUWi", "nc", "zbb,64bit")
 
 // Zbc or Zbkc extension
 TARGET_BUILTIN(__builtin_riscv_clmul, "LiLiLi", "nc", "zbc|zbkc")


Index: clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
===
--- clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
+++ clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
@@ -34,7 +34,7 @@
 // RV64ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.ctlz.i32(i32 [[TMP0]], i1 false)
 // RV64ZBB-NEXT:ret i32 [[TMP1]]
 //
-int clz_32(int a) {
+int clz_32(unsigned int a) {
   return __builtin_riscv_clz_32(a);
 }
 
@@ -46,7 +46,7 @@
 // RV64ZBB-NEXT:[[TMP1:%.*]] = call i64 @llvm.ctlz.i64(i64 [[TMP0]], i1 false)
 // RV64ZBB-NEXT:ret i64 [[TMP1]]
 //
-long clz_64(long a) {
+int clz_64(unsigned long a) {
   return __builtin_riscv_clz_64(a);
 }
 
@@ -58,7 +58,7 @@
 // RV64ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.cttz.i32(i32 [[TMP0]], i1 false)
 // RV64ZBB-NEXT:ret i32 [[TMP1]]
 //
-int ctz_32(int a) {
+int ctz_32(unsigned int a) {
   return __builtin_riscv_ctz_32(a);
 }
 
@@ -70,6 +70,6 @@
 // RV64ZBB-NEXT:[[TMP1:%.*]] = call i64 @llvm.cttz.i64(i64 [[TMP0]], i1 false)
 // RV64ZBB-NEXT:ret i64 [[TMP1]]
 //
-long ctz_64(long a) {
+int ctz_64(unsigned long a) {
   return __builtin_riscv_ctz_64(a);
 }
\ No newline at end of file
Index: clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
===
--- clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
+++ clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
@@ -22,7 +22,7 @@
 // RV32ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.ctlz.i32(i32 [[TMP0]], i1 false)
 // RV32ZBB-NEXT:ret i32 

[PATCH] D153298: [clang-tidy] Extend bugprone-exception-escape diagnostics

2023-06-19 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

Question would be, does this can stay +- like this and we could wait with 
extension this until some users for example complain, that they would like it 
to be extended, or this need to be done now.
Main reason for this change is, that often I run into situation when there were 
some warning raised for some function, but after deeper investigation it were 
for example due to some exceptions being thrown in some boost library.
And that hard to guess were the issue were.




Comment at: clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp:84-86
+  if (AnalyzeResult.containsUnknownElements())
+diag(MatchedDecl->getLocation(), "may throw unknown exceptions",
+ DiagnosticIDs::Note);

isuckatcs wrote:
> I'm still not sure how I feel about this message though.
I also, my main reason was to show user that except listed exceptions, also 
some other exceptions may be thrown, that we do not know because they throw 
from an functions without implementation.
In ideal condition I should just raise this warning for a function that we 
called, that we do not have implementation, and we do not know what it throws.
I would say that this could be improved in future. Originally I raised all 
those notes against a main function, changed this recently to show were throws 
are called.



Comment at: clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp:334
+  CaughtExceptions.insert({ExceptionTy, ThrowLoc});
+  continue;
 }

isuckatcs wrote:
> This `continue` and the other one change the behaviour of this function.  
> Without this some additional conditions are also checked after the `else if` 
> block. Shouldn't we preserve the old behaviour?
No, old behavior were inefficient. All push_backs push same exception into 
vector, that we later remove from set. So when we execute additional `if`s we 
still going to push same execution to vector, and as a result we going to try 
to remove same element from set twice. That`s not needed.



Comment at: clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp:390
   for (const Type *T : TypesToDelete)
-ThrownExceptions.erase(T);
+ThrownExceptions.erase({T, SourceLocation()});
 

isuckatcs wrote:
> This line makes me wonder if it's worth using a `map` instead of a `set` for 
> `ThrownExceptions`. You could map the type to the location. I mean 
> technically, that happens now too, but not with the appropriate data 
> structure. 
> 
> Also I wonder what happens if a function can throw the same type from 
> multiple locations. E.g.:
> ```lang=c++
> void foo(int x) {
>   if(x == 0) 
> throw 1;
>   
>   if(x == 1)
> throw 2;
> }
> ```
> Here only the last location will be preserved, so maybe mapping `Type` to 
> `vector` would be better.
We use llvm::SmallSet, but there is no llvm::SmallMap. I wanted to preserve 
memory optimizations, as using some map could hit performance, after all we 
create many of those temporary containers.
And with map I run into some issues (it didn't like const pointer as key).

As for double throw of same type. I agree, but I don't think its worth being 
implemented currently.
Once user remove one exception, check will show second. Many checks work like 
that.
This is just to provide small hint.



Comment at: clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h:46
+
+  friend bool operator<(const ThrowInfo , const ThrowInfo ) noexcept {
+return L.ThrowType < R.ThrowType;

isuckatcs wrote:
> What is the reason behind declaring this operator and the one below as 
> `friend`?
I just get used to do that. Usually friend enable conversion, but here we do 
not have constructor or derived classes, so that's not needed.
I can change this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153298

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


[PATCH] D153298: [clang-tidy] Extend bugprone-exception-escape diagnostics

2023-06-19 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL updated this revision to Diff 532783.
PiotrZSL marked 3 inline comments as done.
PiotrZSL added a comment.

Review fixes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153298

Files:
  clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
  clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
  clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-rethrow.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-throw.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
@@ -9,6 +9,7 @@
 struct throwing_destructor {
   ~throwing_destructor() {
 // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: an exception may be thrown in function '~throwing_destructor' which should not throw exceptions
+// CHECK-MESSAGES: :[[@LINE+1]]:5: note: may throw 'int' here
 throw 1;
   }
 };
@@ -16,6 +17,7 @@
 struct throwing_move_constructor {
   throwing_move_constructor(throwing_move_constructor&&) {
 // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: an exception may be thrown in function 'throwing_move_constructor' which should not throw exceptions
+// CHECK-MESSAGES: :[[@LINE+1]]:5: note: may throw 'int' here
 throw 1;
   }
 };
@@ -23,12 +25,14 @@
 struct throwing_move_assignment {
   throwing_move_assignment& operator=(throwing_move_assignment&&) {
 // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: an exception may be thrown in function 'operator=' which should not throw exceptions
+// CHECK-MESSAGES: :[[@LINE+1]]:5: note: may throw 'int' here
 throw 1;
   }
 };
 
 void throwing_noexcept() noexcept {
-// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throwing_noexcept' which should not throw exceptions
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throwing_noexcept' which should not throw exceptions
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: note: may throw 'int' here
   throw 1;
 }
 
@@ -42,6 +46,7 @@
 
 void throw_and_catch_some(int n) noexcept {
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_and_catch_some' which should not throw exceptions
+  // CHECK-MESSAGES: :[[@LINE+3]]:5: note: may throw 'double' here
   try {
 if (n) throw 1;
 throw 1.1;
@@ -70,6 +75,7 @@
 
 void throw_and_rethrow() noexcept {
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_and_rethrow' which should not throw exceptions
+  // CHECK-MESSAGES: :[[@LINE+2]]:5: note: may throw 'int' here
   try {
 throw 1;
   } catch(int &) {
@@ -79,6 +85,7 @@
 
 void throw_catch_throw() noexcept {
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_catch_throw' which should not throw exceptions
+  // CHECK-MESSAGES: :[[@LINE+4]]:5: note: may throw 'int' here
   try {
 throw 1;
   } catch(int &) {
@@ -88,6 +95,7 @@
 
 void throw_catch_rethrow_the_rest(int n) noexcept {
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_catch_rethrow_the_rest' which should not throw exceptions
+  // CHECK-MESSAGES: :[[@LINE+3]]:5: note: may throw 'double' here
   try {
 if (n) throw 1;
 throw 1.1;
@@ -120,6 +128,7 @@
 
 void throw_catch_multi_ptr_1() noexcept {
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_catch_multi_ptr_1' which should not throw exceptions
+  // CHECK-MESSAGES: :[[@LINE+3]]:5: note: may throw 'char **' here
   try {
 char **p = 0;
 throw p;
@@ -152,7 +161,7 @@
 }
 
 // FIXME: In this case 'a' is convertible to the handler and should be caught
-// but in reality it's thrown. Note that clang doesn't report a warning for 
+// but in reality it's thrown. Note that clang doesn't report a warning for
 // this either.
 void throw_catch_multi_ptr_5() noexcept {
   try {
@@ -165,6 +174,7 @@
 
 void throw_c_catch_pointer() noexcept {
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_c_catch_pointer' which should not throw exceptions
+  // CHECK-MESSAGES: :[[@LINE+4]]:5: note: may throw 'const int *' here
   try {
 int a = 1;
 const int *p = 
@@ -174,6 +184,7 @@
 
 void throw_c_catch_pointer_v() noexcept {
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_c_catch_pointer_v' which should not throw exceptions
+  // CHECK-MESSAGES: :[[@LINE+4]]:5: note: may throw 'const int *' here
   try 

[clang] dafaa84 - [XRay] Make llvm.xray.customevent parameter type match __xray_customevent

2023-06-19 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-06-19T20:38:16-07:00
New Revision: dafaa8463ef6991055c2fcee799757fa46965625

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

LOG: [XRay] Make llvm.xray.customevent parameter type match __xray_customevent

The intrinsic has a smaller integer type than the parameter type of
builtin-function/API. Fix this similar to commit 
3fa3cb408d8d0f1365b322262e501b6945f7ead9.

Added: 


Modified: 
clang/test/CodeGen/xray-always-emit-customevent.cpp
clang/test/CodeGen/xray-customevent.cpp
clang/test/CodeGen/xray-instrumentation-bundles.cpp
llvm/include/llvm/IR/Intrinsics.td
llvm/test/CodeGen/X86/xray-custom-log.ll

Removed: 




diff  --git a/clang/test/CodeGen/xray-always-emit-customevent.cpp 
b/clang/test/CodeGen/xray-always-emit-customevent.cpp
index 63d4b91f81908..289111c90ff0a 100644
--- a/clang/test/CodeGen/xray-always-emit-customevent.cpp
+++ b/clang/test/CodeGen/xray-always-emit-customevent.cpp
@@ -6,5 +6,5 @@
 [[clang::xray_never_instrument]] void neverInstrument() {
   static constexpr char kPhase[] = "never";
   __xray_customevent(kPhase, 5);
-  // CHECK: call void @llvm.xray.customevent(ptr{{.*}}, i32 5)
+  // CHECK: call void @llvm.xray.customevent(ptr{{.*}}, i64 5)
 }

diff  --git a/clang/test/CodeGen/xray-customevent.cpp 
b/clang/test/CodeGen/xray-customevent.cpp
index efaa26d633109..c64cbbd7c4236 100644
--- a/clang/test/CodeGen/xray-customevent.cpp
+++ b/clang/test/CodeGen/xray-customevent.cpp
@@ -4,14 +4,14 @@
 [[clang::xray_always_instrument]] void alwaysInstrument() {
   static constexpr char kPhase[] = "instrument";
   __xray_customevent(kPhase, 10);
-  // CHECK: call void @llvm.xray.customevent(ptr{{.*}}, i32 10)
+  // CHECK: call void @llvm.xray.customevent(ptr{{.*}}, i64 10)
 }
 
 // CHECK-LABEL: @_Z15neverInstrumentv
 [[clang::xray_never_instrument]] void neverInstrument() {
   static constexpr char kPhase[] = "never";
   __xray_customevent(kPhase, 5);
-  // CHECK-NOT: call void @llvm.xray.customevent(ptr{{.*}}, i32 5)
+  // CHECK-NOT: call void @llvm.xray.customevent(
 }
 
 // CHECK-LABEL: @_Z21conditionalInstrumenti
@@ -23,6 +23,6 @@
   else
 __xray_customevent(kUntrue, 6);
 
-  // CHECK: call void @llvm.xray.customevent(ptr{{.*}}, i32 4)
-  // CHECK: call void @llvm.xray.customevent(ptr{{.*}}, i32 6)
+  // CHECK: call void @llvm.xray.customevent(ptr{{.*}}, i64 4)
+  // CHECK: call void @llvm.xray.customevent(ptr{{.*}}, i64 6)
 }

diff  --git a/clang/test/CodeGen/xray-instrumentation-bundles.cpp 
b/clang/test/CodeGen/xray-instrumentation-bundles.cpp
index 45ea6e514e6cc..7b9ccb25a3b52 100644
--- a/clang/test/CodeGen/xray-instrumentation-bundles.cpp
+++ b/clang/test/CodeGen/xray-instrumentation-bundles.cpp
@@ -52,8 +52,8 @@
   static constexpr char kPhase[] = "always";
   __xray_customevent(kPhase, 6);
   __xray_typedevent(1, kPhase, 6);
-  // CUSTOM: call void @llvm.xray.customevent(ptr{{.*}}, i32 6)
-  // NOCUSTOM-NOT: call void @llvm.xray.customevent(ptr{{.*}}, i32 6)
+  // CUSTOM: call void @llvm.xray.customevent(ptr {{.*}}, i64 6)
+  // NOCUSTOM-NOT: call void @llvm.xray.customevent(
   // TYPED: call void @llvm.xray.typedevent(i64 {{.*}}, ptr{{.*}}, i64 6)
   // NOTYPED-NOT: call void @llvm.xray.typedevent(
 }

diff  --git a/llvm/include/llvm/IR/Intrinsics.td 
b/llvm/include/llvm/IR/Intrinsics.td
index fbb2fa9a65646..c03eafea2438b 100644
--- a/llvm/include/llvm/IR/Intrinsics.td
+++ b/llvm/include/llvm/IR/Intrinsics.td
@@ -2253,7 +2253,7 @@ def int_hwasan_check_memaccess_shortgranules :
 
//===--===//
 // Custom event logging for x-ray.
 // Takes a pointer to a string and the length of the string.
-def int_xray_customevent : Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty],
+def int_xray_customevent : Intrinsic<[], [llvm_ptr_ty, llvm_i64_ty],
  [IntrWriteMem, NoCapture>,
   ReadOnly>]>;
 // Typed event logging for x-ray.

diff  --git a/llvm/test/CodeGen/X86/xray-custom-log.ll 
b/llvm/test/CodeGen/X86/xray-custom-log.ll
index ea0d14b9cc7a2..c41aa1e986815 100644
--- a/llvm/test/CodeGen/X86/xray-custom-log.ll
+++ b/llvm/test/CodeGen/X86/xray-custom-log.ll
@@ -6,10 +6,10 @@
 
 define i32 @customevent() nounwind "function-instrument"="xray-always" !dbg !1 
{
 %eventptr = alloca i8
-%eventsize = alloca i32
-store i32 3, ptr %eventsize
-%val = load i32, ptr %eventsize
-call void @llvm.xray.customevent(ptr %eventptr, i32 %val), !dbg !8
+%eventsize = alloca i64
+store i64 3, ptr %eventsize
+%val = load i64, ptr %eventsize
+call void @llvm.xray.customevent(ptr %eventptr, i64 %val), !dbg !8
 ; CHECK-LABEL: Lxray_event_sled_0:
 ; CHECK:   .byte 

[PATCH] D152391: [Clang] Allow bitcode linking when the input is LLVM-IR

2023-06-19 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152391

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


[PATCH] D138397: HIP: Directly call ldexp builtins

2023-06-19 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.


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

https://reviews.llvm.org/D138397

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


[PATCH] D153208: [clang-format] Add InsertNewlineAtEOF to .clang-format files

2023-06-19 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D153208#4433511 , 
@HazardyKnusperkeks wrote:

> In D153208#4431697 , @owenpan wrote:
>
>> In D153208#4431239 , 
>> @HazardyKnusperkeks wrote:
>>
>>> We also could add a clang-format style, the you wouldn't have to to touch 
>>> all .clang-format files. ;)
>>
>> Something like `BasedOnStyle: clang-format`? I like it but feel that it 
>> should be an undocumented feature. What do you all think?
>
> I don't know if I want this or if it just a joke. But if we do it, I would 
> document it, something like. "Basically LLVM Style, which uses some of the 
> newer options, to enforce some of the LLVM style guide rules."

That would seem odd with `LLVM`, `Google`, and other current `BasedOnStyle` 
values unless we make it hidden for "internal" use. I'll just land this patch 
as is and not worry about it now.


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

https://reviews.llvm.org/D153208

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


[PATCH] D153243: [clang-format] Don't finalize #if, #else, #endif, etc.

2023-06-19 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:1416-1421
+  if (Tok->is(tok::hash) && !Tok->Previous && Tok->Next &&
+  Tok->Next->isOneOf(tok::pp_if, tok::pp_ifdef, tok::pp_ifndef,
+ tok::pp_elif, tok::pp_elifdef, tok::pp_elifndef,
+ tok::pp_else, tok::pp_endif)) {
+Tok = Tok->Next;
+  }

Sedeniono wrote:
> After some time, I found your comment 
> [here](https://reviews.llvm.org/D150057#inline-1449546) which explains the 
> intention of the "do not finalize '#'" thing. Would it be possible to provide 
> the reasoning here as some comment, or at least some hint that it has to do 
> with multiple passes because of PP branches? To give future readers some 
> chance to understand what is going on. Maybe something along the lines of
> ```
> // Never mark the '#' of a PP branch as finalized, since clang-format 
> performs 
> // multiple passes, where each pass represents a version where the code of 
> // one of the PP branches is filled in. Later passes must also  be allowed to 
> // format the PP tokens.
> ```
> Alternatively or additionally, I would be happy with a link to [your 
> explanation](https://reviews.llvm.org/D150057#inline-1449546) in the code or 
> the commit message, if the llvm rules/conventions allow it.
> 
> Apart from this, I have dug way too little into how clang-format works to 
> reason about the change. I tested it with the full hpp file from 
> https://github.com/llvm/llvm-project/issues/57117, and can confirm that the 
> issue is fixed. So I believe you. ;-)
> But: Considering your comment 
> [here](https://reviews.llvm.org/D150057#inline-1449546), I thought that the 
> whole "do not finalize '#'" thing is relevant only if there are some 
> "else"-PP-branches? But in the minimal example/the unit test, there is no 
> "else" branch? How do the multiple passes because of PP branches relate to 
> the `clang-format off` comment?
> Alternatively or additionally, I would be happy with a link to [your 
> explanation](https://reviews.llvm.org/D150057#inline-1449546) in the code or 
> the commit message, if the llvm rules/conventions allow it.

I've updated the summary and will include the link in the commit message.

> But: Considering your comment 
> [here](https://reviews.llvm.org/D150057#inline-1449546), I thought that the 
> whole "do not finalize '#'" thing is relevant only if there are some 
> "else"-PP-branches? But in the minimal example/the unit test, there is no 
> "else" branch?

This patch fixes the issue that `#if`/`#else` etc. may get formatted even if 
`clang-format off` is specified. It's not specific to `#else`, and the added 
unit test is sufficient.

> How do the multiple passes because of PP branches relate to the `clang-format 
> off` comment?

They are not (or should not be) related. We probably should add an attribute to 
`FormatToken` exclusively for `clang-format off` as `Finalized` doesn't 
necessarily mean `clang-format off` is in effect.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153243

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


[PATCH] D153314: [clang] Replace uses of CGBuilderTy::CreateElementBitCast (NFC)

2023-06-19 Thread Youngsuk Kim via Phabricator via cfe-commits
JOE1994 created this revision.
JOE1994 added reviewers: barannikov88, nikic.
Herald added subscribers: StephenFan, kbarton, nemanjai.
Herald added a project: All.
JOE1994 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Partial progress towards replacing `CreateElementBitCast`, as it no
longer does what its name suggests. Either replace its uses with
`Address::withElementType()`, or remove them if no longer needed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153314

Files:
  clang/lib/CodeGen/CGAtomic.cpp
  clang/lib/CodeGen/CGCXXABI.cpp
  clang/lib/CodeGen/CGNonTrivialStruct.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/lib/CodeGen/Targets/AArch64.cpp
  clang/lib/CodeGen/Targets/ARM.cpp
  clang/lib/CodeGen/Targets/Hexagon.cpp
  clang/lib/CodeGen/Targets/LoongArch.cpp
  clang/lib/CodeGen/Targets/PPC.cpp
  clang/lib/CodeGen/Targets/X86.cpp

Index: clang/lib/CodeGen/Targets/X86.cpp
===
--- clang/lib/CodeGen/Targets/X86.cpp
+++ clang/lib/CodeGen/Targets/X86.cpp
@@ -318,8 +318,7 @@
   ResultTruncRegTypes.push_back(CoerceTy);
 
   // Coerce the integer by bitcasting the return slot pointer.
-  ReturnSlot.setAddress(
-  CGF.Builder.CreateElementBitCast(ReturnSlot.getAddress(CGF), CoerceTy));
+  ReturnSlot.setAddress(ReturnSlot.getAddress(CGF).withElementType(CoerceTy));
   ResultRegDests.push_back(ReturnSlot);
 
   rewriteInputConstraintReferences(NumOutputs, 1, AsmString);
@@ -3048,7 +3047,7 @@
 assert(AI.isDirect() && "Unexpected ABI info for mixed regs");
 llvm::StructType *ST = cast(AI.getCoerceToType());
 Address Tmp = CGF.CreateMemTemp(Ty);
-Tmp = CGF.Builder.CreateElementBitCast(Tmp, ST);
+Tmp = Tmp.withElementType(ST);
 assert(ST->getNumElements() == 2 && "Unexpected ABI info for mixed regs");
 llvm::Type *TyLo = ST->getElementType(0);
 llvm::Type *TyHi = ST->getElementType(1);
@@ -3076,11 +3075,10 @@
 CharUnits::fromQuantity(getDataLayout().getABITypeAlign(TyHi)));
 CGF.Builder.CreateStore(V, CGF.Builder.CreateStructGEP(Tmp, 1));
 
-RegAddr = CGF.Builder.CreateElementBitCast(Tmp, LTy);
+RegAddr = Tmp.withElementType(LTy);
   } else if (neededInt) {
 RegAddr = Address(CGF.Builder.CreateGEP(CGF.Int8Ty, RegSaveArea, gp_offset),
-  CGF.Int8Ty, CharUnits::fromQuantity(8));
-RegAddr = CGF.Builder.CreateElementBitCast(RegAddr, LTy);
+  LTy, CharUnits::fromQuantity(8));
 
 // Copy to a temporary if necessary to ensure the appropriate alignment.
 auto TInfo = getContext().getTypeInfoInChars(Ty);
@@ -3097,8 +3095,7 @@
 
   } else if (neededSSE == 1) {
 RegAddr = Address(CGF.Builder.CreateGEP(CGF.Int8Ty, RegSaveArea, fp_offset),
-  CGF.Int8Ty, CharUnits::fromQuantity(16));
-RegAddr = CGF.Builder.CreateElementBitCast(RegAddr, LTy);
+  LTy, CharUnits::fromQuantity(16));
   } else {
 assert(neededSSE == 2 && "Invalid number of needed registers!");
 // SSE registers are spaced 16 bytes apart in the register save
@@ -3118,15 +3115,15 @@
  : llvm::StructType::get(CGF.DoubleTy, CGF.DoubleTy);
 llvm::Value *V;
 Address Tmp = CGF.CreateMemTemp(Ty);
-Tmp = CGF.Builder.CreateElementBitCast(Tmp, ST);
-V = CGF.Builder.CreateLoad(CGF.Builder.CreateElementBitCast(
-RegAddrLo, ST->getStructElementType(0)));
+Tmp = Tmp.withElementType(ST);
+V = CGF.Builder.CreateLoad(
+RegAddrLo.withElementType(ST->getStructElementType(0)));
 CGF.Builder.CreateStore(V, CGF.Builder.CreateStructGEP(Tmp, 0));
-V = CGF.Builder.CreateLoad(CGF.Builder.CreateElementBitCast(
-RegAddrHi, ST->getStructElementType(1)));
+V = CGF.Builder.CreateLoad(
+RegAddrHi.withElementType(ST->getStructElementType(1)));
 CGF.Builder.CreateStore(V, CGF.Builder.CreateStructGEP(Tmp, 1));
 
-RegAddr = CGF.Builder.CreateElementBitCast(Tmp, LTy);
+RegAddr = Tmp.withElementType(LTy);
   }
 
   // AMD64-ABI 3.5.7p5: Step 5. Set:
Index: clang/lib/CodeGen/Targets/PPC.cpp
===
--- clang/lib/CodeGen/Targets/PPC.cpp
+++ clang/lib/CodeGen/Targets/PPC.cpp
@@ -31,8 +31,8 @@
   }
 
   llvm::Type *EltTy = CGF.ConvertTypeForMem(CTy->getElementType());
-  RealAddr = CGF.Builder.CreateElementBitCast(RealAddr, EltTy);
-  ImagAddr = CGF.Builder.CreateElementBitCast(ImagAddr, EltTy);
+  RealAddr = RealAddr.withElementType(EltTy);
+  ImagAddr = ImagAddr.withElementType(EltTy);
   llvm::Value *Real = CGF.Builder.CreateLoad(RealAddr, ".vareal");
   llvm::Value *Imag = CGF.Builder.CreateLoad(ImagAddr, ".vaimag");
 
@@ -456,8 +456,7 @@
 Builder.CreateMul(NumRegs, Builder.getInt8(RegSize.getQuantity()));
 RegAddr = Address(
 Builder.CreateInBoundsGEP(CGF.Int8Ty, RegAddr.getPointer(), RegOffset),
-

[PATCH] D153293: [clang][WebAssembly] support wasm32-wasi shared libraries

2023-06-19 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 accepted this revision.
sbc100 added a comment.
This revision is now accepted and ready to land.

lgtm.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153293

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


[PATCH] D151696: [x86] Remove CPU_SPECIFIC* MACROs and add getManglingForCPU

2023-06-19 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe updated this revision to Diff 532772.
FreddyYe added a comment.

Adjust atom_sse4_2_movbe test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151696

Files:
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/attr-cpuspecific-avx-abi.c
  clang/test/CodeGen/attr-cpuspecific.c
  llvm/include/llvm/TargetParser/X86TargetParser.def
  llvm/include/llvm/TargetParser/X86TargetParser.h
  llvm/lib/Target/X86/X86.td
  llvm/lib/TargetParser/X86TargetParser.cpp
  llvm/test/CodeGen/X86/cpus-intel.ll

Index: llvm/test/CodeGen/X86/cpus-intel.ll
===
--- llvm/test/CodeGen/X86/cpus-intel.ll
+++ llvm/test/CodeGen/X86/cpus-intel.ll
@@ -6,16 +6,24 @@
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=i586 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium-mmx 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_mmx 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=i686 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentiumpro 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_pro 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium2 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_ii 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium3 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium3m 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_iii 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_iii_no_xmm_regs 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_m 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium-m 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium4 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium4m 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_4 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=yonah 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=prescott 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_4_sse3 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=lakemont 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=raptorlake 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=meteorlake 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
@@ -26,26 +34,39 @@
 
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=nocona 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=core2 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=core_2_duo_ssse3 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=penryn 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=core_2_duo_sse4_1 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o 

[PATCH] D152785: [COFF] Support -gsplit-dwarf for COFF on Windows

2023-06-19 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen marked an inline comment as done.
HaohaiWen added a comment.

Any other comments? If not , I'll land this patch tomorrow.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152785

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


[PATCH] D151696: [x86] Remove CPU_SPECIFIC* MACROs and add getManglingForCPU

2023-06-19 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe added inline comments.



Comment at: llvm/lib/TargetParser/X86TargetParser.cpp:110
   FeatureBitset Features;
+  char Mangling;
+  bool OnlyForCPUDispatchSpecific;

RKSimon wrote:
> Do we have a documented list of the mangling values anywhere? The values 
> below look too much like magic numbers tbh.
I think not. I copied them from the old MACROs in X86TargetParser.def. I think 
the values are just used to do some distinguish from different CPUs. And 
'a'-'Z' is about to run out of soon here. We probably need to extend the 
mangling, may be with another letter as prefix. @erichkeane may have a better 
answer here.



Comment at: llvm/test/CodeGen/X86/cpus-intel.ll:90
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown 
-mcpu=graniterapids 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR 
--allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown 
-mcpu=atom_sse4_2_movbe 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR 
--allow-empty
 

RKSimon wrote:
> put this with the goldmonth checks?
I'll do the adjust. BTW I'd like also to mention below:

Here are the rules I used to add features/tuning model in X86.td for missing 
cpu names in CPU_SPECIFIC Macros:

RULE 1: Infer from the name itself. E.g. pentium_4 -> pentium4, pentium_iii -> 
pentium3
RULE 2: CPU_SPECIFIC_ALIAS can tell me its old name. Using the old name to 
continue to infer.
RULE 3: Use the feature list in CPU_SPECIFIC to compare and append with 
existing CPU names:
```
pentium_4_sse3 -> prescott
core_2_duo_ssse3 -> core2
core_2_duo_sse4_1 -> penryn
atom_sse4_2 -> silvermont
core_i7_sse4_2 -> nehalem
core_aes_pclmulqdq -> westmere
core_5th_gen_avx_tsx -> broadwell
```
There is only one exception: atom_sse4_2_movbe. For now I set it as goldmont 
features and silvermont tuning model according to its definition:
```
CPU_SPECIFIC("atom_sse4_2_movbe", "silvermont", 'd', 
"+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt")
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151696

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


[clang] cb9ac70 - Reland "[DebugMetadata][DwarfDebug] Support function-local types in lexical block scopes (4/7)" (2)

2023-06-19 Thread Vladislav Dzhidzhoev via cfe-commits

Author: Vladislav Dzhidzhoev
Date: 2023-06-20T03:01:46+02:00
New Revision: cb9ac7051589ea0d05507f9370d0716bef86b4ae

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

LOG: Reland "[DebugMetadata][DwarfDebug] Support function-local types in 
lexical block scopes (4/7)" (2)

Test "local-type-as-template-parameter.ll" is now enabled only for
x86_64.

Authored-by: Kristina Bessonova 

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

Depends on D144005

Added: 
llvm/test/DebugInfo/Generic/inlined-local-type.ll
llvm/test/DebugInfo/Generic/lexical-block-retained-types.ll
llvm/test/DebugInfo/Generic/lexical-block-types.ll
llvm/test/DebugInfo/X86/local-type-as-template-parameter.ll
llvm/test/DebugInfo/X86/split-dwarf-local-import.ll
llvm/test/DebugInfo/X86/split-dwarf-local-import2.ll
llvm/test/DebugInfo/X86/split-dwarf-local-import3.ll

Modified: 
clang/test/CodeGen/debug-info-codeview-unnamed.c
clang/test/CodeGen/debug-info-unused-types.c
clang/test/CodeGen/debug-info-unused-types.cpp
clang/test/CodeGenCXX/debug-info-access.cpp
clang/test/CodeGenCXX/debug-info-anon-union-vars.cpp
clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp
clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
clang/test/CodeGenCXX/debug-lambda-this.cpp
llvm/include/llvm/IR/DIBuilder.h
llvm/lib/Bitcode/Reader/MetadataLoader.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/lib/IR/DIBuilder.cpp
llvm/lib/IR/Verifier.cpp
llvm/test/Bitcode/upgrade-cu-locals.ll
llvm/test/Bitcode/upgrade-cu-locals.ll.bc
llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll
llvm/test/DebugInfo/X86/set.ll

Removed: 
llvm/test/DebugInfo/Generic/split-dwarf-local-import.ll
llvm/test/DebugInfo/Generic/split-dwarf-local-import2.ll
llvm/test/DebugInfo/Generic/split-dwarf-local-import3.ll



diff  --git a/clang/test/CodeGen/debug-info-codeview-unnamed.c 
b/clang/test/CodeGen/debug-info-codeview-unnamed.c
index bd2a7543e56b2..16ffb3682236f 100644
--- a/clang/test/CodeGen/debug-info-codeview-unnamed.c
+++ b/clang/test/CodeGen/debug-info-codeview-unnamed.c
@@ -8,23 +8,23 @@ int main(int argc, char* argv[], char* arge[]) {
   //
   struct { int bar; } one = {42};
   //
-  // LINUX:  !{{[0-9]+}} = !DILocalVariable(name: "one"
-  // LINUX-SAME: type: [[TYPE_OF_ONE:![0-9]+]]
-  // LINUX-SAME: )
-  // LINUX:  [[TYPE_OF_ONE]] = distinct !DICompositeType(
+  // LINUX:  [[TYPE_OF_ONE:![0-9]+]] = distinct !DICompositeType(
   // LINUX-SAME: tag: DW_TAG_structure_type
   // LINUX-NOT:  name:
   // LINUX-NOT:  identifier:
   // LINUX-SAME: )
+  // LINUX:  !{{[0-9]+}} = !DILocalVariable(name: "one"
+  // LINUX-SAME: type: [[TYPE_OF_ONE]]
+  // LINUX-SAME: )
   //
-  // MSVC:   !{{[0-9]+}} = !DILocalVariable(name: "one"
-  // MSVC-SAME:  type: [[TYPE_OF_ONE:![0-9]+]]
-  // MSVC-SAME:  )
-  // MSVC:   [[TYPE_OF_ONE]] = distinct !DICompositeType
+  // MSVC:   [[TYPE_OF_ONE:![0-9]+]] = distinct !DICompositeType
   // MSVC-SAME:  tag: DW_TAG_structure_type
   // MSVC-NOT:   name:
   // MSVC-NOT:   identifier:
   // MSVC-SAME:  )
+  // MSVC:   !{{[0-9]+}} = !DILocalVariable(name: "one"
+  // MSVC-SAME:  type: [[TYPE_OF_ONE]]
+  // MSVC-SAME:  )
 
   return 0;
 }

diff  --git a/clang/test/CodeGen/debug-info-unused-types.c 
b/clang/test/CodeGen/debug-info-unused-types.c
index 3e9f7b07658e3..5bcc71f710a5c 100644
--- a/clang/test/CodeGen/debug-info-unused-types.c
+++ b/clang/test/CodeGen/debug-info-unused-types.c
@@ -18,13 +18,13 @@ void quux(void) {
 // CHECK: !DICompileUnit{{.+}}retainedTypes: [[RETTYPES:![0-9]+]]
 // CHECK: [[TYPE0:![0-9]+]] = !DICompositeType(tag: DW_TAG_enumeration_type, 
name: "bar"
 // CHECK: [[TYPE1:![0-9]+]] = !DIEnumerator(name: "BAR"
-// CHECK: [[TYPE2:![0-9]+]] = !DICompositeType(tag: DW_TAG_enumeration_type, 
name: "z"
-// CHECK: [[TYPE3:![0-9]+]] = !DIEnumerator(name: "Z"
-// CHECK: [[RETTYPES]] = !{[[TYPE4:![0-9]+]], [[TYPE5:![0-9]+]], [[TYPE0]], 
[[TYPE6:![0-9]+]], {{![0-9]+}}, [[TYPE7:![0-9]+]], [[TYPE2]], [[TYPE8:![0-9]+]]}
-// CHECK: [[TYPE4]] = !DIDerivedType(tag: DW_TAG_typedef, name: "my_int"
-// CHECK: [[TYPE5]] = distinct !DICompositeType(tag: DW_TAG_structure_type, 
name: "foo"
-// CHECK: [[TYPE6]] = distinct !DICompositeType(tag: DW_TAG_union_type, name: 
"baz"
-// CHECK: [[TYPE7]] = distinct !DICompositeType(tag: DW_TAG_structure_type, 
name: "y"
+// CHECK: [[RETTYPES]] = !{[[TYPE2:![0-9]+]], [[TYPE3:![0-9]+]], [[TYPE0]], 
[[TYPE4:![0-9]+]], {{![0-9]+}}, [[TYPE5:![0-9]+]], [[TYPE6:![0-9]+]], 

[clang] fec7c64 - Revert "Reland "[DebugMetadata][DwarfDebug] Support function-local types in lexical block scopes (4/7)""

2023-06-19 Thread Vladislav Dzhidzhoev via cfe-commits

Author: Vladislav Dzhidzhoev
Date: 2023-06-20T01:54:48+02:00
New Revision: fec7c6457ced7e87d4e0837402b0b8a644cf6242

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

LOG: Revert "Reland "[DebugMetadata][DwarfDebug] Support function-local types 
in lexical block scopes (4/7)""

This reverts commit 2da45172c4bcd42f704c57c656926f56f32fc5ce.
Test local-type-as-template-parameter.ll fails on ppc64-aix.

Added: 
llvm/test/DebugInfo/Generic/split-dwarf-local-import.ll
llvm/test/DebugInfo/Generic/split-dwarf-local-import2.ll
llvm/test/DebugInfo/Generic/split-dwarf-local-import3.ll

Modified: 
clang/test/CodeGen/debug-info-codeview-unnamed.c
clang/test/CodeGen/debug-info-unused-types.c
clang/test/CodeGen/debug-info-unused-types.cpp
clang/test/CodeGenCXX/debug-info-access.cpp
clang/test/CodeGenCXX/debug-info-anon-union-vars.cpp
clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp
clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
clang/test/CodeGenCXX/debug-lambda-this.cpp
llvm/include/llvm/IR/DIBuilder.h
llvm/lib/Bitcode/Reader/MetadataLoader.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/lib/IR/DIBuilder.cpp
llvm/lib/IR/Verifier.cpp
llvm/test/Bitcode/upgrade-cu-locals.ll
llvm/test/Bitcode/upgrade-cu-locals.ll.bc
llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll
llvm/test/DebugInfo/X86/set.ll

Removed: 
llvm/test/DebugInfo/Generic/inlined-local-type.ll
llvm/test/DebugInfo/Generic/lexical-block-retained-types.ll
llvm/test/DebugInfo/Generic/lexical-block-types.ll
llvm/test/DebugInfo/Generic/local-type-as-template-parameter.ll
llvm/test/DebugInfo/X86/split-dwarf-local-import.ll
llvm/test/DebugInfo/X86/split-dwarf-local-import2.ll
llvm/test/DebugInfo/X86/split-dwarf-local-import3.ll



diff  --git a/clang/test/CodeGen/debug-info-codeview-unnamed.c 
b/clang/test/CodeGen/debug-info-codeview-unnamed.c
index 16ffb3682236f..bd2a7543e56b2 100644
--- a/clang/test/CodeGen/debug-info-codeview-unnamed.c
+++ b/clang/test/CodeGen/debug-info-codeview-unnamed.c
@@ -8,23 +8,23 @@ int main(int argc, char* argv[], char* arge[]) {
   //
   struct { int bar; } one = {42};
   //
-  // LINUX:  [[TYPE_OF_ONE:![0-9]+]] = distinct !DICompositeType(
+  // LINUX:  !{{[0-9]+}} = !DILocalVariable(name: "one"
+  // LINUX-SAME: type: [[TYPE_OF_ONE:![0-9]+]]
+  // LINUX-SAME: )
+  // LINUX:  [[TYPE_OF_ONE]] = distinct !DICompositeType(
   // LINUX-SAME: tag: DW_TAG_structure_type
   // LINUX-NOT:  name:
   // LINUX-NOT:  identifier:
   // LINUX-SAME: )
-  // LINUX:  !{{[0-9]+}} = !DILocalVariable(name: "one"
-  // LINUX-SAME: type: [[TYPE_OF_ONE]]
-  // LINUX-SAME: )
   //
-  // MSVC:   [[TYPE_OF_ONE:![0-9]+]] = distinct !DICompositeType
+  // MSVC:   !{{[0-9]+}} = !DILocalVariable(name: "one"
+  // MSVC-SAME:  type: [[TYPE_OF_ONE:![0-9]+]]
+  // MSVC-SAME:  )
+  // MSVC:   [[TYPE_OF_ONE]] = distinct !DICompositeType
   // MSVC-SAME:  tag: DW_TAG_structure_type
   // MSVC-NOT:   name:
   // MSVC-NOT:   identifier:
   // MSVC-SAME:  )
-  // MSVC:   !{{[0-9]+}} = !DILocalVariable(name: "one"
-  // MSVC-SAME:  type: [[TYPE_OF_ONE]]
-  // MSVC-SAME:  )
 
   return 0;
 }

diff  --git a/clang/test/CodeGen/debug-info-unused-types.c 
b/clang/test/CodeGen/debug-info-unused-types.c
index 5bcc71f710a5c..3e9f7b07658e3 100644
--- a/clang/test/CodeGen/debug-info-unused-types.c
+++ b/clang/test/CodeGen/debug-info-unused-types.c
@@ -18,13 +18,13 @@ void quux(void) {
 // CHECK: !DICompileUnit{{.+}}retainedTypes: [[RETTYPES:![0-9]+]]
 // CHECK: [[TYPE0:![0-9]+]] = !DICompositeType(tag: DW_TAG_enumeration_type, 
name: "bar"
 // CHECK: [[TYPE1:![0-9]+]] = !DIEnumerator(name: "BAR"
-// CHECK: [[RETTYPES]] = !{[[TYPE2:![0-9]+]], [[TYPE3:![0-9]+]], [[TYPE0]], 
[[TYPE4:![0-9]+]], {{![0-9]+}}, [[TYPE5:![0-9]+]], [[TYPE6:![0-9]+]], 
[[TYPE8:![0-9]+]]}
-// CHECK: [[TYPE2]] = !DIDerivedType(tag: DW_TAG_typedef, name: "my_int"
-// CHECK: [[TYPE3]] = distinct !DICompositeType(tag: DW_TAG_structure_type, 
name: "foo"
-// CHECK: [[TYPE4]] = distinct !DICompositeType(tag: DW_TAG_union_type, name: 
"baz"
-// CHECK: [[TYPE5]] = distinct !DICompositeType(tag: DW_TAG_structure_type, 
name: "y"
-// CHECK: [[TYPE6]] = !DICompositeType(tag: DW_TAG_enumeration_type, name: "z"
-// CHECK: [[TYPE7:![0-9]+]] = !DIEnumerator(name: "Z"
+// CHECK: [[TYPE2:![0-9]+]] = !DICompositeType(tag: DW_TAG_enumeration_type, 
name: "z"
+// CHECK: [[TYPE3:![0-9]+]] = !DIEnumerator(name: "Z"
+// CHECK: [[RETTYPES]] = !{[[TYPE4:![0-9]+]], [[TYPE5:![0-9]+]], 

[PATCH] D153310: Add builtin_elementwise_pow

2023-06-19 Thread Joshua Batista via Phabricator via cfe-commits
bob80905 created this revision.
Herald added subscribers: luke, Anastasia, frasercrmck, luismarques, apazos, 
sameer.abuasal, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, 
MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, 
simoncook, johnrusso, rbar, asb.
Herald added a project: All.
bob80905 requested review of this revision.
Herald added subscribers: cfe-commits, wangpc.
Herald added a project: clang.

Add codegen for llvm pow elementwise builtin
The pow elementwise builtin is necessary for HLSL codegen.
Tests were added to make sure that the expected errors are encountered when 
these functions are given inputs of incompatible types, or too many inputs.
The new builtin is restricted to floating point types only.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153310

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/Builtins.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-elementwise-math.c
  clang/test/Sema/aarch64-sve-vector-pow-ops.c
  clang/test/Sema/builtins-elementwise-math.c
  clang/test/Sema/riscv-sve-vector-pow-ops.c
  clang/test/SemaCXX/builtins-elementwise-math.cpp

Index: clang/test/SemaCXX/builtins-elementwise-math.cpp
===
--- clang/test/SemaCXX/builtins-elementwise-math.cpp
+++ clang/test/SemaCXX/builtins-elementwise-math.cpp
@@ -108,3 +108,11 @@
   static_assert(!is_const::value);
   static_assert(!is_const::value);
 }
+
+void test_builtin_elementwise_pow() {
+  const double a = 2;
+  double b = 1;
+  static_assert(!is_const::value);
+  static_assert(!is_const::value);
+  static_assert(!is_const::value);
+}
Index: clang/test/Sema/riscv-sve-vector-pow-ops.c
===
--- /dev/null
+++ clang/test/Sema/riscv-sve-vector-pow-ops.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \
+// RUN:   -target-feature +v -target-feature +zfh -target-feature +experimental-zvfh \
+// RUN:   -disable-O0-optnone -o - -fsyntax-only %s -verify 
+// REQUIRES: riscv-registered-target
+
+#include 
+
+
+vfloat32mf2_t test_pow_vv_i8mf8(vfloat32mf2_t v) {
+
+  return __builtin_elementwise_pow(v, v);
+  // expected-error@-1 {{1st argument must be a vector, integer or floating point type}}
+}
\ No newline at end of file
Index: clang/test/Sema/builtins-elementwise-math.c
===
--- clang/test/Sema/builtins-elementwise-math.c
+++ clang/test/Sema/builtins-elementwise-math.c
@@ -438,6 +438,65 @@
   // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
 }
 
+void test_builtin_elementwise_pow(int i, short s, double d, float4 v, int3 iv, unsigned3 uv, int *p) {
+  i = __builtin_elementwise_pow(p, d);
+  // expected-error@-1 {{arguments are of different types ('int *' vs 'double')}}
+
+  struct Foo foo = __builtin_elementwise_pow(i, i);
+  // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'int'}}
+
+  i = __builtin_elementwise_pow(i);
+  // expected-error@-1 {{too few arguments to function call, expected 2, have 1}}
+
+  i = __builtin_elementwise_pow();
+  // expected-error@-1 {{too few arguments to function call, expected 2, have 0}}
+
+  i = __builtin_elementwise_pow(i, i, i);
+  // expected-error@-1 {{too many arguments to function call, expected 2, have 3}}
+
+  i = __builtin_elementwise_pow(v, iv);
+  // expected-error@-1 {{arguments are of different types ('float4' (vector of 4 'float' values) vs 'int3' (vector of 3 'int' values))}}
+
+  i = __builtin_elementwise_pow(uv, iv);
+  // expected-error@-1 {{arguments are of different types ('unsigned3' (vector of 3 'unsigned int' values) vs 'int3' (vector of 3 'int' values))}}
+
+  v = __builtin_elementwise_pow(v, v);
+  // expected-error@-1 {{1st argument must be a vector of integers (was 'float4' (vector of 4 'float' values))}}
+
+  s = __builtin_elementwise_pow(i, s);
+
+  enum e { one,
+   two };
+  i = __builtin_elementwise_pow(one, two);
+
+  enum f { three };
+  enum f x = __builtin_elementwise_pow(one, three);
+
+  _BitInt(32) ext; // expected-warning {{'_BitInt' in C17 and earlier is a Clang extension}}
+  ext = __builtin_elementwise_pow(ext, ext);
+
+  const int ci;
+  i = __builtin_elementwise_pow(ci, i);
+  i = __builtin_elementwise_pow(i, ci);
+  i = __builtin_elementwise_pow(ci, ci);
+
+  i = __builtin_elementwise_pow(i, int_as_one); // ok (attributes don't match)?
+  i = __builtin_elementwise_pow(i, b);  // ok (sugar doesn't match)?
+
+  int A[10];
+  A = __builtin_elementwise_pow(A, A);
+  // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was 'int *')}}
+
+  int(ii);
+  int j;
+  j = __builtin_elementwise_pow(i, j);
+
+  _Complex 

[PATCH] D153008: [RISCV] Allow slash-star comments in instruction operands

2023-06-19 Thread Abel Bernabeu via Phabricator via cfe-commits
abel-bernabeu added a comment.

@jrtc27:

The tests:

- are under llvm/test/MC/RISCV
- use llvm-mc as assembler (rather than C!)
- are as simple as they can be
- cover every line touched by this patch.

Would you unblock this now? Thanks for your feedback so far.

@MaskRay:

Let me know if you miss any testing or places where comments are still not 
possible. Am pretty sure I am covering every case.

You have been added as coauthor here (with the standard "Co-Authored-By: " tag 
on the commit message) and you can close https://reviews.llvm.org/D153204 in 
return :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153008

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


[PATCH] D153008: [RISCV] Allow slash-star comments in instruction operands

2023-06-19 Thread Abel Bernabeu via Phabricator via cfe-commits
abel-bernabeu updated this revision to Diff 532758.
abel-bernabeu added a comment.

On the zdinx test, changed a FileCheck comment that was written starting with 
"//" rather than "#".

Changed for "#" just for consistency with the rest of tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153008

Files:
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/test/MC/RISCV/comments-zdinx.ll
  llvm/test/MC/RISCV/comments.ll

Index: llvm/test/MC/RISCV/comments.ll
===
--- /dev/null
+++ llvm/test/MC/RISCV/comments.ll
@@ -0,0 +1,67 @@
+# RUN: llvm-mc -triple=riscv64 --preserve-comments \
+# RUN:--mattr=+v,+experimental-zfa,+experimental-zcmp,+experimental-ztso %s \
+# RUN:| FileCheck %s  --match-full-lines
+
+/*c0*/ li /*c1*/ a0 /*c2*/ , /*c3*/ 0 /*c4*/
+# CHECK: li	a0, 0	#c0	#c1	#c2	#c3	#c4
+
+/*c0*/ lw /*c1*/ a0 /*c2*/ , /*c3*/ 0 /*c4*/ ( /*c5*/ a1 /*c6*/ ) /*c7*/
+# CHECK: lw  a0, 0(a1)   #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7
+
+/*c0*/ lw /*c1*/ a0 /*c2*/ , /*c3*/ ( /*c4*/ a1 /*c5*/ ) /*c6*/
+# CHECK: lw  a0, 0(a1)   #c0 #c1 #c2 #c3 #c4 #c5 #c6
+
+/*c0*/ fli.s /*c1*/ ft0 /*c2*/ , /*c3*/ nan /*c4*/
+# CHECK: fli.s	ft0, nan	#c0	#c1	#c2	#c3	#c4
+
+/*c0*/ fli.s /*c1*/ ft0 /*c2*/ , /*c3*/ 1.0 /*c4*/
+# CHECK: fli.s	ft0, 1.0	#c0	#c1	#c2	#c3	#c4
+
+/*c0*/ auipc /*c1*/ a0 /*c2*/ , /*c3*/ %pcrel_hi /*c4*/ ( /*c5*/ a1 /*c6*/ ) /*c7*/
+# CHECK:  auipc   a0, %pcrel_hi(a1)   #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7
+
+/*c0*/ la /*c1*/ s0 /*c2*/ , /*c3*/ symbol /*c4*/ + /*c5*/ 10 /*c6*/
+# CHECK: .Lpcrel_hi0:#c0 #c1 #c2 #c3 #c4 #c5 #c6
+# CHECK-NEXT: auipc   s0, %pcrel_hi(symbol+10)
+# CHECK-NEXT: addis0, s0, %pcrel_lo(.Lpcrel_hi0)
+
+/*c0*/ la /*c1*/ s0 /*c2*/ , /*c3*/ symbol /*c4*/ - /*c5*/ 10 /*c6*/
+# CHECK: .Lpcrel_hi1:#c0 #c1 #c2 #c3 #c4 #c5	#c6
+# CHECK-NEXT: auipc   s0, %pcrel_hi(symbol-10)
+# CHECK-NEXT: addis0, s0, %pcrel_lo(.Lpcrel_hi1)
+
+/*c0*/ vsetivli /*c1*/ a2 /*c2*/ , /*c3*/ 31 /*c4*/ , /*c5*/ e32 /*c6*/ , /*c7*/ m1 /*c8*/ , /*c9*/ ta /*c10*/ , /*c11*/ ma /*c12*/
+# CHECK: vsetivlia2, 31, e32, m1, ta, ma #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8 #c9 #c10#c11#c12
+
+/*c0*/ vadd.vv /*c1*/ v1 /*c2*/ , /*c3*/ v2 /*c4*/ , /*c5*/ v3 /*c6*/ , /*c7*/ v0.t /*c8*/
+# CHECK: vadd.vv v1, v2, v3, v0.t#c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8
+
+/*c0*/ cm.push /*c1*/ { /*c2*/ ra /*c3*/ , /*c4*/ s0 /*c5*/ - /*c6*/ s1 /*c7*/ } /*c8*/ , /*c9*/ - /*c10*/ 32 /*c11*/
+# CHECK: cm.push {ra, s0-s1}, -32#c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8 #c9 #c10#c11
+
+/*c0*/ cm.popret /*c0*/ { /*c1*/ x1 /*c2*/ , /*c3*/ x8 /*c4*/ - /*c5*/ x9 /*c6*/ , /*c7*/ x18 /*c8*/ - /*c9*/ x20 /*c10*/ } /*c11*/ , /*c12*/ 64 /*c13*/
+# CHECK: cm.popret   {ra, s0-s4}, 64 #c0 #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8 #c9 #c10#c11#c12#c13
+
+/*c0*/ fence /*c1*/ 0 /*c2*/ , /*c3*/ 0 /*c4*/
+# CHECK: fence   0, 0#c0 #c1 #c2 #c3 #c4
+
+/*c0*/ fence /*c1*/ iorw /*c2*/ , /*c3*/ iorw /*c4*/
+# CHECK: fence   #c0 #c1 #c2 #c3 #c4
+
+/*c0*/ fence.tso /*c1*/
+# CHECK: fence.tso   #c0 #c1
+
+/*c0*/ fence.i /*c1*/
+# CHECK: fence.i #c0 #c1
+
+/*c0*/ nop /*c1*/
+# CHECK: nop	#c0	#c1
+
+/*c0*/ .option /*c1*/ arch /*c2*/ , /*c3*/ rv64gc /*c4*/
+# CHECK: .option arch, rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0
+
+/*c0*/ .attribute /*c1*/ priv_spec /*c2*/ , /*c3*/ 2 /*c4*/
+# CHECK: .attribute  8, 2
+
+/*c0*/ .attribute /*c1*/ arch /*c2*/ , /*c3*/ "rv32i_zvfbfmin0p6" /*c4*/
+# CHECK: .attribute  5, "rv32i2p1_f2p2_zicsr2p0_zve32f1p0_zve32x1p0_zvfbfmin0p6_zvl32b1p0"
Index: llvm/test/MC/RISCV/comments-zdinx.ll
===
--- /dev/null
+++ llvm/test/MC/RISCV/comments-zdinx.ll
@@ -0,0 +1,4 @@
+# RUN: llvm-mc -triple=riscv64 --preserve-comments --mattr=+zdinx  %s | FileCheck %s --match-full-lines
+
+/*c0*/ fmadd.d /*c1*/ x10 /*c2*/ , /*c3*/ x12 /*c4*/ , /*c5*/ x14 /*c6*/ , /*c7*/ x16 /*c8*/ , /*c9*/ dyn /*c10*/
+# CHECK: fmadd.d a0, a2, a4, a6  #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8 #c9 #c10
Index: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
===
--- llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -107,6 +107,8 @@
uint64_t ,
bool MatchingInlineAsm) override;
 
+  AsmToken peekNextNext();
+
   bool parseRegister(MCRegister , 

[PATCH] D153008: [RISCV] Allow slash-star comments in instruction operands

2023-06-19 Thread Abel Bernabeu via Phabricator via cfe-commits
abel-bernabeu accepted this revision.
abel-bernabeu added a comment.

Am happy with the current patch version


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153008

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


[PATCH] D153008: [RISCV] Allow slash-star comments in instruction operands

2023-06-19 Thread Abel Bernabeu via Phabricator via cfe-commits
abel-bernabeu updated this revision to Diff 532754.
abel-bernabeu added a comment.

Removed a gratuitous blank line


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153008

Files:
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/test/MC/RISCV/comments-zdinx.ll
  llvm/test/MC/RISCV/comments.ll

Index: llvm/test/MC/RISCV/comments.ll
===
--- /dev/null
+++ llvm/test/MC/RISCV/comments.ll
@@ -0,0 +1,67 @@
+# RUN: llvm-mc -triple=riscv64 --preserve-comments \
+# RUN:--mattr=+v,+experimental-zfa,+experimental-zcmp,+experimental-ztso %s \
+# RUN:| FileCheck %s  --match-full-lines
+
+/*c0*/ li /*c1*/ a0 /*c2*/ , /*c3*/ 0 /*c4*/
+# CHECK: li	a0, 0	#c0	#c1	#c2	#c3	#c4
+
+/*c0*/ lw /*c1*/ a0 /*c2*/ , /*c3*/ 0 /*c4*/ ( /*c5*/ a1 /*c6*/ ) /*c7*/
+# CHECK: lw  a0, 0(a1)   #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7
+
+/*c0*/ lw /*c1*/ a0 /*c2*/ , /*c3*/ ( /*c4*/ a1 /*c5*/ ) /*c6*/
+# CHECK: lw  a0, 0(a1)   #c0 #c1 #c2 #c3 #c4 #c5 #c6
+
+/*c0*/ fli.s /*c1*/ ft0 /*c2*/ , /*c3*/ nan /*c4*/
+# CHECK: fli.s	ft0, nan	#c0	#c1	#c2	#c3	#c4
+
+/*c0*/ fli.s /*c1*/ ft0 /*c2*/ , /*c3*/ 1.0 /*c4*/
+# CHECK: fli.s	ft0, 1.0	#c0	#c1	#c2	#c3	#c4
+
+/*c0*/ auipc /*c1*/ a0 /*c2*/ , /*c3*/ %pcrel_hi /*c4*/ ( /*c5*/ a1 /*c6*/ ) /*c7*/
+# CHECK:  auipc   a0, %pcrel_hi(a1)   #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7
+
+/*c0*/ la /*c1*/ s0 /*c2*/ , /*c3*/ symbol /*c4*/ + /*c5*/ 10 /*c6*/
+# CHECK: .Lpcrel_hi0:#c0 #c1 #c2 #c3 #c4 #c5 #c6
+# CHECK-NEXT: auipc   s0, %pcrel_hi(symbol+10)
+# CHECK-NEXT: addis0, s0, %pcrel_lo(.Lpcrel_hi0)
+
+/*c0*/ la /*c1*/ s0 /*c2*/ , /*c3*/ symbol /*c4*/ - /*c5*/ 10 /*c6*/
+# CHECK: .Lpcrel_hi1:#c0 #c1 #c2 #c3 #c4 #c5	#c6
+# CHECK-NEXT: auipc   s0, %pcrel_hi(symbol-10)
+# CHECK-NEXT: addis0, s0, %pcrel_lo(.Lpcrel_hi1)
+
+/*c0*/ vsetivli /*c1*/ a2 /*c2*/ , /*c3*/ 31 /*c4*/ , /*c5*/ e32 /*c6*/ , /*c7*/ m1 /*c8*/ , /*c9*/ ta /*c10*/ , /*c11*/ ma /*c12*/
+# CHECK: vsetivlia2, 31, e32, m1, ta, ma #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8 #c9 #c10#c11#c12
+
+/*c0*/ vadd.vv /*c1*/ v1 /*c2*/ , /*c3*/ v2 /*c4*/ , /*c5*/ v3 /*c6*/ , /*c7*/ v0.t /*c8*/
+# CHECK: vadd.vv v1, v2, v3, v0.t#c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8
+
+/*c0*/ cm.push /*c1*/ { /*c2*/ ra /*c3*/ , /*c4*/ s0 /*c5*/ - /*c6*/ s1 /*c7*/ } /*c8*/ , /*c9*/ - /*c10*/ 32 /*c11*/
+# CHECK: cm.push {ra, s0-s1}, -32#c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8 #c9 #c10#c11
+
+/*c0*/ cm.popret /*c0*/ { /*c1*/ x1 /*c2*/ , /*c3*/ x8 /*c4*/ - /*c5*/ x9 /*c6*/ , /*c7*/ x18 /*c8*/ - /*c9*/ x20 /*c10*/ } /*c11*/ , /*c12*/ 64 /*c13*/
+# CHECK: cm.popret   {ra, s0-s4}, 64 #c0 #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8 #c9 #c10#c11#c12#c13
+
+/*c0*/ fence /*c1*/ 0 /*c2*/ , /*c3*/ 0 /*c4*/
+# CHECK: fence   0, 0#c0 #c1 #c2 #c3 #c4
+
+/*c0*/ fence /*c1*/ iorw /*c2*/ , /*c3*/ iorw /*c4*/
+# CHECK: fence   #c0 #c1 #c2 #c3 #c4
+
+/*c0*/ fence.tso /*c1*/
+# CHECK: fence.tso   #c0 #c1
+
+/*c0*/ fence.i /*c1*/
+# CHECK: fence.i #c0 #c1
+
+/*c0*/ nop /*c1*/
+# CHECK: nop	#c0	#c1
+
+/*c0*/ .option /*c1*/ arch /*c2*/ , /*c3*/ rv64gc /*c4*/
+# CHECK: .option arch, rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0
+
+/*c0*/ .attribute /*c1*/ priv_spec /*c2*/ , /*c3*/ 2 /*c4*/
+# CHECK: .attribute  8, 2
+
+/*c0*/ .attribute /*c1*/ arch /*c2*/ , /*c3*/ "rv32i_zvfbfmin0p6" /*c4*/
+# CHECK: .attribute  5, "rv32i2p1_f2p2_zicsr2p0_zve32f1p0_zve32x1p0_zvfbfmin0p6_zvl32b1p0"
Index: llvm/test/MC/RISCV/comments-zdinx.ll
===
--- /dev/null
+++ llvm/test/MC/RISCV/comments-zdinx.ll
@@ -0,0 +1,4 @@
+# RUN: llvm-mc -triple=riscv64 --preserve-comments --mattr=+zdinx  %s | FileCheck %s --match-full-lines
+
+/*c0*/ fmadd.d /*c1*/ x10 /*c2*/ , /*c3*/ x12 /*c4*/ , /*c5*/ x14 /*c6*/ , /*c7*/ x16 /*c8*/ , /*c9*/ dyn /*c10*/
+// CHECK: fmadd.d a0, a2, a4, a6  #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8 #c9 #c10
Index: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
===
--- llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -107,6 +107,8 @@
uint64_t ,
bool MatchingInlineAsm) override;
 
+  AsmToken peekNextNext();
+
   bool parseRegister(MCRegister , SMLoc ,
  SMLoc ) override;
   OperandMatchResultTy tryParseRegister(MCRegister , SMLoc ,
@@ -1577,10 +1579,38 

[PATCH] D153008: [RISCV] Allow slash-star comments in instruction operands

2023-06-19 Thread Abel Bernabeu via Phabricator via cfe-commits
abel-bernabeu updated this revision to Diff 532753.
abel-bernabeu added a comment.

Added --match-fulllines to FileCheck for making the check stricter.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153008

Files:
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/test/MC/RISCV/comments-zdinx.ll
  llvm/test/MC/RISCV/comments.ll

Index: llvm/test/MC/RISCV/comments.ll
===
--- /dev/null
+++ llvm/test/MC/RISCV/comments.ll
@@ -0,0 +1,68 @@
+# RUN: llvm-mc -triple=riscv64 --preserve-comments \
+# RUN:--mattr=+v,+experimental-zfa,+experimental-zcmp,+experimental-ztso %s \
+# RUN:| FileCheck %s  --match-full-lines
+
+/*c0*/ li /*c1*/ a0 /*c2*/ , /*c3*/ 0 /*c4*/
+# CHECK: li	a0, 0	#c0	#c1	#c2	#c3	#c4
+
+/*c0*/ lw /*c1*/ a0 /*c2*/ , /*c3*/ 0 /*c4*/ ( /*c5*/ a1 /*c6*/ ) /*c7*/
+# CHECK: lw  a0, 0(a1)   #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7
+
+/*c0*/ lw /*c1*/ a0 /*c2*/ , /*c3*/ ( /*c4*/ a1 /*c5*/ ) /*c6*/
+# CHECK: lw  a0, 0(a1)   #c0 #c1 #c2 #c3 #c4 #c5 #c6
+
+/*c0*/ fli.s /*c1*/ ft0 /*c2*/ , /*c3*/ nan /*c4*/
+# CHECK: fli.s	ft0, nan	#c0	#c1	#c2	#c3	#c4
+
+/*c0*/ fli.s /*c1*/ ft0 /*c2*/ , /*c3*/ 1.0 /*c4*/
+# CHECK: fli.s	ft0, 1.0	#c0	#c1	#c2	#c3	#c4
+
+/*c0*/ auipc /*c1*/ a0 /*c2*/ , /*c3*/ %pcrel_hi /*c4*/ ( /*c5*/ a1 /*c6*/ ) /*c7*/
+# CHECK:  auipc   a0, %pcrel_hi(a1)   #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7
+
+/*c0*/ la /*c1*/ s0 /*c2*/ , /*c3*/ symbol /*c4*/ + /*c5*/ 10 /*c6*/
+# CHECK: .Lpcrel_hi0:#c0 #c1 #c2 #c3 #c4 #c5 #c6
+# CHECK-NEXT: auipc   s0, %pcrel_hi(symbol+10)
+# CHECK-NEXT: addis0, s0, %pcrel_lo(.Lpcrel_hi0)
+
+/*c0*/ la /*c1*/ s0 /*c2*/ , /*c3*/ symbol /*c4*/ - /*c5*/ 10 /*c6*/
+# CHECK: .Lpcrel_hi1:#c0 #c1 #c2 #c3 #c4 #c5	#c6
+# CHECK-NEXT: auipc   s0, %pcrel_hi(symbol-10)
+# CHECK-NEXT: addis0, s0, %pcrel_lo(.Lpcrel_hi1)
+
+/*c0*/ vsetivli /*c1*/ a2 /*c2*/ , /*c3*/ 31 /*c4*/ , /*c5*/ e32 /*c6*/ , /*c7*/ m1 /*c8*/ , /*c9*/ ta /*c10*/ , /*c11*/ ma /*c12*/
+# CHECK: vsetivlia2, 31, e32, m1, ta, ma #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8 #c9 #c10#c11#c12
+
+/*c0*/ vadd.vv /*c1*/ v1 /*c2*/ , /*c3*/ v2 /*c4*/ , /*c5*/ v3 /*c6*/ , /*c7*/ v0.t /*c8*/
+# CHECK: vadd.vv v1, v2, v3, v0.t#c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8
+
+/*c0*/ cm.push /*c1*/ { /*c2*/ ra /*c3*/ , /*c4*/ s0 /*c5*/ - /*c6*/ s1 /*c7*/ } /*c8*/ , /*c9*/ - /*c10*/ 32 /*c11*/
+# CHECK: cm.push {ra, s0-s1}, -32#c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8 #c9 #c10#c11
+
+/*c0*/ cm.popret /*c0*/ { /*c1*/ x1 /*c2*/ , /*c3*/ x8 /*c4*/ - /*c5*/ x9 /*c6*/ , /*c7*/ x18 /*c8*/ - /*c9*/ x20 /*c10*/ } /*c11*/ , /*c12*/ 64 /*c13*/
+# CHECK: cm.popret   {ra, s0-s4}, 64 #c0 #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8 #c9 #c10#c11#c12#c13
+
+/*c0*/ fence /*c1*/ 0 /*c2*/ , /*c3*/ 0 /*c4*/
+# CHECK: fence   0, 0#c0 #c1 #c2 #c3 #c4
+
+/*c0*/ fence /*c1*/ iorw /*c2*/ , /*c3*/ iorw /*c4*/
+# CHECK: fence   #c0 #c1 #c2 #c3 #c4
+
+/*c0*/ fence.tso /*c1*/
+# CHECK: fence.tso   #c0 #c1
+
+/*c0*/ fence.i /*c1*/
+# CHECK: fence.i #c0 #c1
+
+/*c0*/ nop /*c1*/
+# CHECK: nop	#c0	#c1
+
+/*c0*/ .option /*c1*/ arch /*c2*/ , /*c3*/ rv64gc /*c4*/
+
+# CHECK: .option arch, rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0
+
+/*c0*/ .attribute /*c1*/ priv_spec /*c2*/ , /*c3*/ 2 /*c4*/
+# CHECK: .attribute  8, 2
+
+/*c0*/ .attribute /*c1*/ arch /*c2*/ , /*c3*/ "rv32i_zvfbfmin0p6" /*c4*/
+# CHECK: .attribute  5, "rv32i2p1_f2p2_zicsr2p0_zve32f1p0_zve32x1p0_zvfbfmin0p6_zvl32b1p0"
Index: llvm/test/MC/RISCV/comments-zdinx.ll
===
--- /dev/null
+++ llvm/test/MC/RISCV/comments-zdinx.ll
@@ -0,0 +1,4 @@
+# RUN: llvm-mc -triple=riscv64 --preserve-comments --mattr=+zdinx  %s | FileCheck %s --match-full-lines
+
+/*c0*/ fmadd.d /*c1*/ x10 /*c2*/ , /*c3*/ x12 /*c4*/ , /*c5*/ x14 /*c6*/ , /*c7*/ x16 /*c8*/ , /*c9*/ dyn /*c10*/
+// CHECK: fmadd.d a0, a2, a4, a6  #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8 #c9 #c10
Index: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
===
--- llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -107,6 +107,8 @@
uint64_t ,
bool MatchingInlineAsm) override;
 
+  AsmToken peekNextNext();
+
   bool parseRegister(MCRegister , SMLoc ,
  SMLoc ) override;
   OperandMatchResultTy 

[PATCH] D153298: [clang-tidy] Extend bugprone-exception-escape diagnostics

2023-06-19 Thread Domján Dániel via Phabricator via cfe-commits
isuckatcs added inline comments.



Comment at: clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp:84-86
+  if (AnalyzeResult.containsUnknownElements())
+diag(MatchedDecl->getLocation(), "may throw unknown exceptions",
+ DiagnosticIDs::Note);

I'm still not sure how I feel about this message though.



Comment at: clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp:334
+  CaughtExceptions.insert({ExceptionTy, ThrowLoc});
+  continue;
 }

This `continue` and the other one change the behaviour of this function.  
Without this some additional conditions are also checked after the `else if` 
block. Shouldn't we preserve the old behaviour?



Comment at: clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp:390
   for (const Type *T : TypesToDelete)
-ThrownExceptions.erase(T);
+ThrownExceptions.erase({T, SourceLocation()});
 

This line makes me wonder if it's worth using a `map` instead of a `set` for 
`ThrownExceptions`. You could map the type to the location. I mean technically, 
that happens now too, but not with the appropriate data structure. 

Also I wonder what happens if a function can throw the same type from multiple 
locations. E.g.:
```lang=c++
void foo(int x) {
  if(x == 0) 
throw 1;
  
  if(x == 1)
throw 2;
}
```
Here only the last location will be preserved, so maybe mapping `Type` to 
`vector` would be better.



Comment at: clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h:46
+
+  friend bool operator<(const ThrowInfo , const ThrowInfo ) noexcept {
+return L.ThrowType < R.ThrowType;

What is the reason behind declaring this operator and the one below as `friend`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153298

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


[PATCH] D152882: [LinkerWrapper] Support device binaries in multiple link jobs

2023-06-19 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 532748.
jhuber6 added a comment.

I'm not sure why this keeps failing on Windows and have no clue how to tell 
what's going wrong. The builder simply says

  c:\ws\w4\llvm-project\premerge-checks\build\bin\clang-linker-wrapper.exe: 
error: invalid argument

But I'm unsure what could be causing that since it works on Linux and we have 
plenty of other tests that Windows passes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152882

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/amdgpu-openmp-toolchain.c
  clang/test/Driver/linker-wrapper.c
  clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
  clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td
  llvm/include/llvm/Object/OffloadBinary.h

Index: llvm/include/llvm/Object/OffloadBinary.h
===
--- llvm/include/llvm/Object/OffloadBinary.h
+++ llvm/include/llvm/Object/OffloadBinary.h
@@ -17,6 +17,7 @@
 #ifndef LLVM_OBJECT_OFFLOADBINARY_H
 #define LLVM_OBJECT_OFFLOADBINARY_H
 
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Object/Binary.h"
@@ -155,12 +156,22 @@
 /// owns its memory.
 class OffloadFile : public OwningBinary {
 public:
+  /// An ordered pair of the target triple and the architecture.
   using TargetID = std::pair;
 
   OffloadFile(std::unique_ptr Binary,
   std::unique_ptr Buffer)
   : OwningBinary(std::move(Binary), std::move(Buffer)) {}
 
+  Expected copy() const {
+std::unique_ptr Buffer = MemoryBuffer::getMemBufferCopy(
+getBinary()->getMemoryBufferRef().getBuffer());
+auto NewBinaryOrErr = OffloadBinary::create(*Buffer);
+if (!NewBinaryOrErr)
+  return NewBinaryOrErr.takeError();
+return OffloadFile(std::move(*NewBinaryOrErr), std::move(Buffer));
+  }
+
   /// We use the Triple and Architecture pair to group linker inputs together.
   /// This conversion function lets us use these inputs in a hash-map.
   operator TargetID() const {
@@ -168,6 +179,28 @@
   }
 };
 
+/// Queries if the target \p LHS is compatible with \p RHS for linking purposes.
+inline bool areTargetsCompatible(const OffloadFile::TargetID LHS,
+ const OffloadFile::TargetID RHS) {
+  if (LHS == RHS)
+return true;
+
+  // If the target is AMD we check the target IDs for compatibility. A target id
+  // is a string conforming to the folowing BNF syntax:
+  //
+  //  target-id ::= ' ( :  ( '+' | '-' ) )*'
+  //
+  // This is used to link mutually compatible architectures together.
+  llvm::Triple T(LHS.first);
+  if (!T.isAMDGPU())
+return false;
+
+  // The targets are compatible if the architecture is a subset of the other.
+  if (RHS.second.contains(LHS.second))
+return true;
+  return false;
+}
+
 /// Extracts embedded device offloading code from a memory \p Buffer to a list
 /// of \p Binaries.
 Error extractOffloadBinaries(MemoryBufferRef Buffer,
Index: clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td
===
--- clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td
+++ clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td
@@ -67,6 +67,9 @@
 def arch_EQ : Joined<["--"], "arch=">,
   Flags<[DeviceOnlyOption, HelpHidden]>, MetaVarName<"">,
   HelpText<"The device subarchitecture">;
+def full_arch_EQ : Joined<["--"], "full-arch=">,
+  Flags<[DeviceOnlyOption, HelpHidden]>, MetaVarName<"">,
+  HelpText<"The fully qualifier device subarchitecture for AMD's target ID">;
 def triple_EQ : Joined<["--"], "triple=">,
   Flags<[DeviceOnlyOption, HelpHidden]>, MetaVarName<"">,
   HelpText<"The device target triple">;
Index: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
===
--- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -969,9 +969,13 @@
   for (Arg *A : Args)
 DAL.append(A);
 
-  // Set the subarchitecture and target triple for this compilation.
+  // Set the subarchitecture and target triple for this compilation. The input
+  // may be an AMDGPU target-id so we split off anything before the colon.
   const OptTable  = getOptTable();
   DAL.AddJoinedArg(nullptr, Tbl.getOption(OPT_arch_EQ),
+   Args.MakeArgString(
+   Input.front().getBinary()->getArch().split(':').first));
+  DAL.AddJoinedArg(nullptr, Tbl.getOption(OPT_full_arch_EQ),
Args.MakeArgString(Input.front().getBinary()->getArch()));
   DAL.AddJoinedArg(nullptr, Tbl.getOption(OPT_triple_EQ),
Args.MakeArgString(Input.front().getBinary()->getTriple()));
@@ -1001,23 +1005,13 @@
 /// Transforms all the extracted offloading input files into an image that can
 /// be registered by 

[PATCH] D153294: [clang] Do not create ExprWithCleanups while checking immediate invocation

2023-06-19 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:18177
getASTContext()),
   /*IsImmediateInvocation*/ true);
   if (Cached.hasValue())

Drive by nit clean-up while we are here.



Comment at: clang/test/SemaCXX/consteval-cleanup.cpp:19
+  // CHECK: foo
+  // CHECK: ExprWithCleanups
+  // CHECK-NEXT: BinaryOperator

I am not too sure on this but perhaps showing `P : P` and `A : A` in the checks 
would be helpful 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153294

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


[PATCH] D153228: [clang-format] Fixed bad performance with enabled qualifier fixer.

2023-06-19 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks accepted this revision.
HazardyKnusperkeks added a comment.
This revision is now accepted and ready to land.

Please wait for at least @MyDeveloperDay to say something, as he is the 
original author of the work.




Comment at: clang/lib/Format/Format.cpp:3475
   AnalyzerPass;
   SmallVector Passes;
 

Sedeniono wrote:
> HazardyKnusperkeks wrote:
> > Just increase here, and add a comment that there are multiple passes added 
> > in `addQualifierAlignmentFixerPasses`.
> > 
> > I think the idea was and should be that we always store the pointers on the 
> > stack.
> Ok, done.
You don't need to comment done. But please check the "Done" on my comment. :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153228

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


[PATCH] D153208: [clang-format] Add InsertNewlineAtEOF to .clang-format files

2023-06-19 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

In D153208#4431697 , @owenpan wrote:

> In D153208#4431239 , 
> @HazardyKnusperkeks wrote:
>
>> We also could add a clang-format style, the you wouldn't have to to touch 
>> all .clang-format files. ;)
>
> Something like `BasedOnStyle: clang-format`? I like it but feel that it 
> should be an undocumented feature. What do you all think?

I don't know if I want this or if it just a joke. But if we do it, I would 
document it, something like. "Basically LLVM Style, which uses some of the 
newer options, to enforce some of the LLVM style guide rules."


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

https://reviews.llvm.org/D153208

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


[PATCH] D153235: [RISCV] Change the type of argument to clz and ctz from ZiZi/WiWi to iUi/iULi

2023-06-19 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsRISCV.def:22
+TARGET_BUILTIN(__builtin_riscv_clz_32, "iUi", "nc", "zbb|xtheadbb")
+TARGET_BUILTIN(__builtin_riscv_clz_64, "iULi", "nc", "zbb|xtheadbb,64bit")
+TARGET_BUILTIN(__builtin_riscv_ctz_32, "iUi", "nc", "zbb")

I'd prefer we use `UWi` instead of `ULi`. If we ever implement ilp32 on RV64, 
long will not be xlen bits.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153235

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


[clang] 407dcaf - [Driver] Correct -fnoxray-link-deps to -fno-xray-link-deps

2023-06-19 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-06-19T12:48:33-07:00
New Revision: 407dcaf002f71abf940f3e903fa17791b150995d

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

LOG: [Driver] Correct -fnoxray-link-deps to -fno-xray-link-deps

and removed unused CC1Option.
Also change -whole-archive to the canonical spelling and improve tests.

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/XRayArgs.cpp
clang/test/Driver/XRay/xray-nolinkdeps.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 87df2266bd7e3..cf002e772df02 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2266,10 +2266,8 @@ defm xray_function_index : 
BoolFOption<"xray-function-index",
   " expense of single-function patching performance">>;
 
 def fxray_link_deps : Flag<["-"], "fxray-link-deps">, Group,
-  Flags<[CC1Option]>,
-  HelpText<"Tells clang to add the link dependencies for XRay.">;
-def fnoxray_link_deps : Flag<["-"], "fnoxray-link-deps">, Group,
-  Flags<[CC1Option]>;
+  HelpText<"Link XRay runtime library when -fxray-instrument is specified 
(default)">;
+def fno_xray_link_deps : Flag<["-"], "fno-xray-link-deps">, Group;
 
 def fxray_instrumentation_bundle :
   Joined<["-"], "fxray-instrumentation-bundle=">,

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 165b1f9ae1300..2d9392893bc36 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1236,11 +1236,11 @@ bool tools::addXRayRuntime(const ToolChain, const 
ArgList , ArgStringLis
 return false;
 
   if (TC.getXRayArgs().needsXRayRt()) {
-CmdArgs.push_back("-whole-archive");
+CmdArgs.push_back("--whole-archive");
 CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray"));
 for (const auto  : TC.getXRayArgs().modeList())
   CmdArgs.push_back(TC.getCompilerRTArgString(Args, Mode));
-CmdArgs.push_back("-no-whole-archive");
+CmdArgs.push_back("--no-whole-archive");
 return true;
   }
 

diff  --git a/clang/lib/Driver/XRayArgs.cpp b/clang/lib/Driver/XRayArgs.cpp
index f15a91f1aba44..9a4b28576a9b9 100644
--- a/clang/lib/Driver/XRayArgs.cpp
+++ b/clang/lib/Driver/XRayArgs.cpp
@@ -74,7 +74,7 @@ XRayArgs::XRayArgs(const ToolChain , const ArgList ) {
 << XRayInstrument->getSpelling() << A->getSpelling();
 
   if (!Args.hasFlag(options::OPT_fxray_link_deps,
-options::OPT_fnoxray_link_deps, true))
+options::OPT_fno_xray_link_deps, true))
 XRayRT = false;
 
   auto Bundles =

diff  --git a/clang/test/Driver/XRay/xray-nolinkdeps.cpp 
b/clang/test/Driver/XRay/xray-nolinkdeps.cpp
index 5461fc325a242..0c42c1af4f926 100644
--- a/clang/test/Driver/XRay/xray-nolinkdeps.cpp
+++ b/clang/test/Driver/XRay/xray-nolinkdeps.cpp
@@ -1,8 +1,6 @@
-// RUN: %clang -v -o /dev/null -fxray-instrument -fnoxray-link-deps %s -### \
+// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fxray-instrument 
-fxray-link-deps -fno-xray-link-deps %s \
 // RUN: 2>&1 | FileCheck --check-prefix DISABLE %s
-// RUN: %clang -v -o /dev/null -fxray-instrument -fxray-link-deps %s -### \
+// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fxray-instrument %s \
 // RUN: 2>&1 | FileCheck --check-prefix ENABLE %s
-// ENABLE: clang_rt.xray
+// ENABLE:  "--whole-archive" 
"{{.*}}clang_rt.xray{{.*}}"--no-whole-archive"
 // DISABLE-NOT: clang_rt.xray
-// REQUIRES: linux || freebsd
-// REQUIRES: amd64 || x86_64 || x86_64h || arm || aarch64 || arm64



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


[PATCH] D153243: [clang-format] Don't finalize #if, #else, #endif, etc.

2023-06-19 Thread Sedenion via Phabricator via cfe-commits
Sedeniono requested changes to this revision.
Sedeniono added inline comments.
This revision now requires changes to proceed.



Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:1416-1421
+  if (Tok->is(tok::hash) && !Tok->Previous && Tok->Next &&
+  Tok->Next->isOneOf(tok::pp_if, tok::pp_ifdef, tok::pp_ifndef,
+ tok::pp_elif, tok::pp_elifdef, tok::pp_elifndef,
+ tok::pp_else, tok::pp_endif)) {
+Tok = Tok->Next;
+  }

After some time, I found your comment 
[here](https://reviews.llvm.org/D150057#inline-1449546) which explains the 
intention of the "do not finalize '#'" thing. Would it be possible to provide 
the reasoning here as some comment, or at least some hint that it has to do 
with multiple passes because of PP branches? To give future readers some chance 
to understand what is going on. Maybe something along the lines of
```
// Never mark the '#' of a PP branch as finalized, since clang-format performs 
// multiple passes, where each pass represents a version where the code of 
// one of the PP branches is filled in. Later passes must also  be allowed to 
// format the PP tokens.
```
Alternatively or additionally, I would be happy with a link to [your 
explanation](https://reviews.llvm.org/D150057#inline-1449546) in the code or 
the commit message, if the llvm rules/conventions allow it.

Apart from this, I have dug way too little into how clang-format works to 
reason about the change. I tested it with the full hpp file from 
https://github.com/llvm/llvm-project/issues/57117, and can confirm that the 
issue is fixed. So I believe you. ;-)
But: Considering your comment 
[here](https://reviews.llvm.org/D150057#inline-1449546), I thought that the 
whole "do not finalize '#'" thing is relevant only if there are some 
"else"-PP-branches? But in the minimal example/the unit test, there is no 
"else" branch? How do the multiple passes because of PP branches relate to the 
`clang-format off` comment?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153243

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


[PATCH] D153008: [RISCV] Allow slash-star comments in instruction operands

2023-06-19 Thread Abel Bernabeu via Phabricator via cfe-commits
abel-bernabeu added inline comments.



Comment at: llvm/test/MC/RISCV/comments.ll:25
+# CHECK: .Lpcrel_hi0:#c0 #c1 #c2 #c3 #c4 #c5 #c6
+# CHECK: auipc   s0, %pcrel_hi(symbol+10)
+# CHECK: addis0, s0, %pcrel_lo(.Lpcrel_hi0)

This should be CHECK-NEXT rather than CHECK. Will update again tonight.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153008

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


[PATCH] D153248: [clangd] Use resolveTypeToRecordDecl() to resolve the type of a base specifier during heuristic resolution

2023-06-19 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

In D153248#4432108 , @hokein wrote:

> The other question might worth thinking, are these cases critical to fix now? 
> I'm not sure `this->find()` is a common case (`find();` already works today).

I may have simplified the test case a bit too much; a more representative case 
is one where the base class is a template, and the derived class passes its 
template parameter to the base:

  template 
  struct Waldo {
void find();
  };
  
  template 
  using Wally = Waldo;
  
  template 
  struct S : Wally {
void Foo() { this->find(); }
  };

In a case like, the base class is a "dependent base", and the `this->` is 
required (without it the code doesn't compile, because the compiler only 
attempts the first phase of the name lookup on `find`, and that gives no 
results).

In any case, the code was reduced from a bug report affecting a real codebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153248

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


[PATCH] D146148: Float_t and double_t types shouldn't be modified by #pragma clang fp eval_method

2023-06-19 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 532734.

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

https://reviews.llvm.org/D146148

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/IdentifierTable.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Basic/TokenKinds.h
  clang/lib/Basic/Builtins.cpp
  clang/lib/Basic/IdentifierTable.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/test/Sema/abi-check-1.cpp
  clang/test/Sema/abi-check-2.cpp
  clang/test/Sema/abi-check-3.cpp
  clang/test/Sema/attr-only-in-default-eval.cpp

Index: clang/test/Sema/attr-only-in-default-eval.cpp
===
--- /dev/null
+++ clang/test/Sema/attr-only-in-default-eval.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef float float_t [[clang::available_only_in_default_eval_method]];
+using double_t __attribute__((available_only_in_default_eval_method)) = double;
+
+// expected-error@+1{{'available_only_in_default_eval_method' attribute only applies to typedefs}}
+class  __attribute__((available_only_in_default_eval_method)) C1 {
+};
+// expected-error@+1{{'available_only_in_default_eval_method' attribute only applies to typedefs}}
+class  [[clang::available_only_in_default_eval_method]] C2 {
+};
+
+// expected-error@+1{{'available_only_in_default_eval_method' attribute only applies to typedefs}}
+struct [[clang::available_only_in_default_eval_method]] S1;
+// expected-error@+1{{'available_only_in_default_eval_method' attribute only applies to typedefs}}
+struct __attribute__((available_only_in_default_eval_method)) S2;
+
+// expected-error@+1{{'available_only_in_default_eval_method' attribute only applies to typedefs}}
+void __attribute__((available_only_in_default_eval_method)) foo();
+// expected-error@+1{{'available_only_in_default_eval_method' attribute cannot be applied to types}}
+void [[clang::available_only_in_default_eval_method]] goo();
+// expected-error@+1{{'available_only_in_default_eval_method' attribute cannot be applied to types}}
+void bar() [[clang::available_only_in_default_eval_method]];
+// expected-error@+1{{'available_only_in_default_eval_method' attribute only applies to typedefs}}
+void barz() __attribute__((available_only_in_default_eval_method));
+
Index: clang/test/Sema/abi-check-3.cpp
===
--- /dev/null
+++ clang/test/Sema/abi-check-3.cpp
@@ -0,0 +1,86 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -DNOERROR %s
+// RUN: %clang_cc1 -fsyntax-only -verify -ffp-eval-method=extended -DNOERROR %s
+
+// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=source %s
+// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=double %s
+
+
+#ifdef NOERROR
+// expected-no-diagnostics
+typedef float float_t;
+typedef double double_t;
+#else
+typedef float float_t; //expected-error 9 {{cannot use type 'float_t' within '#pragma clang fp eval_method'; type is set according to the default eval method for the translation unit}}
+
+typedef double double_t; //expected-error 9 {{cannot use type 'double_t' within '#pragma clang fp eval_method'; type is set according to the default eval method for the translation unit}}
+#endif
+
+float foo1() {
+#pragma clang fp eval_method(extended)
+  float a;
+  double b;
+  return a - b;
+}
+
+float foo2() {
+#pragma clang fp eval_method(extended)
+  float_t a; 
+  double_t b; 
+  return a - b;
+}
+
+void foo3() {
+#pragma clang fp eval_method(extended)
+  char buff[sizeof(float_t)];
+  char bufd[sizeof(double_t)];
+  buff[1] = bufd[2];
+}
+
+float foo4() {
+#pragma clang fp eval_method(extended)
+  typedef float_t FT;
+  typedef double_t DT;
+  FT a;
+  DT b;
+  return a - b;
+}
+
+int foo5() {
+#pragma clang fp eval_method(extended)
+  int t = _Generic( 1.0L, float_t:1, default:0);
+  int v = _Generic( 1.0L, double_t:1, default:0);
+  return t;
+}
+
+void foo6() {
+#pragma clang fp eval_method(extended)
+  auto resf = [](float_t f) { return f; };
+  auto resd = [](double_t g) { return g; };
+}
+
+void foo7() {
+#pragma clang fp eval_method(extended)
+  float f = (float_t)1; 
+  double d = (double_t)2; 
+}
+
+void foo8() {
+#pragma clang fp eval_method(extended)
+  using Ft = float_t;
+  using Dt = double_t;
+  Ft a;
+  Dt b;
+}
+
+void foo9() {
+#pragma clang fp eval_method(extended)
+  float c1 = (float_t)12;
+  double c2 = (double_t)13;
+}
+
+float foo10() {
+#pragma clang fp eval_method(extended)
+  extern float_t f;
+  extern double_t g;
+  return f-g;
+}
Index: clang/test/Sema/abi-check-2.cpp
===
--- /dev/null
+++ clang/test/Sema/abi-check-2.cpp
@@ -0,0 +1,85 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -DNOERROR %s
+// RUN: %clang_cc1 -fsyntax-only 

[PATCH] D153228: [clang-format] Fixed bad performance with enabled qualifier fixer.

2023-06-19 Thread Sedenion via Phabricator via cfe-commits
Sedeniono marked 2 inline comments as done.
Sedeniono added inline comments.



Comment at: clang/lib/Format/Format.cpp:3475
   AnalyzerPass;
   SmallVector Passes;
 

HazardyKnusperkeks wrote:
> Just increase here, and add a comment that there are multiple passes added in 
> `addQualifierAlignmentFixerPasses`.
> 
> I think the idea was and should be that we always store the pointers on the 
> stack.
Ok, done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153228

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


[PATCH] D153251: [clangd] Index the type of a non-type template parameter

2023-06-19 Thread Nathan Ridge via Phabricator via cfe-commits
nridge planned changes to this revision.
nridge added inline comments.



Comment at: clang/lib/Index/IndexDecl.cpp:708
   } else if (const auto *NTTP = dyn_cast(TP)) {
+IndexCtx.indexTypeSourceInfo(NTTP->getTypeSourceInfo(), Parent);
 if (NTTP->hasDefaultArgument())

hokein wrote:
> since this is a change in clang libindex, I think it would be better to have 
> the unittest in (clang/unittests/Index/IndexTests.cpp).
Will do


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153251

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


[PATCH] D153228: [clang-format] Fixed bad performance with enabled qualifier fixer.

2023-06-19 Thread Sedenion via Phabricator via cfe-commits
Sedeniono updated this revision to Diff 532721.
Sedeniono added a comment.

As suggested by HazardyKnusperkeks, increased the number of stack elements and 
removed the reserve(). That causes all Passes to be stored on the stack. (I 
counted 17 distinct possible passes, but not all of them can be active at the 
same time: Some are javascript and some a C++ exclusive.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153228

Files:
  clang/lib/Format/Format.cpp
  clang/lib/Format/QualifierAlignmentFixer.cpp
  clang/lib/Format/QualifierAlignmentFixer.h
  clang/unittests/Format/QualifierFixerTest.cpp

Index: clang/unittests/Format/QualifierFixerTest.cpp
===
--- clang/unittests/Format/QualifierFixerTest.cpp
+++ clang/unittests/Format/QualifierFixerTest.cpp
@@ -1016,8 +1016,8 @@
   std::vector Left;
   std::vector Right;
   std::vector ConfiguredTokens;
-  QualifierAlignmentFixer::PrepareLeftRightOrdering(Style.QualifierOrder, Left,
-Right, ConfiguredTokens);
+  prepareLeftRightOrderingForQualifierAlignmentFixer(Style.QualifierOrder, Left,
+ Right, ConfiguredTokens);
 
   EXPECT_EQ(Left.size(), (size_t)2);
   EXPECT_EQ(Right.size(), (size_t)2);
@@ -1181,10 +1181,12 @@
   Style.QualifierAlignment = FormatStyle::QAS_Custom;
   Style.QualifierOrder = {"static", "const", "type"};
 
-  ReplacementCount = 0;
-  EXPECT_EQ(ReplacementCount, 0);
   verifyFormat("static const uint32 foo[] = {0, 31};", Style);
+  EXPECT_EQ(ReplacementCount, 0);
+
   verifyFormat("#define MACRO static const", Style);
+  EXPECT_EQ(ReplacementCount, 0);
+
   verifyFormat("using sc = static const", Style);
   EXPECT_EQ(ReplacementCount, 0);
 }
Index: clang/lib/Format/QualifierAlignmentFixer.h
===
--- clang/lib/Format/QualifierAlignmentFixer.h
+++ clang/lib/Format/QualifierAlignmentFixer.h
@@ -25,32 +25,13 @@
 const Environment &)>
 AnalyzerPass;
 
-class QualifierAlignmentFixer : public TokenAnalyzer {
-  // Left to Right ordering requires multiple passes
-  SmallVector Passes;
-  StringRef 
-  ArrayRef Ranges;
-  unsigned FirstStartColumn;
-  unsigned NextStartColumn;
-  unsigned LastStartColumn;
-  StringRef FileName;
+void addQualifierAlignmentFixerPasses(const FormatStyle ,
+  SmallVector );
 
-public:
-  QualifierAlignmentFixer(const Environment , const FormatStyle ,
-  StringRef , ArrayRef Ranges,
-  unsigned FirstStartColumn, unsigned NextStartColumn,
-  unsigned LastStartColumn, StringRef FileName);
-
-  std::pair
-  analyze(TokenAnnotator ,
-  SmallVectorImpl ,
-  FormatTokenLexer ) override;
-
-  static void PrepareLeftRightOrdering(const std::vector ,
-   std::vector ,
-   std::vector ,
-   std::vector );
-};
+void prepareLeftRightOrderingForQualifierAlignmentFixer(
+const std::vector , std::vector ,
+std::vector ,
+std::vector );
 
 class LeftRightQualifierAlignmentFixer : public TokenAnalyzer {
   std::string Qualifier;
Index: clang/lib/Format/QualifierAlignmentFixer.cpp
===
--- clang/lib/Format/QualifierAlignmentFixer.cpp
+++ clang/lib/Format/QualifierAlignmentFixer.cpp
@@ -25,18 +25,13 @@
 namespace clang {
 namespace format {
 
-QualifierAlignmentFixer::QualifierAlignmentFixer(
-const Environment , const FormatStyle , StringRef ,
-ArrayRef Ranges, unsigned FirstStartColumn,
-unsigned NextStartColumn, unsigned LastStartColumn, StringRef FileName)
-: TokenAnalyzer(Env, Style), Code(Code), Ranges(Ranges),
-  FirstStartColumn(FirstStartColumn), NextStartColumn(NextStartColumn),
-  LastStartColumn(LastStartColumn), FileName(FileName) {
+void addQualifierAlignmentFixerPasses(const FormatStyle ,
+  SmallVector ) {
   std::vector LeftOrder;
   std::vector RightOrder;
   std::vector ConfiguredQualifierTokens;
-  PrepareLeftRightOrdering(Style.QualifierOrder, LeftOrder, RightOrder,
-   ConfiguredQualifierTokens);
+  prepareLeftRightOrderingForQualifierAlignmentFixer(
+  Style.QualifierOrder, LeftOrder, RightOrder, ConfiguredQualifierTokens);
 
   // Handle the left and right alignment separately.
   for (const auto  : LeftOrder) {
@@ -59,51 +54,6 @@
   }
 }
 
-std::pair QualifierAlignmentFixer::analyze(
-TokenAnnotator & /*Annotator*/,
-SmallVectorImpl & /*AnnotatedLines*/,
-FormatTokenLexer & /*Tokens*/) {
-  auto Env = Environment::make(Code, FileName, Ranges, FirstStartColumn,
-   

[PATCH] D148216: Add support for annotations in UpdateTestChecks (NFC)

2023-06-19 Thread Henrik G Olsson via Phabricator via cfe-commits
hnrklssn marked an inline comment as done.
hnrklssn added inline comments.



Comment at: llvm/utils/UpdateTestChecks/common.py:1286
+  if value == default_value:
+continue
 if action.dest == 'filters':

nikic wrote:
> nikic wrote:
> > nikic wrote:
> > > hnrklssn wrote:
> > > > nikic wrote:
> > > > > We should also not print the `all` argument for `--check-globals` 
> > > > > argument for `version < 3`, otherwise that will introduce a spurious 
> > > > > change in all such tests.
> > > > I don't know how to dynamically change the `--check-globals` option 
> > > > between `store_true` and `choices`, since the behaviour can itself be 
> > > > affected by which argument is passed to the `--version` option. So the 
> > > > way I see it there's no way of knowing how to parse between two 
> > > > different option types ahead of time. For the default when no option is 
> > > > specified the parsing is the same however, so we can simply infer later 
> > > > what option is implied based on the version.
> > > It's not necessary to change the option, just how it is printed. I.e. add 
> > > something like this:
> > > ```
> > > if args.version < 3 and value == "all":
> > > # Don't include argument value in older versions.
> > > autogenerated_note_args += "--check-globals "
> > > continue
> > > ```
> > Ah, I get what you're saying now -- old UTC_ARGS are not accepted at all 
> > anymore, and trying to update existing tests will just fail with an error!
> > 
> > We do need old UTC_ARGS to work. I think you can make the argument value 
> > optional using these options:
> > ```
> > nargs="?", 
> > const="default",
> > default="default",
> > choices=["none", "smart", "all", "default"],
> > ```
> > 
> > Or possibly omit const/default and handle None instead.
> Correction, I think the right options are:
> ```
> nargs="?",
> const="all",
> default="default",
> choices=["none", "smart", "all"],
> ```
> That is, use `"default"` is it's not specified at all, use `"all"` if only 
> `--check-globals` is passed and also accept `--check-globals none|smart|all`.
Ah nice, I did not expect the library to support this use case!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148216

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


[PATCH] D148216: Add support for annotations in UpdateTestChecks (NFC)

2023-06-19 Thread Henrik G Olsson via Phabricator via cfe-commits
hnrklssn updated this revision to Diff 532719.
hnrklssn added a comment.

Keep supporting --check-globals without explicit level as meaning 
'--check-globals all'


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148216

Files:
  clang/test/utils/update_cc_test_checks/Inputs/annotations.c
  clang/test/utils/update_cc_test_checks/Inputs/annotations.c.expected
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.expected
  clang/test/utils/update_cc_test_checks/annotations.test
  clang/test/utils/update_cc_test_checks/check-globals.test
  clang/test/utils/update_cc_test_checks/generated-funcs.test
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/check_attrs.ll.funcattrs.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.generated.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.nogenerated.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs_prefix_reuse.ll.generated.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs_prefix_reuse.ll.nogenerated.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.noglobals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.transitiveglobals.expected
  llvm/test/tools/UpdateTestChecks/update_test_checks/various_ir_values.test
  llvm/utils/UpdateTestChecks/common.py
  llvm/utils/update_cc_test_checks.py
  llvm/utils/update_test_checks.py

Index: llvm/utils/update_test_checks.py
===
--- llvm/utils/update_test_checks.py
+++ llvm/utils/update_test_checks.py
@@ -79,7 +79,10 @@
 )
 parser.add_argument(
 "--check-globals",
-action="store_true",
+nargs="?",
+const="all",
+default="default",
+choices=["none", "smart", "all"],
 help="Check global entries (global variables, metadata, attribute sets, ...) for functions",
 )
 parser.add_argument("tests", nargs="+")
@@ -195,7 +198,7 @@
 common.dump_input_lines(output_lines, ti, prefix_set, ";")
 
 args = ti.args
-if args.check_globals:
+if args.check_globals != 'none':
 generated_prefixes.extend(
 common.add_global_checks(
 builder.global_var_dict(),
@@ -205,6 +208,7 @@
 global_vars_seen_dict,
 args.preserve_names,
 True,
+args.check_globals,
 )
 )
 
@@ -272,6 +276,7 @@
 global_vars_seen_dict,
 args.preserve_names,
 True,
+args.check_globals,
 )
 )
 has_checked_pre_function_globals = True
@@ -301,7 +306,7 @@
 continue
 is_in_function = is_in_function_start = True
 
-if args.check_globals:
+if args.check_globals != 'none':
 generated_prefixes.extend(
 common.add_global_checks(
 builder.global_var_dict(),
@@ -311,6 +316,7 @@
 global_vars_seen_dict,
 args.preserve_names,
 False,
+args.check_globals,
 )
 )
 if ti.args.gen_unused_prefix_body:
Index: llvm/utils/update_cc_test_checks.py
===
--- llvm/utils/update_cc_test_checks.py
+++ llvm/utils/update_cc_test_checks.py
@@ -205,7 +205,10 @@
 )
 parser.add_argument(
 "--check-globals",
-action="store_true",
+nargs="?",
+const="all",
+default="default",
+choices=["none", "smart", "all"],
 help="Check global entries (global variables, metadata, attribute sets, ...) for functions",
 )
 parser.add_argument("tests", nargs="+")
@@ -436,7 +439,7 @@
 is_filtered=builder.is_filtered(),
 )
 
-if ti.args.check_globals:
+if ti.args.check_globals != 'none':
 generated_prefixes.extend(
 common.add_global_checks(
 builder.global_var_dict(),
@@ -444,8 +447,9 @@
 run_list,
 output_lines,
 global_vars_seen_dict,
+

[PATCH] D153233: clang: Add __builtin_elementwise_rint and nearbyint

2023-06-19 Thread Joshua Batista via Phabricator via cfe-commits
bob80905 added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:656
+  T __builtin_elementwise_nearbyint(T x) round x to the nearest  integer 
value in floating point format,  floating point types
+ rounding according to the current 
current rounding direction.
+ May not raise the inexact 
floating-point exception. This is

typo with the word current.



Comment at: clang/docs/ReleaseNotes.rst:234
   arbitrary floating-point and vector of floating-point types.
-
+- Added ``__builtin_elementwise_rint`` for  builtin for floating
+  point types. This allows access to ``llvm.rint`` for

Don't think this for is necessary or intended, and it appears in the nearbyint 
description too.


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

https://reviews.llvm.org/D153233

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


[clang] 2da4517 - Reland "[DebugMetadata][DwarfDebug] Support function-local types in lexical block scopes (4/7)"

2023-06-19 Thread Vladislav Dzhidzhoev via cfe-commits

Author: Vladislav Dzhidzhoev
Date: 2023-06-19T19:50:46+02:00
New Revision: 2da45172c4bcd42f704c57c656926f56f32fc5ce

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

LOG: Reland "[DebugMetadata][DwarfDebug] Support function-local types in 
lexical block scopes (4/7)"

Test "local-type-as-template-parameter.ll" now requires linux-system.

Authored-by: Kristina Bessonova 

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

Depends on D144005

Added: 
llvm/test/DebugInfo/Generic/inlined-local-type.ll
llvm/test/DebugInfo/Generic/lexical-block-retained-types.ll
llvm/test/DebugInfo/Generic/lexical-block-types.ll
llvm/test/DebugInfo/Generic/local-type-as-template-parameter.ll
llvm/test/DebugInfo/X86/split-dwarf-local-import.ll
llvm/test/DebugInfo/X86/split-dwarf-local-import2.ll
llvm/test/DebugInfo/X86/split-dwarf-local-import3.ll

Modified: 
clang/test/CodeGen/debug-info-codeview-unnamed.c
clang/test/CodeGen/debug-info-unused-types.c
clang/test/CodeGen/debug-info-unused-types.cpp
clang/test/CodeGenCXX/debug-info-access.cpp
clang/test/CodeGenCXX/debug-info-anon-union-vars.cpp
clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp
clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
clang/test/CodeGenCXX/debug-lambda-this.cpp
llvm/include/llvm/IR/DIBuilder.h
llvm/lib/Bitcode/Reader/MetadataLoader.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/lib/IR/DIBuilder.cpp
llvm/lib/IR/Verifier.cpp
llvm/test/Bitcode/upgrade-cu-locals.ll
llvm/test/Bitcode/upgrade-cu-locals.ll.bc
llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll
llvm/test/DebugInfo/X86/set.ll

Removed: 
llvm/test/DebugInfo/Generic/split-dwarf-local-import.ll
llvm/test/DebugInfo/Generic/split-dwarf-local-import2.ll
llvm/test/DebugInfo/Generic/split-dwarf-local-import3.ll



diff  --git a/clang/test/CodeGen/debug-info-codeview-unnamed.c 
b/clang/test/CodeGen/debug-info-codeview-unnamed.c
index bd2a7543e56b2..16ffb3682236f 100644
--- a/clang/test/CodeGen/debug-info-codeview-unnamed.c
+++ b/clang/test/CodeGen/debug-info-codeview-unnamed.c
@@ -8,23 +8,23 @@ int main(int argc, char* argv[], char* arge[]) {
   //
   struct { int bar; } one = {42};
   //
-  // LINUX:  !{{[0-9]+}} = !DILocalVariable(name: "one"
-  // LINUX-SAME: type: [[TYPE_OF_ONE:![0-9]+]]
-  // LINUX-SAME: )
-  // LINUX:  [[TYPE_OF_ONE]] = distinct !DICompositeType(
+  // LINUX:  [[TYPE_OF_ONE:![0-9]+]] = distinct !DICompositeType(
   // LINUX-SAME: tag: DW_TAG_structure_type
   // LINUX-NOT:  name:
   // LINUX-NOT:  identifier:
   // LINUX-SAME: )
+  // LINUX:  !{{[0-9]+}} = !DILocalVariable(name: "one"
+  // LINUX-SAME: type: [[TYPE_OF_ONE]]
+  // LINUX-SAME: )
   //
-  // MSVC:   !{{[0-9]+}} = !DILocalVariable(name: "one"
-  // MSVC-SAME:  type: [[TYPE_OF_ONE:![0-9]+]]
-  // MSVC-SAME:  )
-  // MSVC:   [[TYPE_OF_ONE]] = distinct !DICompositeType
+  // MSVC:   [[TYPE_OF_ONE:![0-9]+]] = distinct !DICompositeType
   // MSVC-SAME:  tag: DW_TAG_structure_type
   // MSVC-NOT:   name:
   // MSVC-NOT:   identifier:
   // MSVC-SAME:  )
+  // MSVC:   !{{[0-9]+}} = !DILocalVariable(name: "one"
+  // MSVC-SAME:  type: [[TYPE_OF_ONE]]
+  // MSVC-SAME:  )
 
   return 0;
 }

diff  --git a/clang/test/CodeGen/debug-info-unused-types.c 
b/clang/test/CodeGen/debug-info-unused-types.c
index 3e9f7b07658e3..5bcc71f710a5c 100644
--- a/clang/test/CodeGen/debug-info-unused-types.c
+++ b/clang/test/CodeGen/debug-info-unused-types.c
@@ -18,13 +18,13 @@ void quux(void) {
 // CHECK: !DICompileUnit{{.+}}retainedTypes: [[RETTYPES:![0-9]+]]
 // CHECK: [[TYPE0:![0-9]+]] = !DICompositeType(tag: DW_TAG_enumeration_type, 
name: "bar"
 // CHECK: [[TYPE1:![0-9]+]] = !DIEnumerator(name: "BAR"
-// CHECK: [[TYPE2:![0-9]+]] = !DICompositeType(tag: DW_TAG_enumeration_type, 
name: "z"
-// CHECK: [[TYPE3:![0-9]+]] = !DIEnumerator(name: "Z"
-// CHECK: [[RETTYPES]] = !{[[TYPE4:![0-9]+]], [[TYPE5:![0-9]+]], [[TYPE0]], 
[[TYPE6:![0-9]+]], {{![0-9]+}}, [[TYPE7:![0-9]+]], [[TYPE2]], [[TYPE8:![0-9]+]]}
-// CHECK: [[TYPE4]] = !DIDerivedType(tag: DW_TAG_typedef, name: "my_int"
-// CHECK: [[TYPE5]] = distinct !DICompositeType(tag: DW_TAG_structure_type, 
name: "foo"
-// CHECK: [[TYPE6]] = distinct !DICompositeType(tag: DW_TAG_union_type, name: 
"baz"
-// CHECK: [[TYPE7]] = distinct !DICompositeType(tag: DW_TAG_structure_type, 
name: "y"
+// CHECK: [[RETTYPES]] = !{[[TYPE2:![0-9]+]], [[TYPE3:![0-9]+]], [[TYPE0]], 
[[TYPE4:![0-9]+]], {{![0-9]+}}, [[TYPE5:![0-9]+]], [[TYPE6:![0-9]+]], 

[PATCH] D153293: [clang][WebAssembly] support wasm32-wasi shared libraries

2023-06-19 Thread Joel Dice via Phabricator via cfe-commits
dicej updated this revision to Diff 532705.
dicej added a comment.

generalize Wasm tests and release notes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153293

Files:
  clang/docs/ReleaseNotes.rst
  clang/test/Driver/wasm-toolchain.c


Index: clang/test/Driver/wasm-toolchain.c
===
--- clang/test/Driver/wasm-toolchain.c
+++ clang/test/Driver/wasm-toolchain.c
@@ -33,13 +33,20 @@
 // LINK_KNOWN: "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK_KNOWN: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi" "crt1.o" "[[temp]]" 
"-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
-// -shared should be passed through to `wasm-ld` and not include crt1.o
+// -shared should be passed through to `wasm-ld` and not include crt1.o with a 
known OS.
 
 // RUN: %clang -### -shared --target=wasm32-wasi --sysroot=/foo %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=LINK_KNOWN_SHARED %s
 // LINK_KNOWN_SHARED: "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK_KNOWN_SHARED: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi" "-shared" 
"[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
+// -shared should be passed through to `wasm-ld` and not include crt1.o with 
an unknown OS.
+
+// RUN: %clang -### -shared --target=wasm32-unknown-unknown --sysroot=/foo %s 
2>&1 \
+// RUN:   | FileCheck -check-prefix=LINK_UNKNOWN_SHARED %s
+// LINK_UNKNOWN_SHARED: "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// LINK_UNKNOWN_SHARED: wasm-ld{{.*}}" "-shared" "[[temp]]" "-lc" 
"{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+
 // A basic C link command-line with optimization with known OS.
 
 // RUN: %clang -### -O2 --target=wasm32-wasi --sysroot=/foo %s 2>&1 \
@@ -53,11 +60,17 @@
 // RUN:   | FileCheck -check-prefix=COMPILE %s
 // COMPILE: "-cc1" {{.*}} "-internal-isystem" "/foo/include/wasm32-wasi" 
"-internal-isystem" "/foo/include"
 
-// -fPIC should work for WASI
+// -fPIC should work on a known OS
 
 // RUN: %clang -### -fPIC --target=wasm32-wasi --sysroot=/foo %s 2>&1 \
-// RUN:   | FileCheck -check-prefix=COMPILE_PIC %s
-// COMPILE_PIC: "-cc1" {{.*}} "-mrelocation-model" "pic" "-pic-level" "2" 
{{.*}} "-internal-isystem" "/foo/include/wasm32-wasi" "-internal-isystem" 
"/foo/include"
+// RUN:   | FileCheck -check-prefix=COMPILE_KNOWN_PIC %s
+// COMPILE_KNOWN_PIC: "-cc1" {{.*}} "-mrelocation-model" "pic" "-pic-level" 
"2" {{.*}} "-internal-isystem" "/foo/include/wasm32-wasi" "-internal-isystem" 
"/foo/include"
+
+// -fPIC should work on an unknown OS
+
+// RUN: %clang -### -fPIC --target=wasm32-unknown-unknown --sysroot=/foo %s 
2>&1 \
+// RUN:   | FileCheck -check-prefix=COMPILE_UNKNOWN_PIC %s
+// COMPILE_UNKNOWN_PIC: "-cc1" {{.*}} "-mrelocation-model" "pic" "-pic-level" 
"2"
 
 // Thread-related command line tests.
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -701,8 +701,9 @@
 
 WebAssembly Support
 ^^^
-- The `wasm32-wasi` target now supports `Emscripten-style shared libraries
-  
`_.
+- Shared library support (and PIC code generation) for WebAssembly is no longer
+  limited to the Emscripten target OS and now works with other targets such as
+  wasm32-wasi.
 
 AVR Support
 ^^^


Index: clang/test/Driver/wasm-toolchain.c
===
--- clang/test/Driver/wasm-toolchain.c
+++ clang/test/Driver/wasm-toolchain.c
@@ -33,13 +33,20 @@
 // LINK_KNOWN: "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK_KNOWN: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi" "crt1.o" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
-// -shared should be passed through to `wasm-ld` and not include crt1.o
+// -shared should be passed through to `wasm-ld` and not include crt1.o with a known OS.
 
 // RUN: %clang -### -shared --target=wasm32-wasi --sysroot=/foo %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=LINK_KNOWN_SHARED %s
 // LINK_KNOWN_SHARED: "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK_KNOWN_SHARED: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi" "-shared" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
+// -shared should be passed through to `wasm-ld` and not include crt1.o with an unknown OS.
+
+// RUN: %clang -### -shared --target=wasm32-unknown-unknown --sysroot=/foo %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINK_UNKNOWN_SHARED %s
+// LINK_UNKNOWN_SHARED: "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// LINK_UNKNOWN_SHARED: wasm-ld{{.*}}" "-shared" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+
 // A basic C link command-line with optimization with known OS.
 
 // RUN: %clang -### -O2 --target=wasm32-wasi --sysroot=/foo %s 2>&1 \
@@ -53,11 +60,17 @@
 // RUN:   | FileCheck 

[PATCH] D149596: [AIX][TLS] Relax front end diagnostics to accept the local-exec TLS model

2023-06-19 Thread Amy Kwan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG706b5472d897: [AIX][TLS] Relax front end diagnostics to 
accept the local-exec TLS model (authored by amyk).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149596

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/PowerPC/aix-tls-model.cpp
  clang/test/Sema/aix-attr-tls_model.c


Index: clang/test/Sema/aix-attr-tls_model.c
===
--- clang/test/Sema/aix-attr-tls_model.c
+++ clang/test/Sema/aix-attr-tls_model.c
@@ -8,4 +8,4 @@
 static __thread int y __attribute((tls_model("global-dynamic"))); // no-warning
 static __thread int y __attribute((tls_model("local-dynamic"))); // 
expected-error {{TLS model 'local-dynamic' is not yet supported on AIX}}
 static __thread int y __attribute((tls_model("initial-exec"))); // 
expected-error {{TLS model 'initial-exec' is not yet supported on AIX}}
-static __thread int y __attribute((tls_model("local-exec"))); // 
expected-error {{TLS model 'local-exec' is not yet supported on AIX}}
+static __thread int y __attribute((tls_model("local-exec"))); // no-warning
Index: clang/test/CodeGen/PowerPC/aix-tls-model.cpp
===
--- clang/test/CodeGen/PowerPC/aix-tls-model.cpp
+++ clang/test/CodeGen/PowerPC/aix-tls-model.cpp
@@ -2,12 +2,12 @@
 // RUN: %clang_cc1 %s -triple powerpc-unknown-aix -target-cpu pwr8 
-ftls-model=global-dynamic -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-GD
 // RUN: not %clang_cc1 %s -triple powerpc-unknown-aix -target-cpu pwr8 
-ftls-model=local-dynamic -emit-llvm 2>&1 | FileCheck %s 
-check-prefix=CHECK-LD-ERROR
 // RUN: not %clang_cc1 %s -triple powerpc-unknown-aix -target-cpu pwr8 
-ftls-model=initial-exec -emit-llvm  2>&1 | FileCheck %s 
-check-prefix=CHECK-IE-ERROR
-// RUN: not %clang_cc1 %s -triple powerpc-unknown-aix -target-cpu pwr8 
-ftls-model=local-exec -emit-llvm 2>&1 | FileCheck %s 
-check-prefix=CHECK-LE-ERROR
+// RUN: %clang_cc1 %s -triple powerpc-unknown-aix -target-cpu pwr8 
-ftls-model=local-exec -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-LE
 // RUN: %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 
-emit-llvm -o - | FileCheck %s -check-prefix=CHECK-GD
 // RUN: %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 
-ftls-model=global-dynamic -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-GD
 // RUN: not %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 
-ftls-model=local-dynamic -emit-llvm 2>&1 | FileCheck %s 
-check-prefix=CHECK-LD-ERROR
 // RUN: not %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 
-ftls-model=initial-exec -emit-llvm  2>&1 | FileCheck %s 
-check-prefix=CHECK-IE-ERROR
-// RUN: not %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 
-ftls-model=local-exec -emit-llvm 2>&1 | FileCheck %s 
-check-prefix=CHECK-LE-ERROR
+// RUN: %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 
-ftls-model=local-exec -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-LE
 
 int z1 = 0;
 int z2;
@@ -23,4 +23,7 @@
 // CHECK-GD: @_ZZ1fvE1y = internal thread_local global i32 0
 // CHECK-LD-ERROR:  error: TLS model 'local-dynamic' is not yet supported on 
AIX
 // CHECK-IE-ERROR:  error: TLS model 'initial-exec' is not yet supported on AIX
-// CHECK-LE-ERROR:  error: TLS model 'local-exec' is not yet supported on AIX
+// CHECK-LE: @z1 ={{.*}} global i32 0
+// CHECK-LE: @z2 ={{.*}} global i32 0
+// CHECK-LE: @x ={{.*}} thread_local(localexec) global i32 0
+// CHECK-LE: @_ZZ1fvE1y = internal thread_local(localexec) global i32 0
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -2039,7 +2039,7 @@
   }
 
   if (S.Context.getTargetInfo().getTriple().isOSAIX() &&
-  Model != "global-dynamic") {
+  Model != "global-dynamic" && Model != "local-exec") {
 S.Diag(LiteralLoc, diag::err_aix_attr_unsupported_tls_model) << Model;
 return;
   }
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1894,7 +1894,7 @@
   if (Arg *A = Args.getLastArg(OPT_ftlsmodel_EQ)) {
 if (T.isOSAIX()) {
   StringRef Name = A->getValue();
-  if (Name != "global-dynamic")
+  if (Name != "global-dynamic" && Name != "local-exec")
 Diags.Report(diag::err_aix_unsupported_tls_model) << Name;
 }
   }


Index: clang/test/Sema/aix-attr-tls_model.c
===
--- clang/test/Sema/aix-attr-tls_model.c
+++ clang/test/Sema/aix-attr-tls_model.c
@@ -8,4 +8,4 @@
 static __thread int y 

[clang] 706b547 - [AIX][TLS] Relax front end diagnostics to accept the local-exec TLS model

2023-06-19 Thread Amy Kwan via cfe-commits

Author: Amy Kwan
Date: 2023-06-19T12:17:30-05:00
New Revision: 706b5472d897ca75ebd210e4109637793288bcf2

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

LOG: [AIX][TLS] Relax front end diagnostics to accept the local-exec TLS model

This patch relaxes the front end AIX diagnostics added in D102070 to accept the
local-exec TLS model, as we plan to support this model in a series of future 
patches.

The diagnostics are relaxed when local-exec is used as a compiler option to
`-ftls-model=*` and in the `__attribute__((tls_model("local-exec")))` attribute.

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

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/CodeGen/PowerPC/aix-tls-model.cpp
clang/test/Sema/aix-attr-tls_model.c

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index f6c04febfd192..dca8853f1c204 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1894,7 +1894,7 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions 
, ArgList ,
   if (Arg *A = Args.getLastArg(OPT_ftlsmodel_EQ)) {
 if (T.isOSAIX()) {
   StringRef Name = A->getValue();
-  if (Name != "global-dynamic")
+  if (Name != "global-dynamic" && Name != "local-exec")
 Diags.Report(diag::err_aix_unsupported_tls_model) << Name;
 }
   }

diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 40438214d2b46..d9146a89d322e 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -2039,7 +2039,7 @@ static void handleTLSModelAttr(Sema , Decl *D, const 
ParsedAttr ) {
   }
 
   if (S.Context.getTargetInfo().getTriple().isOSAIX() &&
-  Model != "global-dynamic") {
+  Model != "global-dynamic" && Model != "local-exec") {
 S.Diag(LiteralLoc, diag::err_aix_attr_unsupported_tls_model) << Model;
 return;
   }

diff  --git a/clang/test/CodeGen/PowerPC/aix-tls-model.cpp 
b/clang/test/CodeGen/PowerPC/aix-tls-model.cpp
index a531f558ac796..2b53df54a5e3c 100644
--- a/clang/test/CodeGen/PowerPC/aix-tls-model.cpp
+++ b/clang/test/CodeGen/PowerPC/aix-tls-model.cpp
@@ -2,12 +2,12 @@
 // RUN: %clang_cc1 %s -triple powerpc-unknown-aix -target-cpu pwr8 
-ftls-model=global-dynamic -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-GD
 // RUN: not %clang_cc1 %s -triple powerpc-unknown-aix -target-cpu pwr8 
-ftls-model=local-dynamic -emit-llvm 2>&1 | FileCheck %s 
-check-prefix=CHECK-LD-ERROR
 // RUN: not %clang_cc1 %s -triple powerpc-unknown-aix -target-cpu pwr8 
-ftls-model=initial-exec -emit-llvm  2>&1 | FileCheck %s 
-check-prefix=CHECK-IE-ERROR
-// RUN: not %clang_cc1 %s -triple powerpc-unknown-aix -target-cpu pwr8 
-ftls-model=local-exec -emit-llvm 2>&1 | FileCheck %s 
-check-prefix=CHECK-LE-ERROR
+// RUN: %clang_cc1 %s -triple powerpc-unknown-aix -target-cpu pwr8 
-ftls-model=local-exec -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-LE
 // RUN: %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 
-emit-llvm -o - | FileCheck %s -check-prefix=CHECK-GD
 // RUN: %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 
-ftls-model=global-dynamic -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-GD
 // RUN: not %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 
-ftls-model=local-dynamic -emit-llvm 2>&1 | FileCheck %s 
-check-prefix=CHECK-LD-ERROR
 // RUN: not %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 
-ftls-model=initial-exec -emit-llvm  2>&1 | FileCheck %s 
-check-prefix=CHECK-IE-ERROR
-// RUN: not %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 
-ftls-model=local-exec -emit-llvm 2>&1 | FileCheck %s 
-check-prefix=CHECK-LE-ERROR
+// RUN: %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 
-ftls-model=local-exec -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-LE
 
 int z1 = 0;
 int z2;
@@ -23,4 +23,7 @@ int f() {
 // CHECK-GD: @_ZZ1fvE1y = internal thread_local global i32 0
 // CHECK-LD-ERROR:  error: TLS model 'local-dynamic' is not yet supported on 
AIX
 // CHECK-IE-ERROR:  error: TLS model 'initial-exec' is not yet supported on AIX
-// CHECK-LE-ERROR:  error: TLS model 'local-exec' is not yet supported on AIX
+// CHECK-LE: @z1 ={{.*}} global i32 0
+// CHECK-LE: @z2 ={{.*}} global i32 0
+// CHECK-LE: @x ={{.*}} thread_local(localexec) global i32 0
+// CHECK-LE: @_ZZ1fvE1y = internal thread_local(localexec) global i32 0

diff  --git a/clang/test/Sema/aix-attr-tls_model.c 
b/clang/test/Sema/aix-attr-tls_model.c
index 8cf3086fc1aa0..245a4434d35c6 100644
--- a/clang/test/Sema/aix-attr-tls_model.c
+++ b/clang/test/Sema/aix-attr-tls_model.c
@@ -8,4 +8,4 @@
 static __thread 

[clang] aeb99dc - Revert "[DebugMetadata][DwarfDebug] Support function-local types in lexical block scopes (4/7)"

2023-06-19 Thread Vladislav Dzhidzhoev via cfe-commits

Author: Vladislav Dzhidzhoev
Date: 2023-06-19T19:16:13+02:00
New Revision: aeb99dc48a58f872465e818d0eda7d9c3f221e06

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

LOG: Revert "[DebugMetadata][DwarfDebug] Support function-local types in 
lexical block scopes (4/7)"

This reverts commit 66511b401042f28c74d2ded3aac76d19a53bd7c4.
llvm/test/DebugInfo/Generic/local-type-as-template-parameter.ll is
broken.

Added: 


Modified: 
clang/test/CodeGen/debug-info-codeview-unnamed.c
clang/test/CodeGen/debug-info-unused-types.c
clang/test/CodeGen/debug-info-unused-types.cpp
clang/test/CodeGenCXX/debug-info-access.cpp
clang/test/CodeGenCXX/debug-info-anon-union-vars.cpp
clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp
clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
clang/test/CodeGenCXX/debug-lambda-this.cpp
llvm/include/llvm/IR/DIBuilder.h
llvm/lib/Bitcode/Reader/MetadataLoader.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/lib/IR/DIBuilder.cpp
llvm/lib/IR/Verifier.cpp
llvm/test/Bitcode/upgrade-cu-locals.ll
llvm/test/Bitcode/upgrade-cu-locals.ll.bc
llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll
llvm/test/DebugInfo/X86/set.ll

Removed: 
llvm/test/DebugInfo/Generic/inlined-local-type.ll
llvm/test/DebugInfo/Generic/lexical-block-retained-types.ll
llvm/test/DebugInfo/Generic/lexical-block-types.ll
llvm/test/DebugInfo/Generic/local-type-as-template-parameter.ll



diff  --git a/clang/test/CodeGen/debug-info-codeview-unnamed.c 
b/clang/test/CodeGen/debug-info-codeview-unnamed.c
index 16ffb3682236f..bd2a7543e56b2 100644
--- a/clang/test/CodeGen/debug-info-codeview-unnamed.c
+++ b/clang/test/CodeGen/debug-info-codeview-unnamed.c
@@ -8,23 +8,23 @@ int main(int argc, char* argv[], char* arge[]) {
   //
   struct { int bar; } one = {42};
   //
-  // LINUX:  [[TYPE_OF_ONE:![0-9]+]] = distinct !DICompositeType(
+  // LINUX:  !{{[0-9]+}} = !DILocalVariable(name: "one"
+  // LINUX-SAME: type: [[TYPE_OF_ONE:![0-9]+]]
+  // LINUX-SAME: )
+  // LINUX:  [[TYPE_OF_ONE]] = distinct !DICompositeType(
   // LINUX-SAME: tag: DW_TAG_structure_type
   // LINUX-NOT:  name:
   // LINUX-NOT:  identifier:
   // LINUX-SAME: )
-  // LINUX:  !{{[0-9]+}} = !DILocalVariable(name: "one"
-  // LINUX-SAME: type: [[TYPE_OF_ONE]]
-  // LINUX-SAME: )
   //
-  // MSVC:   [[TYPE_OF_ONE:![0-9]+]] = distinct !DICompositeType
+  // MSVC:   !{{[0-9]+}} = !DILocalVariable(name: "one"
+  // MSVC-SAME:  type: [[TYPE_OF_ONE:![0-9]+]]
+  // MSVC-SAME:  )
+  // MSVC:   [[TYPE_OF_ONE]] = distinct !DICompositeType
   // MSVC-SAME:  tag: DW_TAG_structure_type
   // MSVC-NOT:   name:
   // MSVC-NOT:   identifier:
   // MSVC-SAME:  )
-  // MSVC:   !{{[0-9]+}} = !DILocalVariable(name: "one"
-  // MSVC-SAME:  type: [[TYPE_OF_ONE]]
-  // MSVC-SAME:  )
 
   return 0;
 }

diff  --git a/clang/test/CodeGen/debug-info-unused-types.c 
b/clang/test/CodeGen/debug-info-unused-types.c
index 5bcc71f710a5c..3e9f7b07658e3 100644
--- a/clang/test/CodeGen/debug-info-unused-types.c
+++ b/clang/test/CodeGen/debug-info-unused-types.c
@@ -18,13 +18,13 @@ void quux(void) {
 // CHECK: !DICompileUnit{{.+}}retainedTypes: [[RETTYPES:![0-9]+]]
 // CHECK: [[TYPE0:![0-9]+]] = !DICompositeType(tag: DW_TAG_enumeration_type, 
name: "bar"
 // CHECK: [[TYPE1:![0-9]+]] = !DIEnumerator(name: "BAR"
-// CHECK: [[RETTYPES]] = !{[[TYPE2:![0-9]+]], [[TYPE3:![0-9]+]], [[TYPE0]], 
[[TYPE4:![0-9]+]], {{![0-9]+}}, [[TYPE5:![0-9]+]], [[TYPE6:![0-9]+]], 
[[TYPE8:![0-9]+]]}
-// CHECK: [[TYPE2]] = !DIDerivedType(tag: DW_TAG_typedef, name: "my_int"
-// CHECK: [[TYPE3]] = distinct !DICompositeType(tag: DW_TAG_structure_type, 
name: "foo"
-// CHECK: [[TYPE4]] = distinct !DICompositeType(tag: DW_TAG_union_type, name: 
"baz"
-// CHECK: [[TYPE5]] = distinct !DICompositeType(tag: DW_TAG_structure_type, 
name: "y"
-// CHECK: [[TYPE6]] = !DICompositeType(tag: DW_TAG_enumeration_type, name: "z"
-// CHECK: [[TYPE7:![0-9]+]] = !DIEnumerator(name: "Z"
+// CHECK: [[TYPE2:![0-9]+]] = !DICompositeType(tag: DW_TAG_enumeration_type, 
name: "z"
+// CHECK: [[TYPE3:![0-9]+]] = !DIEnumerator(name: "Z"
+// CHECK: [[RETTYPES]] = !{[[TYPE4:![0-9]+]], [[TYPE5:![0-9]+]], [[TYPE0]], 
[[TYPE6:![0-9]+]], {{![0-9]+}}, [[TYPE7:![0-9]+]], [[TYPE2]], [[TYPE8:![0-9]+]]}
+// CHECK: [[TYPE4]] = !DIDerivedType(tag: DW_TAG_typedef, name: "my_int"
+// CHECK: [[TYPE5]] = distinct !DICompositeType(tag: DW_TAG_structure_type, 
name: "foo"
+// CHECK: [[TYPE6]] = distinct !DICompositeType(tag: DW_TAG_union_type, name: 
"baz"
+// 

[PATCH] D153293: [clang][WebAssembly] support wasm32-wasi shared libraries

2023-06-19 Thread Joel Dice via Phabricator via cfe-commits
dicej added a comment.

Thanks for the review.  I'll post an update shortly.




Comment at: clang/docs/ReleaseNotes.rst:705
+- The `wasm32-wasi` target now supports `Emscripten-style shared libraries
+  
`_.
 

sbc100 wrote:
> Would it not make more sense to simply say that all WebAssembly targets now 
> support shared libraries and PIC code generation?   Perhaps we could phrase 
> it something like this:
> 
> "Shared library support (and PIC code generation) for is no longer limited to 
> the Emscripten target OS and now works with other targets such as 
> wasm32-wasi."
Agreed! I'll update it.



Comment at: clang/test/Driver/wasm-toolchain.c:38
+
+// RUN: %clang -### -shared --target=wasm32-wasi --sysroot=/foo %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINK_KNOWN_SHARED %s

sbc100 wrote:
> Perhaps this part could be enerat
Sorry, I'm having trouble parsing this; did your comment get cut off?



Comment at: clang/test/Driver/wasm-toolchain.c:56
 
+// -fPIC should work for WASI
+

sbc100 wrote:
> The test above say `with known OS`..  which is perhaps more appropriate here.
> 
> Also, shouldn't all these also work (and be tested with) unknown OS?
Sounds reasonable.  I'll edit the comment and add tests for the unknown case.



Comment at: llvm/utils/lit/lit/llvm/config.py:347
+return triple
+
 m = re.match(r"(\w+)-(\w+)-(\w+)", triple)

sbc100 wrote:
> Are the the changes to this file meant to be part of this CL?
The `check-clang` target doesn't work at all if the target "triple" is a 
double, e.g.:

```
llvm-lit: 
/Users/dicej/p/wasi-sdk/src/llvm-project/llvm/utils/lit/lit/llvm/config.py:459: 
note: using clang: /Users/dicej/p/wasi-sdk/build/llvm/bin/clang
llvm-lit: 
/Users/dicej/p/wasi-sdk/src/llvm-project/llvm/utils/lit/lit/llvm/config.py:324: 
fatal: Could not turn 'wasm32-wasi' into Itanium ABI triple
```

@sunfish had been using this patch locally to work around the issue, so I 
figured I'd include the patch here so it stops being a stumbling block.  
Perhaps there's a better way to address it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153293

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


[PATCH] D153298: [clang-tidy] Extend bugprone-exception-escape diagnostics

2023-06-19 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL created this revision.
PiotrZSL added reviewers: njames93, carlosgalvezp, isuckatcs, JonasToth, 
baloghadamsoftware.
Herald added a subscriber: xazax.hun.
Herald added a project: All.
PiotrZSL requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Emit additional notes with information about thrown uncaught
exceptions at a location where they thrown or re-thrown.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153298

Files:
  clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
  clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
  clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-rethrow.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-throw.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
@@ -9,6 +9,7 @@
 struct throwing_destructor {
   ~throwing_destructor() {
 // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: an exception may be thrown in function '~throwing_destructor' which should not throw exceptions
+// CHECK-MESSAGES: :[[@LINE+1]]:5: note: may throw 'int' here
 throw 1;
   }
 };
@@ -16,6 +17,7 @@
 struct throwing_move_constructor {
   throwing_move_constructor(throwing_move_constructor&&) {
 // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: an exception may be thrown in function 'throwing_move_constructor' which should not throw exceptions
+// CHECK-MESSAGES: :[[@LINE+1]]:5: note: may throw 'int' here
 throw 1;
   }
 };
@@ -23,12 +25,14 @@
 struct throwing_move_assignment {
   throwing_move_assignment& operator=(throwing_move_assignment&&) {
 // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: an exception may be thrown in function 'operator=' which should not throw exceptions
+// CHECK-MESSAGES: :[[@LINE+1]]:5: note: may throw 'int' here
 throw 1;
   }
 };
 
 void throwing_noexcept() noexcept {
-// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throwing_noexcept' which should not throw exceptions
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throwing_noexcept' which should not throw exceptions
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: note: may throw 'int' here
   throw 1;
 }
 
@@ -42,6 +46,7 @@
 
 void throw_and_catch_some(int n) noexcept {
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_and_catch_some' which should not throw exceptions
+  // CHECK-MESSAGES: :[[@LINE+3]]:5: note: may throw 'double' here
   try {
 if (n) throw 1;
 throw 1.1;
@@ -70,6 +75,7 @@
 
 void throw_and_rethrow() noexcept {
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_and_rethrow' which should not throw exceptions
+  // CHECK-MESSAGES: :[[@LINE+2]]:5: note: may throw 'int' here
   try {
 throw 1;
   } catch(int &) {
@@ -79,6 +85,7 @@
 
 void throw_catch_throw() noexcept {
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_catch_throw' which should not throw exceptions
+  // CHECK-MESSAGES: :[[@LINE+4]]:5: note: may throw 'int' here
   try {
 throw 1;
   } catch(int &) {
@@ -88,6 +95,7 @@
 
 void throw_catch_rethrow_the_rest(int n) noexcept {
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_catch_rethrow_the_rest' which should not throw exceptions
+  // CHECK-MESSAGES: :[[@LINE+3]]:5: note: may throw 'double' here
   try {
 if (n) throw 1;
 throw 1.1;
@@ -120,6 +128,7 @@
 
 void throw_catch_multi_ptr_1() noexcept {
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_catch_multi_ptr_1' which should not throw exceptions
+  // CHECK-MESSAGES: :[[@LINE+3]]:5: note: may throw 'char **' here
   try {
 char **p = 0;
 throw p;
@@ -152,7 +161,7 @@
 }
 
 // FIXME: In this case 'a' is convertible to the handler and should be caught
-// but in reality it's thrown. Note that clang doesn't report a warning for 
+// but in reality it's thrown. Note that clang doesn't report a warning for
 // this either.
 void throw_catch_multi_ptr_5() noexcept {
   try {
@@ -165,6 +174,7 @@
 
 void throw_c_catch_pointer() noexcept {
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_c_catch_pointer' which should not throw exceptions
+  // CHECK-MESSAGES: :[[@LINE+4]]:5: note: may throw 'const int *' here
   try {
 int a = 1;
 const int *p = 
@@ -174,6 +184,7 @@
 
 void 

[PATCH] D153296: [AST] Stop evaluate constant expression if the condition expression which in switch statement contains errors

2023-06-19 Thread Yurong via Phabricator via cfe-commits
yronglin added a comment.

Oops, compiler explorer website seems crashed, Once it's recovery, I'll append 
a link.

  :2:13: error: use of undeclared identifier 'f'
  2 | switch (f) {
| ^
  clang++: /root/llvm-project/llvm/lib/Support/APInt.cpp:282: int 
llvm::APInt::compareSigned(const llvm::APInt&) const: Assertion `BitWidth == 
RHS.BitWidth && "Bit widths must be same for comparison"' failed.
  PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ 
and include the crash backtrace, preprocessed source, and associated run script.
  Stack dump:
  0.Program arguments: 
/opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -gdwarf-4 -g -o 
/app/output.s -mllvm --x86-asm-syntax=intel -S 
--gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics 
-fno-crash-diagnostics -std=c++20 
  1.:11:1: current parser token 'static_assert'
  2.:1:36: parsing function body 'foo'
   #0 0x55cfeaf267ff llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
(/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c3a7ff)
   #1 0x55cfeaf2456c llvm::sys::CleanupOnSignal(unsigned long) 
(/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c3856c)
   #2 0x55cfeae6e528 CrashRecoverySignalHandler(int) 
CrashRecoveryContext.cpp:0:0
   #3 0x7f6bd7059420 __restore_rt 
(/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
   #4 0x7f6bd6b2600b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
   #5 0x7f6bd6b05859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
   #6 0x7f6bd6b05729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
   #7 0x7f6bd6b16fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
   #8 0x55cfeae461cd llvm::APInt::compareSigned(llvm::APInt const&) const 
(/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b5a1cd)
   #9 0x55cfee84a705 EvaluateStmt((anonymous namespace)::StmtResult&, 
(anonymous namespace)::EvalInfo&, clang::Stmt const*, clang::SwitchCase const*) 
(.part.0) ExprConstant.cpp:0:0
  #10 0x55cfee84a25f EvaluateStmt((anonymous namespace)::StmtResult&, 
(anonymous namespace)::EvalInfo&, clang::Stmt const*, clang::SwitchCase const*) 
(.part.0) ExprConstant.cpp:0:0
  #11 0x55cfee84e961 HandleFunctionCall(clang::SourceLocation, 
clang::FunctionDecl const*, (anonymous namespace)::LValue const*, 
llvm::ArrayRef, (anonymous namespace)::CallRef, clang::Stmt 
const*, (anonymous namespace)::EvalInfo&, clang::APValue&, (anonymous 
namespace)::LValue const*) ExprConstant.cpp:0:0
  #12 0x55cfee8918d8 
clang::Expr::isPotentialConstantExpr(clang::FunctionDecl const*, 
llvm::SmallVectorImpl>&) 
(/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x75a58d8)
  #13 0x55cfedaae4de 
clang::Sema::CheckConstexprFunctionDefinition(clang::FunctionDecl const*, 
clang::Sema::CheckConstexprKind) 
(/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x67c24de)
  #14 0x55cfeda05350 clang::Sema::ActOnFinishFunctionBody(clang::Decl*, 
clang::Stmt*, bool) 
(/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6719350)
  #15 0x55cfed77b2dd 
clang::Parser::ParseFunctionStatementBody(clang::Decl*, 
clang::Parser::ParseScope&) 
(/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x648f2dd)
  #16 0x55cfed6a5dc1 
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, 
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) 
(/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x63b9dc1)
  #17 0x55cfed6cccd0 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, 
clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, 
clang::Parser::ForRangeInit*) 
(/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x63e0cd0)
  #18 0x55cfed699661 
clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, 
clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) 
(/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x63ad661)
  #19 0x55cfed699f1f 
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, 
clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) 
(.part.0) Parser.cpp:0:0
  #20 0x55cfed6a08c1 
clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, 
clang::ParsedAttributes&, clang::ParsingDeclSpec*) 
(/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x63b48c1)
  #21 0x55cfed6a1236 
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&, 
clang::Sema::ModuleImportState&) 
(/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x63b5236)
  #22 0x55cfed6a16d4 
clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr&, 
clang::Sema::ModuleImportState&) 
(/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x63b56d4)
  #23 0x55cfed694fca clang::ParseAST(clang::Sema&, bool, bool) 
(/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x63a8fca)
  #24 0x55cfec1997d8 

[PATCH] D153296: [AST] Stop evaluate constant expression if the condition expression which in switch statement contains errors

2023-06-19 Thread Yurong via Phabricator via cfe-commits
yronglin created this revision.
Herald added a project: All.
yronglin requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Signed-off-by: yronglin 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153296

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/SemaCXX/switch.cpp


Index: clang/test/SemaCXX/switch.cpp
===
--- clang/test/SemaCXX/switch.cpp
+++ clang/test/SemaCXX/switch.cpp
@@ -146,3 +146,15 @@
 }
 
 } // namespace EmptyEnum
+
+constexpr int foo(unsigned char c) {
+switch (f) { // expected-error {{use of undeclared identifier}}
+case 0:
+return 7;
+default:
+break;
+}
+return 0;
+}
+
+static_assert(foo('d')); // expected-error {{static assertion expression is 
not an integral constant expression}}
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -4983,7 +4983,9 @@
 !EvaluateDecl(Info, SS->getConditionVariable()))
   return ESR_Failed;
 if (SS->getCond()->isValueDependent()) {
-  if (!EvaluateDependentExpr(SS->getCond(), Info))
+  // Stop evaluate if condition expression contains errors.
+  if (SS->getCond()->containsErrors() ||
+  !EvaluateDependentExpr(SS->getCond(), Info))
 return ESR_Failed;
 } else {
   if (!EvaluateInteger(SS->getCond(), Value, Info))


Index: clang/test/SemaCXX/switch.cpp
===
--- clang/test/SemaCXX/switch.cpp
+++ clang/test/SemaCXX/switch.cpp
@@ -146,3 +146,15 @@
 }
 
 } // namespace EmptyEnum
+
+constexpr int foo(unsigned char c) {
+switch (f) { // expected-error {{use of undeclared identifier}}
+case 0:
+return 7;
+default:
+break;
+}
+return 0;
+}
+
+static_assert(foo('d')); // expected-error {{static assertion expression is not an integral constant expression}}
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -4983,7 +4983,9 @@
 !EvaluateDecl(Info, SS->getConditionVariable()))
   return ESR_Failed;
 if (SS->getCond()->isValueDependent()) {
-  if (!EvaluateDependentExpr(SS->getCond(), Info))
+  // Stop evaluate if condition expression contains errors.
+  if (SS->getCond()->containsErrors() ||
+  !EvaluateDependentExpr(SS->getCond(), Info))
 return ESR_Failed;
 } else {
   if (!EvaluateInteger(SS->getCond(), Value, Info))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D153293: [clang][WebAssembly] support wasm32-wasi shared libraries

2023-06-19 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added a comment.
Herald added a subscriber: ormris.

Nice!  lgtm with a couple of nits




Comment at: clang/docs/ReleaseNotes.rst:705
+- The `wasm32-wasi` target now supports `Emscripten-style shared libraries
+  
`_.
 

Would it not make more sense to simply say that all WebAssembly targets now 
support shared libraries and PIC code generation?   Perhaps we could phrase it 
something like this:

"Shared library support (and PIC code generation) for is no longer limited to 
the Emscripten target OS and now works with other targets such as wasm32-wasi."



Comment at: clang/test/Driver/wasm-toolchain.c:38
+
+// RUN: %clang -### -shared --target=wasm32-wasi --sysroot=/foo %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINK_KNOWN_SHARED %s

Perhaps this part could be enerat



Comment at: clang/test/Driver/wasm-toolchain.c:56
 
+// -fPIC should work for WASI
+

The test above say `with known OS`..  which is perhaps more appropriate here.

Also, shouldn't all these also work (and be tested with) unknown OS?



Comment at: llvm/utils/lit/lit/llvm/config.py:347
+return triple
+
 m = re.match(r"(\w+)-(\w+)-(\w+)", triple)

Are the the changes to this file meant to be part of this CL?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153293

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


[PATCH] D150860: [OpenMP] Change clang emitTargetDataCalls to use OMPIRBuilder

2023-06-19 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:10399
+DeviceID = CGF.Builder.getInt64(OMP_DEVICEID_UNDEF);
+  }
 

jdoerfert wrote:
> Move this behind the if generation and guard the emit scalar with a 
> conditional, all is only needed if both Device is present and IfCond is not 
> known true.
I have moved the device generation after the if generation.
But I am not sure what should be the guard here for emitting the scalar.

My idea was to generate something like:


```
%new_dev = alloca ...
if.then
%x = load %device
store %x %new_dev
...
begin_mapper(..., %new_dev, ...)
...
if.then
...
end_mapper(..., %new_dev, ...)
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150860

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


[PATCH] D152435: [analyzer][CStringChecker] Adjust the invalidation operation on the super region of the destination buffer during string copy

2023-06-19 Thread Ella Ma via Phabricator via cfe-commits
OikawaKirie added a comment.

BTW, what does the `Done` checkbox mean in the code comments?




Comment at: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp:286-287
+  SVal V,
+  std::function);
 

steakhal wrote:
> I'd highly suggest making this a template taking the functor that way.
> Given that we modify these functions, we should make them comply with the 
> lower camel case naming convention.
> And their variables with upper camel case.
> I'd highly suggest making this a template taking the functor that way.

Any examples?
Do you mean
```
template 
static ProgramStateRef
InvalidateBufferAux(CheckerContext , ProgramStateRef state, const Expr *Ex,
SVal V, std::function CallBack);
```



Comment at: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp:1054
+SVal SizeV, QualType SizeTy) {
+  return InvalidateBufferAux(
+  C, S, BufE, BufV,

steakhal wrote:
> Shouldn't we assert that `SizeV` is some known value or at least smaller than 
> (or equal to) the extent of the buffer?
The calls in `CStringChecker::evalCopyCommon` and 
`CStringChecker::evalStrcpyCommon` seem to have chances able to pass an unknown 
value. But I am not very sure about this.

If the `SizeV` is sure to be smaller or equal to the extent of the buffer, the 
`IsFirstBufInBound` check seems useless.
Maybe I need to dig deeper into the callers.



Comment at: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp:1075-1077
+  [](RegionAndSymbolInvalidationTraits &, const MemRegion *R) {
+return MemRegion::FieldRegionKind == R->getKind();
+  });

steakhal wrote:
> The lambdas inline in the call look a bit messy. I would prefer declaring it 
> and passing it as an argument separately.
> This applies to the rest of the lambdas as well.
> And their variables with upper camel case.

What about the variable names for the lambdas? Lower camel or upper camel?
I cannot find the rules for named lambdas from the guidance 
.



Comment at: clang/test/Analysis/issue-55019.cpp:80-87
+  std::copy(p, p + 1, x.arr);
+
+  // FIXME: As we currently cannot know whether the copy overflows, the checker
+  // invalidates the entire `x` object. When the copy size through iterators
+  // can be correctly modeled, we can then update the verify direction from
+  // SymRegion to HeapSymRegion as this std::copy call never overflows and
+  // hence the pointer `x.ptr` shall not be invalidated.

> So, you say that It should be `HeapSymRegion` instead because `x.arr` 
> shouldn't be invalidated because the `std::copy` won't modify it. Right?

Yes, but just in this test case.

The size of `x.arr` is 4 and the copy length is 1, which means the call to 
`std::copy` here never overflows.
Therefore, we should not invalidate the super region `x` and keep `x.ptr` still 
pointing to the original `HeapSymRegion` unchanged.
However, the copy length computed through iterators is not modeled currently in 
`CStringChecker::evalStdCopyCommon`, where 
`InvalidateDestinationBufferAlwaysEscapeSuperRegion` is called.
When it is modeled in the future, the function should call 
`InvalidateDestinationBufferBySize` instead to make the invalidation of the 
super region determined by the copy length to report potential leaks.



Comment at: clang/test/Analysis/pr22954.c:560
   clang_analyzer_eval(x263.s1[0] == 0); // expected-warning{{UNKNOWN}}
+  // expected-warning@-1{{Potential leak of memory pointed to by 'x263.s2'}}
   clang_analyzer_eval(x263.s1[1] == 0); // expected-warning{{UNKNOWN}}

steakhal wrote:
> Ah, the leak should have been reported at the end of the full-expression of 
> `memcpy`.
> If we have this expect line here it could mislead the reader that it has 
> anything to do with the `eval` call before.
> 
> In fact, any statement after `memcpy` would have this diagnostic.
> I have seen cases where we have a `next_line()` opaque call after such places 
> to anchor the leak diagnostic.
> I think we can do the same here.
> Its not advised to have different, but similar looking hunks out of which 
> some are the consequence of the semantic change we made and also have others 
> where they are just refactors.

Do you mean I only need to update the verification direction here as you 
suggested above and leave others unchanged?


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

https://reviews.llvm.org/D152435

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


[PATCH] D138278: TableGen: honor LLVM_LINK_LLVM_DYLIB by default

2023-06-19 Thread Nicolai Hähnle via Phabricator via cfe-commits
nhaehnle added a comment.
Herald added a subscriber: wangpc.

I haven't looked at this in a while, sorry. I do plan to cycle back to it 
eventually, but right now my work scheduling is more stack-based than FIFO and 
this is fairly low down...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138278

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


[PATCH] D153294: [clang] Do not create ExprWithCleanups while checking immediate invocation

2023-06-19 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon created this revision.
Herald added a project: All.
Fznamznon requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Immediate invocations do not need to run cleanups themselves and the
destructors need to run after each full-expression is processed.
Attempting to add ExprWithCleanups for each immediate invocation may cause
adding it in the wrong place and producing code with memory leaks.

Thanks @ilya-biryukov for helping reducing the reproducer and confirming
that the analysis is correct.

Fixes https://github.com/llvm/llvm-project/issues/60709


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153294

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGenCXX/consteval-cleanup.cpp
  clang/test/SemaCXX/consteval-cleanup.cpp


Index: clang/test/SemaCXX/consteval-cleanup.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/consteval-cleanup.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -Wno-unused-value -std=c++20 -ast-dump -verify %s -ast-dump 
| FileCheck %s
+
+// expected-no-diagnostics
+
+struct P {
+  consteval P() {}
+};
+
+struct A {
+  A(int v) { this->data = new int(v); }
+  ~A() { delete data; }
+private:
+  int *data;
+};
+
+void foo() {
+  for (;A(1), P(), false;);
+  // CHECK: foo
+  // CHECK: ExprWithCleanups
+  // CHECK-NEXT: BinaryOperator
+  // CHECK: ConstantExpr
+  // CHECK-NOT: ExprWithCleanups
+}
+
+struct B {
+  int *p = new int(38);
+  consteval int get() { return *p; }
+  constexpr ~B() { delete p; }
+};
+
+void bar() {
+  // CHECK: bar
+  // CHECK: ExprWithCleanups
+  // CHECK-NEXT: ConstantExpr
+  int k = B().get();
+}
Index: clang/test/CodeGenCXX/consteval-cleanup.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/consteval-cleanup.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -std=c++20 -Wno-unused-value -triple x86_64-linux-gnu 
-emit-llvm %s -o - | FileCheck %s
+
+struct P {
+  consteval P() {}
+};
+
+struct A {
+  A(int v) { this->data = new int(v); }
+  ~A() { delete data; }
+private:
+  int *data;
+};
+
+void foo() {
+  for (;A(1), P(), false;);
+  // CHECK: foo
+  // CHECK: for.cond:
+  // CHECK: call void @_ZN1AC1Ei
+  // CHECK: call void @_ZN1AD1Ev
+  // CHECK: for.body
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -18170,8 +18170,6 @@
 return E;
   }
 
-  E = MaybeCreateExprWithCleanups(E);
-
   ConstantExpr *Res = ConstantExpr::Create(
   getASTContext(), E.get(),
   ConstantExpr::getStorageKind(Decl->getReturnType().getTypePtr(),
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -520,6 +520,10 @@
   type by the default argument promotions, and thus this is UB. Clang's
   behavior now matches GCC's behavior in C++.
   (`#38717 _`).
+- Fix missing destructor calls and therefore memory leaks in generated code
+  when an immediate invocation appears as a part of an expression that produces
+  temporaries.
+  (`#60709 _`).
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/SemaCXX/consteval-cleanup.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/consteval-cleanup.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -Wno-unused-value -std=c++20 -ast-dump -verify %s -ast-dump | FileCheck %s
+
+// expected-no-diagnostics
+
+struct P {
+  consteval P() {}
+};
+
+struct A {
+  A(int v) { this->data = new int(v); }
+  ~A() { delete data; }
+private:
+  int *data;
+};
+
+void foo() {
+  for (;A(1), P(), false;);
+  // CHECK: foo
+  // CHECK: ExprWithCleanups
+  // CHECK-NEXT: BinaryOperator
+  // CHECK: ConstantExpr
+  // CHECK-NOT: ExprWithCleanups
+}
+
+struct B {
+  int *p = new int(38);
+  consteval int get() { return *p; }
+  constexpr ~B() { delete p; }
+};
+
+void bar() {
+  // CHECK: bar
+  // CHECK: ExprWithCleanups
+  // CHECK-NEXT: ConstantExpr
+  int k = B().get();
+}
Index: clang/test/CodeGenCXX/consteval-cleanup.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/consteval-cleanup.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -std=c++20 -Wno-unused-value -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s
+
+struct P {
+  consteval P() {}
+};
+
+struct A {
+  A(int v) { this->data = new int(v); }
+  ~A() { delete data; }
+private:
+  int *data;
+};
+
+void foo() {
+  for (;A(1), P(), false;);
+  // CHECK: foo
+  // CHECK: for.cond:
+  // CHECK: call void @_ZN1AC1Ei
+  // CHECK: call void @_ZN1AD1Ev
+  // CHECK: for.body
+}
Index: 

[PATCH] D153293: [clang][WebAssembly] support wasm32-wasi shared libraries

2023-06-19 Thread Joel Dice via Phabricator via cfe-commits
dicej created this revision.
Herald added subscribers: pmatos, asb, delcypher, sunfish, hiraditya, 
jgravelle-google, sbc100, dschuff.
Herald added a project: All.
dicej requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, MaskRay, aheejin.
Herald added projects: clang, LLVM.

This adds support for Emscripten-style shared libraries [1] to the `wasm32-wasi`
target.  Previously, only static linking was supported, and the `-shared` and
`-fPIC` flags were simply ignored.  Now both flags are honored.

Since WASI runtimes do not necessarily include JavaScript support, we cannot
rely on the JS-based Emscripten linker to link shared libraries.  Instead, we
link them using the Component Model proposal [2].

We have prototyped shared library support in `wasi-sdk` [3] and put together a
demo [4] which uses a patched version of `wit-component` [5] to link libraries
using the Component Model.  We plan to submit the required changes upstream to
the respective repositories in the next week or two.

[1] https://github.com/WebAssembly/tool-conventions/blob/main/DynamicLinking.md
[2] 
https://github.com/WebAssembly/component-model/blob/main/design/mvp/examples/SharedEverythingDynamicLinking.md
[3] https://github.com/dicej/wasi-sdk/tree/dynamic-linking
[4] https://github.com/dicej/component-linking-demo
[5] 
https://github.com/bytecodealliance/wasm-tools/tree/main/crates/wit-component

Signed-off-by: Joel Dice 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153293

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/test/Driver/wasm-toolchain.c
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/utils/lit/lit/llvm/config.py

Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -328,6 +328,9 @@
 return False
 
 def make_itanium_abi_triple(self, triple):
+if triple == "wasm32-wasi":
+return triple
+
 m = re.match(r"(\w+)-(\w+)-(\w+)", triple)
 if not m:
 self.lit_config.fatal(
@@ -339,6 +342,9 @@
 return m.group(1) + "-" + m.group(2) + "-" + m.group(3) + "-gnu"
 
 def make_msabi_triple(self, triple):
+if triple == "wasm32-wasi":
+return triple
+
 m = re.match(r"(\w+)-(\w+)-(\w+)", triple)
 if not m:
 self.lit_config.fatal("Could not turn '%s' into MS ABI triple" % triple)
Index: llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
@@ -99,13 +99,6 @@
 return Reloc::Static;
   }
 
-  if (!TT.isOSEmscripten()) {
-// Relocation modes other than static are currently implemented in a way
-// that only works for Emscripten, so disable them if we aren't targeting
-// Emscripten.
-return Reloc::Static;
-  }
-
   return *RM;
 }
 
Index: clang/test/Driver/wasm-toolchain.c
===
--- clang/test/Driver/wasm-toolchain.c
+++ clang/test/Driver/wasm-toolchain.c
@@ -33,6 +33,13 @@
 // LINK_KNOWN: "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK_KNOWN: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi" "crt1.o" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
+// -shared should be passed through to `wasm-ld` and not include crt1.o
+
+// RUN: %clang -### -shared --target=wasm32-wasi --sysroot=/foo %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINK_KNOWN_SHARED %s
+// LINK_KNOWN_SHARED: "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// LINK_KNOWN_SHARED: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi" "-shared" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+
 // A basic C link command-line with optimization with known OS.
 
 // RUN: %clang -### -O2 --target=wasm32-wasi --sysroot=/foo %s 2>&1 \
@@ -46,6 +53,12 @@
 // RUN:   | FileCheck -check-prefix=COMPILE %s
 // COMPILE: "-cc1" {{.*}} "-internal-isystem" "/foo/include/wasm32-wasi" "-internal-isystem" "/foo/include"
 
+// -fPIC should work for WASI
+
+// RUN: %clang -### -fPIC --target=wasm32-wasi --sysroot=/foo %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=COMPILE_PIC %s
+// COMPILE_PIC: "-cc1" {{.*}} "-mrelocation-model" "pic" "-pic-level" "2" {{.*}} "-internal-isystem" "/foo/include/wasm32-wasi" "-internal-isystem" "/foo/include"
+
 // Thread-related command line tests.
 
 // '-pthread' sets +atomics, +bulk-memory, +mutable-globals, +sign-ext, and --shared-memory
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -101,13 +101,16 @@
   << CM << A->getOption().getName();
 

[PATCH] D153282: [clang][DebugInfo] Emit DW_AT_deleted on any deleted member function

2023-06-19 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl accepted this revision.
aprantl added a comment.
This revision is now accepted and ready to land.

Since a boolean flag is effectively free in DWARF as it can be stored in the 
abbreviations, this looks like a good change to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153282

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


[PATCH] D149444: [ARM] Allow codegen for Armv6m eXecute-Only (XO) sections

2023-06-19 Thread Ties Stuij via Phabricator via cfe-commits
stuij marked an inline comment as done.
stuij added a comment.






Comment at: clang/test/Driver/arm-execute-only.c:1
-// RUN: not %clang -c -target thumbv6m-eabi -mexecute-only %s 2>&1 | \
+// RUN: %clang -c -### --target=thumbv6m-eabi -mexecute-only %s 2>&1 | \
+// RUN:   FileCheck -allow-empty --check-prefix CHECK-EXECUTE-ONLY %s

MaskRay wrote:
> stuij wrote:
> > MaskRay wrote:
> > > If you don't check -cc1 options with FileCheck, you can also replace 
> > > `-###` with `-fdriver-only -Werror` and drop two `-NOT:` patterns below. 
> > > You can play with some examples to see its effect:)
> > > 
> > > If the `clang -c -fdriver-only -Werror` command gives no output, you can 
> > > use `... 2>&1 | count 0`
> > Very useful info. Thanks for the tips!
> LGTM once the simplification is done (e.g. `clang -c -fdriver-only -Werror`)
yup, thanks for that. I was struggling to get rid of those NOTs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149444

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


[PATCH] D153008: [RISCV] Allow slash-star comments in instruction operands

2023-06-19 Thread Abel Bernabeu via Phabricator via cfe-commits
abel-bernabeu updated this revision to Diff 532686.
abel-bernabeu added a comment.

Rebased on top of the latest changes in RISCVAsmParser.cpp

Moved the testing to llc-mc test cases under lvm/test/MC/RISCV/

Covered with tests for every single case where the parser consumes a
token and a potential comment needs to be handled. Having manually
verified that the testing coverage is complete.

Reworked the code using getLexer().peekTokens for ignoring comments.

If a comment is not handled proper, now is a bug, because the feature
is complete and the testing has full coverage.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153008

Files:
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/test/MC/RISCV/comments-zdinx.ll
  llvm/test/MC/RISCV/comments.ll

Index: llvm/test/MC/RISCV/comments.ll
===
--- /dev/null
+++ llvm/test/MC/RISCV/comments.ll
@@ -0,0 +1,70 @@
+# RUN: llvm-mc -triple=riscv64 --preserve-comments \
+# RUN:--mattr=+v,+experimental-zfa,+experimental-zcmp,+experimental-ztso %s \
+# RUN:| FileCheck %s
+
+/*c0*/ li /*c1*/ a0 /*c2*/ , /*c3*/ 0 /*c4*/
+# CHECK: li  a0, 0   # c0# c1# c2# c3
+
+/*c0*/ lw /*c1*/ a0 /*c2*/ , /*c3*/ 0 /*c4*/ ( /*c5*/ a1 /*c6*/ ) /*c7*/
+# CHECK: lw  a0, 0(a1)   #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7
+
+/*c0*/ lw /*c1*/ a0 /*c2*/ , /*c3*/ ( /*c4*/ a1 /*c5*/ ) /*c6*/
+# CHECK: lw  a0, 0(a1)   #c0 #c1 #c2 #c3 #c4 #c5 #c6
+
+/*c0*/ fli.s /*c1*/ ft0 /*c2*/ , /*c3*/ nan /*c4*/
+# CHECK: fli.s   ft0, nan#c0 #c1 #c2 #c3 #c4
+
+/*c0*/ fli.s /*c1*/ ft0 /*c2*/ , /*c3*/ 1.0 /*c4*/
+# CHECK: fli.s   ft0, 1.0#c0 #c1 #c2 #c3 #c4
+
+/*c0*/ auipc /*c1*/ a0 /*c2*/ , /*c3*/ %pcrel_hi /*c4*/ ( /*c5*/ a1 /*c6*/ ) /*c7*/
+# CHECK:  auipc   a0, %pcrel_hi(a1)   #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7
+
+/*c0*/ la /*c1*/ s0 /*c2*/ , /*c3*/ symbol /*c4*/ + /*c5*/ 10 /*c6*/
+# CHECK: .Lpcrel_hi0:#c0 #c1 #c2 #c3 #c4 #c5 #c6
+# CHECK: auipc   s0, %pcrel_hi(symbol+10)
+# CHECK: addis0, s0, %pcrel_lo(.Lpcrel_hi0)
+
+/*c0*/ la /*c1*/ s0 /*c2*/ , /*c3*/ symbol /*c4*/ - /*c5*/ 10
+# CHECK: .Lpcrel_hi1:#c0 #c1 #c2 #c3 #c4 #c5
+# CHECK: auipc   s0, %pcrel_hi(symbol-10)
+# CHECK: addis0, s0, %pcrel_lo(.Lpcrel_hi1)
+
+/*c0*/ vsetivli /*c1*/ a2 /*c2*/ , /*c3*/ 31 /*c4*/ , /*c5*/ e32 /*c6*/ , /*c7*/ m1 /*c8*/ , /*c9*/ ta /*c10*/ , /*c11*/ ma /*c12*/
+# CHECK: vsetivlia2, 31, e32, m1, ta, ma #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8 #c9 #c10#c11#c12
+
+/*c0*/ vadd.vv /*c1*/ v1 /*c2*/ , /*c3*/ v2 /*c4*/ , /*c5*/ v3 /*c6*/ , /*c7*/ v0.t /*c8*/
+# CHECK: vadd.vv v1, v2, v3, v0.t#c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8
+
+/*c0*/ cm.push /*c1*/ { /*c2*/ ra /*c3*/ , /*c4*/ s0 /*c5*/ - /*c6*/ s1 /*c7*/ } /*c8*/ , /*c9*/ - /*c10*/ 32 /*c11*/
+# CHECK: cm.push {ra, s0-s1}, -32#c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8 #c9 #c10#c11
+
+/*c0*/ cm.popret /*c0*/ { /*c1*/ x1 /*c2*/ , /*c3*/ x8 /*c4*/ - /*c5*/ x9 /*c6*/ , /*c7*/ x18 /*c8*/ - /*c9*/ x20 /*c10*/ } /*c11*/ , /*c12*/ 64 /*c13*/
+# CHECK: cm.popret   {ra, s0-s4}, 64 #c0 #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8 #c9 #c10#c11#c12#c13
+
+/*c0*/ fence /*c1*/ 0 /*c2*/ , /*c3*/ 0 /*c4*/
+# CHECK: fence   0, 0#c0 #c1 #c2 #c3 #c4
+
+/*c0*/ fence /*c1*/ iorw /*c2*/ , /*c3*/ iorw /*c4*/
+# CHECK: fence   #c0 #c1 #c2 #c3 #c4
+
+/*c0*/ fence.tso /*c1*/
+# CHECK: fence.tso   #c0 #c1
+
+/*c0*/ fence.i /*c1*/
+# CHECK: fence.i #c0 #c1
+
+/*c0*/ nop /*c1*/
+# CHECK: nop #c0 #c1
+
+/*c0*/ .option /*c1*/ arch /*c2*/ , /*c3*/ rv64gc /*c4*/
+# CHECK: #c0 #c1 #c2 #c3 #c4
+# CHECK-NEXT: .option arch, rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0
+
+/*c0*/ .attribute /*c1*/ priv_spec /*c2*/ , /*c3*/ 2 /*c4*/
+# CHECK: .attribute  8, 2
+# CHECK-NEXT: #c0 #c1 #c2 #c3 #c4
+
+/*c0*/ .attribute /*c1*/ arch /*c2*/ , /*c3*/ "rv32i_zvfbfmin0p6" /*c4*/
+# CHECK: .attribute  5, "rv32i2p1_f2p2_zicsr2p0_zve32f1p0_zve32x1p0_zvfbfmin0p6_zvl32b1p0"
+# CHECK-NEXT: #c0 #c1 #c2 #c3 #c4
\ No newline at end of file
Index: llvm/test/MC/RISCV/comments-zdinx.ll
===
--- /dev/null
+++ llvm/test/MC/RISCV/comments-zdinx.ll
@@ -0,0 +1,4 @@
+# RUN: llvm-mc -triple=riscv64 --preserve-comments --mattr=+zdinx  %s | FileCheck %s
+
+/*c0*/ fmadd.d /*c1*/ x10 /*c2*/ , /*c3*/ x12 /*c4*/ , /*c5*/ x14 /*c6*/ , /*c7*/ x16 /*c8*/ , /*c9*/ dyn /*c10*/
+// CHECK: fmadd.d a0, a2, a4, 

[PATCH] D148216: Add support for annotations in UpdateTestChecks (NFC)

2023-06-19 Thread Nikita Popov via Phabricator via cfe-commits
nikic added inline comments.



Comment at: llvm/utils/UpdateTestChecks/common.py:1286
+  if value == default_value:
+continue
 if action.dest == 'filters':

nikic wrote:
> nikic wrote:
> > hnrklssn wrote:
> > > nikic wrote:
> > > > We should also not print the `all` argument for `--check-globals` 
> > > > argument for `version < 3`, otherwise that will introduce a spurious 
> > > > change in all such tests.
> > > I don't know how to dynamically change the `--check-globals` option 
> > > between `store_true` and `choices`, since the behaviour can itself be 
> > > affected by which argument is passed to the `--version` option. So the 
> > > way I see it there's no way of knowing how to parse between two different 
> > > option types ahead of time. For the default when no option is specified 
> > > the parsing is the same however, so we can simply infer later what option 
> > > is implied based on the version.
> > It's not necessary to change the option, just how it is printed. I.e. add 
> > something like this:
> > ```
> > if args.version < 3 and value == "all":
> > # Don't include argument value in older versions.
> > autogenerated_note_args += "--check-globals "
> > continue
> > ```
> Ah, I get what you're saying now -- old UTC_ARGS are not accepted at all 
> anymore, and trying to update existing tests will just fail with an error!
> 
> We do need old UTC_ARGS to work. I think you can make the argument value 
> optional using these options:
> ```
> nargs="?", 
> const="default",
> default="default",
> choices=["none", "smart", "all", "default"],
> ```
> 
> Or possibly omit const/default and handle None instead.
Correction, I think the right options are:
```
nargs="?",
const="all",
default="default",
choices=["none", "smart", "all"],
```
That is, use `"default"` is it's not specified at all, use `"all"` if only 
`--check-globals` is passed and also accept `--check-globals none|smart|all`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148216

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


[PATCH] D149443: [ARM] add Thumb-1 8-bit movs/adds relocations to LLVM

2023-06-19 Thread Ties Stuij via Phabricator via cfe-commits
stuij updated this revision to Diff 532685.
stuij marked 3 inline comments as done.
stuij added a comment.

addressed review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149443

Files:
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  llvm/include/llvm/BinaryFormat/ELFRelocs/ARM.def
  llvm/lib/Target/ARM/ARMInstrInfo.td
  llvm/lib/Target/ARM/ARMInstrThumb.td
  llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMFixupKinds.h
  llvm/lib/Target/ARM/MCTargetDesc/ARMMCCodeEmitter.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMMCExpr.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMMCExpr.h
  llvm/test/MC/ARM/negative-immediates-thumb1-fail.s
  llvm/test/MC/ARM/thumb-8-bit-relocs.s
  llvm/test/MC/ARM/thumb-diagnostics.s
  llvm/test/MC/ARM/thumb-fixups.s

Index: llvm/test/MC/ARM/thumb-fixups.s
===
--- /dev/null
+++ llvm/test/MC/ARM/thumb-fixups.s
@@ -0,0 +1,25 @@
+@ RUN: llvm-mc -triple armv6m-unknown-unknown %s --show-encoding > %t
+@ RUN: FileCheck < %t %s
+
+movs r3, :upper8_15:_foo
+adds r3, :upper0_7:_foo
+adds r3, :lower8_15:_foo
+adds r3, :lower0_7:_foo
+
+@ CHECK: movsr3, :upper8_15:_foo @ encoding: [A,0x23]
+@ CHECK-NEXT: @   fixup A - offset: 0, value: _foo, kind: fixup_arm_thumb_upper_8_15
+@ CHECK-NEXT: addsr3, :upper0_7:_foo  @ encoding: [A,0x33]
+@ CHECK-NEXT: @   fixup A - offset: 0, value: _foo, kind: fixup_arm_thumb_upper_0_7
+@ CHECK-NEXT: addsr3, :lower8_15:_foo @ encoding: [A,0x33]
+@ CHECK-NEXT: @   fixup A - offset: 0, value: _foo, kind: fixup_arm_thumb_lower_8_15
+@ CHECK-NEXT: addsr3, :lower0_7:_foo  @ encoding: [A,0x33]
+@ CHECK-NEXT: @   fixup A - offset: 0, value: _foo, kind: fixup_arm_thumb_lower_0_7
+
+@ GNU syntax variants:
+movs r3, #:upper8_15:#_foo
+movs r3, #:upper8_15:_foo
+
+@ CHECK: movsr3, :upper8_15:_foo @ encoding: [A,0x23]
+@ CHECK-NEXT: @   fixup A - offset: 0, value: _foo, kind: fixup_arm_thumb_upper_8_15
+@ CHECK-NEXT: movsr3, :upper8_15:_foo @ encoding: [A,0x23]
+@ CHECK-NEXT: @   fixup A - offset: 0, value: _foo, kind: fixup_arm_thumb_upper_8_15
Index: llvm/test/MC/ARM/thumb-diagnostics.s
===
--- llvm/test/MC/ARM/thumb-diagnostics.s
+++ llvm/test/MC/ARM/thumb-diagnostics.s
@@ -195,6 +195,34 @@
 @ CHECK-ERRORS: note: operand must be an immediate in the range [0,31]
 @ CHECK-ERRORS: note: too many operands for instruction
 
+@ Out of range immediates for MOVS/ADDS instruction.
+movs r3, #-1
+adds r3, #256
+@ CHECK-ERRORS: error: invalid instruction, any one of the following would fix this:
+@ CHECK-ERRORS-NEXT: movs r3, #-1
+@ CHECK-ERRORS-NEXT: ^
+@ CHECK-ERRORS: note: operand must be an immediate in the range [0,255] or a relocatable expression
+@ CHECK-ERRORS-NEXT: movs r3, #-1
+@ CHECK-ERRORS-NEXT:  ^
+@ CHECK-ERRORS: note: operand must be a register in range [r0, r7]
+@ CHECK-ERRORS-NEXT: movs r3, #-1
+@ CHECK-ERRORS-NEXT:  ^
+@ CHECK-ERRORS: error: invalid instruction, any one of the following would fix this:
+@ CHECK-ERRORS-NEXT: adds r3, #256
+@ CHECK-ERRORS-NEXT: ^
+@ CHECK-ERRORS: note: instruction requires: thumb2
+@ CHECK-ERRORS-NEXT: adds r3, #256
+@ CHECK-ERRORS-NEXT: ^
+@ CHECK-ERRORS: note: invalid operand for instruction
+@ CHECK-ERRORS-NEXT: adds r3, #256
+@ CHECK-ERRORS-NEXT:  ^
+@ CHECK-ERRORS-NEXT: note: operand must be an immediate in the range [0,255] or a relocatable expression
+@ CHECK-ERRORS-NEXT: adds r3, #256
+@ CHECK-ERRORS-NEXT:  ^
+@ CHECK-ERRORS-NEXT: note: operand must be a register in range [r0, r7]
+@ CHECK-ERRORS-NEXT: adds r3, #256
+@ CHECK-ERRORS-NEXT:  ^
+
 @ Mismatched source/destination operands for MUL instruction.
 muls r1, r2, r3
 @ CHECK-ERRORS: error: destination register must match source register
Index: llvm/test/MC/ARM/thumb-8-bit-relocs.s
===
--- /dev/null
+++ llvm/test/MC/ARM/thumb-8-bit-relocs.s
@@ -0,0 +1,35 @@
+@ RUN: llvm-mc -triple thumbv6m-eabi -o - %s | FileCheck %s
+@ RUN: llvm-mc -triple thumbv6m-eabi -filetype obj -o - %s | llvm-readobj -r - \
+@ RUN:   | FileCheck -check-prefix CHECK-RELOCATIONS %s
+@ RUN: llvm-mc -triple thumbv7m-eabi -o - %s | FileCheck %s
+@ RUN: llvm-mc -triple thumbv7m-eabi -filetype obj -o - %s | llvm-readobj -r - \
+@ RUN:   | FileCheck -check-prefix CHECK-RELOCATIONS %s
+
+.syntax unified
+
+.type function,%function
+function:
+  bx lr
+
+.global external
+.type external,%function
+
+.type test,%function
+test:
+  movs r3, :upper8_15:function
+  adds r3, :upper0_7:function
+  adds r3, 

[PATCH] D149444: [ARM] Allow codegen for Armv6m eXecute-Only (XO) sections

2023-06-19 Thread Ties Stuij via Phabricator via cfe-commits
stuij updated this revision to Diff 532684.
stuij added a comment.

address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149444

Files:
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/test/Driver/arm-execute-only.c


Index: clang/test/Driver/arm-execute-only.c
===
--- clang/test/Driver/arm-execute-only.c
+++ clang/test/Driver/arm-execute-only.c
@@ -1,19 +1,22 @@
-// RUN: not %clang -c -target thumbv6m-eabi -mexecute-only %s 2>&1 | \
+// RUN: %clang -c -fdriver-only -Werror --target=arm-arm-none-eabi \
+// RUN:   -march=armv6-m -mexecute-only %s 2>&1 | count 0
+
+// RUN: %clang -### -c --target=arm-arm-none-eabi -march=armv6 -mexecute-only 
%s 2>&1 |\
 // RUN:   FileCheck --check-prefix CHECK-EXECUTE-ONLY-NOT-SUPPORTED %s
-// CHECK-EXECUTE-ONLY-NOT-SUPPORTED: error: execute only is not supported for 
the thumbv6m sub-architecture
+// CHECK-EXECUTE-ONLY-NOT-SUPPORTED: error: execute only is not supported for 
the armv6 sub-architecture
 
-// RUN: not %clang -target armv8m.main-eabi -mexecute-only -mno-movt %s 2>&1 \
+// RUN: %clang -### --target=arm-arm-none-eabi -march=armv8-m.main 
-mexecute-only -mno-movt %s 2>&1 \
 // RUN:| FileCheck %s -check-prefix CHECK-EXECUTE-ONLY-NO-MOVT
 // CHECK-EXECUTE-ONLY-NO-MOVT: error: option '-mexecute-only' cannot be 
specified with '-mno-movt'
 
-// RUN: %clang -target armv7m-eabi -x assembler -mexecute-only %s -c -### 2>&1 
\
+// RUN: %clang -### --target=arm-arm-none-eabi -march=armv7-m -x assembler 
-mexecute-only %s -c -### 2>&1 \
 // RUN:| FileCheck %s --check-prefix=CHECK-NO-EXECUTE-ONLY-ASM
 // CHECK-NO-EXECUTE-ONLY-ASM: warning: argument unused during compilation: 
'-mexecute-only'
 
 // -mpure-code flag for GCC compatibility
-// RUN: not %clang -c -target thumbv6m-eabi -mpure-code %s 2>&1 | \
+// RUN: %clang -### -c --target=arm-arm-none-eabi -march=armv6 -mpure-code %s 
2>&1 | \
 // RUN:   FileCheck --check-prefix CHECK-EXECUTE-ONLY-NOT-SUPPORTED %s
 
-// RUN: not %clang -target armv8m.main-eabi -mpure-code -mno-movt %s 2>&1 \
+// RUN: %clang -### --target=arm-arm-none-eabi -march=armv8-m.main -mpure-code 
-mno-movt %s 2>&1 \
 // RUN:| FileCheck %s -check-prefix CHECK-PURE-CODE-NO-MOVT
 // CHECK-PURE-CODE-NO-MOVT: error: option '-mpure-code' cannot be specified 
with '-mno-movt'
Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -824,7 +824,8 @@
 if (Arg *A = Args.getLastArg(options::OPT_mexecute_only, 
options::OPT_mno_execute_only)) {
   if (A->getOption().matches(options::OPT_mexecute_only)) {
 if (getARMSubArchVersionNumber(Triple) < 7 &&
-llvm::ARM::parseArch(Triple.getArchName()) != 
llvm::ARM::ArchKind::ARMV6T2)
+llvm::ARM::parseArch(Triple.getArchName()) != 
llvm::ARM::ArchKind::ARMV6T2 &&
+llvm::ARM::parseArch(Triple.getArchName()) != 
llvm::ARM::ArchKind::ARMV6M)
   D.Diag(diag::err_target_unsupported_execute_only) << 
Triple.getArchName();
 else if (Arg *B = Args.getLastArg(options::OPT_mno_movt))
   D.Diag(diag::err_opt_not_valid_with_opt)


Index: clang/test/Driver/arm-execute-only.c
===
--- clang/test/Driver/arm-execute-only.c
+++ clang/test/Driver/arm-execute-only.c
@@ -1,19 +1,22 @@
-// RUN: not %clang -c -target thumbv6m-eabi -mexecute-only %s 2>&1 | \
+// RUN: %clang -c -fdriver-only -Werror --target=arm-arm-none-eabi \
+// RUN:   -march=armv6-m -mexecute-only %s 2>&1 | count 0
+
+// RUN: %clang -### -c --target=arm-arm-none-eabi -march=armv6 -mexecute-only %s 2>&1 |\
 // RUN:   FileCheck --check-prefix CHECK-EXECUTE-ONLY-NOT-SUPPORTED %s
-// CHECK-EXECUTE-ONLY-NOT-SUPPORTED: error: execute only is not supported for the thumbv6m sub-architecture
+// CHECK-EXECUTE-ONLY-NOT-SUPPORTED: error: execute only is not supported for the armv6 sub-architecture
 
-// RUN: not %clang -target armv8m.main-eabi -mexecute-only -mno-movt %s 2>&1 \
+// RUN: %clang -### --target=arm-arm-none-eabi -march=armv8-m.main -mexecute-only -mno-movt %s 2>&1 \
 // RUN:| FileCheck %s -check-prefix CHECK-EXECUTE-ONLY-NO-MOVT
 // CHECK-EXECUTE-ONLY-NO-MOVT: error: option '-mexecute-only' cannot be specified with '-mno-movt'
 
-// RUN: %clang -target armv7m-eabi -x assembler -mexecute-only %s -c -### 2>&1 \
+// RUN: %clang -### --target=arm-arm-none-eabi -march=armv7-m -x assembler -mexecute-only %s -c -### 2>&1 \
 // RUN:| FileCheck %s --check-prefix=CHECK-NO-EXECUTE-ONLY-ASM
 // CHECK-NO-EXECUTE-ONLY-ASM: warning: argument unused during compilation: '-mexecute-only'
 
 // -mpure-code flag for GCC compatibility
-// RUN: not %clang -c -target thumbv6m-eabi -mpure-code %s 2>&1 | \
+// 

[PATCH] D148216: Add support for annotations in UpdateTestChecks (NFC)

2023-06-19 Thread Nikita Popov via Phabricator via cfe-commits
nikic added inline comments.



Comment at: llvm/utils/UpdateTestChecks/common.py:1286
+  if value == default_value:
+continue
 if action.dest == 'filters':

nikic wrote:
> hnrklssn wrote:
> > nikic wrote:
> > > We should also not print the `all` argument for `--check-globals` 
> > > argument for `version < 3`, otherwise that will introduce a spurious 
> > > change in all such tests.
> > I don't know how to dynamically change the `--check-globals` option between 
> > `store_true` and `choices`, since the behaviour can itself be affected by 
> > which argument is passed to the `--version` option. So the way I see it 
> > there's no way of knowing how to parse between two different option types 
> > ahead of time. For the default when no option is specified the parsing is 
> > the same however, so we can simply infer later what option is implied based 
> > on the version.
> It's not necessary to change the option, just how it is printed. I.e. add 
> something like this:
> ```
> if args.version < 3 and value == "all":
> # Don't include argument value in older versions.
> autogenerated_note_args += "--check-globals "
> continue
> ```
Ah, I get what you're saying now -- old UTC_ARGS are not accepted at all 
anymore, and trying to update existing tests will just fail with an error!

We do need old UTC_ARGS to work. I think you can make the argument value 
optional using these options:
```
nargs="?", 
const="default",
default="default",
choices=["none", "smart", "all", "default"],
```

Or possibly omit const/default and handle None instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148216

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


[PATCH] D144802: clang: Add __builtin_elementwise_round

2023-06-19 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm added a comment.

2a488b4443a9c0aa0f368aed901676508ced202f 



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

https://reviews.llvm.org/D144802

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


[clang] 2a488b4 - clang: Add __builtin_elementwise_round

2023-06-19 Thread Matt Arsenault via cfe-commits

Author: Matt Arsenault
Date: 2023-06-19T11:32:56-04:00
New Revision: 2a488b4443a9c0aa0f368aed901676508ced202f

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

LOG: clang: Add __builtin_elementwise_round

Added: 


Modified: 
clang/docs/LanguageExtensions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/Builtins.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Sema/SemaChecking.cpp
clang/test/CodeGen/builtins-elementwise-math.c
clang/test/Sema/builtins-elementwise-math.c

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 9944cb28f0487..ab1fe885a3a75 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -645,6 +645,10 @@ Unless specified otherwise operation(±0) = ±0 and 
operation(±infinity) = ±in
  rounding halfway cases to even 
(that is, to the nearest value
  that is an even integer), 
regardless of the current rounding
  direction.
+ T __builtin_elementwise_round(T x)  round x to the nearest  integer 
value in floating point format,  floating point types
+ rounding halfway cases away from 
zero, regardless of the
+ current rounding direction. May 
raise floating-point
+ exceptions.
  T __builtin_elementwise_trunc(T x)  return the integral value nearest 
to but no larger infloating point types
  magnitude than x
  T __builtin_elementwise_canonicalize(T x)   return the platform specific 
canonical encoding  floating point types

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6cee1c83706aa..7c6a350c7eab2 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -228,6 +228,10 @@ Non-comprehensive list of changes in this release
   variable as a way to disable color diagnostics.
 - Clang now supports ``__builtin_isfpclass``, which checks if the specified
   floating-point value falls into any of the specified data classes.
+- Added ``__builtin_elementwise_round`` for  builtin for floating
+  point types. This allows access to ``llvm.round`` for
+  arbitrary floating-point and vector of floating-point types.
+
 
 New Compiler Flags
 --

diff  --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index 59b61b89bd245..aa0076aab951c 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -687,6 +687,7 @@ BUILTIN(__builtin_elementwise_log, "v.", "nct")
 BUILTIN(__builtin_elementwise_log2, "v.", "nct")
 BUILTIN(__builtin_elementwise_log10, "v.", "nct")
 BUILTIN(__builtin_elementwise_roundeven, "v.", "nct")
+BUILTIN(__builtin_elementwise_round, "v.", "nct")
 BUILTIN(__builtin_elementwise_sin, "v.", "nct")
 BUILTIN(__builtin_elementwise_trunc, "v.", "nct")
 BUILTIN(__builtin_elementwise_canonicalize, "v.", "nct")

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 69438960ebf23..7a38ac4ba10cb 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -3194,6 +3194,9 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
   case Builtin::BI__builtin_elementwise_roundeven:
 return RValue::get(emitUnaryBuiltin(*this, E, llvm::Intrinsic::roundeven,
 "elt.roundeven"));
+  case Builtin::BI__builtin_elementwise_round:
+return RValue::get(emitUnaryBuiltin(*this, E, llvm::Intrinsic::round,
+"elt.round"));
   case Builtin::BI__builtin_elementwise_sin:
 return RValue::get(
 emitUnaryBuiltin(*this, E, llvm::Intrinsic::sin, "elt.sin"));

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index d3b37c1fa70a2..72b2f1d1edd82 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -2636,6 +2636,7 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, 
unsigned BuiltinID,
   case Builtin::BI__builtin_elementwise_log2:
   case Builtin::BI__builtin_elementwise_log10:
   case Builtin::BI__builtin_elementwise_roundeven:
+  case Builtin::BI__builtin_elementwise_round:
   case Builtin::BI__builtin_elementwise_sin:
   case Builtin::BI__builtin_elementwise_trunc:
   case Builtin::BI__builtin_elementwise_canonicalize: {

diff  --git a/clang/test/CodeGen/builtins-elementwise-math.c 
b/clang/test/CodeGen/builtins-elementwise-math.c
index 

[PATCH] D153292: [Driver][BareMetal] Error if no matching multilib

2023-06-19 Thread Michael Platings via Phabricator via cfe-commits
michaelplatings created this revision.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
michaelplatings requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Previously if no matching multilib was found then the user would
typically see an error like "fatal error: 'stdio.h' file not found"
which gives no indication as to the underlying problem.
With this change the user will instead see an error like

  clang: error: no multilib found matching flags: 
--target=thumbv7em-none-unknown-eabi -march=...
  clang: note: available multilibs are:
  --target=armv4t-none-unknown-eabi
  --target=thumbv6m-none-unknown-eabi -mfpu=none
  ...


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153292

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/test/Driver/baremetal-multilib.yaml


Index: clang/test/Driver/baremetal-multilib.yaml
===
--- clang/test/Driver/baremetal-multilib.yaml
+++ clang/test/Driver/baremetal-multilib.yaml
@@ -20,6 +20,16 @@
 # CHECK-SAME: "-lc" "-lm" "-lclang_rt.builtins"
 # CHECK-SAME: "-o" "{{.*}}.tmp.out"
 
+# RUN: %T/baremetal_multilib/bin/clang -no-canonical-prefixes -x c++ %s -### 
-o %t.out 2>&1 \
+# RUN: --target=thumbv7em-none-eabi -mfpu=fpv4-sp-d16 --sysroot= \
+# RUN:   | FileCheck --check-prefix=CHECK-NO-MATCH %s
+# CHECK-NO-MATCH: error: no multilib found matching flags:
+# CHECK-NO-MATCH-SAME: --target=thumbv7em-none-unknown-eabi
+# CHECK-NO-MATCH: note: available multilibs are:
+# CHECK-NO-MATCH: --target=thumbv6m-none-unknown-eabi -mfpu=none
+# CHECK-NO-MATCH: --target=thumbv7m-none-unknown-eabi -mfpu=none
+# CHECK-NO-MATCH: --target=thumbv7em-none-unknown-eabi -mfpu=none
+
 # RUN: %T/baremetal_multilib/bin/clang -no-canonical-prefixes 
-print-multi-directory 2>&1 \
 # RUN: --target=thumbv8m.main-none-eabihf --sysroot= \
 # RUN:   | FileCheck --check-prefix=CHECK-PRINT-MULTI-DIRECTORY %s
@@ -75,6 +85,9 @@
 # multilib, layered on top of each other.
 
 Variants:
+- Dir: arm-none-eabi/arm/v4t
+  Flags: [--target=armv4t-none-unknown-eabi]
+
 - Dir: arm-none-eabi/thumb/v6-m/nofp
   Flags: [--target=thumbv6m-none-unknown-eabi, -mfpu=none]
 
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -23,6 +23,8 @@
 #include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/raw_ostream.h"
 
+#include 
+
 using namespace llvm::opt;
 using namespace clang;
 using namespace clang::driver;
@@ -158,20 +160,26 @@
   return Triple.getEnvironmentName() == "elf";
 }
 
-static bool findMultilibsFromYAML(const ToolChain , const Driver ,
+static void findMultilibsFromYAML(const ToolChain , const Driver ,
   StringRef MultilibPath, const ArgList ,
   DetectedMultilibs ) {
   llvm::ErrorOr> MB =
   D.getVFS().getBufferForFile(MultilibPath);
   if (!MB)
-return false;
+return;
   Multilib::flags_list Flags = TC.getMultilibFlags(Args);
   llvm::ErrorOr ErrorOrMultilibSet =
   MultilibSet::parseYaml(*MB.get());
   if (ErrorOrMultilibSet.getError())
-return false;
+return;
   Result.Multilibs = ErrorOrMultilibSet.get();
-  return Result.Multilibs.select(Flags, Result.SelectedMultilibs);
+  if (Result.Multilibs.select(Flags, Result.SelectedMultilibs))
+return;
+  D.Diag(clang::diag::err_drv_no_matching_multilib) << llvm::join(Flags, " ");
+  std::stringstream ss;
+  for (const Multilib  : Result.Multilibs)
+ss << "\n" << llvm::join(Multilib.flags(), " ");
+  D.Diag(clang::diag::note_drv_available_multilibs) << ss.str();
 }
 
 static constexpr llvm::StringLiteral MultilibFilename = "multilib.yaml";
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -733,4 +733,9 @@
 
 def err_drv_expand_response_file : Error<
   "failed to expand response file: %0">;
+
+def err_drv_no_matching_multilib : Error<
+  "no multilib found matching flags: %0">;
+def note_drv_available_multilibs : Note<
+  "available multilibs are:%0">;
 }


Index: clang/test/Driver/baremetal-multilib.yaml
===
--- clang/test/Driver/baremetal-multilib.yaml
+++ clang/test/Driver/baremetal-multilib.yaml
@@ -20,6 +20,16 @@
 # CHECK-SAME: "-lc" "-lm" "-lclang_rt.builtins"
 # CHECK-SAME: "-o" "{{.*}}.tmp.out"
 
+# RUN: %T/baremetal_multilib/bin/clang -no-canonical-prefixes -x c++ %s -### -o %t.out 2>&1 \
+# RUN: --target=thumbv7em-none-eabi -mfpu=fpv4-sp-d16 --sysroot= \
+# RUN:   | FileCheck --check-prefix=CHECK-NO-MATCH 

[PATCH] D144802: clang: Add __builtin_elementwise_round

2023-06-19 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff accepted this revision.
sepavloff added a comment.
This revision is now accepted and ready to land.

LGTM.


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

https://reviews.llvm.org/D144802

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


[PATCH] D148216: Add support for annotations in UpdateTestChecks (NFC)

2023-06-19 Thread Nikita Popov via Phabricator via cfe-commits
nikic added inline comments.



Comment at: llvm/utils/UpdateTestChecks/common.py:1286
+  if value == default_value:
+continue
 if action.dest == 'filters':

hnrklssn wrote:
> nikic wrote:
> > We should also not print the `all` argument for `--check-globals` argument 
> > for `version < 3`, otherwise that will introduce a spurious change in all 
> > such tests.
> I don't know how to dynamically change the `--check-globals` option between 
> `store_true` and `choices`, since the behaviour can itself be affected by 
> which argument is passed to the `--version` option. So the way I see it 
> there's no way of knowing how to parse between two different option types 
> ahead of time. For the default when no option is specified the parsing is the 
> same however, so we can simply infer later what option is implied based on 
> the version.
It's not necessary to change the option, just how it is printed. I.e. add 
something like this:
```
if args.version < 3 and value == "all":
# Don't include argument value in older versions.
autogenerated_note_args += "--check-globals "
continue
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148216

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


[PATCH] D153281: [flang] add -flang-experimental-polymorphism flag to flang-new

2023-06-19 Thread Tom Eccles via Phabricator via cfe-commits
tblah accepted this revision.
tblah added a comment.
This revision is now accepted and ready to land.

Looks good to me, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153281

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


[PATCH] D153282: [clang][DebugInfo] Emit DW_AT_deleted on any deleted member function

2023-06-19 Thread Michael Buch via Phabricator via cfe-commits
Michael137 updated this revision to Diff 532664.
Michael137 added a comment.

- fix test comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153282

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-deleted.cpp
  llvm/test/DebugInfo/X86/DW_AT_deleted.ll

Index: llvm/test/DebugInfo/X86/DW_AT_deleted.ll
===
--- llvm/test/DebugInfo/X86/DW_AT_deleted.ll
+++ llvm/test/DebugInfo/X86/DW_AT_deleted.ll
@@ -12,6 +12,9 @@
 ; 
 ;   deleted(deleted &&) = delete;
 ;   deleted =(deleted &&) = delete;
+;
+;   void func() && = delete;
+;   static void bar() = delete;
 ; 
 ;   ~deleted() = default;
 ; };
@@ -48,6 +51,16 @@
 ; CHECK-NEXT: DW_AT_name [DW_FORM_strx1](indexed (0008) string = "operator=")
 ; CHECK:  DW_AT_deleted [DW_FORM_flag_present]  (true)
 
+; CHECK: DW_TAG_subprogram [10]
+; CHECK-NEXT: DW_AT_linkage_name [DW_FORM_strx1](indexed (000b) string = "_ZNO7deleted4funcEv")
+; CHECK-NEXT: DW_AT_name [DW_FORM_strx1](indexed (000c) string = "func")
+; CHECK:  DW_AT_deleted [DW_FORM_flag_present]  (true)
+
+; CHECK: DW_TAG_subprogram [11]
+; CHECK-NEXT: DW_AT_linkage_name [DW_FORM_strx1](indexed (000d) string = "_ZN7deleted3barEv")
+; CHECK-NEXT: DW_AT_name [DW_FORM_strx1](indexed (000e) string = "bar")
+; CHECK:  DW_AT_deleted [DW_FORM_flag_present]  (true)
+
 ; ModuleID = 'debug-info-deleted.cpp'
 source_filename = "debug-info-deleted.cpp"
 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
@@ -58,8 +71,8 @@
 ; Function Attrs: noinline nounwind optnone uwtable
 define dso_local void @_Z3foov() #0 !dbg !7 {
   %1 = alloca %class.deleted, align 1
-  call void @llvm.dbg.declare(metadata ptr %1, metadata !10, metadata !DIExpression()), !dbg !34
-  ret void, !dbg !35
+  call void @llvm.dbg.declare(metadata ptr %1, metadata !10, metadata !DIExpression()), !dbg !39
+  ret void, !dbg !40
 }
 
 ; Function Attrs: nounwind readnone speculatable willreturn
@@ -84,7 +97,7 @@
 !9 = !{null}
 !10 = !DILocalVariable(name: "obj1", scope: !7, file: !1, line: 15, type: !11)
 !11 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "deleted", file: !1, line: 1, size: 8, flags: DIFlagTypePassByReference, elements: !12, identifier: "_ZTS7deleted")
-!12 = !{!13, !17, !22, !26, !30, !33}
+!12 = !{!13, !17, !22, !26, !30, !33, !34, !36}
 !13 = !DISubprogram(name: "deleted", scope: !11, file: !1, line: 3, type: !14, scopeLine: 3, flags: DIFlagPublic | DIFlagPrototyped, spFlags: 0)
 !14 = !DISubroutineType(types: !15)
 !15 = !{null, !16}
@@ -106,5 +119,10 @@
 !31 = !DISubroutineType(types: !32)
 !32 = !{!25, !16, !29}
 !33 = !DISubprogram(name: "~deleted", scope: !11, file: !1, line: 11, type: !14, scopeLine: 11, flags: DIFlagPublic | DIFlagPrototyped, spFlags: 0)
-!34 = !DILocation(line: 15, column: 13, scope: !7)
-!35 = !DILocation(line: 16, column: 3, scope: !7)
+!34 = !DISubprogram(name: "func", linkageName: "_ZNO7deleted4funcEv", scope: !11, file: !1, line: 13, type: !35, scopeLine: 13, flags: DIFlagPublic | DIFlagPrototyped | DIFlagRValueReference, spFlags: DISPFlagDeleted)   
+!35 = !DISubroutineType(flags: DIFlagRValueReference, types: !15) 
+!36 = !DISubprogram(name: "bar", linkageName: "_ZN7deleted3barEv", scope: !11, file: !1, line: 15, type: !37, scopeLine: 15, flags: DIFlagPublic | DIFlagPrototyped | DIFlagStaticMember, spFlags: DISPFlagDeleted) 
+!37 = !DISubroutineType(types: !38)
+!38 = !{null}
+!39 = !DILocation(line: 15, column: 13, scope: !7)
+!40 = !DILocation(line: 16, column: 3, scope: !7)
Index: clang/test/CodeGenCXX/debug-info-deleted.cpp
===
--- clang/test/CodeGenCXX/debug-info-deleted.cpp
+++ clang/test/CodeGenCXX/debug-info-deleted.cpp
@@ -11,6 +11,8 @@
 // ATTR: DISubprogram(name: "operator=", linkageName: "_ZN7deletedaSERKS_", {{.*}}, flags: DIFlagPublic | DIFlagPrototyped, spFlags: DISPFlagDeleted
 // ATTR: DISubprogram(name: "deleted", {{.*}}, flags: DIFlagPublic | DIFlagPrototyped, spFlags: DISPFlagDeleted
 // ATTR: DISubprogram(name: "operator=", linkageName: "_ZN7deletedaSEOS_", {{.*}}, flags: DIFlagPublic | DIFlagPrototyped, spFlags: DISPFlagDeleted
+// ATTR: DISubprogram(name: "func", {{.*}}, flags: DIFlagPublic | DIFlagPrototyped | 

[PATCH] D153282: [clang][DebugInfo] Emit DW_AT_deleted on any deleted member function

2023-06-19 Thread Michael Buch via Phabricator via cfe-commits
Michael137 created this revision.
Michael137 added reviewers: aprantl, dblaikie.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Currently we emit `DW_AT_deleted` for `deleted` special-member
functions (i.e., ctors/dtors). However, in C++ one can mark any
member function as deleted. This patch expands the set of member
functions for which we emit `DW_AT_deleted`.

The DWARFv5 spec section 5.7.8 says:

  
  In C++, a member function may be declared as deleted. This prevents the 
compiler from
  generating a default implementation of a special member function such as a 
constructor
  or destructor, and can affect overload resolution when used on other member 
functions.
  
  
  If the member function entry has been declared as deleted, then that entry 
has a
  DW_AT_deleted attribute.

Thus this change is conforming.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153282

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-deleted.cpp
  llvm/test/DebugInfo/X86/DW_AT_deleted.ll

Index: llvm/test/DebugInfo/X86/DW_AT_deleted.ll
===
--- llvm/test/DebugInfo/X86/DW_AT_deleted.ll
+++ llvm/test/DebugInfo/X86/DW_AT_deleted.ll
@@ -12,6 +12,9 @@
 ; 
 ;   deleted(deleted &&) = delete;
 ;   deleted =(deleted &&) = delete;
+;
+;   void func() && {}
+;   static void bar() = delete;
 ; 
 ;   ~deleted() = default;
 ; };
@@ -48,6 +51,16 @@
 ; CHECK-NEXT: DW_AT_name [DW_FORM_strx1](indexed (0008) string = "operator=")
 ; CHECK:  DW_AT_deleted [DW_FORM_flag_present]  (true)
 
+; CHECK: DW_TAG_subprogram [10]
+; CHECK-NEXT: DW_AT_linkage_name [DW_FORM_strx1](indexed (000b) string = "_ZNO7deleted4funcEv")
+; CHECK-NEXT: DW_AT_name [DW_FORM_strx1](indexed (000c) string = "func")
+; CHECK:  DW_AT_deleted [DW_FORM_flag_present]  (true)
+
+; CHECK: DW_TAG_subprogram [11]
+; CHECK-NEXT: DW_AT_linkage_name [DW_FORM_strx1](indexed (000d) string = "_ZN7deleted3barEv")
+; CHECK-NEXT: DW_AT_name [DW_FORM_strx1](indexed (000e) string = "bar")
+; CHECK:  DW_AT_deleted [DW_FORM_flag_present]  (true)
+
 ; ModuleID = 'debug-info-deleted.cpp'
 source_filename = "debug-info-deleted.cpp"
 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
@@ -58,8 +71,8 @@
 ; Function Attrs: noinline nounwind optnone uwtable
 define dso_local void @_Z3foov() #0 !dbg !7 {
   %1 = alloca %class.deleted, align 1
-  call void @llvm.dbg.declare(metadata ptr %1, metadata !10, metadata !DIExpression()), !dbg !34
-  ret void, !dbg !35
+  call void @llvm.dbg.declare(metadata ptr %1, metadata !10, metadata !DIExpression()), !dbg !39
+  ret void, !dbg !40
 }
 
 ; Function Attrs: nounwind readnone speculatable willreturn
@@ -84,7 +97,7 @@
 !9 = !{null}
 !10 = !DILocalVariable(name: "obj1", scope: !7, file: !1, line: 15, type: !11)
 !11 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "deleted", file: !1, line: 1, size: 8, flags: DIFlagTypePassByReference, elements: !12, identifier: "_ZTS7deleted")
-!12 = !{!13, !17, !22, !26, !30, !33}
+!12 = !{!13, !17, !22, !26, !30, !33, !34, !36}
 !13 = !DISubprogram(name: "deleted", scope: !11, file: !1, line: 3, type: !14, scopeLine: 3, flags: DIFlagPublic | DIFlagPrototyped, spFlags: 0)
 !14 = !DISubroutineType(types: !15)
 !15 = !{null, !16}
@@ -106,5 +119,10 @@
 !31 = !DISubroutineType(types: !32)
 !32 = !{!25, !16, !29}
 !33 = !DISubprogram(name: "~deleted", scope: !11, file: !1, line: 11, type: !14, scopeLine: 11, flags: DIFlagPublic | DIFlagPrototyped, spFlags: 0)
-!34 = !DILocation(line: 15, column: 13, scope: !7)
-!35 = !DILocation(line: 16, column: 3, scope: !7)
+!34 = !DISubprogram(name: "func", linkageName: "_ZNO7deleted4funcEv", scope: !11, file: !1, line: 13, type: !35, scopeLine: 13, flags: DIFlagPublic | DIFlagPrototyped | DIFlagRValueReference, spFlags: DISPFlagDeleted)   
+!35 = !DISubroutineType(flags: DIFlagRValueReference, types: !15) 
+!36 = !DISubprogram(name: "bar", linkageName: "_ZN7deleted3barEv", scope: !11, file: !1, line: 15, type: !37, scopeLine: 15, flags: DIFlagPublic | DIFlagPrototyped | DIFlagStaticMember, spFlags: DISPFlagDeleted) 
+!37 = !DISubroutineType(types: !38)
+!38 = !{null}
+!39 = !DILocation(line: 15, column: 13, scope: !7)
+!40 = 

[PATCH] D151696: [x86] Remove CPU_SPECIFIC* MACROs and add getManglingForCPU

2023-06-19 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: llvm/lib/TargetParser/X86TargetParser.cpp:110
   FeatureBitset Features;
+  char Mangling;
+  bool OnlyForCPUDispatchSpecific;

Do we have a documented list of the mangling values anywhere? The values below 
look too much like magic numbers tbh.



Comment at: llvm/test/CodeGen/X86/cpus-intel.ll:90
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown 
-mcpu=graniterapids 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR 
--allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown 
-mcpu=atom_sse4_2_movbe 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR 
--allow-empty
 

put this with the goldmonth checks?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151696

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


[PATCH] D153281: [flang] add -flang-experimental-polymorphism flag to flang-new

2023-06-19 Thread David Truby via Phabricator via cfe-commits
DavidTruby created this revision.
DavidTruby added reviewers: tblah, vzakhari, awarzynski.
Herald added a reviewer: sscalpone.
Herald added a subscriber: sunshaoce.
Herald added projects: Flang, All.
DavidTruby requested review of this revision.
Herald added subscribers: cfe-commits, jdoerfert, MaskRay.
Herald added a project: clang.

This flag enables Fortran 2003 polymorphism. It is marked experimental
and not included in --help.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153281

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/flang-experimental-polymorphism-flag.f90


Index: flang/test/Driver/flang-experimental-polymorphism-flag.f90
===
--- /dev/null
+++ flang/test/Driver/flang-experimental-polymorphism-flag.f90
@@ -0,0 +1,10 @@
+! Test -flang-experimental-hlfir flag
+! RUN: %flang_fc1 -flang-experimental-polymorphism -emit-fir -o - %s | 
FileCheck %s
+! RUN: not %flang_fc1 -emit-fir -o - %s 2>&1 | FileCheck %s --check-prefix 
NO-POLYMORPHISM
+
+! CHECK: func.func @_QPtest(%{{.*}}: !fir.class {fir.bindc_name = 
"poly"})
+subroutine test(poly)
+  class(*) :: poly
+end subroutine test
+
+! NO-POLYMORPHISM: not yet implemented: support for polymorphic types
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -43,6 +43,8 @@
 ! CHECK-NEXT:Enable support for generating executables 
(experimental)
 ! CHECK-NEXT: -flang-experimental-hlfir
 ! CHECK-NEXT:Use HLFIR lowering (experimental)
+! CHECK-NEXT: -flang-experimental-polymorphism
+! CHECK-NEXT:Enable Fortran 2003 polymorphism 
(experimental)
 ! CHECK-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type 
in size-related intrinsics
 ! CHECK-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! CHECK-NEXT: -flto= Set LTO mode
Index: flang/lib/Frontend/CompilerInvocation.cpp
===
--- flang/lib/Frontend/CompilerInvocation.cpp
+++ flang/lib/Frontend/CompilerInvocation.cpp
@@ -920,6 +920,10 @@
 res.loweringOpts.setLowerToHighLevelFIR(true);
   }
 
+  if 
(args.hasArg(clang::driver::options::OPT_flang_experimental_polymorphism)) {
+res.loweringOpts.setPolymorphicTypeImpl(true);
+  }
+
   success &= parseFrontendArgs(res.getFrontendOpts(), args, diags);
   parseTargetArgs(res.getTargetOpts(), args);
   parsePreprocessorArgs(res.getPreprocessorOpts(), args);
Index: clang/lib/Driver/ToolChains/Flang.cpp
===
--- clang/lib/Driver/ToolChains/Flang.cpp
+++ clang/lib/Driver/ToolChains/Flang.cpp
@@ -140,6 +140,8 @@
 
   if (Args.hasArg(options::OPT_flang_experimental_hlfir))
 CmdArgs.push_back("-flang-experimental-hlfir");
+  if (Args.hasArg(options::OPT_flang_experimental_polymorphism))
+CmdArgs.push_back("-flang-experimental-polymorphism");
   if (shouldLoopVersion(Args))
 CmdArgs.push_back("-fversion-loops-for-stride");
 }
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -5289,6 +5289,11 @@
   Flags<[FlangOption, FC1Option, FlangOnlyOption, NoXarchOption, HelpHidden]>,
   HelpText<"Use HLFIR lowering (experimental)">;
 
+def flang_experimental_polymorphism : Flag<["-"], 
"flang-experimental-polymorphism">,
+  Flags<[FlangOption, FC1Option, FlangOnlyOption, NoXarchOption, HelpHidden]>,
+  HelpText<"Enable Fortran 2003 polymorphism (experimental)">;
+  
+
 
//===--===//
 // FLangOption + CoreOption + NoXarchOption
 
//===--===//


Index: flang/test/Driver/flang-experimental-polymorphism-flag.f90
===
--- /dev/null
+++ flang/test/Driver/flang-experimental-polymorphism-flag.f90
@@ -0,0 +1,10 @@
+! Test -flang-experimental-hlfir flag
+! RUN: %flang_fc1 -flang-experimental-polymorphism -emit-fir -o - %s | FileCheck %s
+! RUN: not %flang_fc1 -emit-fir -o - %s 2>&1 | FileCheck %s --check-prefix NO-POLYMORPHISM
+
+! CHECK: func.func @_QPtest(%{{.*}}: !fir.class {fir.bindc_name = "poly"})
+subroutine test(poly)
+  class(*) :: poly
+end subroutine test
+
+! NO-POLYMORPHISM: not yet implemented: support for polymorphic types
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ 

[PATCH] D153267: [clang][Diagnostics] Provide parameter source range to arity-mismatch notes

2023-06-19 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

LGTM but let's wait for a second opinion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153267

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


[PATCH] D152548: [Clang][Interp] Diagnose uninitialized ctor of global record arrays

2023-06-19 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder accepted this revision.
tbaeder added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D152548

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


[PATCH] D148216: Add support for annotations in UpdateTestChecks (NFC)

2023-06-19 Thread Henrik G Olsson via Phabricator via cfe-commits
hnrklssn added a comment.

In D148216#4431456 , @jdoerfert wrote:

> could you put a little more information in the commit message please. "It 
> won't do X when we do Y", could mean a lot of things. We don't do Y anymore, 
> or we do X' now, with various choices for X'.

I've updated the commit message to clarify what it means to not emit hardcoded 
identifiers, and that we instead emit regex checkers. Was that what you were 
aiming for, or are there other parts that you would like me to clarify?




Comment at: llvm/utils/UpdateTestChecks/common.py:1286
+  if value == default_value:
+continue
 if action.dest == 'filters':

nikic wrote:
> We should also not print the `all` argument for `--check-globals` argument 
> for `version < 3`, otherwise that will introduce a spurious change in all 
> such tests.
I don't know how to dynamically change the `--check-globals` option between 
`store_true` and `choices`, since the behaviour can itself be affected by which 
argument is passed to the `--version` option. So the way I see it there's no 
way of knowing how to parse between two different option types ahead of time. 
For the default when no option is specified the parsing is the same however, so 
we can simply infer later what option is implied based on the version.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148216

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


[PATCH] D144006: [DebugMetadata][DwarfDebug] Support function-local types in lexical block scopes (4/7)

2023-06-19 Thread Vladislav Dzhidzhoev 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 rG66511b401042: [DebugMetadata][DwarfDebug] Support 
function-local types in lexical block… (authored by dzhidzhoev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144006

Files:
  clang/test/CodeGen/debug-info-codeview-unnamed.c
  clang/test/CodeGen/debug-info-unused-types.c
  clang/test/CodeGen/debug-info-unused-types.cpp
  clang/test/CodeGenCXX/debug-info-access.cpp
  clang/test/CodeGenCXX/debug-info-anon-union-vars.cpp
  clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp
  clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
  clang/test/CodeGenCXX/debug-lambda-this.cpp
  llvm/include/llvm/IR/DIBuilder.h
  llvm/lib/Bitcode/Reader/MetadataLoader.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  llvm/lib/IR/DIBuilder.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/test/Bitcode/upgrade-cu-locals.ll
  llvm/test/Bitcode/upgrade-cu-locals.ll.bc
  llvm/test/DebugInfo/Generic/inlined-local-type.ll
  llvm/test/DebugInfo/Generic/lexical-block-retained-types.ll
  llvm/test/DebugInfo/Generic/lexical-block-types.ll
  llvm/test/DebugInfo/Generic/local-type-as-template-parameter.ll
  llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll
  llvm/test/DebugInfo/X86/set.ll

Index: llvm/test/DebugInfo/X86/set.ll
===
--- llvm/test/DebugInfo/X86/set.ll
+++ llvm/test/DebugInfo/X86/set.ll
@@ -68,11 +68,11 @@
 !llvm.module.flags = !{!18, !19, !20}
 
 !0 = !{!"versions- cm3: d5.10.0 llvm: 9.0"}
-!1 = distinct !DICompileUnit(language: DW_LANG_Modula3, file: !2, producer: "cm3", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !3)
+!1 = distinct !DICompileUnit(language: DW_LANG_Modula3, file: !2, producer: "cm3", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
 !2 = !DIFile(filename: "Main.m3", directory: "/home/cm3/settest/src")
 !3 = !{!4}
 !4 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "Enum", scope: !5, file: !2, line: 11, size: 8, align: 8, elements: !9)
-!5 = distinct !DISubprogram(name: "Test", linkageName: "Main__Test", scope: !2, file: !2, line: 11, type: !6, scopeLine: 11, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !8)
+!5 = distinct !DISubprogram(name: "Test", linkageName: "Main__Test", scope: !2, file: !2, line: 11, type: !6, scopeLine: 11, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !3)
 !6 = !DISubroutineType(types: !7)
 !7 = !{null}
 !8 = !{}
Index: llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll
===
--- llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll
+++ llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll
@@ -38,7 +38,7 @@
 define void @invalid_retained_nodes_list() !dbg !10 { ret void }
 !10 = distinct !DISubprogram(retainedNodes: !0)
 
-; CHECK: invalid retained nodes, expected DILocalVariable, DILabel or DIImportedEntity
+; CHECK: invalid retained nodes, expected DILocalVariable, DILabel, DIImportedEntity or DIType
 define void @invalid_retained_nodes_expected() !dbg !11 { ret void }
 !11 = distinct !DISubprogram(retainedNodes: !{!0})
 
Index: llvm/test/DebugInfo/Generic/local-type-as-template-parameter.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/Generic/local-type-as-template-parameter.ll
@@ -0,0 +1,160 @@
+; RUN: %llc_dwarf -O0 -filetype=obj < %s  \
+; RUN:  | llvm-dwarfdump --show-children --name=foo - \
+; RUN:  | FileCheck --implicit-check-not "{{DW_TAG|NULL}}" %s
+
+; The test ensures that AsmPrinter doesn't crashed compiling this.
+; It also demostrates misplacement for a local type (see PR55680 for details).
+
+; The test compiled from:
+
+; template
+; struct A {
+;   A(T ) : a(in) {}
+;   T a;
+; };
+;
+; __attribute__((always_inline))
+; void foo() {
+;   struct B { int i; };
+;   B objB;
+;   A objA(objB);
+; }
+;
+; int main() {
+;   foo();
+; }
+
+; Concrete out-of-line tree of foo().
+; CHECK: DW_TAG_subprogram
+; CHECK:   DW_AT_abstract_origin {{.*}} "_Z3foov"
+
+; FIXME: 'struct B' should be in the abstract tree below, not here.
+; CHECK:   DW_TAG_structure_type
+; CHECK: DW_AT_name	("B")
+; CHECK: DW_TAG_member
+; CHECK: NULL
+;
+; CHECK:   DW_TAG_variable
+; CHECK: DW_AT_abstract_origin {{.*}} "objB"
+; CHECK:   DW_TAG_variable
+; CHECK: DW_AT_abstract_origin {{.*}} "objA"
+
+; CHECK:   NULL
+
+; Abstract tree of foo().
+; CHECK: DW_TAG_subprogram
+; CHECK:   DW_AT_name	("foo")
+; CHECK:   DW_AT_inline	(DW_INL_inlined)
+
+; CHECK:   DW_TAG_variable
+; CHECK: DW_AT_name	("objB")
+; CHECK:   DW_TAG_variable
+; CHECK: 

[clang] 66511b4 - [DebugMetadata][DwarfDebug] Support function-local types in lexical block scopes (4/7)

2023-06-19 Thread Vladislav Dzhidzhoev via cfe-commits

Author: Vladislav Dzhidzhoev
Date: 2023-06-19T16:42:43+02:00
New Revision: 66511b401042f28c74d2ded3aac76d19a53bd7c4

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

LOG: [DebugMetadata][DwarfDebug] Support function-local types in lexical block 
scopes (4/7)

RFC 
https://discourse.llvm.org/t/rfc-dwarfdebug-fix-and-improve-handling-imported-entities-types-and-static-local-in-subprogram-and-lexical-block-scopes/68544

Similar to imported declarations, the patch tracks function-local types in
DISubprogram's 'retainedNodes' field. DwarfDebug is adjusted in accordance with
the aforementioned metadata change and provided a support of function-local
types scoped within a lexical block.

The patch assumes that DICompileUnit's 'enums field' no longer tracks local
types and DwarfDebug would assert if any locally-scoped types get placed there.

Authored-by: Kristina Bessonova 

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

Depends on D144005

Added: 
llvm/test/DebugInfo/Generic/inlined-local-type.ll
llvm/test/DebugInfo/Generic/lexical-block-retained-types.ll
llvm/test/DebugInfo/Generic/lexical-block-types.ll
llvm/test/DebugInfo/Generic/local-type-as-template-parameter.ll

Modified: 
clang/test/CodeGen/debug-info-codeview-unnamed.c
clang/test/CodeGen/debug-info-unused-types.c
clang/test/CodeGen/debug-info-unused-types.cpp
clang/test/CodeGenCXX/debug-info-access.cpp
clang/test/CodeGenCXX/debug-info-anon-union-vars.cpp
clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp
clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
clang/test/CodeGenCXX/debug-lambda-this.cpp
llvm/include/llvm/IR/DIBuilder.h
llvm/lib/Bitcode/Reader/MetadataLoader.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/lib/IR/DIBuilder.cpp
llvm/lib/IR/Verifier.cpp
llvm/test/Bitcode/upgrade-cu-locals.ll
llvm/test/Bitcode/upgrade-cu-locals.ll.bc
llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll
llvm/test/DebugInfo/X86/set.ll

Removed: 




diff  --git a/clang/test/CodeGen/debug-info-codeview-unnamed.c 
b/clang/test/CodeGen/debug-info-codeview-unnamed.c
index bd2a7543e56b2..16ffb3682236f 100644
--- a/clang/test/CodeGen/debug-info-codeview-unnamed.c
+++ b/clang/test/CodeGen/debug-info-codeview-unnamed.c
@@ -8,23 +8,23 @@ int main(int argc, char* argv[], char* arge[]) {
   //
   struct { int bar; } one = {42};
   //
-  // LINUX:  !{{[0-9]+}} = !DILocalVariable(name: "one"
-  // LINUX-SAME: type: [[TYPE_OF_ONE:![0-9]+]]
-  // LINUX-SAME: )
-  // LINUX:  [[TYPE_OF_ONE]] = distinct !DICompositeType(
+  // LINUX:  [[TYPE_OF_ONE:![0-9]+]] = distinct !DICompositeType(
   // LINUX-SAME: tag: DW_TAG_structure_type
   // LINUX-NOT:  name:
   // LINUX-NOT:  identifier:
   // LINUX-SAME: )
+  // LINUX:  !{{[0-9]+}} = !DILocalVariable(name: "one"
+  // LINUX-SAME: type: [[TYPE_OF_ONE]]
+  // LINUX-SAME: )
   //
-  // MSVC:   !{{[0-9]+}} = !DILocalVariable(name: "one"
-  // MSVC-SAME:  type: [[TYPE_OF_ONE:![0-9]+]]
-  // MSVC-SAME:  )
-  // MSVC:   [[TYPE_OF_ONE]] = distinct !DICompositeType
+  // MSVC:   [[TYPE_OF_ONE:![0-9]+]] = distinct !DICompositeType
   // MSVC-SAME:  tag: DW_TAG_structure_type
   // MSVC-NOT:   name:
   // MSVC-NOT:   identifier:
   // MSVC-SAME:  )
+  // MSVC:   !{{[0-9]+}} = !DILocalVariable(name: "one"
+  // MSVC-SAME:  type: [[TYPE_OF_ONE]]
+  // MSVC-SAME:  )
 
   return 0;
 }

diff  --git a/clang/test/CodeGen/debug-info-unused-types.c 
b/clang/test/CodeGen/debug-info-unused-types.c
index 3e9f7b07658e3..5bcc71f710a5c 100644
--- a/clang/test/CodeGen/debug-info-unused-types.c
+++ b/clang/test/CodeGen/debug-info-unused-types.c
@@ -18,13 +18,13 @@ void quux(void) {
 // CHECK: !DICompileUnit{{.+}}retainedTypes: [[RETTYPES:![0-9]+]]
 // CHECK: [[TYPE0:![0-9]+]] = !DICompositeType(tag: DW_TAG_enumeration_type, 
name: "bar"
 // CHECK: [[TYPE1:![0-9]+]] = !DIEnumerator(name: "BAR"
-// CHECK: [[TYPE2:![0-9]+]] = !DICompositeType(tag: DW_TAG_enumeration_type, 
name: "z"
-// CHECK: [[TYPE3:![0-9]+]] = !DIEnumerator(name: "Z"
-// CHECK: [[RETTYPES]] = !{[[TYPE4:![0-9]+]], [[TYPE5:![0-9]+]], [[TYPE0]], 
[[TYPE6:![0-9]+]], {{![0-9]+}}, [[TYPE7:![0-9]+]], [[TYPE2]], [[TYPE8:![0-9]+]]}
-// CHECK: [[TYPE4]] = !DIDerivedType(tag: DW_TAG_typedef, name: "my_int"
-// CHECK: [[TYPE5]] = distinct !DICompositeType(tag: DW_TAG_structure_type, 
name: "foo"
-// CHECK: [[TYPE6]] = distinct !DICompositeType(tag: DW_TAG_union_type, name: 
"baz"
-// CHECK: [[TYPE7]] = distinct !DICompositeType(tag: DW_TAG_structure_type, 
name: "y"
+// 

[PATCH] D153111: [clang][Serialization][RISCV] Increase the number of reserved predefined type IDs

2023-06-19 Thread Roger Ferrer Ibanez 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 rGfa45f81ff7ea: [clang][Serialization][RISCV] Increase the 
number of reserved predefined type… (authored by rogfer01).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153111

Files:
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/Serialization/ASTReader.cpp
  clang/test/Modules/embed-files-compressed.cpp
  clang/test/Modules/empty.modulemap


Index: clang/test/Modules/empty.modulemap
===
--- clang/test/Modules/empty.modulemap
+++ clang/test/Modules/empty.modulemap
@@ -13,8 +13,8 @@
 // The module file should be identical each time we produce it.
 // RUN: diff %t/base.pcm %t/check.pcm
 //
-// We expect an empty module to be less than 40KB (and at least 10K, for now).
+// We expect an empty module to be less than 60KB (and at least 10K, for now).
 // RUN: wc -c %t/base.pcm | FileCheck --check-prefix=CHECK-SIZE %s
-// CHECK-SIZE: {{(^|[^0-9])[123][0-9][0-9][0-9][0-9]($|[^0-9])}}
+// CHECK-SIZE: {{(^|[^0-9])[1-5][0-9][0-9][0-9][0-9]($|[^0-9])}}
 
 module empty { header "Inputs/empty.h" export * }
Index: clang/test/Modules/embed-files-compressed.cpp
===
--- clang/test/Modules/embed-files-compressed.cpp
+++ clang/test/Modules/embed-files-compressed.cpp
@@ -17,7 +17,7 @@
 // RUN: %clang_cc1 -fmodules -I%t -fmodules-cache-path=%t -fmodule-name=a 
-emit-module %t/modulemap -fmodules-embed-all-files -o %t/a.pcm
 //
 // The above embeds ~4.5MB of highly-predictable /s and \ns into the pcm file.
-// Check that the resulting file is under 40KB:
+// Check that the resulting file is under 60KB:
 //
 // RUN: wc -c %t/a.pcm | FileCheck --check-prefix=CHECK-SIZE %s
-// CHECK-SIZE: {{(^|[^0-9])[123][0-9][0-9][0-9][0-9]($|[^0-9])}}
+// CHECK-SIZE: {{(^|[^0-9])[1-5][0-9][0-9][0-9][0-9]($|[^0-9])}}
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -6983,6 +6983,10 @@
   if (Index < NUM_PREDEF_TYPE_IDS) {
 QualType T;
 switch ((PredefinedTypeIDs)Index) {
+case PREDEF_TYPE_LAST_ID:
+  // We should never use this one.
+  llvm_unreachable("Invalid predefined type");
+  break;
 case PREDEF_TYPE_NULL_ID:
   return QualType();
 case PREDEF_TYPE_VOID_ID:
Index: clang/include/clang/Serialization/ASTBitCodes.h
===
--- clang/include/clang/Serialization/ASTBitCodes.h
+++ clang/include/clang/Serialization/ASTBitCodes.h
@@ -1099,6 +1099,8 @@
 // \brief WebAssembly reference types with auto numeration
 #define WASM_TYPE(Name, Id, SingletonId) PREDEF_TYPE_##Id##_ID,
 #include "clang/Basic/WebAssemblyReferenceTypes.def"
+  // Sentinel value. Considered a predefined type but not useable as one.
+  PREDEF_TYPE_LAST_ID
 };
 
 /// The number of predefined type IDs that are reserved for
@@ -1106,7 +1108,13 @@
 ///
 /// Type IDs for non-predefined types will start at
 /// NUM_PREDEF_TYPE_IDs.
-const unsigned NUM_PREDEF_TYPE_IDS = 300;
+const unsigned NUM_PREDEF_TYPE_IDS = 500;
+
+// Ensure we do not overrun the predefined types we reserved
+// in the enum PredefinedTypeIDs above.
+static_assert(PREDEF_TYPE_LAST_ID < NUM_PREDEF_TYPE_IDS,
+  "Too many enumerators in PredefinedTypeIDs. Review the value of "
+  "NUM_PREDEF_TYPE_IDS");
 
 /// Record codes for each kind of type.
 ///


Index: clang/test/Modules/empty.modulemap
===
--- clang/test/Modules/empty.modulemap
+++ clang/test/Modules/empty.modulemap
@@ -13,8 +13,8 @@
 // The module file should be identical each time we produce it.
 // RUN: diff %t/base.pcm %t/check.pcm
 //
-// We expect an empty module to be less than 40KB (and at least 10K, for now).
+// We expect an empty module to be less than 60KB (and at least 10K, for now).
 // RUN: wc -c %t/base.pcm | FileCheck --check-prefix=CHECK-SIZE %s
-// CHECK-SIZE: {{(^|[^0-9])[123][0-9][0-9][0-9][0-9]($|[^0-9])}}
+// CHECK-SIZE: {{(^|[^0-9])[1-5][0-9][0-9][0-9][0-9]($|[^0-9])}}
 
 module empty { header "Inputs/empty.h" export * }
Index: clang/test/Modules/embed-files-compressed.cpp
===
--- clang/test/Modules/embed-files-compressed.cpp
+++ clang/test/Modules/embed-files-compressed.cpp
@@ -17,7 +17,7 @@
 // RUN: %clang_cc1 -fmodules -I%t -fmodules-cache-path=%t -fmodule-name=a -emit-module %t/modulemap -fmodules-embed-all-files -o %t/a.pcm
 //
 // The above embeds ~4.5MB of highly-predictable /s and \ns into the pcm file.
-// Check that the resulting file is under 40KB:
+// Check that the 

[clang] fa45f81 - [clang][Serialization][RISCV] Increase the number of reserved predefined type IDs

2023-06-19 Thread Roger Ferrer Ibanez via cfe-commits

Author: Roger Ferrer Ibanez
Date: 2023-06-19T14:37:46Z
New Revision: fa45f81ff7ea9fc2a2a40fea8dd7626ecc3a8dbb

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

LOG: [clang][Serialization][RISCV] Increase the number of reserved predefined 
type IDs

In D152070 we added many new intrinsic types required for the RISC-V
Vector Extension.

This was crashing when loading the AST as those types are intrinsically
added to the AST (they don't come from the disk).

The total number required now by clang exceeds 400 so increasing the
value to 500 solves the problem. This value was already increased in
D92715 but I assume this has some impact on the on-disk format.

Also add a static assert to avoid this happening again in the future.

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

Added: 


Modified: 
clang/include/clang/Serialization/ASTBitCodes.h
clang/lib/Serialization/ASTReader.cpp
clang/test/Modules/embed-files-compressed.cpp
clang/test/Modules/empty.modulemap

Removed: 




diff  --git a/clang/include/clang/Serialization/ASTBitCodes.h 
b/clang/include/clang/Serialization/ASTBitCodes.h
index a93eb3d38a480..7019bc5922ebc 100644
--- a/clang/include/clang/Serialization/ASTBitCodes.h
+++ b/clang/include/clang/Serialization/ASTBitCodes.h
@@ -1099,6 +1099,8 @@ enum PredefinedTypeIDs {
 // \brief WebAssembly reference types with auto numeration
 #define WASM_TYPE(Name, Id, SingletonId) PREDEF_TYPE_##Id##_ID,
 #include "clang/Basic/WebAssemblyReferenceTypes.def"
+  // Sentinel value. Considered a predefined type but not useable as one.
+  PREDEF_TYPE_LAST_ID
 };
 
 /// The number of predefined type IDs that are reserved for
@@ -1106,7 +1108,13 @@ enum PredefinedTypeIDs {
 ///
 /// Type IDs for non-predefined types will start at
 /// NUM_PREDEF_TYPE_IDs.
-const unsigned NUM_PREDEF_TYPE_IDS = 300;
+const unsigned NUM_PREDEF_TYPE_IDS = 500;
+
+// Ensure we do not overrun the predefined types we reserved
+// in the enum PredefinedTypeIDs above.
+static_assert(PREDEF_TYPE_LAST_ID < NUM_PREDEF_TYPE_IDS,
+  "Too many enumerators in PredefinedTypeIDs. Review the value of "
+  "NUM_PREDEF_TYPE_IDS");
 
 /// Record codes for each kind of type.
 ///

diff  --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index a0ccc5aa4a741..cba6791783e8b 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -6983,6 +6983,10 @@ QualType ASTReader::GetType(TypeID ID) {
   if (Index < NUM_PREDEF_TYPE_IDS) {
 QualType T;
 switch ((PredefinedTypeIDs)Index) {
+case PREDEF_TYPE_LAST_ID:
+  // We should never use this one.
+  llvm_unreachable("Invalid predefined type");
+  break;
 case PREDEF_TYPE_NULL_ID:
   return QualType();
 case PREDEF_TYPE_VOID_ID:

diff  --git a/clang/test/Modules/embed-files-compressed.cpp 
b/clang/test/Modules/embed-files-compressed.cpp
index ae016bc1f9630..873b3082a2fdf 100644
--- a/clang/test/Modules/embed-files-compressed.cpp
+++ b/clang/test/Modules/embed-files-compressed.cpp
@@ -17,7 +17,7 @@
 // RUN: %clang_cc1 -fmodules -I%t -fmodules-cache-path=%t -fmodule-name=a 
-emit-module %t/modulemap -fmodules-embed-all-files -o %t/a.pcm
 //
 // The above embeds ~4.5MB of highly-predictable /s and \ns into the pcm file.
-// Check that the resulting file is under 40KB:
+// Check that the resulting file is under 60KB:
 //
 // RUN: wc -c %t/a.pcm | FileCheck --check-prefix=CHECK-SIZE %s
-// CHECK-SIZE: {{(^|[^0-9])[123][0-9][0-9][0-9][0-9]($|[^0-9])}}
+// CHECK-SIZE: {{(^|[^0-9])[1-5][0-9][0-9][0-9][0-9]($|[^0-9])}}

diff  --git a/clang/test/Modules/empty.modulemap 
b/clang/test/Modules/empty.modulemap
index 3225d88829ae0..f2d37c19d77bc 100644
--- a/clang/test/Modules/empty.modulemap
+++ b/clang/test/Modules/empty.modulemap
@@ -13,8 +13,8 @@
 // The module file should be identical each time we produce it.
 // RUN: 
diff  %t/base.pcm %t/check.pcm
 //
-// We expect an empty module to be less than 40KB (and at least 10K, for now).
+// We expect an empty module to be less than 60KB (and at least 10K, for now).
 // RUN: wc -c %t/base.pcm | FileCheck --check-prefix=CHECK-SIZE %s
-// CHECK-SIZE: {{(^|[^0-9])[123][0-9][0-9][0-9][0-9]($|[^0-9])}}
+// CHECK-SIZE: {{(^|[^0-9])[1-5][0-9][0-9][0-9][0-9]($|[^0-9])}}
 
 module empty { header "Inputs/empty.h" export * }



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


[PATCH] D152436: [clang][analyzer] Move checker alpha.unix.StdCLibraryFunctions out of alpha.

2023-06-19 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

It is possible to add note tags to show decisions at standard functions. For 
example at `fileno` show if it has failed or not failed. The most simple way is 
to add it to all places, this means a note will show up on any bug path at all 
standard function usages. This is how it works already with the existing notes. 
Like in the following code:

  int __test_case_note();
  
  int test_case_note_1(int y) {
int x1 = __test_case_note(); // expected-note{{Function returns 1}}
int x = __test_case_note(); // expected-note{{Function returns 0}} \
// expected-note{{'x' initialized here}}
return y / x; // expected-warning{{Division by zero}} \
  // expected-note{{Division by zero}}
  }
  
  int test_case_note_2(int y) {
int x = __test_case_note(); // expected-note{{Function returns 1}}
return y / (x - 1); // expected-warning{{Division by zero}} \
// expected-note{{Division by zero}}
  }

Here the first note at line with "x1" is not necessary. This problem can be 
fixed if the note is only shown when the return value is "interesting":

  int __test_case_note();
  
  int test_case_note_1(int y) {
int x1 = __test_case_note(); // no note
int x = __test_case_note(); // expected-note{{Function returns 0}} \
// expected-note{{'x' initialized here}}
return y / x; // expected-warning{{Division by zero}} \
  // expected-note{{Division by zero}}
  }
  
  int test_case_note_2(int y) {
int x = __test_case_note(); // no note
return y / (x - 1); // expected-warning{{Division by zero}} \
// expected-note{{Division by zero}}
  }

But in this case the note at `test_case_note_2` disappears because `x-1` is 
interesting, but not `x`. Fixing this problem looks more difficult.

From these two solutions, which one is better? (Show many unnecessary notes, or 
show only necessary ones but lose some of the useful notes too.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152436

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


[PATCH] D148216: Add support for annotations in UpdateTestChecks (NFC)

2023-06-19 Thread Henrik G Olsson via Phabricator via cfe-commits
hnrklssn updated this revision to Diff 532649.
hnrklssn added a comment.

Rebase after reformatting with Black, update commit message


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148216

Files:
  clang/test/utils/update_cc_test_checks/Inputs/annotations.c
  clang/test/utils/update_cc_test_checks/Inputs/annotations.c.expected
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.expected
  
clang/test/utils/update_cc_test_checks/Inputs/global-hex-value-regex.c.expected
  clang/test/utils/update_cc_test_checks/Inputs/global-value-regex.c.expected
  clang/test/utils/update_cc_test_checks/annotations.test
  clang/test/utils/update_cc_test_checks/check-globals.test
  clang/test/utils/update_cc_test_checks/generated-funcs.test
  clang/test/utils/update_cc_test_checks/global-hex-value-regex.test
  clang/test/utils/update_cc_test_checks/global-value-regex.test
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/check_attrs.ll.funcattrs.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.generated.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.nogenerated.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs_prefix_reuse.ll.generated.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs_prefix_reuse.ll.nogenerated.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.noglobals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.transitiveglobals.expected
  llvm/test/tools/UpdateTestChecks/update_test_checks/generated_funcs.test
  
llvm/test/tools/UpdateTestChecks/update_test_checks/generated_funcs_prefix_reuse.test
  llvm/test/tools/UpdateTestChecks/update_test_checks/various_ir_values.test
  llvm/utils/UpdateTestChecks/common.py
  llvm/utils/update_cc_test_checks.py
  llvm/utils/update_test_checks.py

Index: llvm/utils/update_test_checks.py
===
--- llvm/utils/update_test_checks.py
+++ llvm/utils/update_test_checks.py
@@ -79,7 +79,8 @@
 )
 parser.add_argument(
 "--check-globals",
-action="store_true",
+default="default",
+choices=["none", "smart", "all"],
 help="Check global entries (global variables, metadata, attribute sets, ...) for functions",
 )
 parser.add_argument("tests", nargs="+")
@@ -195,7 +196,7 @@
 common.dump_input_lines(output_lines, ti, prefix_set, ";")
 
 args = ti.args
-if args.check_globals:
+if args.check_globals != 'none':
 generated_prefixes.extend(
 common.add_global_checks(
 builder.global_var_dict(),
@@ -205,6 +206,7 @@
 global_vars_seen_dict,
 args.preserve_names,
 True,
+args.check_globals,
 )
 )
 
@@ -272,6 +274,7 @@
 global_vars_seen_dict,
 args.preserve_names,
 True,
+args.check_globals,
 )
 )
 has_checked_pre_function_globals = True
@@ -301,7 +304,7 @@
 continue
 is_in_function = is_in_function_start = True
 
-if args.check_globals:
+if args.check_globals != 'none':
 generated_prefixes.extend(
 common.add_global_checks(
 builder.global_var_dict(),
@@ -311,6 +314,7 @@
 global_vars_seen_dict,
 args.preserve_names,
 False,
+args.check_globals,
 )
 )
 if ti.args.gen_unused_prefix_body:
Index: llvm/utils/update_cc_test_checks.py
===
--- llvm/utils/update_cc_test_checks.py
+++ llvm/utils/update_cc_test_checks.py
@@ -205,7 +205,8 @@
 )
 parser.add_argument(
 "--check-globals",
-action="store_true",
+default="default",
+choices=["none", "smart", "all"],
 help="Check global entries (global variables, metadata, attribute sets, ...) for functions",
 )
 parser.add_argument("tests", nargs="+")
@@ -436,7 +437,7 @@
 is_filtered=builder.is_filtered(),
 )
 
-if ti.args.check_globals:
+  

[PATCH] D153276: [clang][Interp] Reject reinterpret_cast expressions

2023-06-19 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, erichkeane, tahonermann, shafik.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Add a new `InvalidCast` op for this purpose and emit a diagnostic.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153276

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeExprGen.h
  clang/lib/AST/Interp/Disasm.cpp
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/Opcodes.td
  clang/lib/AST/Interp/PrimType.h
  clang/test/AST/Interp/unsupported.cpp

Index: clang/test/AST/Interp/unsupported.cpp
===
--- clang/test/AST/Interp/unsupported.cpp
+++ clang/test/AST/Interp/unsupported.cpp
@@ -47,3 +47,11 @@
 return 0;
   }
 }
+
+namespace Casts {
+  constexpr int a = reinterpret_cast(12); // expected-error {{must be initialized by a constant expression}} \
+   // expected-note {{reinterpret_cast is not allowed}} \
+   // ref-error {{must be initialized by a constant expression}} \
+   // ref-note {{reinterpret_cast is not allowed}}
+
+}
Index: clang/lib/AST/Interp/PrimType.h
===
--- clang/lib/AST/Interp/PrimType.h
+++ clang/lib/AST/Interp/PrimType.h
@@ -13,6 +13,7 @@
 #ifndef LLVM_CLANG_AST_INTERP_TYPE_H
 #define LLVM_CLANG_AST_INTERP_TYPE_H
 
+#include "llvm/Support/raw_ostream.h"
 #include 
 #include 
 #include 
@@ -42,6 +43,12 @@
   PT_FnPtr,
 };
 
+enum class CastKind : uint8_t {
+  Reinterpret,
+  Dynamic,
+};
+llvm::raw_ostream <<(llvm::raw_ostream , interp::CastKind CK);
+
 constexpr bool isIntegralType(PrimType T) { return T <= PT_Uint64; }
 
 /// Mapping from primitive types to their representation.
Index: clang/lib/AST/Interp/Opcodes.td
===
--- clang/lib/AST/Interp/Opcodes.td
+++ clang/lib/AST/Interp/Opcodes.td
@@ -51,6 +51,7 @@
 def ArgFltSemantics : ArgType { let Name = "const llvm::fltSemantics *"; }
 def ArgRoundingMode : ArgType { let Name = "llvm::RoundingMode"; }
 def ArgLETD: ArgType { let Name = "const LifetimeExtendedTemporaryDecl *"; }
+def ArgCastKind : ArgType { let Name = "CastKind"; }
 
 //===--===//
 // Classes of types instructions operate on.
@@ -636,3 +637,6 @@
 
 // [] -> []
 def Invalid : Opcode {}
+def InvalidCast : Opcode {
+  let Args = [ArgCastKind];
+}
Index: clang/lib/AST/Interp/Interp.h
===
--- clang/lib/AST/Interp/Interp.h
+++ clang/lib/AST/Interp/Interp.h
@@ -1847,6 +1847,14 @@
   return false;
 }
 
+/// Same here, but only for casts.
+inline bool InvalidCast(InterpState , CodePtr OpPC, CastKind Kind) {
+  const SourceLocation  = S.Current->getLocation(OpPC);
+  S.FFDiag(Loc, diag::note_constexpr_invalid_cast)
+  << static_cast(Kind) << S.Current->getRange(OpPC);
+  return false;
+}
+
 //===--===//
 // Read opcode arguments
 //===--===//
Index: clang/lib/AST/Interp/Disasm.cpp
===
--- clang/lib/AST/Interp/Disasm.cpp
+++ clang/lib/AST/Interp/Disasm.cpp
@@ -73,3 +73,15 @@
 Anon->dump();
   }
 }
+
+llvm::raw_ostream <<(llvm::raw_ostream , interp::CastKind CK) {
+  switch (CK) {
+  case interp::CastKind::Reinterpret:
+OS << "reinterpret_cast";
+break;
+  case interp::CastKind::Dynamic:
+OS << "dynamic_cast";
+break;
+  }
+  return OS;
+}
Index: clang/lib/AST/Interp/ByteCodeExprGen.h
===
--- clang/lib/AST/Interp/ByteCodeExprGen.h
+++ clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -98,6 +98,7 @@
   bool VisitLambdaExpr(const LambdaExpr *E);
   bool VisitPredefinedExpr(const PredefinedExpr *E);
   bool VisitCXXThrowExpr(const CXXThrowExpr *E);
+  bool VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *E);
 
 protected:
   bool visitExpr(const Expr *E) override;
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1115,6 +1115,15 @@
   return this->emitInvalid(E);
 }
 
+template 
+bool ByteCodeExprGen::VisitCXXReinterpretCastExpr(
+const CXXReinterpretCastExpr *E) {
+  if (!this->discard(E->getSubExpr()))
+return false;
+
+  return this->emitInvalidCast(CastKind::Reinterpret, E);
+}
+
 template  bool ByteCodeExprGen::discard(const Expr *E) {
   if (E->containsErrors())
 return false;

[PATCH] D153128: [AArch64][RCPC3] Add Neon intrinsics for LDAP1 and STL2

2023-06-19 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson accepted this revision.
tmatheson added a comment.
This revision is now accepted and ready to land.

LGTM. ACLE PR here: https://github.com/ARM-software/acle/pull/265




Comment at: clang/lib/CodeGen/CGBuiltin.cpp:6769
+  // and vstl1(q)_lane, but codegen is equivalent for all of them. Choose an
+  // arbitrary one to be handled as tha canonical variation.
+  { NEON::BI__builtin_neon_vldap1_lane_u64, 
NEON::BI__builtin_neon_vldap1_lane_s64 },




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153128

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


[PATCH] D146148: Float_t and double_t types shouldn't be modified by #pragma clang fp eval_method

2023-06-19 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 532643.
zahiraam marked 2 inline comments as done.

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

https://reviews.llvm.org/D146148

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/IdentifierTable.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Basic/TokenKinds.h
  clang/lib/Basic/Builtins.cpp
  clang/lib/Basic/IdentifierTable.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/test/Sema/abi-check-1.cpp
  clang/test/Sema/abi-check-2.cpp
  clang/test/Sema/abi-check-3.cpp
  clang/test/Sema/attr-only-in-default-eval.cpp

Index: clang/test/Sema/attr-only-in-default-eval.cpp
===
--- /dev/null
+++ clang/test/Sema/attr-only-in-default-eval.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef float float_t [[clang::available_only_in_default_eval_method]];
+using double_t __attribute__((available_only_in_default_eval_method)) = double;
+
+// expected-error@+1{{'available_only_in_default_eval_method' attribute only applies to typedefs}}
+class  __attribute__((available_only_in_default_eval_method)) C1 {
+};
+// expected-error@+1{{'available_only_in_default_eval_method' attribute only applies to typedefs}}
+class  [[clang::available_only_in_default_eval_method]] C2 {
+};
+
+// expected-error@+1{{'available_only_in_default_eval_method' attribute only applies to typedefs}}
+struct [[clang::available_only_in_default_eval_method]] S1;
+// expected-error@+1{{'available_only_in_default_eval_method' attribute only applies to typedefs}}
+struct __attribute__((available_only_in_default_eval_method)) S2;
+
+// expected-error@+1{{'available_only_in_default_eval_method' attribute only applies to typedefs}}
+void __attribute__((available_only_in_default_eval_method)) foo();
+// expected-error@+1{{'available_only_in_default_eval_method' attribute cannot be applied to types}}
+void [[clang::available_only_in_default_eval_method]] goo();
+// expected-error@+1{{'available_only_in_default_eval_method' attribute cannot be applied to types}}
+void bar() [[clang::available_only_in_default_eval_method]];
+// expected-error@+1{{'available_only_in_default_eval_method' attribute only applies to typedefs}}
+void barz() __attribute__((available_only_in_default_eval_method));
+
Index: clang/test/Sema/abi-check-3.cpp
===
--- /dev/null
+++ clang/test/Sema/abi-check-3.cpp
@@ -0,0 +1,86 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -DNOERROR %s
+// RUN: %clang_cc1 -fsyntax-only -verify -ffp-eval-method=extended -DNOERROR %s
+
+// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=source %s
+// RUN: %clang_cc1 -verify -fsyntax-only -ffp-eval-method=double %s
+
+
+#ifdef NOERROR
+// expected-no-diagnostics
+typedef float float_t;
+typedef double double_t;
+#else
+typedef float float_t; //expected-error 9 {{cannot use type 'float_t' within '#pragma clang fp eval_method'; type is set according to the default eval method for the translation unit}}
+
+typedef double double_t; //expected-error 9 {{cannot use type 'double_t' within '#pragma clang fp eval_method'; type is set according to the default eval method for the translation unit}}
+#endif
+
+float foo1() {
+#pragma clang fp eval_method(extended)
+  float a;
+  double b;
+  return a - b;
+}
+
+float foo2() {
+#pragma clang fp eval_method(extended)
+  float_t a; 
+  double_t b; 
+  return a - b;
+}
+
+void foo3() {
+#pragma clang fp eval_method(extended)
+  char buff[sizeof(float_t)];
+  char bufd[sizeof(double_t)];
+  buff[1] = bufd[2];
+}
+
+float foo4() {
+#pragma clang fp eval_method(extended)
+  typedef float_t FT;
+  typedef double_t DT;
+  FT a;
+  DT b;
+  return a - b;
+}
+
+int foo5() {
+#pragma clang fp eval_method(extended)
+  int t = _Generic( 1.0L, float_t:1, default:0);
+  int v = _Generic( 1.0L, double_t:1, default:0);
+  return t;
+}
+
+void foo6() {
+#pragma clang fp eval_method(extended)
+  auto resf = [](float_t f) { return f; };
+  auto resd = [](double_t g) { return g; };
+}
+
+void foo7() {
+#pragma clang fp eval_method(extended)
+  float f = (float_t)1; 
+  double d = (double_t)2; 
+}
+
+void foo8() {
+#pragma clang fp eval_method(extended)
+  using Ft = float_t;
+  using Dt = double_t;
+  Ft a;
+  Dt b;
+}
+
+void foo9() {
+#pragma clang fp eval_method(extended)
+  float c1 = (float_t)12;
+  double c2 = (double_t)13;
+}
+
+float foo10() {
+#pragma clang fp eval_method(extended)
+  extern float_t f;
+  extern double_t g;
+  return f-g;
+}
Index: clang/test/Sema/abi-check-2.cpp
===
--- /dev/null
+++ clang/test/Sema/abi-check-2.cpp
@@ -0,0 +1,85 @@
+// RUN: %clang_cc1 -fsyntax-only -verify 

[PATCH] D144006: [DebugMetadata][DwarfDebug] Support function-local types in lexical block scopes (4/7)

2023-06-19 Thread Vladislav Dzhidzhoev via Phabricator via cfe-commits
dzhidzhoev updated this revision to Diff 532642.
dzhidzhoev added a comment.

Rebased.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144006

Files:
  clang/test/CodeGen/debug-info-codeview-unnamed.c
  clang/test/CodeGen/debug-info-unused-types.c
  clang/test/CodeGen/debug-info-unused-types.cpp
  clang/test/CodeGenCXX/debug-info-access.cpp
  clang/test/CodeGenCXX/debug-info-anon-union-vars.cpp
  clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp
  clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
  clang/test/CodeGenCXX/debug-lambda-this.cpp
  llvm/include/llvm/IR/DIBuilder.h
  llvm/lib/Bitcode/Reader/MetadataLoader.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  llvm/lib/IR/DIBuilder.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/test/Bitcode/upgrade-cu-locals.ll
  llvm/test/Bitcode/upgrade-cu-locals.ll.bc
  llvm/test/DebugInfo/Generic/inlined-local-type.ll
  llvm/test/DebugInfo/Generic/lexical-block-retained-types.ll
  llvm/test/DebugInfo/Generic/lexical-block-types.ll
  llvm/test/DebugInfo/Generic/local-type-as-template-parameter.ll
  llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll
  llvm/test/DebugInfo/X86/set.ll

Index: llvm/test/DebugInfo/X86/set.ll
===
--- llvm/test/DebugInfo/X86/set.ll
+++ llvm/test/DebugInfo/X86/set.ll
@@ -68,11 +68,11 @@
 !llvm.module.flags = !{!18, !19, !20}
 
 !0 = !{!"versions- cm3: d5.10.0 llvm: 9.0"}
-!1 = distinct !DICompileUnit(language: DW_LANG_Modula3, file: !2, producer: "cm3", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !3)
+!1 = distinct !DICompileUnit(language: DW_LANG_Modula3, file: !2, producer: "cm3", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
 !2 = !DIFile(filename: "Main.m3", directory: "/home/cm3/settest/src")
 !3 = !{!4}
 !4 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "Enum", scope: !5, file: !2, line: 11, size: 8, align: 8, elements: !9)
-!5 = distinct !DISubprogram(name: "Test", linkageName: "Main__Test", scope: !2, file: !2, line: 11, type: !6, scopeLine: 11, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !8)
+!5 = distinct !DISubprogram(name: "Test", linkageName: "Main__Test", scope: !2, file: !2, line: 11, type: !6, scopeLine: 11, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !3)
 !6 = !DISubroutineType(types: !7)
 !7 = !{null}
 !8 = !{}
Index: llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll
===
--- llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll
+++ llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll
@@ -38,7 +38,7 @@
 define void @invalid_retained_nodes_list() !dbg !10 { ret void }
 !10 = distinct !DISubprogram(retainedNodes: !0)
 
-; CHECK: invalid retained nodes, expected DILocalVariable, DILabel or DIImportedEntity
+; CHECK: invalid retained nodes, expected DILocalVariable, DILabel, DIImportedEntity or DIType
 define void @invalid_retained_nodes_expected() !dbg !11 { ret void }
 !11 = distinct !DISubprogram(retainedNodes: !{!0})
 
Index: llvm/test/DebugInfo/Generic/local-type-as-template-parameter.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/Generic/local-type-as-template-parameter.ll
@@ -0,0 +1,160 @@
+; RUN: %llc_dwarf -O0 -filetype=obj < %s  \
+; RUN:  | llvm-dwarfdump --show-children --name=foo - \
+; RUN:  | FileCheck --implicit-check-not "{{DW_TAG|NULL}}" %s
+
+; The test ensures that AsmPrinter doesn't crashed compiling this.
+; It also demostrates misplacement for a local type (see PR55680 for details).
+
+; The test compiled from:
+
+; template
+; struct A {
+;   A(T ) : a(in) {}
+;   T a;
+; };
+;
+; __attribute__((always_inline))
+; void foo() {
+;   struct B { int i; };
+;   B objB;
+;   A objA(objB);
+; }
+;
+; int main() {
+;   foo();
+; }
+
+; Concrete out-of-line tree of foo().
+; CHECK: DW_TAG_subprogram
+; CHECK:   DW_AT_abstract_origin {{.*}} "_Z3foov"
+
+; FIXME: 'struct B' should be in the abstract tree below, not here.
+; CHECK:   DW_TAG_structure_type
+; CHECK: DW_AT_name	("B")
+; CHECK: DW_TAG_member
+; CHECK: NULL
+;
+; CHECK:   DW_TAG_variable
+; CHECK: DW_AT_abstract_origin {{.*}} "objB"
+; CHECK:   DW_TAG_variable
+; CHECK: DW_AT_abstract_origin {{.*}} "objA"
+
+; CHECK:   NULL
+
+; Abstract tree of foo().
+; CHECK: DW_TAG_subprogram
+; CHECK:   DW_AT_name	("foo")
+; CHECK:   DW_AT_inline	(DW_INL_inlined)
+
+; CHECK:   DW_TAG_variable
+; CHECK: DW_AT_name	("objB")
+; CHECK:   DW_TAG_variable
+; CHECK: DW_AT_name	("objA")
+
+; CHECK:   NULL
+
+; CHECK: DW_TAG_inlined_subroutine
+; CHECK:   DW_AT_abstract_origin {{.*}} "_Z3foov"
+; CHECK:   DW_TAG_variable
+; CHECK: 

[PATCH] D152391: [Clang] Allow bitcode linking when the input is LLVM-IR

2023-06-19 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a subscriber: ronlieb.
jhuber6 added a comment.

ping
@ronlieb


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152391

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


[PATCH] D153273: CPP-4465 Rework support for CFGScopeBegin, CFGScopeEnd, CFGLifetime elements

2023-06-19 Thread Tomasz Kamiński via Phabricator via cfe-commits
tomasz-kaminski-sonarsource created this revision.
Herald added a reviewer: NoQ.
Herald added a project: All.
tomasz-kaminski-sonarsource requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch reworks generation for the `CFGScopeBegin`, `CFGScopeEnd`,
and `CFGLiftimeEnd`, in a way that they are now compatible with each
other and `CFGAutomaticObjDtor`. All of the above elements are now
generated by a single code path, that conditionally inserts elements if
they are requested.

In addition, the handling of `goto` statements is improved.
The `goto` statement may leave multiple scopes (and trigger destruction
and lifetime end for the affected variables) and enter multiple scopes,
for example:

  C++
  {
int s1;
{
  int s2;
  goto label; // leaves s1, s2, and enters t1 t1
}
  }
  {
int t1;
{
  int t2;
  label:
}
  }

This is performed by first determining the shared parent scope of the
source and destination. And then emitting elements for exiting each
scope between the source and the parent, and entering each scope
between the parent and destination. All such elements are appended
to the source block, as one label may be reached from multiple scopes.

Finally, the approach for handling backward jumps is changed. When
connecting a source block to a destination block that requires the
insertion of additional elements, we put this element into a new block,
which is then linked between the source and the destination block.
For example:

  C++
  {
int t;
  label:
// Destination block referred to as 'DB'
  }
  {
// Source block referred to as 'SB'
Obj s;
goto label;
  }

The jump between `SB` with terminator `T: goto` and `DB` should be
coupled with the following CFG elements:

  CFGAutomaticObjDtor(s)
  CFGLifetimeEnd(s)
  CFGScopeEnd(s)
  CFGScopeBegin(t)

To handle such situations, we create a new link (`LB`) that is linked as
the predecessor of `DB`, to which we transfer the terminator (`goto`
statement) of `SB`. Then `LB` is handled in the same manner as the
source block in the case of forward jumps.
This produces CFG that looks like this:

  SB -> LB (T: goto) -> DB

Finally, the resulting block is linked as the successor of `SB`. Such an
approach uses existing handling of the `noreturn` destructors.
As a reminder, for each destructor of an automatic object that is
marked as `noreturn`, a new `noreturn` block (marked `NBn`) is
created, at the destructor is inserted at the end of it.
To illustrate, given two `noreturn` destructors, we will have:

  SB -> NB1 (noreturn)
  NB2 (noreturn)
  LB (T:goto) -> DB


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153273

Files:
  clang/include/clang/Analysis/CFG.h
  clang/lib/Analysis/CFG.cpp
  clang/test/Analysis/auto-obj-dtors-cfg-output.cpp
  clang/test/Analysis/lifetime-cfg-output.cpp
  clang/test/Analysis/no-exit-cfg.c
  clang/test/Analysis/nonreturn-destructors-cfg-output.cpp
  clang/test/Analysis/scopes-cfg-output.cpp

Index: clang/test/Analysis/scopes-cfg-output.cpp
===
--- clang/test/Analysis/scopes-cfg-output.cpp
+++ clang/test/Analysis/scopes-cfg-output.cpp
@@ -674,30 +674,30 @@
   A f;
 }
 
-// CHECK:  [B8 (ENTRY)]
+// CHECK:  [B9 (ENTRY)]
 // CHECK-NEXT:   Succs (1): B7
 // CHECK:  [B1]
 // CHECK-NEXT:  l1:
 // CHECK-NEXT:   1:  (CXXConstructExpr, [B1.2], A)
 // CHECK-NEXT:   2: A c;
 // CHECK-NEXT:   3: [B1.2].~A() (Implicit destructor)
-// CHECK-NEXT:   4: [B6.5].~A() (Implicit destructor)
-// CHECK-NEXT:   5: [B6.3].~A() (Implicit destructor)
+// CHECK-NEXT:   4: [B6.4].~A() (Implicit destructor)
+// CHECK-NEXT:   5: [B6.2].~A() (Implicit destructor)
 // CHECK-NEXT:   6: [B7.3].~A() (Implicit destructor)
 // CHECK-NEXT:   7: CFGScopeEnd(a)
 // CHECK-NEXT:   Preds (2): B2 B3
 // CHECK-NEXT:   Succs (1): B0
 // CHECK:  [B2]
 // CHECK-NEXT:   1:  (CXXConstructExpr, [B2.2], A)
-// CHECK-NEXT:   2: A b;
+// CHECK-NEXT:   2: A nb;
 // CHECK-NEXT:   3: [B2.2].~A() (Implicit destructor)
-// CHECK-NEXT:   4: [B6.8].~A() (Implicit destructor)
-// CHECK-NEXT:   5: CFGScopeEnd(a)
+// CHECK-NEXT:   4: [B6.7].~A() (Implicit destructor)
+// CHECK-NEXT:   5: CFGScopeEnd(na)
 // CHECK-NEXT:   Preds (1): B4
 // CHECK-NEXT:   Succs (1): B1
 // CHECK:  [B3]
-// CHECK-NEXT:   1: [B6.8].~A() (Implicit destructor)
-// CHECK-NEXT:   2: CFGScopeEnd(a)
+// CHECK-NEXT:   1: [B6.7].~A() (Implicit destructor)
+// CHECK-NEXT:   2: CFGScopeEnd(na)
 // CHECK-NEXT:   T: goto l1;
 // CHECK-NEXT:   Preds (1): B4
 // CHECK-NEXT:   Succs (1): B1
@@ -708,33 +708,35 @@
 // CHECK-NEXT:   Preds (1): B6
 // CHECK-NEXT:   Succs (2): B3 B2
 // CHECK:  [B5]
-// CHECK-NEXT:   1: [B6.8].~A() (Implicit destructor)
-// CHECK-NEXT:   2: [B6.5].~A() (Implicit destructor)
-// CHECK-NEXT:   3: [B6.3].~A() (Implicit destructor)
-// CHECK-NEXT:   4: CFGScopeEnd(cb)
-// CHECK-NEXT:   T: 

[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-06-19 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152495

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


[PATCH] D152570: [clang] Apply -fmacro-prefix-map to anonymous tags in template arguments

2023-06-19 Thread Tulio Magno Quites Machado Filho via Phabricator via cfe-commits
tuliom added inline comments.



Comment at: clang/test/CodeGenCXX/macro-prefix-map-lambda.cpp:11
+  auto *s = lambdatest([](){});
+// CHECK: @"__PRETTY_FUNCTION__._Z10lambdatestIZ4mainE3$_0EDaOT_" = private 
unnamed_addr constant [{{[0-9]+}} x i8] c"auto lambdatest(f &&) [f = (lambda at 
./UNLIKELY_PATH/empty{{/|}}{{.*}}.cpp:[[#@LINE-1]]:24)]\00", align 1
+

zixuan-wu wrote:
> Hi, it's weird that the align in CSKY target is not 1, instead it's 4. 
> Anybody know the key point?
And on SystemZ it's 2.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152570

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


[PATCH] D151938: [clang][index] NFCI: Make `CXFile` a `FileEntryRef`

2023-06-19 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added inline comments.



Comment at: clang/tools/libclang/CXFile.h:18
+inline CXFile makeCXFile(OptionalFileEntryRef FE) {
+  return CXFile(FE ? >getMapEntry() : nullptr);
+}

Gcc warns here:
```
../../clang/tools/libclang/CXFile.h:18:50: warning: cast from type 'const 
MapEntry*' {aka 'const 
llvm::StringMapEntry >*'} to type 
'CXFile' {aka 'void*'} casts away qualifiers [-Wcast-qual]
```
Anything that should be fixed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151938

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


[PATCH] D144802: clang: Add __builtin_elementwise_round

2023-06-19 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:647
+ T __builtin_elementwise_round(T x)  round x to the nearest integer value 
in floating point format,   floating point types
+ rounding halfway cases to even 
(that is, to the nearest value
+ that is an even integer), 
regardless of the current rounding

python3kgae wrote:
> Is this still true for round?
No, I got the two crossed. I also need to add elementwise_rint 


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

https://reviews.llvm.org/D144802

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


[PATCH] D153271: [include-cleaner] Bailout on invalid code for the command-line tool

2023-06-19 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: kadircet.
Herald added a project: All.
hokein requested review of this revision.
Herald added a project: clang-tools-extra.

The binary tool only works on working source code, if the source code is
not compilable, don't perform any analysis and edits.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153271

Files:
  clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp


Index: clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
===
--- clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
+++ clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
@@ -108,10 +108,18 @@
   }
 
   void EndSourceFile() override {
+const auto  = getCompilerInstance().getSourceManager();
+if (SM.getDiagnostics().hasUncompilableErrorOccurred()) {
+  llvm::errs()
+  << "Skipping file " << getCurrentFile()
+  << " due to compiler errors. clang-include-cleaner expects to "
+ "work on compilable source code.\n";
+  return;
+}
+
 if (!HTMLReportPath.empty())
   writeHTML();
 
-const auto  = getCompilerInstance().getSourceManager();
 auto  = getCompilerInstance().getPreprocessor().getHeaderSearchInfo();
 llvm::StringRef Path =
 SM.getFileEntryForID(SM.getMainFileID())->tryGetRealPathName();


Index: clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
===
--- clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
+++ clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
@@ -108,10 +108,18 @@
   }
 
   void EndSourceFile() override {
+const auto  = getCompilerInstance().getSourceManager();
+if (SM.getDiagnostics().hasUncompilableErrorOccurred()) {
+  llvm::errs()
+  << "Skipping file " << getCurrentFile()
+  << " due to compiler errors. clang-include-cleaner expects to "
+ "work on compilable source code.\n";
+  return;
+}
+
 if (!HTMLReportPath.empty())
   writeHTML();
 
-const auto  = getCompilerInstance().getSourceManager();
 auto  = getCompilerInstance().getPreprocessor().getHeaderSearchInfo();
 llvm::StringRef Path =
 SM.getFileEntryForID(SM.getMainFileID())->tryGetRealPathName();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D138504: clang/HIP: Remove __llvm_amdgcn_* wrapper hacks

2023-06-19 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm added a comment.

f407a7399575a6821940973c54754d42e72dd9ce


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

https://reviews.llvm.org/D138504

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


[clang] f407a73 - clang/HIP: Remove __llvm_amdgcn_* wrapper hacks

2023-06-19 Thread Matt Arsenault via cfe-commits

Author: Matt Arsenault
Date: 2023-06-19T08:55:10-04:00
New Revision: f407a7399575a6821940973c54754d42e72dd9ce

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

LOG: clang/HIP: Remove __llvm_amdgcn_* wrapper hacks

These are leftover hacks from using asm declaratios to access
intrinsics.

Added: 


Modified: 
clang/lib/Headers/__clang_hip_libdevice_declares.h
clang/lib/Headers/__clang_hip_math.h

Removed: 




diff  --git a/clang/lib/Headers/__clang_hip_libdevice_declares.h 
b/clang/lib/Headers/__clang_hip_libdevice_declares.h
index be25f4b4a0506..2fc5e17d2f1ea 100644
--- a/clang/lib/Headers/__clang_hip_libdevice_declares.h
+++ b/clang/lib/Headers/__clang_hip_libdevice_declares.h
@@ -137,23 +137,6 @@ __device__ __attribute__((const)) float 
__ocml_fma_rte_f32(float, float, float);
 __device__ __attribute__((const)) float __ocml_fma_rtn_f32(float, float, 
float);
 __device__ __attribute__((const)) float __ocml_fma_rtp_f32(float, float, 
float);
 __device__ __attribute__((const)) float __ocml_fma_rtz_f32(float, float, 
float);
-
-__device__ inline __attribute__((const)) float
-__llvm_amdgcn_cos_f32(float __x) {
-  return __builtin_amdgcn_cosf(__x);
-}
-__device__ inline __attribute__((const)) float
-__llvm_amdgcn_rcp_f32(float __x) {
-  return __builtin_amdgcn_rcpf(__x);
-}
-__device__ inline __attribute__((const)) float
-__llvm_amdgcn_rsq_f32(float __x) {
-  return __builtin_amdgcn_rsqf(__x);
-}
-__device__ inline __attribute__((const)) float
-__llvm_amdgcn_sin_f32(float __x) {
-  return __builtin_amdgcn_sinf(__x);
-}
 // END INTRINSICS
 // END FLOAT
 
@@ -277,15 +260,6 @@ __device__ __attribute__((const)) double 
__ocml_fma_rtp_f64(double, double,
 __device__ __attribute__((const)) double __ocml_fma_rtz_f64(double, double,
 double);
 
-__device__ inline __attribute__((const)) double
-__llvm_amdgcn_rcp_f64(double __x) {
-  return __builtin_amdgcn_rcp(__x);
-}
-__device__ inline __attribute__((const)) double
-__llvm_amdgcn_rsq_f64(double __x) {
-  return __builtin_amdgcn_rsq(__x);
-}
-
 __device__ __attribute__((const)) _Float16 __ocml_ceil_f16(_Float16);
 __device__ _Float16 __ocml_cos_f16(_Float16);
 __device__ __attribute__((const)) _Float16 __ocml_cvtrtn_f16_f32(float);
@@ -305,7 +279,6 @@ __device__ __attribute__((const)) int 
__ocml_isnan_f16(_Float16);
 __device__ __attribute__((pure)) _Float16 __ocml_log_f16(_Float16);
 __device__ __attribute__((pure)) _Float16 __ocml_log10_f16(_Float16);
 __device__ __attribute__((pure)) _Float16 __ocml_log2_f16(_Float16);
-__device__ __attribute__((const)) _Float16 __llvm_amdgcn_rcp_f16(_Float16);
 __device__ __attribute__((const)) _Float16 __ocml_rint_f16(_Float16);
 __device__ __attribute__((const)) _Float16 __ocml_rsqrt_f16(_Float16);
 __device__ _Float16 __ocml_sin_f16(_Float16);
@@ -332,11 +305,6 @@ __device__ __attribute__((const)) __2i16 
__ocml_isnan_2f16(__2f16);
 __device__ __attribute__((pure)) __2f16 __ocml_log_2f16(__2f16);
 __device__ __attribute__((pure)) __2f16 __ocml_log10_2f16(__2f16);
 __device__ __attribute__((pure)) __2f16 __ocml_log2_2f16(__2f16);
-__device__ inline __2f16
-__llvm_amdgcn_rcp_2f16(__2f16 __x) // Not currently exposed by ROCDL.
-{
-  return (__2f16)(__llvm_amdgcn_rcp_f16(__x.x), __llvm_amdgcn_rcp_f16(__x.y));
-}
 __device__ __attribute__((const)) __2f16 __ocml_rint_2f16(__2f16);
 __device__ __attribute__((const)) __2f16 __ocml_rsqrt_2f16(__2f16);
 __device__ __2f16 __ocml_sin_2f16(__2f16);

diff  --git a/clang/lib/Headers/__clang_hip_math.h 
b/clang/lib/Headers/__clang_hip_math.h
index f7949f30dfbae..2b33efcd8317a 100644
--- a/clang/lib/Headers/__clang_hip_math.h
+++ b/clang/lib/Headers/__clang_hip_math.h
@@ -647,7 +647,7 @@ float __frcp_rn(float __x) { return 1.0f / __x; }
 #endif
 
 __DEVICE__
-float __frsqrt_rn(float __x) { return __llvm_amdgcn_rsq_f32(__x); }
+float __frsqrt_rn(float __x) { return __builtin_amdgcn_rsqf(__x); }
 
 #if defined OCML_BASIC_ROUNDED_OPERATIONS
 __DEVICE__



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


[PATCH] D150997: [llvm] Split out DenseMapInfo specialization

2023-06-19 Thread Nikita Popov via Phabricator via cfe-commits
nikic accepted this revision.
nikic added a comment.
This revision is now accepted and ready to land.

LGTM. The diff looks weird for some reason, but the downloadable `.diff` file 
looks fine.


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

https://reviews.llvm.org/D150997

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


[clang] 85232b0 - HIP: Directly call isfinite builtins

2023-06-19 Thread Matt Arsenault via cfe-commits

Author: Matt Arsenault
Date: 2023-06-19T08:48:48-04:00
New Revision: 85232b0ecbf817bc1d70ae602cf44cf6ea03c0e6

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

LOG: HIP: Directly call isfinite builtins

Added: 


Modified: 
clang/lib/Headers/__clang_hip_math.h
clang/test/Headers/__clang_hip_math.hip

Removed: 




diff  --git a/clang/lib/Headers/__clang_hip_math.h 
b/clang/lib/Headers/__clang_hip_math.h
index c19e32bd29364..f7949f30dfbae 100644
--- a/clang/lib/Headers/__clang_hip_math.h
+++ b/clang/lib/Headers/__clang_hip_math.h
@@ -268,7 +268,7 @@ __DEVICE__
 int ilogbf(float __x) { return __ocml_ilogb_f32(__x); }
 
 __DEVICE__
-__RETURN_TYPE __finitef(float __x) { return __ocml_isfinite_f32(__x); }
+__RETURN_TYPE __finitef(float __x) { return __builtin_isfinite(__x); }
 
 __DEVICE__
 __RETURN_TYPE __isinff(float __x) { return __builtin_isinf(__x); }
@@ -817,7 +817,7 @@ __DEVICE__
 int ilogb(double __x) { return __ocml_ilogb_f64(__x); }
 
 __DEVICE__
-__RETURN_TYPE __finite(double __x) { return __ocml_isfinite_f64(__x); }
+__RETURN_TYPE __finite(double __x) { return __builtin_isfinite(__x); }
 
 __DEVICE__
 __RETURN_TYPE __isinf(double __x) { return __builtin_isinf(__x); }

diff  --git a/clang/test/Headers/__clang_hip_math.hip 
b/clang/test/Headers/__clang_hip_math.hip
index 7169614112d18..bb96aeaa1ab9b 100644
--- a/clang/test/Headers/__clang_hip_math.hip
+++ b/clang/test/Headers/__clang_hip_math.hip
@@ -1155,17 +1155,14 @@ extern "C" __device__ int test_ilogb(double x) {
 
 // DEFAULT-LABEL: @test___finitef(
 // DEFAULT-NEXT:  entry:
-// DEFAULT-NEXT:[[CALL_I:%.*]] = tail call i32 @__ocml_isfinite_f32(float 
noundef [[X:%.*]]) #[[ATTR14]]
-// DEFAULT-NEXT:[[TOBOOL_I:%.*]] = icmp ne i32 [[CALL_I]], 0
-// DEFAULT-NEXT:[[CONV:%.*]] = zext i1 [[TOBOOL_I]] to i32
+// DEFAULT-NEXT:[[TMP0:%.*]] = tail call contract float 
@llvm.fabs.f32(float [[X:%.*]]) #[[ATTR17:[0-9]+]]
+// DEFAULT-NEXT:[[CMPINF_I:%.*]] = fcmp contract one float [[TMP0]], 
0x7FF0
+// DEFAULT-NEXT:[[CONV:%.*]] = zext i1 [[CMPINF_I]] to i32
 // DEFAULT-NEXT:ret i32 [[CONV]]
 //
 // FINITEONLY-LABEL: @test___finitef(
 // FINITEONLY-NEXT:  entry:
-// FINITEONLY-NEXT:[[CALL_I:%.*]] = tail call i32 
@__ocml_isfinite_f32(float noundef nofpclass(nan inf) [[X:%.*]]) #[[ATTR14]]
-// FINITEONLY-NEXT:[[TOBOOL_I:%.*]] = icmp ne i32 [[CALL_I]], 0
-// FINITEONLY-NEXT:[[CONV:%.*]] = zext i1 [[TOBOOL_I]] to i32
-// FINITEONLY-NEXT:ret i32 [[CONV]]
+// FINITEONLY-NEXT:ret i32 1
 //
 extern "C" __device__ BOOL_TYPE test___finitef(float x) {
   return __finitef(x);
@@ -1173,17 +1170,14 @@ extern "C" __device__ BOOL_TYPE test___finitef(float x) 
{
 
 // DEFAULT-LABEL: @test___finite(
 // DEFAULT-NEXT:  entry:
-// DEFAULT-NEXT:[[CALL_I:%.*]] = tail call i32 @__ocml_isfinite_f64(double 
noundef [[X:%.*]]) #[[ATTR14]]
-// DEFAULT-NEXT:[[TOBOOL_I:%.*]] = icmp ne i32 [[CALL_I]], 0
-// DEFAULT-NEXT:[[CONV:%.*]] = zext i1 [[TOBOOL_I]] to i32
+// DEFAULT-NEXT:[[TMP0:%.*]] = tail call contract double 
@llvm.fabs.f64(double [[X:%.*]]) #[[ATTR17]]
+// DEFAULT-NEXT:[[CMPINF_I:%.*]] = fcmp contract one double [[TMP0]], 
0x7FF0
+// DEFAULT-NEXT:[[CONV:%.*]] = zext i1 [[CMPINF_I]] to i32
 // DEFAULT-NEXT:ret i32 [[CONV]]
 //
 // FINITEONLY-LABEL: @test___finite(
 // FINITEONLY-NEXT:  entry:
-// FINITEONLY-NEXT:[[CALL_I:%.*]] = tail call i32 
@__ocml_isfinite_f64(double noundef nofpclass(nan inf) [[X:%.*]]) #[[ATTR14]]
-// FINITEONLY-NEXT:[[TOBOOL_I:%.*]] = icmp ne i32 [[CALL_I]], 0
-// FINITEONLY-NEXT:[[CONV:%.*]] = zext i1 [[TOBOOL_I]] to i32
-// FINITEONLY-NEXT:ret i32 [[CONV]]
+// FINITEONLY-NEXT:ret i32 1
 //
 extern "C" __device__ BOOL_TYPE test___finite(double x) {
   return __finite(x);
@@ -1191,7 +1185,7 @@ extern "C" __device__ BOOL_TYPE test___finite(double x) {
 
 // DEFAULT-LABEL: @test___isinff(
 // DEFAULT-NEXT:  entry:
-// DEFAULT-NEXT:[[TMP0:%.*]] = tail call contract float 
@llvm.fabs.f32(float [[X:%.*]]) #[[ATTR17:[0-9]+]]
+// DEFAULT-NEXT:[[TMP0:%.*]] = tail call contract float 
@llvm.fabs.f32(float [[X:%.*]]) #[[ATTR17]]
 // DEFAULT-NEXT:[[CMPINF_I:%.*]] = fcmp contract oeq float [[TMP0]], 
0x7FF0
 // DEFAULT-NEXT:[[CONV:%.*]] = zext i1 [[CMPINF_I]] to i32
 // DEFAULT-NEXT:ret i32 [[CONV]]



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


[PATCH] D153267: [clang][Diagnostics] Provide parameter source range to arity-mismatch notes

2023-06-19 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet created this revision.
hazohelet added reviewers: aaron.ballman, tbaeder, cjdb, erichkeane.
Herald added a project: All.
hazohelet requested review of this revision.
Herald added a project: clang.

On mismatch of arity of functions like

  void func( int aa, int bb) {}
  void callsite() { func(3); }

this patch provides parameter source range to the diagnostic and makes it look 
like the following

  void func( int aa, int bb) {}
   ^ ~~


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153267

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/Misc/diag-func-call-ranges.c
  clang/test/Misc/diag-func-call-ranges.cpp


Index: clang/test/Misc/diag-func-call-ranges.cpp
===
--- /dev/null
+++ clang/test/Misc/diag-func-call-ranges.cpp
@@ -0,0 +1,14 @@
+// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-print-source-range-info %s 
2>&1 | FileCheck %s --strict-whitespace
+
+// CHECK: error: no matching function for call to 'func'
+
+// CHECK:  :{[[@LINE+1]]:12-[[@LINE+1]]:18}: note: {{.*}} requires single 
argument
+void func( int aa ) {}
+// CHECK:  :{[[@LINE+1]]:12-[[@LINE+3]]:18}: note: {{.*}} requires 3 
arguments
+void func( int aa,
+   int bb,
+   int cc) {}
+
+void arity_mismatch() {
+  (void)func(2, 4);
+}
Index: clang/test/Misc/diag-func-call-ranges.c
===
--- /dev/null
+++ clang/test/Misc/diag-func-call-ranges.c
@@ -0,0 +1,11 @@
+// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-print-source-range-info %s 
2>&1 | FileCheck %s --strict-whitespace
+
+// CHECK:  :{9:10-9:14}: error: too few arguments
+// CHECK:  :{7:12-7:26}: note: 'func' declared here
+// CHECK:  :{10:10-10:14}{10:20-10:24}: error: too many arguments
+// CHECK:  :{7:12-7:26}: note: 'func' declared here
+void func( int aa, int bb) {}
+void arity_mismatch() {
+  (void)(func(3));
+  (void)(func(3, 4,5, 6));
+}
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -11037,11 +11037,13 @@
   if (modeCount == 1 && Fn->getParamDecl(0)->getDeclName())
 S.Diag(Fn->getLocation(), diag::note_ovl_candidate_arity_one)
 << (unsigned)FnKindPair.first << (unsigned)FnKindPair.second
-<< Description << mode << Fn->getParamDecl(0) << NumFormalArgs;
+<< Description << mode << Fn->getParamDecl(0) << NumFormalArgs
+<< Fn->getParametersSourceRange();
   else
 S.Diag(Fn->getLocation(), diag::note_ovl_candidate_arity)
 << (unsigned)FnKindPair.first << (unsigned)FnKindPair.second
-<< Description << mode << modeCount << NumFormalArgs;
+<< Description << mode << modeCount << NumFormalArgs
+<< Fn->getParametersSourceRange();
 
   MaybeEmitInheritedConstructorNote(S, Found);
 }
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6448,7 +6448,8 @@
 
   // Emit the location of the prototype.
   if (!TC && FDecl && !FDecl->getBuiltinID() && !IsExecConfig)
-Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
+Diag(FDecl->getLocation(), diag::note_callee_decl)
+<< FDecl << FDecl->getParametersSourceRange();
 
   return true;
 }
@@ -6493,7 +6494,8 @@
 
   // Emit the location of the prototype.
   if (!TC && FDecl && !FDecl->getBuiltinID() && !IsExecConfig)
-Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
+Diag(FDecl->getLocation(), diag::note_callee_decl)
+<< FDecl << FDecl->getParametersSourceRange();
 
   // This deletes the extra arguments.
   Call->shrinkNumArgs(NumParams);


Index: clang/test/Misc/diag-func-call-ranges.cpp
===
--- /dev/null
+++ clang/test/Misc/diag-func-call-ranges.cpp
@@ -0,0 +1,14 @@
+// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-print-source-range-info %s 2>&1 | FileCheck %s --strict-whitespace
+
+// CHECK: error: no matching function for call to 'func'
+
+// CHECK:  :{[[@LINE+1]]:12-[[@LINE+1]]:18}: note: {{.*}} requires single argument
+void func( int aa ) {}
+// CHECK:  :{[[@LINE+1]]:12-[[@LINE+3]]:18}: note: {{.*}} requires 3 arguments
+void func( int aa,
+   int bb,
+   int cc) {}
+
+void arity_mismatch() {
+  (void)func(2, 4);
+}
Index: clang/test/Misc/diag-func-call-ranges.c
===
--- /dev/null
+++ clang/test/Misc/diag-func-call-ranges.c
@@ -0,0 +1,11 @@
+// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-print-source-range-info %s 2>&1 | FileCheck %s --strict-whitespace
+
+// CHECK:  :{9:10-9:14}: error: too few arguments

[PATCH] D146557: [MLIR][OpenMP] Refactoring createTargetData in OMPIRBuilder

2023-06-19 Thread Akash Banerjee via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa032dc139dda: [MLIR][OpenMP] Refactoring createTargetData in 
OMPIRBuilder (authored by TIFitis).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146557

Files:
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
  mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
  mlir/test/Target/LLVMIR/omptarget-llvm.mlir

Index: mlir/test/Target/LLVMIR/omptarget-llvm.mlir
===
--- mlir/test/Target/LLVMIR/omptarget-llvm.mlir
+++ mlir/test/Target/LLVMIR/omptarget-llvm.mlir
@@ -11,29 +11,28 @@
   llvm.return
 }
 
+// CHECK: @.offload_sizes = private unnamed_addr constant [1 x i64] [i64 4]
 // CHECK: @.offload_maptypes = private unnamed_addr constant [1 x i64] [i64 3]
 // CHECK-LABEL: define void @_QPopenmp_target_data() {
 // CHECK: %[[VAL_0:.*]] = alloca [1 x ptr], align 8
 // CHECK: %[[VAL_1:.*]] = alloca [1 x ptr], align 8
-// CHECK: %[[VAL_2:.*]] = alloca [1 x i64], align 8
+// CHECK: %[[VAL_2:.*]] = alloca [1 x ptr], align 8
 // CHECK: %[[VAL_3:.*]] = alloca i32, i64 1, align 4
 // CHECK: br label %[[VAL_4:.*]]
-// CHECK:   [[VAL_4]]:
-// CHECK: %[[VAL_5:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
-// CHECK: store ptr %[[VAL_3]], ptr %[[VAL_5]], align 8
-// CHECK: %[[VAL_6:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
+// CHECK:   entry:; preds = %[[VAL_5:.*]]
+// CHECK: %[[VAL_6:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
 // CHECK: store ptr %[[VAL_3]], ptr %[[VAL_6]], align 8
-// CHECK: %[[VAL_7:.*]] = getelementptr inbounds [1 x i64], ptr %[[VAL_2]], i32 0, i32 0
-// CHECK: store i64 ptrtoint (ptr getelementptr (ptr, ptr null, i32 1) to i64), ptr %[[VAL_7]], align 4
-// CHECK: %[[VAL_8:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
-// CHECK: %[[VAL_9:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
-// CHECK: %[[VAL_10:.*]] = getelementptr inbounds [1 x i64], ptr %[[VAL_2]], i32 0, i32 0
-// CHECK: call void @__tgt_target_data_begin_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_8]], ptr %[[VAL_9]], ptr %[[VAL_10]], ptr @.offload_maptypes, ptr @.offload_mapnames, ptr null)
+// CHECK: %[[VAL_7:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
+// CHECK: store ptr %[[VAL_3]], ptr %[[VAL_7]], align 8
+// CHECK: %[[VAL_8:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_2]], i64 0, i64 0
+// CHECK: store ptr null, ptr %[[VAL_8]], align 8
+// CHECK: %[[VAL_9:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
+// CHECK: %[[VAL_10:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
+// CHECK: call void @__tgt_target_data_begin_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_9]], ptr %[[VAL_10]], ptr @.offload_sizes, ptr @.offload_maptypes, ptr null, ptr null)
 // CHECK: store i32 99, ptr %[[VAL_3]], align 4
 // CHECK: %[[VAL_11:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
 // CHECK: %[[VAL_12:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
-// CHECK: %[[VAL_13:.*]] = getelementptr inbounds [1 x i64], ptr %[[VAL_2]], i32 0, i32 0
-// CHECK: call void @__tgt_target_data_end_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_11]], ptr %[[VAL_12]], ptr %[[VAL_13]], ptr @.offload_maptypes, ptr @.offload_mapnames, ptr null)
+// CHECK: call void @__tgt_target_data_end_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_11]], ptr %[[VAL_12]], ptr @.offload_sizes, ptr @.offload_maptypes, ptr null, ptr null)
 // CHECK: ret void
 
 // -
@@ -51,35 +50,34 @@
   llvm.return
 }
 
+// CHECK: @.offload_sizes = private unnamed_addr constant [1 x i64] [i64 4096]
 // CHECK: @.offload_maptypes = private unnamed_addr constant [1 x i64] [i64 2]
 // CHECK-LABEL: define void @_QPopenmp_target_data_region
 // CHECK: (ptr %[[ARG_0:.*]]) {
 // CHECK: %[[VAL_0:.*]] = alloca [1 x ptr], align 8
 // CHECK: %[[VAL_1:.*]] = alloca [1 x ptr], align 8
-// CHECK: %[[VAL_2:.*]] = alloca [1 x i64], align 8
+// CHECK: %[[VAL_2:.*]] = alloca [1 x ptr], align 8
 // CHECK: br label %[[VAL_3:.*]]
-// CHECK:   [[VAL_3]]:
-// CHECK: %[[VAL_4:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
-// CHECK: store ptr %[[VAL_5:.*]], ptr %[[VAL_4]], align 8
-// CHECK: %[[VAL_6:.*]] = getelementptr inbounds [1 x 

[PATCH] D138397: HIP: Directly call ldexp builtins

2023-06-19 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

ping


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

https://reviews.llvm.org/D138397

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


[PATCH] D153006: [clang][dataflow] Perform deep copies in copy and move operations.

2023-06-19 Thread Martin Böhme via Phabricator via cfe-commits
mboehme updated this revision to Diff 532604.
mboehme marked an inline comment as done.
mboehme added a comment.

Use `cast_or_null` instead of `cast` in `VisitCXXOperatorCallExpr`. Added a test
that crashes without this change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153006

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/include/clang/Analysis/FlowSensitive/RecordOps.h
  clang/include/clang/Analysis/FlowSensitive/StorageLocation.h
  clang/include/clang/Analysis/FlowSensitive/Value.h
  clang/lib/Analysis/FlowSensitive/CMakeLists.txt
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/RecordOps.cpp
  clang/lib/Analysis/FlowSensitive/Transfer.cpp
  clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
  clang/unittests/Analysis/FlowSensitive/RecordOpsTest.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -12,7 +12,7 @@
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Analysis/FlowSensitive/DataflowAnalysisContext.h"
 #include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"
-#include "clang/Analysis/FlowSensitive/NoopAnalysis.h"
+#include "clang/Analysis/FlowSensitive/RecordOps.h"
 #include "clang/Analysis/FlowSensitive/StorageLocation.h"
 #include "clang/Analysis/FlowSensitive/Value.h"
 #include "clang/Basic/LangStandard.h"
@@ -38,59 +38,22 @@
 using ::testing::NotNull;
 using ::testing::UnorderedElementsAre;
 
-using BuiltinOptions = DataflowAnalysisContext::Options;
-
-template 
-llvm::Error
-runDataflowReturnError(llvm::StringRef Code, Matcher Match,
-   DataflowAnalysisOptions Options,
-   LangStandard::Kind Std = LangStandard::lang_cxx17,
-   llvm::StringRef TargetFun = "target") {
-  using ast_matchers::hasName;
-  llvm::SmallVector ASTBuildArgs = {
-  // -fnodelayed-template-parsing is the default everywhere but on Windows.
-  // Set it explicitly so that tests behave the same on Windows as on other
-  // platforms.
-  "-fsyntax-only", "-fno-delayed-template-parsing",
-  "-std=" +
-  std::string(LangStandard::getLangStandardForKind(Std).getName())};
-  AnalysisInputs AI(
-  Code, hasName(TargetFun),
-  [UseBuiltinModel = Options.BuiltinOpts.has_value()](ASTContext ,
-  Environment ) {
-return NoopAnalysis(
-C,
-DataflowAnalysisOptions{
-UseBuiltinModel ? Env.getDataflowAnalysisContext().getOptions()
-: std::optional()});
-  });
-  AI.ASTBuildArgs = ASTBuildArgs;
-  if (Options.BuiltinOpts)
-AI.BuiltinOptions = *Options.BuiltinOpts;
-  return checkDataflow(
-  std::move(AI),
-  /*VerifyResults=*/
-  [](
-  const llvm::StringMap> ,
-  const AnalysisOutputs ) { Match(Results, AO.ASTCtx); });
-}
-
-template 
-void runDataflow(llvm::StringRef Code, Matcher Match,
+template 
+void runDataflow(llvm::StringRef Code, VerifyResultsT VerifyResults,
  DataflowAnalysisOptions Options,
  LangStandard::Kind Std = LangStandard::lang_cxx17,
  llvm::StringRef TargetFun = "target") {
   ASSERT_THAT_ERROR(
-  runDataflowReturnError(Code, Match, Options, Std, TargetFun),
+  runDataflowReturnError(Code, VerifyResults, Options, Std, TargetFun),
   llvm::Succeeded());
 }
 
-template 
-void runDataflow(llvm::StringRef Code, Matcher Match,
+template 
+void runDataflow(llvm::StringRef Code, VerifyResultsT VerifyResults,
  LangStandard::Kind Std = LangStandard::lang_cxx17,
  bool ApplyBuiltinTransfer = true,
  llvm::StringRef TargetFun = "target") {
-  runDataflow(Code, std::move(Match),
+  runDataflow(Code, std::move(VerifyResults),
   {ApplyBuiltinTransfer ? BuiltinOptions{}
 : std::optional()},
   Std, TargetFun);
@@ -1987,22 +1950,20 @@
 };
 
 void target() {
-  A Foo;
-  A Bar;
-  (void)Foo.Baz;
+  A Foo = { 1 };
+  A Bar = { 2 };
   // [[p1]]
   Foo = Bar;
   // [[p2]]
+  int val = 3;
+  Foo.Baz = val;
+  // [[p3]]
 }
   )";
   runDataflow(
   Code,
   [](const llvm::StringMap> ,
  ASTContext ) {
-ASSERT_THAT(Results.keys(), UnorderedElementsAre("p1", "p2"));
-const Environment  = getEnvironmentAtAnnotation(Results, "p1");
-const Environment  = getEnvironmentAtAnnotation(Results, "p2");
-
 

[PATCH] D85471: Make clang HIP headers compatible with C++98

2023-06-19 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

Can you either

1. Add test coverage
2. Delete this entirely


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85471

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


[PATCH] D85471: Make clang HIP headers compatible with C++98

2023-06-19 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.
Herald added a project: All.

I don't understand why this is necessary. What does cmake have to do with it? 
Is HIP just not defaulting to the correct default C++ standard?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85471

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


  1   2   >