[PATCH] D141754: [5/15][Clang][RISCV][NFC] Remove extra attribute Policy::IntrinsicWithoutMU by reusing HasTailPolicy and HasMaskPolicy

2023-01-16 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng added a comment.

Wait, I fell HasTailPolicy and HasMaskPolicy should be part of Policy object, 
and then it's the Omit to present it's no policy.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141754

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


[PATCH] D141768: [11/15][Clang][RISCV][NFC] Remove Policy::PolicyType::Omit

2023-01-16 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng accepted this revision.
kito-cheng added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: luke.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141768

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


[PATCH] D141803: [Clang] Reject in-class defaulting of previously declared comparison operators

2023-01-16 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu accepted this revision.
ChuanqiXu added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141803

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


[PATCH] D141767: [10/15][Clang][RISCV][NFC] Don't need to check for `MaskPolicy` in `isTAPolicy` and `isTUPolicy`

2023-01-16 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng accepted this revision.
kito-cheng added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: luke.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141767

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


[PATCH] D141764: [9/15][Clang][RISCV][NFC] Use correct type for `RVVTypeCache::computeTypes` under RISCVVEmitter.cpp

2023-01-16 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng accepted this revision.
kito-cheng added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: luke.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141764

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


[PATCH] D71734: [ODRHash] Hash `RecordDecl` and diagnose discovered mismatches.

2023-01-16 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added inline comments.



Comment at: clang/lib/AST/Decl.cpp:4881-4882
+  // For RecordDecl the ODRHash is stored in the remaining 26
+  // bit of RecordDeclBits, adjust the hash to accomodate.
+  setODRHash(Hash.CalculateHash() >> 6);
+  return RecordDeclBits.ODRHash;

I am curious for the operation. It looks dangerous. How can we be sure that the 
hash value is still meaningful after remove its lower 6 bits?



Comment at: clang/lib/AST/ODRDiagsEmitter.cpp:1550-1551
 
+bool ODRDiagsEmitter::diagnoseMismatch(const RecordDecl *FirstRecord,
+   const RecordDecl *SecondRecord) const {
+  if (FirstRecord == SecondRecord)

The implementation of this function looks redundant with other overloads. Of 
course this is not the problem of the patch. I think we can add a FIXME at 
least.



Comment at: clang/lib/AST/ODRHash.cpp:592-593
 
+void ODRHash::AddRecordDecl(const RecordDecl *Record) {
+  AddDecl(Record);
+

For the current implementation, if it makes sense to add an assertion 
`!isa(Record);`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71734

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


[PATCH] D141762: [8/15][Clang][RISCV][NFC] Always emit PolicyAttr in riscv_vector_builtin_cg.inc

2023-01-16 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng accepted this revision.
kito-cheng added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: luke.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141762

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


[PATCH] D141759: [7/15][Clang][RISCV][NFC] Correct the default value for Policy to TAMU

2023-01-16 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng accepted this revision.
kito-cheng added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: luke.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141759

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


[PATCH] D141754: [5/15][Clang][RISCV][NFC] Remove extra attribute Policy::IntrinsicWithoutMU by reusing HasTailPolicy and HasMaskPolicy

2023-01-16 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng added inline comments.
Herald added a subscriber: luke.



Comment at: clang/include/clang/Support/RISCVVIntrinsicUtils.h:388
+   bool HasVL, PolicyScheme Scheme, const bool HasTailPolicy,
+   const bool HasMaskPolicy, bool SupportOverloading,
bool HasBuiltinAlias, llvm::StringRef ManualCodegen,

Drop const for parameter, you don't need const qualifier for those primitive 
types on the parameter list.



Comment at: clang/include/clang/Support/RISCVVIntrinsicUtils.h:470
+   const bool HasTailPolicy,
+   const bool HasMaskPolicy, std::string ,
+   std::string ,

Same here.



Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:151
+RVVTypes , bool HasPolicy, Policy PolicyAttrs,
+const bool HasTailPolicy, const bool HasMaskPolicy);
 

Ditto.



Comment at: clang/lib/Support/RISCVVIntrinsicUtils.cpp:851
+   PolicyScheme Scheme, const bool HasTailPolicy,
+   const bool HasMaskPolicy, bool SupportOverloading,
bool HasBuiltinAlias, StringRef ManualCodegen,

Ditto.



Comment at: clang/lib/Support/RISCVVIntrinsicUtils.cpp:1008
+bool IsMasked, bool HasPolicy, const bool HasTailPolicy,
+const bool HasMaskPolicy, std::string , std::string ,
+std::string , Policy ) {

Ditto.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141754

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


[PATCH] D141756: [6/15][Clang][RISCV][NFC] Instructions with a mask destination register is always tail agnostic

2023-01-16 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng accepted this revision.
kito-cheng added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: luke.

LGTM, the condition of those predictor function more reasonable now


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141756

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


[PATCH] D141886: [Clang][test] Avoid FileCheck error when matching `-cc1`

2023-01-16 Thread hezuoqiang via Phabricator via cfe-commits
hzq marked an inline comment as done.
hzq added a comment.

In D141886#4057549 , @bryanpkc wrote:

> Thanks for the patch. I just have some simple suggestions.

Thanks a lot, modified.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141886

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


[PATCH] D141575: [3/15][Clang][RISCV][NFC] Clarify edge cases of RVVIntrinsic::getSupportedMaskedPolicies for clarity

2023-01-16 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng accepted this revision.
kito-cheng added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: luke.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141575

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


[PATCH] D141886: [Clang][test] Avoid FileCheck error when matching `-cc1`

2023-01-16 Thread hezuoqiang via Phabricator via cfe-commits
hzq updated this revision to Diff 489705.
hzq retitled this revision from "[Clang][Test] Avoid matching version numbers" 
to "[Clang][test] Avoid FileCheck error when matching `-cc1`".
hzq added a comment.

Add `-###` to the command line and update the check content.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141886

Files:
  clang/test/Driver/modules-ts.cpp
  clang/test/Driver/modules.cpp
  clang/test/OpenMP/driver.c


Index: clang/test/OpenMP/driver.c
===
--- clang/test/OpenMP/driver.c
+++ clang/test/OpenMP/driver.c
@@ -3,12 +3,12 @@
 //
 // RUN: %clang %s -### -o %t.o 2>&1 -fopenmp=libomp | FileCheck 
--check-prefix=CHECK-DEFAULT %s
 
-// CHECK-DEFAULT: -cc1
+// CHECK-DEFAULT: "-cc1"
 // CHECK-DEFAULT-NOT: -fnoopenmp-use-tls
 //
 // RUN: %clang %s -### -o %t.o 2>&1 -fopenmp=libomp -fnoopenmp-use-tls | 
FileCheck --check-prefix=CHECK-NO-TLS %s
 
-// CHECK-NO-TLS: -cc1
+// CHECK-NO-TLS: "-cc1"
 // CHECK-NO-TLS-SAME: -fnoopenmp-use-tls
 //
 // RUN: %clang %s -c -E -dM -fopenmp=libomp | FileCheck 
--check-prefix=CHECK-DEFAULT-VERSION %s
Index: clang/test/Driver/modules.cpp
===
--- clang/test/Driver/modules.cpp
+++ clang/test/Driver/modules.cpp
@@ -21,13 +21,13 @@
 
 // Check use of a .pcm file in another compilation.
 //
-// RUN: %clang -std=c++2a -fmodule-file=%t/module.pcm -Dexport= %s -S -o 
%t/module.o -v 2>&1 | FileCheck %s --check-prefix=CHECK-USE
-// RUN: %clang -std=c++20 -fmodule-file=%t/module.pcm -Dexport= %s -S -o 
%t/module.o -v 2>&1 | FileCheck %s --check-prefix=CHECK-USE
+// RUN: %clang -std=c++2a -fmodule-file=%t/module.pcm -Dexport= %s -S -o 
%t/module.o -v -### 2>&1 | FileCheck %s --check-prefix=CHECK-USE
+// RUN: %clang -std=c++20 -fmodule-file=%t/module.pcm -Dexport= %s -S -o 
%t/module.o -v -### 2>&1 | FileCheck %s --check-prefix=CHECK-USE
 //
-// CHECK-USE: -cc1
+// CHECK-USE: "-cc1"
 // CHECK-USE-SAME: {{-emit-obj|-S}}
 // CHECK-USE-SAME: -fmodule-file={{.*}}.pcm
-// CHECK-USE-SAME: -o {{.*}}.{{o|s}}{{"?}} {{.*}}-x c++
+// CHECK-USE-SAME: "-o" {{.*}}.{{o|s}}" {{.*}}-x" "c++"
 // CHECK-USE-SAME: modules.cpp
 
 // Check combining precompile and compile steps works.
Index: clang/test/Driver/modules-ts.cpp
===
--- clang/test/Driver/modules-ts.cpp
+++ clang/test/Driver/modules-ts.cpp
@@ -18,12 +18,12 @@
 
 // Check use of a .pcm file in another compilation.
 //
-// RUN: %clang -fmodules-ts -fmodule-file=%t.pcm -fintegrated-as -Dexport= %s 
-c -o %t.o -v 2>&1 | FileCheck %s --check-prefix=CHECK-USE
+// RUN: %clang -fmodules-ts -fmodule-file=%t.pcm -fintegrated-as -Dexport= %s 
-c -o %t.o -v -### 2>&1 | FileCheck %s --check-prefix=CHECK-USE
 //
-// CHECK-USE: -cc1
+// CHECK-USE: "-cc1"
 // CHECK-USE-SAME: -emit-obj
 // CHECK-USE-SAME: -fmodule-file={{.*}}.pcm
-// CHECK-USE-SAME: -o {{.*}}.o{{"?}} {{.*}}-x c++
+// CHECK-USE-SAME: {{.*}}.o" {{.*}}-x" "c++"
 // CHECK-USE-SAME: modules-ts.cpp
 
 // Check combining precompile and compile steps works.


Index: clang/test/OpenMP/driver.c
===
--- clang/test/OpenMP/driver.c
+++ clang/test/OpenMP/driver.c
@@ -3,12 +3,12 @@
 //
 // RUN: %clang %s -### -o %t.o 2>&1 -fopenmp=libomp | FileCheck --check-prefix=CHECK-DEFAULT %s
 
-// CHECK-DEFAULT: -cc1
+// CHECK-DEFAULT: "-cc1"
 // CHECK-DEFAULT-NOT: -fnoopenmp-use-tls
 //
 // RUN: %clang %s -### -o %t.o 2>&1 -fopenmp=libomp -fnoopenmp-use-tls | FileCheck --check-prefix=CHECK-NO-TLS %s
 
-// CHECK-NO-TLS: -cc1
+// CHECK-NO-TLS: "-cc1"
 // CHECK-NO-TLS-SAME: -fnoopenmp-use-tls
 //
 // RUN: %clang %s -c -E -dM -fopenmp=libomp | FileCheck --check-prefix=CHECK-DEFAULT-VERSION %s
Index: clang/test/Driver/modules.cpp
===
--- clang/test/Driver/modules.cpp
+++ clang/test/Driver/modules.cpp
@@ -21,13 +21,13 @@
 
 // Check use of a .pcm file in another compilation.
 //
-// RUN: %clang -std=c++2a -fmodule-file=%t/module.pcm -Dexport= %s -S -o %t/module.o -v 2>&1 | FileCheck %s --check-prefix=CHECK-USE
-// RUN: %clang -std=c++20 -fmodule-file=%t/module.pcm -Dexport= %s -S -o %t/module.o -v 2>&1 | FileCheck %s --check-prefix=CHECK-USE
+// RUN: %clang -std=c++2a -fmodule-file=%t/module.pcm -Dexport= %s -S -o %t/module.o -v -### 2>&1 | FileCheck %s --check-prefix=CHECK-USE
+// RUN: %clang -std=c++20 -fmodule-file=%t/module.pcm -Dexport= %s -S -o %t/module.o -v -### 2>&1 | FileCheck %s --check-prefix=CHECK-USE
 //
-// CHECK-USE: -cc1
+// CHECK-USE: "-cc1"
 // CHECK-USE-SAME: {{-emit-obj|-S}}
 // CHECK-USE-SAME: -fmodule-file={{.*}}.pcm
-// CHECK-USE-SAME: -o {{.*}}.{{o|s}}{{"?}} {{.*}}-x c++
+// CHECK-USE-SAME: "-o" {{.*}}.{{o|s}}" {{.*}}-x" "c++"
 // CHECK-USE-SAME: modules.cpp
 
 // Check combining precompile and 

[PATCH] D141574: [2/15][Clang][RISCV][NFC] Rename Policy::IsPolicyNone to IsUnspecifed

2023-01-16 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng accepted this revision.
kito-cheng added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: luke.

LGTM, this made the code more expressive.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141574

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


[PATCH] D141892: Implement modernize-use-constraints

2023-01-16 Thread Chris Cotter via Phabricator via cfe-commits
ccotter added a comment.

Overall, we could eventually upgrade code in three stages, each a separate 
reusable check.

1. enable_if -> requires clauses
2. replace the non `_v` templates to the `_v` variants `is_same` -> `is_same_v` 
or the equivalent concept `same_as`
3. replace requires clause on declarations to be template type constraint 
(replace `template  void foo() requires std::same_as void 
foo() {}` to `template  T> void foo() {}`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141892

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


[PATCH] D141892: Implement modernize-use-constraints

2023-01-16 Thread Chris Cotter via Phabricator via cfe-commits
ccotter added a comment.

For the sake of demonstration, 
https://github.com/llvm/llvm-project/commit/9c556ce59edf5a4293d4497d5815544afc0eb878
 is the result of running this tool on all headers under clang/include/clang 
and llvm/include/llvm.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141892

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


[PATCH] D141892: Implement modernize-use-constraints

2023-01-16 Thread Chris Cotter via Phabricator via cfe-commits
ccotter created this revision.
Herald added a subscriber: carlosgalvezp.
Herald added a reviewer: njames93.
Herald added a project: All.
ccotter requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Add new check to replace enable_if with C++20 constraints


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141892

Files:
  clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
  clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize/use-constraints.rst
  
clang-tools-extra/test/clang-tidy/checkers/modernize/use-constraints-first-greatergreater.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize/use-constraints.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize/use-constraints.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/modernize/use-constraints.cpp
@@ -0,0 +1,693 @@
+// RUN: %check_clang_tidy -std=c++20 %s modernize-use-constraints %t
+
+// NOLINTBEGIN
+namespace std {
+template  struct enable_if { };
+
+template  struct enable_if { typedef T type; };
+
+template 
+using enable_if_t = typename enable_if::type;
+
+} // namespace std
+// NOLINTEND
+
+template 
+struct ConsumeVariadic;
+
+struct Obj {
+};
+
+namespace enable_if_in_return_type {
+
+
+// Section 1: enable_if in return type of function
+
+
+
+// General tests
+
+
+template 
+typename std::enable_if::type basic() {
+  return Obj{};
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}Obj basic() requires T::some_value {{{$}}
+
+template 
+std::enable_if_t basic_t() {
+  return Obj{};
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}Obj basic_t() requires T::some_value {{{$}}
+
+template 
+auto basic_trailing() -> typename std::enable_if::type {
+  return Obj{};
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:26: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}auto basic_trailing() -> Obj requires T::some_value {{{$}}
+
+template 
+typename std::enable_if::type existing_constraint() requires (T::another_value) {
+  return Obj{};
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}typename std::enable_if::type existing_constraint() requires (T::another_value) {{{$}}
+
+template 
+typename std::enable_if::type decl_without_def();
+
+template 
+typename std::enable_if::type decl_with_separate_def();
+
+template 
+typename std::enable_if::type decl_with_separate_def() {
+  return Obj{};
+}
+// FIXME - Support definitions with separate decls
+
+template 
+std::enable_if_t no_dependent_type(U) {
+  return Obj{};
+}
+// FIXME - Support non-dependent enable_ifs. Low priority though...
+
+template 
+typename std::enable_if::type* pointer_of_enable_if() {
+  return nullptr;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}template {{$}}
+// CHECK-FIXES-NEXT: {{^}}int* pointer_of_enable_if() requires T::some_value {{{$}}
+
+template 
+std::enable_if_t* pointer_of_enable_if_t() {
+  return nullptr;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}template {{$}}
+// CHECK-FIXES-NEXT: {{^}}int* pointer_of_enable_if_t() requires T::some_value {{{$}}
+
+template 
+const std::enable_if_t* const_pointer_of_enable_if_t() {
+  return nullptr;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:7: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}template {{$}}
+// CHECK-FIXES-NEXT: {{^}}const int* const_pointer_of_enable_if_t() requires T::some_value {{{$}}
+
+template 
+std::enable_if_t const * const_pointer_of_enable_if_t2() {
+  return nullptr;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}template {{$}}
+// CHECK-FIXES-NEXT: {{^}}int const * const_pointer_of_enable_if_t2() requires T::some_value {{{$}}
+
+
+template 
+std::enable_if_t& reference_of_enable_if_t() {
+  static int x; return x;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: use C++20 requires constraints instead of enable_if 

Re: [clang] 931d04b - [ADT] Make StringRef::compare like std::string_view::compare

2023-01-16 Thread David Blaikie via cfe-commits
Nice!

On Sun, Jan 15, 2023 at 12:10 PM Benjamin Kramer via cfe-commits
 wrote:
>
>
> Author: Benjamin Kramer
> Date: 2023-01-15T20:59:21+01:00
> New Revision: 931d04be2fc8f3f0505b43e64297f75d526cb42a
>
> URL: 
> https://github.com/llvm/llvm-project/commit/931d04be2fc8f3f0505b43e64297f75d526cb42a
> DIFF: 
> https://github.com/llvm/llvm-project/commit/931d04be2fc8f3f0505b43e64297f75d526cb42a.diff
>
> LOG: [ADT] Make StringRef::compare like std::string_view::compare
>
> string_view has a slightly weaker contract, which only specifies whether
> the value is bigger or smaller than 0. Adapt users accordingly and just
> forward to the standard function (that also compiles down to memcmp)
>
> Added:
>
>
> Modified:
> clang/lib/AST/DeclarationName.cpp
> clang/lib/Analysis/PathDiagnostic.cpp
> clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
> clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
> lld/COFF/Writer.cpp
> llvm/include/llvm/ADT/SmallString.h
> llvm/include/llvm/ADT/StringRef.h
> llvm/include/llvm/ProfileData/SampleProf.h
> llvm/lib/Transforms/IPO/MergeFunctions.cpp
> llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
> llvm/unittests/ADT/SmallStringTest.cpp
> llvm/unittests/ADT/StringRefTest.cpp
>
> Removed:
>
>
>
> 
> diff  --git a/clang/lib/AST/DeclarationName.cpp 
> b/clang/lib/AST/DeclarationName.cpp
> index b2232ddfced32..c1219041a466b 100644
> --- a/clang/lib/AST/DeclarationName.cpp
> +++ b/clang/lib/AST/DeclarationName.cpp
> @@ -72,15 +72,9 @@ int DeclarationName::compare(DeclarationName LHS, 
> DeclarationName RHS) {
>  }
>  unsigned LN = LHSSelector.getNumArgs(), RN = RHSSelector.getNumArgs();
>  for (unsigned I = 0, N = std::min(LN, RN); I != N; ++I) {
> -  switch (LHSSelector.getNameForSlot(I).compare(
> -  RHSSelector.getNameForSlot(I))) {
> -  case -1:
> -return -1;
> -  case 1:
> -return 1;
> -  default:
> -break;
> -  }
> +  if (int Compare = LHSSelector.getNameForSlot(I).compare(
> +  RHSSelector.getNameForSlot(I)))
> +return Compare;
>  }
>
>  return compareInt(LN, RN);
>
> diff  --git a/clang/lib/Analysis/PathDiagnostic.cpp 
> b/clang/lib/Analysis/PathDiagnostic.cpp
> index 9e1215fe3d01d..ac1306fd80711 100644
> --- a/clang/lib/Analysis/PathDiagnostic.cpp
> +++ b/clang/lib/Analysis/PathDiagnostic.cpp
> @@ -342,7 +342,7 @@ static bool compareCrossTUSourceLocs(FullSourceLoc XL, 
> FullSourceLoc YL) {
>  return XFE && !YFE;
>int NameCmp = XFE->getName().compare(YFE->getName());
>if (NameCmp != 0)
> -return NameCmp == -1;
> +return NameCmp < 0;
>// Last resort: Compare raw file IDs that are possibly expansions.
>return XL.getFileID() < YL.getFileID();
>  }
>
> diff  --git a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp 
> b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
> index b38d18d3691d9..12b948a65261f 100644
> --- a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
> +++ b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
> @@ -2146,7 +2146,7 @@ void CStringChecker::evalStrcmpCommon(CheckerContext 
> , const CallExpr *CE,
>  DefinedSVal zeroVal = svalBuilder.makeIntVal(0, CE->getType());
>  // Constrain strcmp's result range based on the result of StringRef's
>  // comparison methods.
> -BinaryOperatorKind op = (compareRes == 1) ? BO_GT : BO_LT;
> +BinaryOperatorKind op = (compareRes > 0) ? BO_GT : BO_LT;
>  SVal compareWithZero =
>svalBuilder.evalBinOp(state, op, resultVal, zeroVal,
>svalBuilder.getConditionType());
>
> diff  --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp 
> b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
> index 1fb4c83052c4a..1daa58f20fd5b 100644
> --- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
> +++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
> @@ -1272,8 +1272,8 @@ linkAndWrapDeviceFiles(SmallVectorImpl 
> ,
>  // We sort the entries before bundling so they appear in a deterministic
>  // order in the final binary.
>  llvm::sort(Input, [](OffloadingImage , OffloadingImage ) {
> -  return A.StringData["triple"].compare(B.StringData["triple"]) == 1 ||
> - A.StringData["arch"].compare(B.StringData["arch"]) == 1 ||
> +  return A.StringData["triple"] > B.StringData["triple"] ||
> + A.StringData["arch"] > B.StringData["arch"] ||
>   A.TheOffloadKind < B.TheOffloadKind;
>  });
>  auto BundledImagesOrErr = bundleLinkedOutput(Input, Args, Kind);
>
> diff  --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp
> index 09cca5667a470..b02ad01bdef74 100644
> --- a/lld/COFF/Writer.cpp
> +++ b/lld/COFF/Writer.cpp
> @@ -188,7 +188,7 @@ class PartialSectionKey {
>
>bool operator<(const PartialSectionKey ) const {
> 

[PATCH] D71734: [ODRHash] Hash `RecordDecl` and diagnose discovered mismatches.

2023-01-16 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Ping. Also checked the change on a bunch of internal Objective-C/C code using 
modules - no new errors.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71734

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


[PATCH] D140874: [clang][Interp] Support pointer types in compound assignment operations

2023-01-16 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 489694.
tbaeder marked an inline comment as done.

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

https://reviews.llvm.org/D140874

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeExprGen.h
  clang/test/AST/Interp/literals.cpp

Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -669,6 +669,44 @@
   // expected-note {{in call to 'IntMul}} \
   // ref-error {{not an integral constant expression}} \
   // ref-note {{in call to 'IntMul}}
+
+  constexpr int arr[] = {1,2,3};
+  constexpr int ptrInc1() {
+const int *p = arr;
+p += 2;
+return *p;
+  }
+  static_assert(ptrInc1() == 3, "");
+
+  constexpr int ptrInc2() {
+const int *p = arr;
+return *(p += 1);
+  }
+  static_assert(ptrInc2() == 2, "");
+
+  constexpr int ptrInc3() { // expected-error {{never produces a constant expression}} \
+// ref-error {{never produces a constant expression}}
+const int *p = arr;
+p += 12; // expected-note {{cannot refer to element 12 of array of 3 elements}} \
+ // ref-note {{cannot refer to element 12 of array of 3 elements}}
+return *p;
+  }
+
+  constexpr int ptrIncDec1() {
+const int *p = arr;
+p += 2;
+p -= 1;
+return *p;
+  }
+  static_assert(ptrIncDec1() == 2, "");
+
+  constexpr int ptrDec1() { // expected-error {{never produces a constant expression}} \
+// ref-error {{never produces a constant expression}}
+const int *p = arr;
+p -= 1;  // expected-note {{cannot refer to element -1 of array of 3 elements}} \
+ // ref-note {{cannot refer to element -1 of array of 3 elements}}
+return *p;
+  }
 };
 #endif
 
Index: clang/lib/AST/Interp/ByteCodeExprGen.h
===
--- clang/lib/AST/Interp/ByteCodeExprGen.h
+++ clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -87,6 +87,7 @@
   bool VisitCharacterLiteral(const CharacterLiteral *E);
   bool VisitCompoundAssignOperator(const CompoundAssignOperator *E);
   bool VisitFloatCompoundAssignOperator(const CompoundAssignOperator *E);
+  bool VisitPointerCompoundAssignOperator(const CompoundAssignOperator *E);
   bool VisitExprWithCleanups(const ExprWithCleanups *E);
   bool VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *E);
   bool VisitCompoundLiteralExpr(const CompoundLiteralExpr *E);
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -698,6 +698,40 @@
   return this->emitStore(*LT, E);
 }
 
+template 
+bool ByteCodeExprGen::VisitPointerCompoundAssignOperator(
+const CompoundAssignOperator *E) {
+  BinaryOperatorKind Op = E->getOpcode();
+  const Expr *LHS = E->getLHS();
+  const Expr *RHS = E->getRHS();
+  std::optional LT = classify(LHS->getType());
+  std::optional RT = classify(RHS->getType());
+
+  if (!LT || !RT)
+return false;
+  assert(*LT == PT_Ptr);
+
+  if (!visit(LHS))
+return false;
+
+  if (!this->emitLoadPtr(LHS))
+return false;
+
+  if (!visit(RHS))
+return false;
+
+  if (Op == BO_AddAssign)
+this->emitAddOffset(*RT, E);
+  else if (Op == BO_SubAssign)
+this->emitSubOffset(*RT, E);
+  else
+return false;
+
+  if (DiscardResult)
+return this->emitStorePopPtr(E);
+  return this->emitStorePtr(E);
+}
+
 template 
 bool ByteCodeExprGen::VisitCompoundAssignOperator(
 const CompoundAssignOperator *E) {
@@ -707,6 +741,9 @@
   if (E->getType()->isFloatingType())
 return VisitFloatCompoundAssignOperator(E);
 
+  if (E->getType()->isPointerType())
+return VisitPointerCompoundAssignOperator(E);
+
   const Expr *LHS = E->getLHS();
   const Expr *RHS = E->getRHS();
   std::optional LT = classify(E->getComputationLHSType());
@@ -715,9 +752,7 @@
   if (!LT || !RT)
 return false;
 
-  assert(!E->getType()->isPointerType() &&
- "Support pointer arithmethic in compound assignment operators");
-
+  assert(!E->getType()->isPointerType() && "Handled above");
   assert(!E->getType()->isFloatingType() && "Handled above");
 
   // Get LHS pointer, load its value and get RHS value.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D135750: [clang][Interp] Track initialization state of local variables

2023-01-16 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 489693.

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

https://reviews.llvm.org/D135750

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeStmtGen.cpp
  clang/lib/AST/Interp/Context.cpp
  clang/lib/AST/Interp/Descriptor.cpp
  clang/lib/AST/Interp/Descriptor.h
  clang/lib/AST/Interp/EvalEmitter.cpp
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/InterpBlock.h
  clang/lib/AST/Interp/InterpFrame.cpp
  clang/lib/AST/Interp/InterpFrame.h
  clang/lib/AST/Interp/Pointer.cpp
  clang/lib/AST/Interp/Pointer.h
  clang/lib/AST/Interp/Program.cpp
  clang/lib/AST/Interp/Program.h
  clang/test/AST/Interp/cxx20.cpp
  clang/test/AST/Interp/literals.cpp
  clang/test/AST/Interp/loops.cpp

Index: clang/test/AST/Interp/loops.cpp
===
--- clang/test/AST/Interp/loops.cpp
+++ clang/test/AST/Interp/loops.cpp
@@ -5,6 +5,7 @@
 
 // ref-no-diagnostics
 // expected-no-diagnostics
+// expected-cpp20-no-diagnostics
 
 namespace WhileLoop {
   constexpr int f() {
@@ -165,8 +166,6 @@
   static_assert(f5(true) == 8, "");
   static_assert(f5(false) == 5, "");
 
-  /// FIXME: This should be accepted in C++20 but is currently being rejected
-  ///   because the variable declaration doesn't have an initializier.
 #if __cplusplus >= 202002L
   constexpr int f6() {
 int i;
@@ -176,7 +175,7 @@
 } while (true);
 return i;
   }
-  static_assert(f6() == 5, ""); // expected-cpp20-error {{not an integral constant}}
+  static_assert(f6() == 5, "");
 #endif
 
 #if 0
Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -407,8 +407,7 @@
 return 1;
   }
   static_assert(uninit(), ""); // ref-error {{not an integral constant expression}} \
-   // ref-note {{in call to 'uninit()'}} \
-   // expected-error {{not an integral constant expression}}
+   // ref-note {{in call to 'uninit()'}}
 
   constexpr int OverFlow() { // ref-error {{never produces a constant expression}}
 int a = INT_MAX;
Index: clang/test/AST/Interp/cxx20.cpp
===
--- clang/test/AST/Interp/cxx20.cpp
+++ clang/test/AST/Interp/cxx20.cpp
@@ -56,33 +56,51 @@
 }
 static_assert(pointerAssign2() == 12, "");
 
-
 constexpr int unInitLocal() {
   int a;
-  return a; // ref-note{{read of uninitialized object}}
+  return a; // ref-note {{read of uninitialized object}} \
+// expected-note {{read of object outside its lifetime}}
+// FIXME: ^^^ Wrong diagnostic.
 }
-static_assert(unInitLocal() == 0, ""); // expected-error {{not an integral constant expression}} \
-   // ref-error {{not an integral constant expression}} \
-   // ref-note {{in call to 'unInitLocal()'}}
-
-/// TODO: The example above is correctly rejected by the new constexpr
-///   interpreter, but for the wrong reasons. We don't reject it because
-///   it is an uninitialized read, we reject it simply because
-///   the local variable does not have an initializer.
-///
-///   The code below should be accepted but is also being rejected
-///   right now.
-#if 0
+static_assert(unInitLocal() == 0, ""); // ref-error {{not an integral constant expression}} \
+   // ref-note {{in call to 'unInitLocal()'}} \
+   // expected-error {{not an integral constant expression}} \
+   // expected-note {{in call to 'unInitLocal()'}} \
+
 constexpr int initializedLocal() {
   int a;
-  int b;
-
   a = 20;
   return a;
 }
 static_assert(initializedLocal() == 20);
 
-/// Similar here, but the uninitialized local is passed as a function parameter.
+constexpr int initializedLocal2() {
+  int a[2];
+  return *a; // expected-note {{read of object outside its lifetime}} \
+ // ref-note {{read of uninitialized object is not allowed in a constant expression}}
+}
+static_assert(initializedLocal2() == 20); // expected-error {{not an integral constant expression}} \
+  // expected-note {{in call to}} \
+  // ref-error {{not an integral constant expression}} \
+  // ref-note {{in call to}}
+
+
+struct Int { int a; };
+constexpr int initializedLocal3() {
+  Int i;
+  return i.a; // expected-note {{read of object outside its lifetime}} \
+  // ref-note {{read of uninitialized object is not allowed in a constant expression}}
+}
+static_assert(initializedLocal3() == 20); // expected-error {{not an integral constant expression}} \
+  // 

[PATCH] D138546: Clangd: Preserve target flags in system includes extractor

2023-01-16 Thread Christopher Sauer via Phabricator via cfe-commits
cpsauer added a comment.

(If anyone knows what's going on with the (unrelated seeming?) testing timeouts 
please do say.)


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

https://reviews.llvm.org/D138546

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


[PATCH] D141886: [Clang][Test] Avoid matching version numbers

2023-01-16 Thread Bryan Chan via Phabricator via cfe-commits
bryanpkc added a comment.

Thanks for the patch. I just have some simple suggestions.




Comment at: clang/test/Driver/modules-ts.cpp:23
 //
-// CHECK-USE: -cc1
+// CHECK-USE: -cc1{{[^[:xdigit:]]}}
 // CHECK-USE-SAME: -emit-obj

An easier-to-understand fix is to simply combine this line and the next:
```
// CHECK-USE: -cc1 {{.*}} -emit-obj
```



Comment at: clang/test/OpenMP/driver.c:6
 
-// CHECK-DEFAULT: -cc1
+// CHECK-DEFAULT: -cc1{{[^[:xdigit:]]}}
 // CHECK-DEFAULT-NOT: -fnoopenmp-use-tls

With `-###` on the command line, a better fix for this is:
```
// CHECK-DEFAULT: "-cc1"
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141886

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


[PATCH] D131938: [C++20] [Coroutines] Disable to take the address of labels in coroutines

2023-01-16 Thread Chuanqi Xu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcc526e346deb: [C++20] [Coroutines] Disable to take the 
address of labels in coroutines (authored by ChuanqiXu).

Changed prior to commit:
  https://reviews.llvm.org/D131938?vs=452925=489677#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131938

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/ScopeInfo.h
  clang/lib/Sema/ScopeInfo.cpp
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/addr-label-in-coroutines.cpp

Index: clang/test/SemaCXX/addr-label-in-coroutines.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/addr-label-in-coroutines.cpp
@@ -0,0 +1,70 @@
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
+
+#include "Inputs/std-coroutine.h"
+
+struct resumable {
+  struct promise_type {
+resumable get_return_object() { return {}; }
+auto initial_suspend() { return std::suspend_always(); }
+auto final_suspend() noexcept { return std::suspend_always(); }
+void unhandled_exception() {}
+void return_void(){};
+  };
+};
+
+resumable f1(int , int *inst) {
+static void* dispatch_table[] = {&,  // expected-error {{the GNU address of label extension is not allowed in coroutines.}}
+ &,  // expected-error {{the GNU address of label extension is not allowed in coroutines.}}
+ &};// expected-error {{the GNU address of label extension is not allowed in coroutines.}}
+#define DISPATCH() goto *dispatch_table[*inst++]
+inc:
+out++;
+DISPATCH();
+
+suspend:
+co_await std::suspend_always{};
+DISPATCH();
+
+stop:
+co_return;
+}
+
+resumable f2(int , int *inst) {
+void* dispatch_table[] = {nullptr, nullptr, nullptr};
+dispatch_table[0] = &  // expected-error {{the GNU address of label extension is not allowed in coroutines.}}
+dispatch_table[1] = &  // expected-error {{the GNU address of label extension is not allowed in coroutines.}}
+dispatch_table[2] = & // expected-error {{the GNU address of label extension is not allowed in coroutines.}}
+#define DISPATCH() goto *dispatch_table[*inst++]
+inc:
+out++;
+DISPATCH();
+
+suspend:
+co_await std::suspend_always{};
+DISPATCH();
+
+stop:
+co_return;
+}
+
+resumable f3(int , int *inst) {
+void* dispatch_table[] = {nullptr, nullptr, nullptr};
+[&]() -> resumable {
+dispatch_table[0] = &  // expected-error {{the GNU address of label extension is not allowed in coroutines.}}
+dispatch_table[1] = &  // expected-error {{the GNU address of label extension is not allowed in coroutines.}}
+dispatch_table[2] = & // expected-error {{the GNU address of label extension is not allowed in coroutines.}}
+#define DISPATCH() goto *dispatch_table[*inst++]
+inc:
+out++;
+DISPATCH();
+
+suspend:
+co_await std::suspend_always{};
+DISPATCH();
+
+stop:
+co_return;
+}();
+
+co_return;
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -16105,8 +16105,13 @@
 LabelDecl *TheDecl) {
   TheDecl->markUsed(Context);
   // Create the AST node.  The address of a label always has type 'void*'.
-  return new (Context) AddrLabelExpr(OpLoc, LabLoc, TheDecl,
- Context.getPointerType(Context.VoidTy));
+  auto *Res = new (Context) AddrLabelExpr(
+  OpLoc, LabLoc, TheDecl, Context.getPointerType(Context.VoidTy));
+
+  if (getCurFunction())
+getCurFunction()->AddrLabels.push_back(Res);
+
+  return Res;
 }
 
 void Sema::ActOnStartStmtExpr() {
Index: clang/lib/Sema/SemaCoroutine.cpp
===
--- clang/lib/Sema/SemaCoroutine.cpp
+++ clang/lib/Sema/SemaCoroutine.cpp
@@ -1125,6 +1125,12 @@
 Diag(Fn->FirstCoroutineStmtLoc, diag::note_declared_coroutine_here)
 << Fn->getFirstCoroutineStmtKeyword();
   }
+
+  // Coroutines will get splitted into pieces. The GNU address of label
+  // extension wouldn't be meaningful in coroutines.
+  for (AddrLabelExpr *ALE : Fn->AddrLabels)
+Diag(ALE->getBeginLoc(), diag::err_coro_invalid_addr_of_label);
+
   CoroutineStmtBuilder Builder(*this, *FD, *Fn, Body);
   if (Builder.isInvalid() || !Builder.buildStatements())
 return FD->setInvalidDecl();
Index: clang/lib/Sema/ScopeInfo.cpp
===
--- clang/lib/Sema/ScopeInfo.cpp
+++ clang/lib/Sema/ScopeInfo.cpp
@@ -56,6 +56,7 @@
   ModifiedNonNullParams.clear();
   Blocks.clear();
   

[clang] cc526e3 - [C++20] [Coroutines] Disable to take the address of labels in coroutines

2023-01-16 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2023-01-17T11:35:32+08:00
New Revision: cc526e346debbaf1d2d32a59230288a4e98294c7

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

LOG: [C++20] [Coroutines] Disable to take the address of labels in coroutines

Closing https://github.com/llvm/llvm-project/issues/56436

We can't support the GNU address of label extension in coroutines well
in current architecture. Since the coroutines are going to split into
pieces in the middle end so the address of labels are ambiguous that
time.

To avoid any further misunderstanding, we try to emit an error here.

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

Added: 
clang/test/SemaCXX/addr-label-in-coroutines.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/ScopeInfo.h
clang/lib/Sema/ScopeInfo.cpp
clang/lib/Sema/SemaCoroutine.cpp
clang/lib/Sema/SemaExpr.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3bbab951e8a8c..de038fe2d13ec 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -452,6 +452,8 @@ Improvements to Clang's diagnostics
 - Add ``-Wreturn-local-addr``, a GCC alias for ``-Wreturn-stack-address``.
 - Clang now suppresses ``-Wlogical-op-parentheses`` on ``(x && a || b)`` and 
``(a || b && x)``
   only when ``x`` is a string literal.
+- Clang will now reject the GNU extension address of label in coroutines 
explicitly.
+  This fixes `Issue 56436 
`_.
 
 Non-comprehensive list of changes in this release
 -

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 02afb098b2395..50050e1885ae8 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11360,6 +11360,9 @@ def warn_non_aligned_allocation_function : Warning <
 def err_conflicting_aligned_options : Error <
   "conflicting option '-fcoro-aligned-allocation' and 
'-fno-aligned-allocation'"
 >;
+def err_coro_invalid_addr_of_label : Error<
+  "the GNU address of label extension is not allowed in coroutines."
+>;
 } // end of coroutines issue category
 
 let CategoryName = "Documentation Issue" in {

diff  --git a/clang/include/clang/Sema/ScopeInfo.h 
b/clang/include/clang/Sema/ScopeInfo.h
index 363fbf454879d..65fa18fbb2903 100644
--- a/clang/include/clang/Sema/ScopeInfo.h
+++ b/clang/include/clang/Sema/ScopeInfo.h
@@ -233,6 +233,9 @@ class FunctionScopeInfo {
   /// modified in the function.
   llvm::SmallPtrSet ModifiedNonNullParams;
 
+  /// The set of GNU address of label extension "&".
+  llvm::SmallVector AddrLabels;
+
 public:
   /// Represents a simple identification of a weak object.
   ///

diff  --git a/clang/lib/Sema/ScopeInfo.cpp b/clang/lib/Sema/ScopeInfo.cpp
index f4dda9f194e78..e313052b3ab38 100644
--- a/clang/lib/Sema/ScopeInfo.cpp
+++ b/clang/lib/Sema/ScopeInfo.cpp
@@ -56,6 +56,7 @@ void FunctionScopeInfo::Clear() {
   ModifiedNonNullParams.clear();
   Blocks.clear();
   ByrefBlockVars.clear();
+  AddrLabels.clear();
 }
 
 static const NamedDecl *getBestPropertyDecl(const ObjCPropertyRefExpr *PropE) {

diff  --git a/clang/lib/Sema/SemaCoroutine.cpp 
b/clang/lib/Sema/SemaCoroutine.cpp
index 4cedd53a76785..79c08adb8fabc 100644
--- a/clang/lib/Sema/SemaCoroutine.cpp
+++ b/clang/lib/Sema/SemaCoroutine.cpp
@@ -1125,6 +1125,12 @@ void Sema::CheckCompletedCoroutineBody(FunctionDecl *FD, 
Stmt *) {
 Diag(Fn->FirstCoroutineStmtLoc, diag::note_declared_coroutine_here)
 << Fn->getFirstCoroutineStmtKeyword();
   }
+
+  // Coroutines will get splitted into pieces. The GNU address of label
+  // extension wouldn't be meaningful in coroutines.
+  for (AddrLabelExpr *ALE : Fn->AddrLabels)
+Diag(ALE->getBeginLoc(), diag::err_coro_invalid_addr_of_label);
+
   CoroutineStmtBuilder Builder(*this, *FD, *Fn, Body);
   if (Builder.isInvalid() || !Builder.buildStatements())
 return FD->setInvalidDecl();

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index d90c28432a6b6..be3a6bd321edc 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -16105,8 +16105,13 @@ ExprResult Sema::ActOnAddrLabel(SourceLocation OpLoc, 
SourceLocation LabLoc,
 LabelDecl *TheDecl) {
   TheDecl->markUsed(Context);
   // Create the AST node.  The address of a label always has type 'void*'.
-  return new (Context) AddrLabelExpr(OpLoc, LabLoc, TheDecl,
- Context.getPointerType(Context.VoidTy));
+  auto *Res = new (Context) AddrLabelExpr(
+  OpLoc, 

[PATCH] D141873: [Clang][OpenMP] Fix the issue that a functor is not captured properly in a task region

2023-01-16 Thread Shilei Tian 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 rGae53c7f4a211: [Clang][OpenMP] Fix the issue that a functor 
is not captured properly in a task… (authored by tianshilei1992).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141873

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/bug57757.cpp


Index: clang/test/OpenMP/bug57757.cpp
===
--- /dev/null
+++ clang/test/OpenMP/bug57757.cpp
@@ -0,0 +1,56 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --include-generated-funcs 
--prefix-filecheck-ir-name _
+// RUN: %clang_cc1 -fopenmp -O1 -x c++ -triple x86_64-apple-darwin10 
-emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK
+
+template 
+void run_task(Function function, Args... args) {
+#pragma omp task untied
+  { function(args...); }
+}
+
+void bar(int a, float b);
+
+void foo() {
+  int a;
+  float b;
+  run_task(bar, a, b);
+}
+// CHECK-LABEL: define {{[^@]+}}@_Z3foov
+// CHECK-SAME: () local_unnamed_addr #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call i32 @__kmpc_global_thread_num(ptr 
nonnull @[[GLOB1:[0-9]+]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call ptr @__kmpc_omp_task_alloc(ptr 
nonnull @[[GLOB1]], i32 [[TMP0]], i32 0, i64 56, i64 1, ptr nonnull 
@.omp_task_entry.)
+// CHECK-NEXT:[[TMP2:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_T_WITH_PRIVATES:%.*]], ptr [[TMP1]], i64 0, i32 1
+// CHECK-NEXT:store ptr @_Z3barif, ptr [[TMP2]], align 8, !tbaa 
[[TBAA3:![0-9]+]]
+// CHECK-NEXT:[[TMP3:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_T:%.*]], ptr [[TMP1]], i64 0, i32 2
+// CHECK-NEXT:store i32 0, ptr [[TMP3]], align 8, !tbaa [[TBAA12:![0-9]+]]
+// CHECK-NEXT:[[TMP4:%.*]] = tail call i32 @__kmpc_omp_task(ptr nonnull 
@[[GLOB1]], i32 [[TMP0]], ptr [[TMP1]])
+// CHECK-NEXT:ret void
+//
+//
+// CHECK-LABEL: define {{[^@]+}}@.omp_task_entry.
+// CHECK-SAME: (i32 noundef [[TMP0:%.*]], ptr noalias noundef [[TMP1:%.*]]) 
#[[ATTR3:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP2:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_T:%.*]], ptr [[TMP1]], i64 0, i32 2
+// CHECK-NEXT:tail call void 
@llvm.experimental.noalias.scope.decl(metadata [[META13:![0-9]+]])
+// CHECK-NEXT:tail call void 
@llvm.experimental.noalias.scope.decl(metadata [[META16:![0-9]+]])
+// CHECK-NEXT:[[TMP3:%.*]] = load i32, ptr [[TMP2]], align 4, !tbaa 
[[TBAA18:![0-9]+]], !alias.scope !13, !noalias !16
+// CHECK-NEXT:switch i32 [[TMP3]], label [[DOTOMP_OUTLINED__EXIT:%.*]] [
+// CHECK-NEXT:i32 0, label [[DOTUNTIED_JMP__I:%.*]]
+// CHECK-NEXT:i32 1, label [[DOTUNTIED_NEXT__I:%.*]]
+// CHECK-NEXT:]
+// CHECK:   .untied.jmp..i:
+// CHECK-NEXT:store i32 1, ptr [[TMP2]], align 4, !tbaa [[TBAA18]], 
!alias.scope !13, !noalias !16
+// CHECK-NEXT:[[TMP4:%.*]] = tail call i32 @__kmpc_omp_task(ptr nonnull 
@[[GLOB1]], i32 [[TMP0]], ptr [[TMP1]]), !noalias !19
+// CHECK-NEXT:br label [[DOTOMP_OUTLINED__EXIT]]
+// CHECK:   .untied.next..i:
+// CHECK-NEXT:[[TMP5:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_T_WITH_PRIVATES:%.*]], ptr [[TMP1]], i64 0, i32 1
+// CHECK-NEXT:[[TMP6:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_T_WITH_PRIVATES]], ptr [[TMP1]], i64 0, i32 1, i32 2
+// CHECK-NEXT:[[TMP7:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_T_WITH_PRIVATES]], ptr [[TMP1]], i64 0, i32 1, i32 1
+// CHECK-NEXT:[[TMP8:%.*]] = load ptr, ptr [[TMP5]], align 8, !tbaa 
[[TBAA20:![0-9]+]], !alias.scope !16, !noalias !13
+// CHECK-NEXT:[[TMP9:%.*]] = load i32, ptr [[TMP7]], align 4, !tbaa 
[[TBAA18]], !alias.scope !16, !noalias !13
+// CHECK-NEXT:[[TMP10:%.*]] = load float, ptr [[TMP6]], align 4, !tbaa 
[[TBAA21:![0-9]+]], !alias.scope !16, !noalias !13
+// CHECK-NEXT:tail call void [[TMP8]](i32 noundef [[TMP9]], float noundef 
[[TMP10]]) #[[ATTR2:[0-9]+]], !noalias !19
+// CHECK-NEXT:br label [[DOTOMP_OUTLINED__EXIT]]
+// CHECK:   .omp_outlined..exit:
+// CHECK-NEXT:ret i32 0
+//
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -4067,9 +4067,13 @@
 Visit(C);
   }
 }
-if (Expr *Callee = S->getCallee())
-  if (auto *CE = dyn_cast(Callee->IgnoreParenImpCasts()))
+if (Expr *Callee = S->getCallee()) {
+  auto *CI = Callee->IgnoreParenImpCasts();
+  if (auto *CE = dyn_cast(CI))
 Visit(CE->getBase());
+  else if (auto *CE = dyn_cast(CI))
+Visit(CE);
+}
   }
   void VisitStmt(Stmt *S) {
 for (Stmt *C : S->children()) {


Index: clang/test/OpenMP/bug57757.cpp

[clang] ae53c7f - [Clang][OpenMP] Fix the issue that a functor is not captured properly in a task region

2023-01-16 Thread Shilei Tian via cfe-commits

Author: Shilei Tian
Date: 2023-01-16T22:35:05-05:00
New Revision: ae53c7f4a21104e2eb84139f3ce4c468e2632590

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

LOG: [Clang][OpenMP] Fix the issue that a functor is not captured properly in a 
task region

This patch fixes the issue that a functor is not captured properly if
that is used in a task region. It was introduced by 
https://reviews.llvm.org/D114546
where `CallExpr` is treated specially, but the callee itself is not properly 
visited.
https://reviews.llvm.org/D115902 already did some fix for one case. This patch
fixes another case.

Fix #57757.

Reviewed By: ABataev

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

Added: 
clang/test/OpenMP/bug57757.cpp

Modified: 
clang/lib/Sema/SemaOpenMP.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 2ab6cba689e58..f3c886c13d308 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -4067,9 +4067,13 @@ class DSAAttrChecker final : public 
StmtVisitor {
 Visit(C);
   }
 }
-if (Expr *Callee = S->getCallee())
-  if (auto *CE = dyn_cast(Callee->IgnoreParenImpCasts()))
+if (Expr *Callee = S->getCallee()) {
+  auto *CI = Callee->IgnoreParenImpCasts();
+  if (auto *CE = dyn_cast(CI))
 Visit(CE->getBase());
+  else if (auto *CE = dyn_cast(CI))
+Visit(CE);
+}
   }
   void VisitStmt(Stmt *S) {
 for (Stmt *C : S->children()) {

diff  --git a/clang/test/OpenMP/bug57757.cpp b/clang/test/OpenMP/bug57757.cpp
new file mode 100644
index 0..7894796ac4628
--- /dev/null
+++ b/clang/test/OpenMP/bug57757.cpp
@@ -0,0 +1,56 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --include-generated-funcs 
--prefix-filecheck-ir-name _
+// RUN: %clang_cc1 -fopenmp -O1 -x c++ -triple x86_64-apple-darwin10 
-emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK
+
+template 
+void run_task(Function function, Args... args) {
+#pragma omp task untied
+  { function(args...); }
+}
+
+void bar(int a, float b);
+
+void foo() {
+  int a;
+  float b;
+  run_task(bar, a, b);
+}
+// CHECK-LABEL: define {{[^@]+}}@_Z3foov
+// CHECK-SAME: () local_unnamed_addr #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call i32 @__kmpc_global_thread_num(ptr 
nonnull @[[GLOB1:[0-9]+]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call ptr @__kmpc_omp_task_alloc(ptr 
nonnull @[[GLOB1]], i32 [[TMP0]], i32 0, i64 56, i64 1, ptr nonnull 
@.omp_task_entry.)
+// CHECK-NEXT:[[TMP2:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_T_WITH_PRIVATES:%.*]], ptr [[TMP1]], i64 0, i32 1
+// CHECK-NEXT:store ptr @_Z3barif, ptr [[TMP2]], align 8, !tbaa 
[[TBAA3:![0-9]+]]
+// CHECK-NEXT:[[TMP3:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_T:%.*]], ptr [[TMP1]], i64 0, i32 2
+// CHECK-NEXT:store i32 0, ptr [[TMP3]], align 8, !tbaa [[TBAA12:![0-9]+]]
+// CHECK-NEXT:[[TMP4:%.*]] = tail call i32 @__kmpc_omp_task(ptr nonnull 
@[[GLOB1]], i32 [[TMP0]], ptr [[TMP1]])
+// CHECK-NEXT:ret void
+//
+//
+// CHECK-LABEL: define {{[^@]+}}@.omp_task_entry.
+// CHECK-SAME: (i32 noundef [[TMP0:%.*]], ptr noalias noundef [[TMP1:%.*]]) 
#[[ATTR3:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP2:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_T:%.*]], ptr [[TMP1]], i64 0, i32 2
+// CHECK-NEXT:tail call void 
@llvm.experimental.noalias.scope.decl(metadata [[META13:![0-9]+]])
+// CHECK-NEXT:tail call void 
@llvm.experimental.noalias.scope.decl(metadata [[META16:![0-9]+]])
+// CHECK-NEXT:[[TMP3:%.*]] = load i32, ptr [[TMP2]], align 4, !tbaa 
[[TBAA18:![0-9]+]], !alias.scope !13, !noalias !16
+// CHECK-NEXT:switch i32 [[TMP3]], label [[DOTOMP_OUTLINED__EXIT:%.*]] [
+// CHECK-NEXT:i32 0, label [[DOTUNTIED_JMP__I:%.*]]
+// CHECK-NEXT:i32 1, label [[DOTUNTIED_NEXT__I:%.*]]
+// CHECK-NEXT:]
+// CHECK:   .untied.jmp..i:
+// CHECK-NEXT:store i32 1, ptr [[TMP2]], align 4, !tbaa [[TBAA18]], 
!alias.scope !13, !noalias !16
+// CHECK-NEXT:[[TMP4:%.*]] = tail call i32 @__kmpc_omp_task(ptr nonnull 
@[[GLOB1]], i32 [[TMP0]], ptr [[TMP1]]), !noalias !19
+// CHECK-NEXT:br label [[DOTOMP_OUTLINED__EXIT]]
+// CHECK:   .untied.next..i:
+// CHECK-NEXT:[[TMP5:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_T_WITH_PRIVATES:%.*]], ptr [[TMP1]], i64 0, i32 1
+// CHECK-NEXT:[[TMP6:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_T_WITH_PRIVATES]], ptr [[TMP1]], i64 0, i32 1, i32 2
+// CHECK-NEXT:[[TMP7:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_T_WITH_PRIVATES]], ptr [[TMP1]], i64 0, i32 1, i32 1
+// CHECK-NEXT:[[TMP8:%.*]] = load ptr, ptr 

[PATCH] D141886: [Clang][Test] Avoid matching version numbers

2023-01-16 Thread hezuoqiang via Phabricator via cfe-commits
hzq created this revision.
Herald added a project: All.
hzq requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

If the version number starts with cc1, such as: clang-cc1514432c58
In the test case the `-cc1` option will match the version number instead of the 
command line. resulting in a check failure.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141886

Files:
  clang/test/Driver/modules-ts.cpp
  clang/test/Driver/modules.cpp
  clang/test/OpenMP/driver.c


Index: clang/test/OpenMP/driver.c
===
--- clang/test/OpenMP/driver.c
+++ clang/test/OpenMP/driver.c
@@ -3,12 +3,12 @@
 //
 // RUN: %clang %s -### -o %t.o 2>&1 -fopenmp=libomp | FileCheck 
--check-prefix=CHECK-DEFAULT %s
 
-// CHECK-DEFAULT: -cc1
+// CHECK-DEFAULT: -cc1{{[^[:xdigit:]]}}
 // CHECK-DEFAULT-NOT: -fnoopenmp-use-tls
 //
 // RUN: %clang %s -### -o %t.o 2>&1 -fopenmp=libomp -fnoopenmp-use-tls | 
FileCheck --check-prefix=CHECK-NO-TLS %s
 
-// CHECK-NO-TLS: -cc1
+// CHECK-NO-TLS: -cc1{{[^[:xdigit:]]}}
 // CHECK-NO-TLS-SAME: -fnoopenmp-use-tls
 //
 // RUN: %clang %s -c -E -dM -fopenmp=libomp | FileCheck 
--check-prefix=CHECK-DEFAULT-VERSION %s
Index: clang/test/Driver/modules.cpp
===
--- clang/test/Driver/modules.cpp
+++ clang/test/Driver/modules.cpp
@@ -24,7 +24,7 @@
 // RUN: %clang -std=c++2a -fmodule-file=%t/module.pcm -Dexport= %s -S -o 
%t/module.o -v 2>&1 | FileCheck %s --check-prefix=CHECK-USE
 // RUN: %clang -std=c++20 -fmodule-file=%t/module.pcm -Dexport= %s -S -o 
%t/module.o -v 2>&1 | FileCheck %s --check-prefix=CHECK-USE
 //
-// CHECK-USE: -cc1
+// CHECK-USE: -cc1{{[^[:xdigit:]]}}
 // CHECK-USE-SAME: {{-emit-obj|-S}}
 // CHECK-USE-SAME: -fmodule-file={{.*}}.pcm
 // CHECK-USE-SAME: -o {{.*}}.{{o|s}}{{"?}} {{.*}}-x c++
Index: clang/test/Driver/modules-ts.cpp
===
--- clang/test/Driver/modules-ts.cpp
+++ clang/test/Driver/modules-ts.cpp
@@ -20,7 +20,7 @@
 //
 // RUN: %clang -fmodules-ts -fmodule-file=%t.pcm -fintegrated-as -Dexport= %s 
-c -o %t.o -v 2>&1 | FileCheck %s --check-prefix=CHECK-USE
 //
-// CHECK-USE: -cc1
+// CHECK-USE: -cc1{{[^[:xdigit:]]}}
 // CHECK-USE-SAME: -emit-obj
 // CHECK-USE-SAME: -fmodule-file={{.*}}.pcm
 // CHECK-USE-SAME: -o {{.*}}.o{{"?}} {{.*}}-x c++


Index: clang/test/OpenMP/driver.c
===
--- clang/test/OpenMP/driver.c
+++ clang/test/OpenMP/driver.c
@@ -3,12 +3,12 @@
 //
 // RUN: %clang %s -### -o %t.o 2>&1 -fopenmp=libomp | FileCheck --check-prefix=CHECK-DEFAULT %s
 
-// CHECK-DEFAULT: -cc1
+// CHECK-DEFAULT: -cc1{{[^[:xdigit:]]}}
 // CHECK-DEFAULT-NOT: -fnoopenmp-use-tls
 //
 // RUN: %clang %s -### -o %t.o 2>&1 -fopenmp=libomp -fnoopenmp-use-tls | FileCheck --check-prefix=CHECK-NO-TLS %s
 
-// CHECK-NO-TLS: -cc1
+// CHECK-NO-TLS: -cc1{{[^[:xdigit:]]}}
 // CHECK-NO-TLS-SAME: -fnoopenmp-use-tls
 //
 // RUN: %clang %s -c -E -dM -fopenmp=libomp | FileCheck --check-prefix=CHECK-DEFAULT-VERSION %s
Index: clang/test/Driver/modules.cpp
===
--- clang/test/Driver/modules.cpp
+++ clang/test/Driver/modules.cpp
@@ -24,7 +24,7 @@
 // RUN: %clang -std=c++2a -fmodule-file=%t/module.pcm -Dexport= %s -S -o %t/module.o -v 2>&1 | FileCheck %s --check-prefix=CHECK-USE
 // RUN: %clang -std=c++20 -fmodule-file=%t/module.pcm -Dexport= %s -S -o %t/module.o -v 2>&1 | FileCheck %s --check-prefix=CHECK-USE
 //
-// CHECK-USE: -cc1
+// CHECK-USE: -cc1{{[^[:xdigit:]]}}
 // CHECK-USE-SAME: {{-emit-obj|-S}}
 // CHECK-USE-SAME: -fmodule-file={{.*}}.pcm
 // CHECK-USE-SAME: -o {{.*}}.{{o|s}}{{"?}} {{.*}}-x c++
Index: clang/test/Driver/modules-ts.cpp
===
--- clang/test/Driver/modules-ts.cpp
+++ clang/test/Driver/modules-ts.cpp
@@ -20,7 +20,7 @@
 //
 // RUN: %clang -fmodules-ts -fmodule-file=%t.pcm -fintegrated-as -Dexport= %s -c -o %t.o -v 2>&1 | FileCheck %s --check-prefix=CHECK-USE
 //
-// CHECK-USE: -cc1
+// CHECK-USE: -cc1{{[^[:xdigit:]]}}
 // CHECK-USE-SAME: -emit-obj
 // CHECK-USE-SAME: -fmodule-file={{.*}}.pcm
 // CHECK-USE-SAME: -o {{.*}}.o{{"?}} {{.*}}-x c++
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 61fa12d - [NFC][X86] clang-format change for avx512vlbwintrin.h

2023-01-16 Thread Freddy Ye via cfe-commits

Author: Freddy Ye
Date: 2023-01-17T10:43:51+08:00
New Revision: 61fa12d0c78b5624914b8bd7937eba03f8973434

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

LOG: [NFC][X86] clang-format change for avx512vlbwintrin.h

Added: 


Modified: 
clang/lib/Headers/avx512vlbwintrin.h

Removed: 




diff  --git a/clang/lib/Headers/avx512vlbwintrin.h 
b/clang/lib/Headers/avx512vlbwintrin.h
index a40ee824ef210..148af5ab9a34d 100644
--- a/clang/lib/Headers/avx512vlbwintrin.h
+++ b/clang/lib/Headers/avx512vlbwintrin.h
@@ -3000,19 +3000,19 @@ _mm_reduce_or_epi8(__m128i __W) {
 }
 
 static __inline__ signed char __DEFAULT_FN_ATTRS128
-_mm_mask_reduce_add_epi8( __mmask16 __M, __m128i __W) {
+_mm_mask_reduce_add_epi8(__mmask16 __M, __m128i __W) {
   __W = _mm_maskz_mov_epi8(__M, __W);
   return __builtin_reduce_add((__v16qs)__W);
 }
 
 static __inline__ signed char __DEFAULT_FN_ATTRS128
-_mm_mask_reduce_mul_epi8( __mmask16 __M, __m128i __W) {
+_mm_mask_reduce_mul_epi8(__mmask16 __M, __m128i __W) {
   __W = _mm_mask_mov_epi8(_mm_set1_epi8(1), __M, __W);
   return __builtin_reduce_mul((__v16qs)__W);
 }
 
 static __inline__ signed char __DEFAULT_FN_ATTRS128
-_mm_mask_reduce_and_epi8( __mmask16 __M, __m128i __W) {
+_mm_mask_reduce_and_epi8(__mmask16 __M, __m128i __W) {
   __W = _mm_mask_mov_epi8(_mm_set1_epi8(-1), __M, __W);
   return __builtin_reduce_and((__v16qs)__W);
 }
@@ -3088,19 +3088,19 @@ _mm256_reduce_or_epi8(__m256i __W) {
 }
 
 static __inline__ signed char __DEFAULT_FN_ATTRS256
-_mm256_mask_reduce_add_epi8( __mmask32 __M, __m256i __W) {
+_mm256_mask_reduce_add_epi8(__mmask32 __M, __m256i __W) {
   __W = _mm256_maskz_mov_epi8(__M, __W);
   return __builtin_reduce_add((__v32qs)__W);
 }
 
 static __inline__ signed char __DEFAULT_FN_ATTRS256
-_mm256_mask_reduce_mul_epi8( __mmask32 __M, __m256i __W) {
+_mm256_mask_reduce_mul_epi8(__mmask32 __M, __m256i __W) {
   __W = _mm256_mask_mov_epi8(_mm256_set1_epi8(1), __M, __W);
   return __builtin_reduce_mul((__v32qs)__W);
 }
 
 static __inline__ signed char __DEFAULT_FN_ATTRS256
-_mm256_mask_reduce_and_epi8( __mmask32 __M, __m256i __W) {
+_mm256_mask_reduce_and_epi8(__mmask32 __M, __m256i __W) {
   __W = _mm256_mask_mov_epi8(_mm256_set1_epi8(-1), __M, __W);
   return __builtin_reduce_and((__v32qs)__W);
 }



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


[PATCH] D141572: [C++] [Coroutines] Deprecates the '-fcoroutines-ts' flag

2023-01-16 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu updated this revision to Diff 489665.
ChuanqiXu added a comment.

Address comments and refine the wording from "use `-std=c++20`" to "use 
`-std=c++20` or higher".


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

https://reviews.llvm.org/D141572

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/coroutines.cpp
  libcxx/test/libcxx/assertions/headers_declare_verbose_abort.sh.cpp
  libcxx/test/libcxx/clang_tidy.sh.cpp
  libcxx/test/libcxx/double_include.sh.cpp
  libcxx/test/libcxx/min_max_macros.compile.pass.cpp
  libcxx/test/libcxx/modules_include.sh.cpp
  libcxx/test/libcxx/nasty_macros.compile.pass.cpp
  libcxx/test/libcxx/no_assert_include.compile.pass.cpp
  libcxx/utils/generate_header_tests.py

Index: libcxx/utils/generate_header_tests.py
===
--- libcxx/utils/generate_header_tests.py
+++ libcxx/utils/generate_header_tests.py
@@ -19,6 +19,9 @@
 
 "filesystem": "!defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)",
 
+# TODO LLVM17: simplify this to __cplusplus >= 202002L
+"coroutine": "(defined(__cpp_impl_coroutine) && __cpp_impl_coroutine >= 201902L) || (defined(__cpp_coroutines) && __cpp_coroutines >= 201703L)",
+
 "clocale": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
 "codecvt": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
 "fstream": "!defined(_LIBCPP_HAS_NO_LOCALIZATION) && !defined(_LIBCPP_HAS_NO_FSTREAM)",
Index: libcxx/test/libcxx/no_assert_include.compile.pass.cpp
===
--- libcxx/test/libcxx/no_assert_include.compile.pass.cpp
+++ libcxx/test/libcxx/no_assert_include.compile.pass.cpp
@@ -66,7 +66,9 @@
 #include 
 #include 
 #include 
-#include 
+#if (defined(__cpp_impl_coroutine) && __cpp_impl_coroutine >= 201902L) || (defined(__cpp_coroutines) && __cpp_coroutines >= 201703L)
+#   include 
+#endif
 #include 
 #include 
 #include 
Index: libcxx/test/libcxx/nasty_macros.compile.pass.cpp
===
--- libcxx/test/libcxx/nasty_macros.compile.pass.cpp
+++ libcxx/test/libcxx/nasty_macros.compile.pass.cpp
@@ -193,7 +193,9 @@
 #include 
 #include 
 #include 
-#include 
+#if (defined(__cpp_impl_coroutine) && __cpp_impl_coroutine >= 201902L) || (defined(__cpp_coroutines) && __cpp_coroutines >= 201703L)
+#   include 
+#endif
 #include 
 #include 
 #include 
Index: libcxx/test/libcxx/modules_include.sh.cpp
===
--- libcxx/test/libcxx/modules_include.sh.cpp
+++ libcxx/test/libcxx/modules_include.sh.cpp
@@ -154,7 +154,7 @@
 #include 
 #endif
 // RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_26
-#if defined(TEST_26)
+#if defined(TEST_26) && (defined(__cpp_impl_coroutine) && __cpp_impl_coroutine >= 201902L) || (defined(__cpp_coroutines) && __cpp_coroutines >= 201703L)
 #include 
 #endif
 // RUN: %{cxx} %s %{flags} %{compile_flags} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only -DTEST_27
Index: libcxx/test/libcxx/min_max_macros.compile.pass.cpp
===
--- libcxx/test/libcxx/min_max_macros.compile.pass.cpp
+++ libcxx/test/libcxx/min_max_macros.compile.pass.cpp
@@ -95,8 +95,10 @@
 TEST_MACROS();
 #include 
 TEST_MACROS();
-#include 
+#if (defined(__cpp_impl_coroutine) && __cpp_impl_coroutine >= 201902L) || (defined(__cpp_coroutines) && __cpp_coroutines >= 201703L)
+#   include 
 TEST_MACROS();
+#endif
 #include 
 TEST_MACROS();
 #include 
Index: libcxx/test/libcxx/double_include.sh.cpp
===
--- libcxx/test/libcxx/double_include.sh.cpp
+++ libcxx/test/libcxx/double_include.sh.cpp
@@ -69,7 +69,9 @@
 #include 
 #include 
 #include 
-#include 
+#if (defined(__cpp_impl_coroutine) && __cpp_impl_coroutine >= 201902L) || (defined(__cpp_coroutines) && __cpp_coroutines >= 201703L)
+#   include 
+#endif
 #include 
 #include 
 #include 
Index: libcxx/test/libcxx/clang_tidy.sh.cpp
===
--- libcxx/test/libcxx/clang_tidy.sh.cpp
+++ libcxx/test/libcxx/clang_tidy.sh.cpp
@@ -68,7 +68,9 @@
 #include 
 #include 
 #include 
-#include 
+#if (defined(__cpp_impl_coroutine) && __cpp_impl_coroutine >= 201902L) || (defined(__cpp_coroutines) && __cpp_coroutines >= 201703L)
+#   include 
+#endif
 #include 
 #include 
 #include 
Index: libcxx/test/libcxx/assertions/headers_declare_verbose_abort.sh.cpp
===
--- libcxx/test/libcxx/assertions/headers_declare_verbose_abort.sh.cpp
+++ libcxx/test/libcxx/assertions/headers_declare_verbose_abort.sh.cpp
@@ -199,7 +199,7 @@
 #endif
 
 // RUN: %{build} -DTEST_26
-#if defined(TEST_26)
+#if 

[PATCH] D131938: [C++20] [Coroutines] Disable to take the address of labels in coroutines

2023-01-16 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu accepted this revision.
ChuanqiXu added a comment.
This revision is now accepted and ready to land.

Oh, sorry, I forgot this. Given D132084  is 
not updated recently, I think we can merge this first. And it should be fine to 
remove this one after patches like D132084  
works properly.


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

https://reviews.llvm.org/D131938

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


[PATCH] D137058: [Driver] [Modules] Support -fmodule-output (1/2)

2023-01-16 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D137058#4056647 , @Jake-Egan wrote:

> Hi, this new test fails on AIX 
> https://lab.llvm.org/buildbot/#/builders/214/builds/5351/steps/6/logs/FAIL__Clang__module-output_cppm
> Could you take a look?

I added `// REQUIRES: x86-registered-target`. Is it still failing?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137058

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


[PATCH] D141206: [clang] [MinGW] Avoid adding /include and /lib when cross compiling

2023-01-16 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfd15cb935d7a: [clang] [MinGW] Avoid adding 
base/include and base/lib when cross compiling (authored by 
mstorsjo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141206

Files:
  clang/lib/Driver/ToolChains/MinGW.cpp
  clang/test/Driver/mingw-sysroot.cpp


Index: clang/test/Driver/mingw-sysroot.cpp
===
--- clang/test/Driver/mingw-sysroot.cpp
+++ clang/test/Driver/mingw-sysroot.cpp
@@ -22,7 +22,12 @@
 // If we find a gcc in the path with the right triplet prefix, pick that as
 // sysroot:
 
-// RUN: env "PATH=%T/testroot-gcc/bin:%PATH%" %clang -target 
x86_64-w64-mingw32 -rtlib=platform -stdlib=libstdc++ --sysroot="" -c -### %s 
2>&1 | FileCheck -check-prefix=CHECK_TESTROOT_GCC %s
+// This test is only executed on non-Windows systems, i.e. only when
+// cross compiling. Check that we don't add the tool root's plain include
+// directory to the path - this would end up including /usr/include for
+// cross toolchains installed in /usr.
+
+// RUN: env "PATH=%T/testroot-gcc/bin:%PATH%" %clang -target 
x86_64-w64-mingw32 -rtlib=platform -stdlib=libstdc++ --sysroot="" -c -### %s 
2>&1 | FileCheck -check-prefix=CHECK_TESTROOT_GCC %s 
--implicit-check-not="\"{{.*}}/testroot-gcc{{/|}}include\""
 // CHECK_TESTROOT_GCC: "-internal-isystem" 
"[[BASE:[^"]+]]/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}10.2-posix{{/|}}include{{/|}}c++"
 // CHECK_TESTROOT_GCC-SAME: {{^}} "-internal-isystem" 
"[[BASE]]/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}10.2-posix{{/|}}include{{/|}}c++{{/|}}x86_64-w64-mingw32"
 // CHECK_TESTROOT_GCC-SAME: {{^}} "-internal-isystem" 
"[[BASE]]/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}10.2-posix{{/|}}include{{/|}}c++{{/|}}backward"
@@ -32,6 +37,13 @@
 // CHECK_TESTROOT_GCC: "-internal-isystem" 
"[[BASE]]/testroot-gcc{{/|}}x86_64-w64-mingw32{{/|}}include"
 
 
+// If we pass --sysroot explicitly, then we do include /include
+// even when cross compiling.
+// RUN: %clang -target x86_64-w64-mingw32 -rtlib=platform -stdlib=libstdc++ 
--sysroot="%T/testroot-gcc" -c -### %s 2>&1 | FileCheck 
-check-prefix=CHECK_TESTROOT_GCC_EXPLICIT %s
+
+// CHECK_TESTROOT_GCC_EXPLICIT: "-internal-isystem" 
"{{[^"]+}}/testroot-gcc{{/|}}include"
+
+
 // If there's a matching sysroot next to the clang binary itself, prefer that
 // over a gcc in the path:
 
Index: clang/lib/Driver/ToolChains/MinGW.cpp
===
--- clang/lib/Driver/ToolChains/MinGW.cpp
+++ clang/lib/Driver/ToolChains/MinGW.cpp
@@ -348,6 +348,15 @@
  Exec, CmdArgs, Inputs, Output));
 }
 
+static bool isCrossCompiling(const llvm::Triple , bool RequireArchMatch) {
+  llvm::Triple HostTriple(llvm::Triple::normalize(LLVM_HOST_TRIPLE));
+  if (HostTriple.getOS() != llvm::Triple::Win32)
+return true;
+  if (RequireArchMatch && HostTriple.getArch() != T.getArch())
+return true;
+  return false;
+}
+
 // Simplified from 
Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple.
 static bool findGccVersion(StringRef LibDir, std::string ,
std::string ,
@@ -487,7 +496,13 @@
   getFilePaths().push_back(
   (Base + SubdirName + llvm::sys::path::get_separator() + 
"mingw/lib").str());
 
-  getFilePaths().push_back(Base + "lib");
+  // Only include /lib if we're not cross compiling (not even for
+  // windows->windows to a different arch), or if the sysroot has been set
+  // (where we presume the user has pointed it at an arch specific
+  // subdirectory).
+  if (!::isCrossCompiling(getTriple(), /*RequireArchMatch=*/true) ||
+  getDriver().SysRoot.size())
+getFilePaths().push_back(Base + "lib");
 
   NativeLLVMSupport =
   Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER)
@@ -649,7 +664,13 @@
   addSystemInclude(DriverArgs, CC1Args,
Base + SubdirName + llvm::sys::path::get_separator() + 
"usr/include");
 
-  addSystemInclude(DriverArgs, CC1Args, Base + "include");
+  // Only include /include if we're not cross compiling (but do allow it
+  // if we're on Windows and building for Windows on another architecture),
+  // or if the sysroot has been set (where we presume the user has pointed it
+  // at an arch specific subdirectory).
+  if (!::isCrossCompiling(getTriple(), /*RequireArchMatch=*/false) ||
+  getDriver().SysRoot.size())
+addSystemInclude(DriverArgs, CC1Args, Base + "include");
 }
 
 void toolchains::MinGW::addClangTargetOptions(


Index: clang/test/Driver/mingw-sysroot.cpp
===
--- clang/test/Driver/mingw-sysroot.cpp
+++ 

[clang] fd15cb9 - [clang] [MinGW] Avoid adding /include and /lib when cross compiling

2023-01-16 Thread Martin Storsjö via cfe-commits

Author: Martin Storsjö
Date: 2023-01-17T00:39:12+02:00
New Revision: fd15cb935d7aae25ad62bfe06fe9f17cea585978

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

LOG: [clang] [MinGW] Avoid adding /include and /lib when cross 
compiling

The MinGW compiler driver first tries to deduce the root of
the toolchain installation (either clang itself or a separate
cross mingw gcc installation). On top of this root, a number
of include and lib paths are added (some added unconditionally,
some only if they exist):
- /x86_64-w64-mingw32/include
- /include
- /include/x86_64-w64-windows-gnu
(Some more are also added for libstdc++ and/or libc++.)

The first one is the one commonly used for MinGW targets so
far. For LLVM runtimes installed with the
LLVM_ENABLE_PER_TARGET_RUNTIME_DIR option, the latter two are
used though (this is currently not the default, not yet at least).

For cross compiling, if base is a separate dedicated directory,
this is fine, but when using the sysroots of a distro-installed
cross mingw toolchain, base is /usr - and having /usr/include
in the include path for cross compilation is a potential
source for problems; see
https://github.com/llvm/llvm-project/issues/59871.

If not cross compiling though, /include needs to be included
too. E.g. in the case of msys2, most headers are in e.g.
/mingw64/include while the compiler is /mingw64/bin/clang.

When cross compiling, if the sysroot has been explicitly set
by the user, keep /include too. (In the case of a distro
provided cross gcc toolchain in /usr, the sysroot needs to be set
to /usr and not /usr/x86_64-w64-mingw32 though, to be able to find
libgcc files under /usr/lib/gcc/x86_64-w64-mingw32. So with such a
toolchain, setting the sysroot explicitly does retain the problem.)

All in all - this avoids adding /usr/include and /usr/lib to the
include/lib paths when doing mingw cross compilation with a
distro-provided sysroot in /usr/x86_64-w64-mingw32.

Test that the include directory is omitted in the mingw-sysroot.cpp
tests, when cross compiling. That test is only ever executed on
non-Windows hosts, since it uses symlinks to set up fake environments
with colocated compilers and header/lib directories. There aren't
really any current corresponding tests for the same implicit behaviours
when actually running on Windows.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/MinGW.cpp
clang/test/Driver/mingw-sysroot.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/MinGW.cpp 
b/clang/lib/Driver/ToolChains/MinGW.cpp
index 4d4c9b5930cfe..908484fcc0b81 100644
--- a/clang/lib/Driver/ToolChains/MinGW.cpp
+++ b/clang/lib/Driver/ToolChains/MinGW.cpp
@@ -348,6 +348,15 @@ void tools::MinGW::Linker::ConstructJob(Compilation , 
const JobAction ,
  Exec, CmdArgs, Inputs, Output));
 }
 
+static bool isCrossCompiling(const llvm::Triple , bool RequireArchMatch) {
+  llvm::Triple HostTriple(llvm::Triple::normalize(LLVM_HOST_TRIPLE));
+  if (HostTriple.getOS() != llvm::Triple::Win32)
+return true;
+  if (RequireArchMatch && HostTriple.getArch() != T.getArch())
+return true;
+  return false;
+}
+
 // Simplified from 
Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple.
 static bool findGccVersion(StringRef LibDir, std::string ,
std::string ,
@@ -487,7 +496,13 @@ toolchains::MinGW::MinGW(const Driver , const 
llvm::Triple ,
   getFilePaths().push_back(
   (Base + SubdirName + llvm::sys::path::get_separator() + 
"mingw/lib").str());
 
-  getFilePaths().push_back(Base + "lib");
+  // Only include /lib if we're not cross compiling (not even for
+  // windows->windows to a 
diff erent arch), or if the sysroot has been set
+  // (where we presume the user has pointed it at an arch specific
+  // subdirectory).
+  if (!::isCrossCompiling(getTriple(), /*RequireArchMatch=*/true) ||
+  getDriver().SysRoot.size())
+getFilePaths().push_back(Base + "lib");
 
   NativeLLVMSupport =
   Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER)
@@ -649,7 +664,13 @@ void toolchains::MinGW::AddClangSystemIncludeArgs(const 
ArgList ,
   addSystemInclude(DriverArgs, CC1Args,
Base + SubdirName + llvm::sys::path::get_separator() + 
"usr/include");
 
-  addSystemInclude(DriverArgs, CC1Args, Base + "include");
+  // Only include /include if we're not cross compiling (but do allow it
+  // if we're on Windows and building for Windows on another architecture),
+  // or if the sysroot has been set (where we presume the user has pointed it
+  // at an arch specific subdirectory).
+  if (!::isCrossCompiling(getTriple(), /*RequireArchMatch=*/false) ||
+  

[PATCH] D141873: [Clang][OpenMP] Fix the issue that a functor is not captured properly in a task region

2023-01-16 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141873

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


[PATCH] D141873: [Clang][OpenMP] Fix the issue that a functor is not captured properly in a task region

2023-01-16 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 created this revision.
tianshilei1992 added reviewers: ABataev, jdoerfert.
Herald added subscribers: guansong, yaxunl.
Herald added a project: All.
tianshilei1992 requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

This patch fixes the issue that a functor is not captured properly if
that is used in a task region. It was introduced by 
https://reviews.llvm.org/D114546
where `CallExpr` is treated specially, but the callee itself is not properly 
visited.
https://reviews.llvm.org/D115902 already did some fix for one case. This patch
fixes another case.

Fix #57757.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141873

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/bug57757.cpp


Index: clang/test/OpenMP/bug57757.cpp
===
--- /dev/null
+++ clang/test/OpenMP/bug57757.cpp
@@ -0,0 +1,56 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --include-generated-funcs 
--prefix-filecheck-ir-name _
+// RUN: %clang_cc1 -fopenmp -O1 -x c++ -triple x86_64-apple-darwin10 
-emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK
+
+template 
+void run_task(Function function, Args... args) {
+#pragma omp task untied
+  { function(args...); }
+}
+
+void bar(int a, float b);
+
+void foo() {
+  int a;
+  float b;
+  run_task(bar, a, b);
+}
+// CHECK-LABEL: define {{[^@]+}}@_Z3foov
+// CHECK-SAME: () local_unnamed_addr #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call i32 @__kmpc_global_thread_num(ptr 
nonnull @[[GLOB1:[0-9]+]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call ptr @__kmpc_omp_task_alloc(ptr 
nonnull @[[GLOB1]], i32 [[TMP0]], i32 0, i64 56, i64 1, ptr nonnull 
@.omp_task_entry.)
+// CHECK-NEXT:[[TMP2:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_T_WITH_PRIVATES:%.*]], ptr [[TMP1]], i64 0, i32 1
+// CHECK-NEXT:store ptr @_Z3barif, ptr [[TMP2]], align 8, !tbaa 
[[TBAA3:![0-9]+]]
+// CHECK-NEXT:[[TMP3:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_T:%.*]], ptr [[TMP1]], i64 0, i32 2
+// CHECK-NEXT:store i32 0, ptr [[TMP3]], align 8, !tbaa [[TBAA12:![0-9]+]]
+// CHECK-NEXT:[[TMP4:%.*]] = tail call i32 @__kmpc_omp_task(ptr nonnull 
@[[GLOB1]], i32 [[TMP0]], ptr [[TMP1]])
+// CHECK-NEXT:ret void
+//
+//
+// CHECK-LABEL: define {{[^@]+}}@.omp_task_entry.
+// CHECK-SAME: (i32 noundef [[TMP0:%.*]], ptr noalias noundef [[TMP1:%.*]]) 
#[[ATTR3:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP2:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_T:%.*]], ptr [[TMP1]], i64 0, i32 2
+// CHECK-NEXT:tail call void 
@llvm.experimental.noalias.scope.decl(metadata [[META13:![0-9]+]])
+// CHECK-NEXT:tail call void 
@llvm.experimental.noalias.scope.decl(metadata [[META16:![0-9]+]])
+// CHECK-NEXT:[[TMP3:%.*]] = load i32, ptr [[TMP2]], align 4, !tbaa 
[[TBAA18:![0-9]+]], !alias.scope !13, !noalias !16
+// CHECK-NEXT:switch i32 [[TMP3]], label [[DOTOMP_OUTLINED__EXIT:%.*]] [
+// CHECK-NEXT:i32 0, label [[DOTUNTIED_JMP__I:%.*]]
+// CHECK-NEXT:i32 1, label [[DOTUNTIED_NEXT__I:%.*]]
+// CHECK-NEXT:]
+// CHECK:   .untied.jmp..i:
+// CHECK-NEXT:store i32 1, ptr [[TMP2]], align 4, !tbaa [[TBAA18]], 
!alias.scope !13, !noalias !16
+// CHECK-NEXT:[[TMP4:%.*]] = tail call i32 @__kmpc_omp_task(ptr nonnull 
@[[GLOB1]], i32 [[TMP0]], ptr [[TMP1]]), !noalias !19
+// CHECK-NEXT:br label [[DOTOMP_OUTLINED__EXIT]]
+// CHECK:   .untied.next..i:
+// CHECK-NEXT:[[TMP5:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_T_WITH_PRIVATES:%.*]], ptr [[TMP1]], i64 0, i32 1
+// CHECK-NEXT:[[TMP6:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_T_WITH_PRIVATES]], ptr [[TMP1]], i64 0, i32 1, i32 2
+// CHECK-NEXT:[[TMP7:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_T_WITH_PRIVATES]], ptr [[TMP1]], i64 0, i32 1, i32 1
+// CHECK-NEXT:[[TMP8:%.*]] = load ptr, ptr [[TMP5]], align 8, !tbaa 
[[TBAA20:![0-9]+]], !alias.scope !16, !noalias !13
+// CHECK-NEXT:[[TMP9:%.*]] = load i32, ptr [[TMP7]], align 4, !tbaa 
[[TBAA18]], !alias.scope !16, !noalias !13
+// CHECK-NEXT:[[TMP10:%.*]] = load float, ptr [[TMP6]], align 4, !tbaa 
[[TBAA21:![0-9]+]], !alias.scope !16, !noalias !13
+// CHECK-NEXT:tail call void [[TMP8]](i32 noundef [[TMP9]], float noundef 
[[TMP10]]) #[[ATTR2:[0-9]+]], !noalias !19
+// CHECK-NEXT:br label [[DOTOMP_OUTLINED__EXIT]]
+// CHECK:   .omp_outlined..exit:
+// CHECK-NEXT:ret i32 0
+//
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -4067,9 +4067,13 @@
 Visit(C);
   }
 }
-if (Expr *Callee = S->getCallee())
-  if (auto *CE = dyn_cast(Callee->IgnoreParenImpCasts()))
+if (Expr *Callee = S->getCallee()) {
+  

[PATCH] D140158: [CUDA] Allow targeting NVPTX directly without a host toolchain

2023-01-16 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

FWIW, creating CUBIN from C/C++ directly would be really useful when debugging 
(and in combination with our soon to be available JIT object loader).

@tra Can we get this in somehow?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140158

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


[PATCH] D141814: [llvm][ADT] Replace uses of `makeMutableArrayRef` with deduction guides

2023-01-16 Thread Joe Loser via Phabricator via cfe-commits
jloser added inline comments.



Comment at: lldb/source/Host/common/NativeProcessProtocol.cpp:652
 
   auto data =
+  llvm::MutableArrayRef(static_cast(buf), bytes_read);

serge-sans-paille wrote:
> random nit: This could be rewritten as
> 
> ```
> llvm::MutableArrayRef data(static_cast(buf), bytes_read);
> ```
> 
> now
Yep, I just changed that before landing this. Thanks for the review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141814

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


[PATCH] D141814: [llvm][ADT] Replace uses of `makeMutableArrayRef` with deduction guides

2023-01-16 Thread Joe Loser 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 rGa288d7f93770: [llvm][ADT] Replace uses of 
`makeMutableArrayRef` with deduction guides (authored by jloser).

Changed prior to commit:
  https://reviews.llvm.org/D141814?vs=489419=489635#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141814

Files:
  bolt/lib/Profile/DataAggregator.cpp
  clang-tools-extra/clangd/FuzzyMatch.cpp
  clang-tools-extra/clangd/SemanticSelection.cpp
  clang-tools-extra/clangd/index/dex/Trigram.cpp
  clang-tools-extra/pseudo/include/clang-pseudo/Forest.h
  clang/include/clang/AST/DeclOpenMP.h
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/StmtOpenMP.h
  clang/include/clang/Lex/MacroInfo.h
  clang/lib/AST/StmtOpenMP.cpp
  lld/COFF/Chunks.cpp
  lld/COFF/DebugTypes.cpp
  lld/COFF/Writer.cpp
  lld/ELF/InputFiles.h
  lld/ELF/SyntheticSections.cpp
  lldb/source/Host/common/NativeProcessProtocol.cpp
  llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
  llvm/include/llvm/IR/DataLayout.h
  llvm/include/llvm/IR/Metadata.h
  llvm/include/llvm/ProfileData/InstrProf.h
  llvm/include/llvm/Support/Parallel.h
  llvm/lib/Analysis/ConstantFolding.cpp
  llvm/lib/ExecutionEngine/ExecutionEngine.cpp
  llvm/lib/Support/Path.cpp
  llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
  llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
  llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
  llvm/unittests/Support/Path.cpp
  mlir/lib/Bytecode/Writer/IRNumbering.cpp
  mlir/lib/Dialect/Affine/Transforms/LoopCoalescing.cpp
  mlir/test/mlir-tblgen/constraint-unique.td
  mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp

Index: mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
===
--- mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -2746,7 +2746,7 @@
   ///
   /// {0}: The region's index.
   const char *const getSingleRegion =
-  "::llvm::makeMutableArrayRef((*this)->getRegion({0}))";
+  "::llvm::MutableArrayRef((*this)->getRegion({0}))";
 
   // If we have no regions, there is nothing more to do.
   const auto canSkip = [](const NamedRegion ) {
@@ -2781,7 +2781,7 @@
   /// Get a single successor.
   ///
   /// {0}: The successor's name.
-  const char *const getSingleSuccessor = "::llvm::makeMutableArrayRef({0}())";
+  const char *const getSingleSuccessor = "::llvm::MutableArrayRef({0}())";
 
   // If we have no successors, there is nothing more to do.
   const auto canSkip = [](const NamedSuccessor ) {
Index: mlir/test/mlir-tblgen/constraint-unique.td
===
--- mlir/test/mlir-tblgen/constraint-unique.td
+++ mlir/test/mlir-tblgen/constraint-unique.td
@@ -127,10 +127,10 @@
 // CHECK: for (auto [[$RET_VALUE:.*]] : [[$RET_VALUE_GROUP]])
 // CHECK-NEXT:  if (::mlir::failed([[$A_TYPE_CONSTRAINT]](*this, [[$RET_VALUE]].getType(), "result", index++)))
 // CHECK-NEXT:return ::mlir::failure();
-// CHECK: for (auto  : ::llvm::makeMutableArrayRef((*this)->getRegion(0)))
+// CHECK: for (auto  : ::llvm::MutableArrayRef((*this)->getRegion(0)))
 // CHECK-NEXT:  if (::mlir::failed([[$A_REGION_CONSTRAINT]](*this, region, "d", index++)))
 // CHECK-NEXT:return ::mlir::failure();
-// CHECK: for (auto *successor : ::llvm::makeMutableArrayRef(c()))
+// CHECK: for (auto *successor : ::llvm::MutableArrayRef(c()))
 // CHECK-NEXT:  if (::mlir::failed([[$A_SUCCESSOR_CONSTRAINT]](*this, successor, "c", index++)))
 // CHECK-NEXT:return ::mlir::failure();
 
@@ -148,9 +148,9 @@
 // CHECK: for (auto [[$RET_VALUE:.*]] : [[$RET_VALUE_GROUP]])
 // CHECK-NEXT:  if (::mlir::failed([[$O_TYPE_CONSTRAINT]](*this, [[$RET_VALUE]].getType(), "result", index++)))
 // CHECK-NEXT:return ::mlir::failure();
-// CHECK: for (auto  : ::llvm::makeMutableArrayRef((*this)->getRegion(0)))
+// CHECK: for (auto  : ::llvm::MutableArrayRef((*this)->getRegion(0)))
 // CHECK-NEXT:  if (::mlir::failed([[$O_REGION_CONSTRAINT]](*this, region, "d", index++)))
 // CHECK-NEXT:return ::mlir::failure();
-// CHECK: for (auto *successor : ::llvm::makeMutableArrayRef(c()))
+// CHECK: for (auto *successor : ::llvm::MutableArrayRef(c()))
 // CHECK-NEXT:  if (::mlir::failed([[$O_SUCCESSOR_CONSTRAINT]](*this, successor, "c", index++)))
 // CHECK-NEXT:return ::mlir::failure();
Index: mlir/lib/Dialect/Affine/Transforms/LoopCoalescing.cpp
===
--- mlir/lib/Dialect/Affine/Transforms/LoopCoalescing.cpp
+++ mlir/lib/Dialect/Affine/Transforms/LoopCoalescing.cpp
@@ -80,8 +80,7 @@
 LLVM_DEBUG(llvm::dbgs() << "  found coalesceable band from " << start
   

[PATCH] D141581: [clang] Make clangBasic and clangDriver depend on LLVMTargetParser.

2023-01-16 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added a comment.

In D141581#4056825 , @barannikov88 
wrote:

> clangBasic and clangDriver already have a dependency on TargetParser (see 
> LLVM_LINK_COMPONENTS at the beginning of corresponding files). Is that not 
> enough?
> Will it build if you just remove the additional dependency?

No - if we just specify the dependency in `LLVM_LINK_COMPONENTS`, there are 
build failures, as explained in the commit message of 
https://reviews.llvm.org/rGac1ffd3caca12c254e0b8c847aa8ce8e51b6cfbf.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141581

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


[PATCH] D141871: [Clang][OpenMP] Add parse and sema for iterator map modifier

2023-01-16 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/include/clang/AST/OpenMPClause.h:5780
+  /// Iterator modifier
+  Expr *IteratorModifierExpr = nullptr;
+

We're using tail allocation for such objects.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141871

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


[PATCH] D141528: [Clang][OpenMP] Fix loop directive nested inside a parallel

2023-01-16 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


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

https://reviews.llvm.org/D141528

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


[PATCH] D135495: [clang-tidy] handle pointers in `ExceptionAnalyzer`

2023-01-16 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp:81
+  FromPointeeTy->getUnqualifiedDesugaredType();
+  const Type *ToPointeeUQTy = ToPointeeTy->getUnqualifiedDesugaredType();
+

Here I am also wondering if we actually want canonical types.



Comment at: clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp:95
+
+  if (P1->isArrayType() && P2->isArrayType()) {
+// At every level that array type is involved in, at least

isuckatcs wrote:
> xazax.hun wrote:
> > isuckatcs wrote:
> > > xazax.hun wrote:
> > > > If none of the functions I recommended works for you, I still strongly 
> > > > suggest reusing utilities from ASTContext, like `UnwrapSimilarTypes` 
> > > > and `UnwrapSimilarArrayTypes`.
> > > I didn't check all of the functions inside `ASTContext`, but here we have 
> > > very specific rules, we need to check. One utility might help with one 
> > > check or two, but won't replace the need to go ove all of them. Also I 
> > > think it's easier to understand which section checks what, if I keep them 
> > > separated.
> > > 
> > > In an ealier comment I link to [[ 
> > > https://en.cppreference.com/w/cpp/language/implicit_conversion#Qualification_conversions
> > >  | the section on cppreference ]], which discusses what these rules are. 
> > > Also there I found one controversial example, that's only detected by 
> > > MSVC. I wonder if you know why that happens.
> > I see. It is unfortunate that we cannot simply reuse the corresponding 
> > functionality from Sema. The code mostly looks good to me, apart from some 
> > nits.
> > It is unfortunate that we cannot simply reuse the corresponding 
> > functionality from Sema.
> 
> It is indeed unfortunate, though I wonder if we want to move this 
> functionality to `ASTContext`, so that it can be reused outside the 
> `ExceptionAnalyzer`.
I am not opposed to that, but I think in that case we want this method to be 
used in the regular compilation pipeline to make sure it is correct. 


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

https://reviews.llvm.org/D135495

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


[PATCH] D141871: [Clang][OpenMP] Add parse and sema for iterator map modifier

2023-01-16 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
doru1004 created this revision.
doru1004 added reviewers: jdoerfert, ABataev, carlo.bertolli, ronl, 
gregrodgers, jhuber6.
doru1004 added a project: OpenMP.
Herald added subscribers: guansong, yaxunl.
Herald added a project: All.
doru1004 requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

This patch adds parse and sema support for iterator map modifier.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141871

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/OpenMPKinds.def
  clang/include/clang/Basic/OpenMPKinds.h
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/target_ast_print.cpp

Index: clang/test/OpenMP/target_ast_print.cpp
===
--- clang/test/OpenMP/target_ast_print.cpp
+++ clang/test/OpenMP/target_ast_print.cpp
@@ -1139,6 +1139,60 @@
 }
 #endif // OMP51
 
+#ifdef OMP52
+
+///==///
+// RUN: %clang_cc1 -DOMP52 -verify -fopenmp -fopenmp-version=52 -ast-print %s | FileCheck %s --check-prefix OMP52
+// RUN: %clang_cc1 -DOMP52 -fopenmp -fopenmp-version=52 -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -DOMP52 -fopenmp -fopenmp-version=52 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s --check-prefix OMP52
+
+// RUN: %clang_cc1 -DOMP52 -verify -fopenmp-simd -fopenmp-version=52 -ast-print %s | FileCheck %s --check-prefix OMP52
+// RUN: %clang_cc1 -DOMP52 -fopenmp-simd -fopenmp-version=52 -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -DOMP52 -fopenmp-simd -fopenmp-version=52 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s --check-prefix OMP52
+
+void foo() {}
+
+template 
+T tmain(T argc, T *argv) {
+  int N = 100;
+  int v[N];
+  #pragma omp target map(iterator(it = 0:N:2), to: v[it])
+  foo();
+  #pragma omp target map(iterator(it = 0:N:4), from: v[it])
+  foo();
+
+  return 0;
+}
+
+// OMP52: template  T tmain(T argc, T *argv) {
+// OMP52-NEXT: int N = 100;
+// OMP52-NEXT: int v[N];
+// OMP52-NEXT: #pragma omp target map(iterator(int it = 0:N:2),to: v[it])
+// OMP52-NEXT: foo()
+// OMP52-NEXT: #pragma omp target map(iterator(int it = 0:N:4),from: v[it])
+// OMP52-NEXT: foo()
+
+// OMP52-LABEL: int main(int argc, char **argv) {
+int main (int argc, char **argv) {
+  int i, j, a[20], always, close;
+// OMP52-NEXT: int i, j, a[20]
+#pragma omp target
+// OMP52-NEXT: #pragma omp target
+  foo();
+// OMP52-NEXT: foo();
+#pragma omp target map(iterator(it = 0:20:2), to: a[it])
+// OMP52-NEXT: #pragma omp target map(iterator(int it = 0:20:2),to: a[it])
+  foo();
+// OMP52-NEXT: foo();
+#pragma omp target map(iterator(it = 0:20:4), from: a[it])
+// OMP52-NEXT: #pragma omp target map(iterator(int it = 0:20:4),from: a[it])
+foo();
+// OMP52-NEXT: foo();
+
+  return tmain(argc, ) + tmain(argv[0][0], argv[0]);
+}
+#endif // OMP52
+
 #ifdef OMPX
 
 // RUN: %clang_cc1 -DOMPX -verify -fopenmp -fopenmp-extensions -ast-print %s | FileCheck %s --check-prefix=OMPX
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -6792,6 +6792,8 @@
   for (unsigned I = 0; I < NumberOfOMPMapClauseModifiers; ++I) {
 Record.push_back(C->getMapTypeModifier(I));
 Record.AddSourceLocation(C->getMapTypeModifierLoc(I));
+if (C->getMapTypeModifier(I) == OMPC_MAP_MODIFIER_iterator)
+  Record.AddStmt(C->getIteratorModifier());
   }
   Record.AddNestedNameSpecifierLoc(C->getMapperQualifierLoc());
   Record.AddDeclarationNameInfo(C->getMapperIdInfo());
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -10773,6 +10773,8 @@
 C->setMapTypeModifier(
 I, static_cast(Record.readInt()));
 C->setMapTypeModifierLoc(I, Record.readSourceLocation());
+if (C->getMapTypeModifier(I) == OMPC_MAP_MODIFIER_iterator)
+  C->setIteratorModifier(Record.readSubExpr());
   }
   C->setMapperQualifierLoc(Record.readNestedNameSpecifierLoc());
   C->setMapperIdInfo(Record.readDeclarationNameInfo());
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -1988,15 +1988,16 @@
   

[PATCH] D135495: [clang-tidy] handle pointers in `ExceptionAnalyzer`

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



Comment at: clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp:95
+
+  if (P1->isArrayType() && P2->isArrayType()) {
+// At every level that array type is involved in, at least

xazax.hun wrote:
> isuckatcs wrote:
> > xazax.hun wrote:
> > > If none of the functions I recommended works for you, I still strongly 
> > > suggest reusing utilities from ASTContext, like `UnwrapSimilarTypes` and 
> > > `UnwrapSimilarArrayTypes`.
> > I didn't check all of the functions inside `ASTContext`, but here we have 
> > very specific rules, we need to check. One utility might help with one 
> > check or two, but won't replace the need to go ove all of them. Also I 
> > think it's easier to understand which section checks what, if I keep them 
> > separated.
> > 
> > In an ealier comment I link to [[ 
> > https://en.cppreference.com/w/cpp/language/implicit_conversion#Qualification_conversions
> >  | the section on cppreference ]], which discusses what these rules are. 
> > Also there I found one controversial example, that's only detected by MSVC. 
> > I wonder if you know why that happens.
> I see. It is unfortunate that we cannot simply reuse the corresponding 
> functionality from Sema. The code mostly looks good to me, apart from some 
> nits.
> It is unfortunate that we cannot simply reuse the corresponding functionality 
> from Sema.

It is indeed unfortunate, though I wonder if we want to move this functionality 
to `ASTContext`, so that it can be reused outside the `ExceptionAnalyzer`.


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

https://reviews.llvm.org/D135495

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


[PATCH] D135495: [clang-tidy] handle pointers in `ExceptionAnalyzer`

2023-01-16 Thread Domján Dániel via Phabricator via cfe-commits
isuckatcs updated this revision to Diff 489626.
isuckatcs marked 7 inline comments as done.
isuckatcs added a comment.

Addressed comments


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

https://reviews.llvm.org/D135495

Files:
  clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
  clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h
  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
@@ -101,6 +101,126 @@
   }
 }
 
+void throw_catch_pointer_c() noexcept {
+  try {
+int a = 1;
+throw 
+  } catch(const int *) {}
+}
+
+void throw_catch_pointer_v() noexcept {
+  try {
+int a = 1;
+throw 
+  } catch(volatile int *) {}
+}
+
+void throw_catch_pointer_cv() noexcept {
+  try {
+int a = 1;
+throw 
+  } catch(const volatile int *) {}
+}
+
+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
+  try {
+char **p = 0;
+throw p;
+  } catch (const char **) {
+  }
+}
+
+void throw_catch_multi_ptr_2() noexcept {
+  try {
+char **p = 0;
+throw p;
+  } catch (const char *const *) {
+  }
+}
+
+void throw_catch_multi_ptr_3() noexcept {
+  try {
+char **p = 0;
+throw p;
+  } catch (volatile char *const *) {
+  }
+}
+
+void throw_catch_multi_ptr_4() noexcept {
+  try {
+char **p = 0;
+throw p;
+  } catch (volatile const char *const *) {
+  }
+}
+
+// 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 
+// this either.
+void throw_catch_multi_ptr_5() noexcept {
+  try {
+double *a[2][3];
+throw a;
+  } catch (double *(*)[3]) {
+  }
+}
+
+
+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
+  try {
+int a = 1;
+const int *p = 
+throw p;
+  } catch(int *) {}
+}
+
+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
+  try {
+int a = 1;
+const int *p = 
+throw p;
+  } catch(volatile int *) {}
+}
+
+void throw_v_catch_pointer() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_v_catch_pointer' which should not throw exceptions
+  try {
+int a = 1;
+volatile int *p = 
+throw p;
+  } catch(int *) {}
+}
+
+void throw_v_catch_pointer_c() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_v_catch_pointer_c' which should not throw exceptions
+  try {
+int a = 1;
+volatile int *p = 
+throw p;
+  } catch(const int *) {}
+}
+
+void throw_cv_catch_pointer_c() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_cv_catch_pointer_c' which should not throw exceptions
+  try {
+int a = 1;
+const volatile int *p = 
+throw p;
+  } catch(const int *) {}
+}
+
+void throw_cv_catch_pointer_v() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_cv_catch_pointer_v' which should not throw exceptions
+  try {
+int a = 1;
+const volatile int *p = 
+throw p;
+  } catch(volatile int *) {}
+}
+
 class base {};
 class derived: public base {};
 
@@ -112,6 +232,24 @@
   }
 }
 
+void throw_derived_catch_base_ptr_c() noexcept {
+  try {
+derived d;
+throw  
+  } catch(const base *) {
+  }
+}
+
+void throw_derived_catch_base_ptr() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_derived_catch_base_ptr' which should not throw exceptions
+  try {
+derived d;
+const derived *p = 
+throw p; 
+  } catch(base *) {
+  }
+}
+
 void try_nested_try(int n) noexcept {
   // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'try_nested_try' which should not throw exceptions
   try {
Index: clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h
===
--- clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h
+++ clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h
@@ -80,7 +80,7 @@
 /// possible to catch multiple exception types by one 'catch' if they
 /// are a subclass of the 'catch'ed exception type.
 /// Returns 'true' if some exceptions were filtered, otherwise 'false'.
-bool filterByCatch(const Type 

[PATCH] D141528: [Clang][OpenMP] Fix loop directive nested inside a parallel

2023-01-16 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
doru1004 added a comment.

ping


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

https://reviews.llvm.org/D141528

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


[PATCH] D141862: [clang][driver][AIX] Add OpenMP runtime if -fopenmp specified

2023-01-16 Thread David Tenty via Phabricator via cfe-commits
daltenty added a comment.

Needs a test, I think we should add a couple of `-fopenmp=foo` run lines to 
`clang/test/Driver/aix-ld.c` to verify that the correct linker options are 
produced for each.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141862

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


[PATCH] D140628: [flang] Add driver install directory to AIX toolchain program paths list

2023-01-16 Thread Paul Scoropan via Phabricator via cfe-commits
pscoro added a comment.
Herald added a subscriber: sunshaoce.

Ping.

This is a needed fix for AIX, the code is trivial and used similarly on other 
targets.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140628

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


[PATCH] D141868: [Clang] [Sema] Removed a fix-it for system headers

2023-01-16 Thread Fahad Nayyar via Phabricator via cfe-commits
fahadnayyar created this revision.
Herald added a subscriber: arphaman.
Herald added a project: All.
fahadnayyar requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Disabled an invalid fix-it which suggested fixes to be applied in system 
headers for some programs in IDEs like Xcode.

rdar://100890960


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141868

Files:
  clang/lib/Sema/SemaOverload.cpp
  clang/test/Index/fixit-sys-header.h
  clang/test/Index/fixit-sysheader-test.cpp
  clang/test/Index/fixit-user-header.h


Index: clang/test/Index/fixit-user-header.h
===
--- /dev/null
+++ clang/test/Index/fixit-user-header.h
@@ -0,0 +1,4 @@
+int func_in_user_header(char * s, unsigned long len)
+{
+return 0;
+}
Index: clang/test/Index/fixit-sysheader-test.cpp
===
--- /dev/null
+++ clang/test/Index/fixit-sysheader-test.cpp
@@ -0,0 +1,21 @@
+// RUN: c-index-test -test-load-source all %s 2>&1 | FileCheck %s
+
+#include "fixit-sys-header.h"
+#include "fixit-user-header.h"
+
+int main(int argc, char const *argv[])
+{
+char* str;{};
+
+func_in_sys_header(str, str + 10);
+// CHECK: Number FIX-ITs = 0
+// CHECK-NEXT: candidate function not viable: no known conversion from 
'char *' to 'unsigned long' for 2nd argument; dereference the argument with *
+// CHECK-NEXT: Number FIX-ITs = 0
+
+func_in_user_header(str, str + 10);
+// CHECK: Number FIX-ITs = 0
+// CHECK-NEXT: candidate function not viable: no known conversion from 
'char *' to 'unsigned long' for 2nd argument; dereference the argument with *
+// CHECK-NEXT: Number FIX-ITs = 2
+
+return 0;
+}
Index: clang/test/Index/fixit-sys-header.h
===
--- /dev/null
+++ clang/test/Index/fixit-sys-header.h
@@ -0,0 +1,6 @@
+#pragma clang system_header
+
+int func_in_sys_header(char * s, unsigned long len)
+{
+return 0;
+}
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -10917,10 +10917,15 @@
 << ToTy << (unsigned)isObjectArgument << I + 1
 << (unsigned)(Cand->Fix.Kind);
 
-  // If we can fix the conversion, suggest the FixIts.
-  for (std::vector::iterator HI = Cand->Fix.Hints.begin(),
-   HE = Cand->Fix.Hints.end(); HI != HE; ++HI)
-FDiag << *HI;
+  // Check that location of Fn is not in system header (rdar://100890960).
+  if (!S.SourceMgr.isInSystemHeader(Fn->getLocation())) {
+// If we can fix the conversion, suggest the FixIts.
+for (std::vector::iterator HI = Cand->Fix.Hints.begin(),
+  HE = Cand->Fix.Hints.end();
+ HI != HE; ++HI)
+FDiag << *HI;
+  }
+
   S.Diag(Fn->getLocation(), FDiag);
 
   MaybeEmitInheritedConstructorNote(S, Cand->FoundDecl);


Index: clang/test/Index/fixit-user-header.h
===
--- /dev/null
+++ clang/test/Index/fixit-user-header.h
@@ -0,0 +1,4 @@
+int func_in_user_header(char * s, unsigned long len)
+{
+return 0;
+}
Index: clang/test/Index/fixit-sysheader-test.cpp
===
--- /dev/null
+++ clang/test/Index/fixit-sysheader-test.cpp
@@ -0,0 +1,21 @@
+// RUN: c-index-test -test-load-source all %s 2>&1 | FileCheck %s
+
+#include "fixit-sys-header.h"
+#include "fixit-user-header.h"
+
+int main(int argc, char const *argv[])
+{
+char* str;{};
+
+func_in_sys_header(str, str + 10);
+// CHECK: Number FIX-ITs = 0
+// CHECK-NEXT: candidate function not viable: no known conversion from 'char *' to 'unsigned long' for 2nd argument; dereference the argument with *
+// CHECK-NEXT: Number FIX-ITs = 0
+
+func_in_user_header(str, str + 10);
+// CHECK: Number FIX-ITs = 0
+// CHECK-NEXT: candidate function not viable: no known conversion from 'char *' to 'unsigned long' for 2nd argument; dereference the argument with *
+// CHECK-NEXT: Number FIX-ITs = 2
+
+return 0;
+}
Index: clang/test/Index/fixit-sys-header.h
===
--- /dev/null
+++ clang/test/Index/fixit-sys-header.h
@@ -0,0 +1,6 @@
+#pragma clang system_header
+
+int func_in_sys_header(char * s, unsigned long len)
+{
+return 0;
+}
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -10917,10 +10917,15 @@
 << ToTy << (unsigned)isObjectArgument << I + 1
 << (unsigned)(Cand->Fix.Kind);
 
-  // If we can fix the conversion, suggest the FixIts.
-  for (std::vector::iterator HI = Cand->Fix.Hints.begin(),
-   

[PATCH] D139926: [clangd] Add semantic tokens for angle brackets

2023-01-16 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

Sorry, that was a bad example as it's not actually valid. Here's a slightly 
modified one:

  template 
  class a {};
  
  constexpr int b = 2;
  constexpr int c = 3;
  constexpr int d = 4;
  
  a e;

The parser knows the first `<` opens a template-param-list because the name 
before it, `a`, resolves to a template-name, and that the second `<` is a 
comparison operator because the name before //that//, `b`, does not.

But a native client-side matcher might incorrectly pick the second `<` as the 
opening angle-bracket to match the `>`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139926

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


[PATCH] D139926: [clangd] Add semantic tokens for angle brackets

2023-01-16 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

In D139926#4056478 , @kadircet wrote:

> This will only make sure we have a distinction between `<<` and `>>` used as 
> operators vs `<`/`>`

Note that `<<` and `>>` are not the only (or even the primary, in my mind) 
issue: there is an ambiguity between `<`/`>` as template argument list 
delimiters vs. comparison operators.

For example:

  template 
  class a {};
  
  constexpr int b = 2;
  constexpr int c = 3;
  
  ac> e;

Here, if the cursor is next to the `<`, a naive client-side angle-bracket 
matcher might highlight the first `>`, when the correct one to highlight would 
be the second one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139926

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


[PATCH] D141192: [Clang] Fix warnings on bad shifts.

2023-01-16 Thread Dmitriy Chestnykh via Phabricator via cfe-commits
chestnykh added a comment.

Ping


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

https://reviews.llvm.org/D141192

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


[PATCH] D141861: [nvptx-arch] Dynamically load the CUDA runtime if not found during the build

2023-01-16 Thread Joseph Huber 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 rG9954516ffb10: [nvptx-arch] Dynamically load the CUDA runtime 
if not found during the build (authored by jhuber6).

Changed prior to commit:
  https://reviews.llvm.org/D141861?vs=489585=489609#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141861

Files:
  clang/tools/nvptx-arch/CMakeLists.txt
  clang/tools/nvptx-arch/NVPTXArch.cpp

Index: clang/tools/nvptx-arch/NVPTXArch.cpp
===
--- clang/tools/nvptx-arch/NVPTXArch.cpp
+++ clang/tools/nvptx-arch/NVPTXArch.cpp
@@ -11,6 +11,12 @@
 //
 //===--===//
 
+#include "llvm/Support/DynamicLibrary.h"
+#include "llvm/Support/Error.h"
+#include 
+#include 
+#include 
+
 #if defined(__has_include)
 #if __has_include("cuda.h")
 #include "cuda.h"
@@ -23,11 +29,53 @@
 #endif
 
 #if !CUDA_HEADER_FOUND
-int main() { return 1; }
-#else
+typedef enum cudaError_enum {
+  CUDA_SUCCESS = 0,
+  CUDA_ERROR_NO_DEVICE = 100,
+} CUresult;
 
-#include 
-#include 
+typedef enum CUdevice_attribute_enum {
+  CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR = 75,
+  CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR = 76,
+} CUdevice_attribute;
+
+typedef uint32_t CUdevice;
+
+CUresult (*cuInit)(unsigned int);
+CUresult (*cuDeviceGetCount)(int *);
+CUresult (*cuGetErrorString)(CUresult, const char **);
+CUresult (*cuDeviceGet)(CUdevice *, int);
+CUresult (*cuDeviceGetAttribute)(int *, CUdevice_attribute, CUdevice);
+
+constexpr const char *DynamicCudaPath = "libcuda.so";
+
+llvm::Error loadCUDA() {
+  std::string ErrMsg;
+  auto DynlibHandle = std::make_unique(
+  llvm::sys::DynamicLibrary::getPermanentLibrary(DynamicCudaPath, ));
+  if (!DynlibHandle->isValid()) {
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "Failed to 'dlopen' %s\n", DynamicCudaPath);
+  }
+#define DYNAMIC_INIT(SYMBOL)   \
+  {\
+void *SymbolPtr = DynlibHandle->getAddressOfSymbol(#SYMBOL);   \
+if (!SymbolPtr)\
+  return llvm::createStringError(llvm::inconvertibleErrorCode(),   \
+ "Failed to 'dlsym' " #SYMBOL);\
+SYMBOL = reinterpret_cast(SymbolPtr);\
+  }
+  DYNAMIC_INIT(cuInit);
+  DYNAMIC_INIT(cuDeviceGetCount);
+  DYNAMIC_INIT(cuGetErrorString);
+  DYNAMIC_INIT(cuDeviceGet);
+  DYNAMIC_INIT(cuDeviceGetAttribute);
+#undef DYNAMIC_INIT
+  return llvm::Error::success();
+}
+#else
+llvm::Error loadCUDA() { return llvm::Error::success(); }
+#endif
 
 static int handleError(CUresult Err) {
   const char *ErrStr = nullptr;
@@ -38,7 +86,13 @@
   return EXIT_FAILURE;
 }
 
-int main() {
+int main(int argc, char *argv[]) {
+  // Attempt to load the NVPTX driver runtime.
+  if (llvm::Error Err = loadCUDA()) {
+logAllUnhandledErrors(std::move(Err), llvm::errs());
+return EXIT_FAILURE;
+  }
+
   if (CUresult Err = cuInit(0)) {
 if (Err == CUDA_ERROR_NO_DEVICE)
   return EXIT_SUCCESS;
@@ -68,5 +122,3 @@
   }
   return EXIT_SUCCESS;
 }
-
-#endif
Index: clang/tools/nvptx-arch/CMakeLists.txt
===
--- clang/tools/nvptx-arch/CMakeLists.txt
+++ clang/tools/nvptx-arch/CMakeLists.txt
@@ -6,6 +6,8 @@
 # //
 # //======//
 
+set(LLVM_LINK_COMPONENTS Support)
+add_clang_tool(nvptx-arch NVPTXArch.cpp)
 
 # TODO: This is deprecated. Since CMake 3.17 we can use FindCUDAToolkit instead.
 find_package(CUDA QUIET)
@@ -15,14 +17,8 @@
   find_library(cuda-library NAMES cuda HINTS "${CUDA_LIBDIR}/stubs")
 endif()
 
-if (NOT CUDA_FOUND OR NOT cuda-library)
-  message(STATUS "Not building nvptx-arch: cuda runtime not found")
-  return()
+# If we found the CUDA library directly we just dynamically link against it.
+if (CUDA_FOUND AND cuda-library)
+  target_include_directories(nvptx-arch PRIVATE ${CUDA_INCLUDE_DIRS})
+  target_link_libraries(nvptx-arch PRIVATE ${cuda-library})
 endif()
-
-add_clang_tool(nvptx-arch NVPTXArch.cpp)
-
-set_target_properties(nvptx-arch PROPERTIES INSTALL_RPATH_USE_LINK_PATH ON)
-target_include_directories(nvptx-arch PRIVATE ${CUDA_INCLUDE_DIRS})
-
-target_link_libraries(nvptx-arch PRIVATE ${cuda-library})
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141859: [amdgpu-arch] Dynamically load the HSA runtime if not found during the build

2023-01-16 Thread Joseph Huber 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 rGf6ace23172e5: [amdgpu-arch] Dynamically load the HSA runtime 
if not found during the build (authored by jhuber6).

Changed prior to commit:
  https://reviews.llvm.org/D141859?vs=489580=489608#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141859

Files:
  clang/tools/amdgpu-arch/AMDGPUArch.cpp
  clang/tools/amdgpu-arch/CMakeLists.txt

Index: clang/tools/amdgpu-arch/CMakeLists.txt
===
--- clang/tools/amdgpu-arch/CMakeLists.txt
+++ clang/tools/amdgpu-arch/CMakeLists.txt
@@ -6,14 +6,13 @@
 # //
 # //===--===//
 
-find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/rocm)
-if (NOT ${hsa-runtime64_FOUND})
-  message(STATUS "Not building amdgpu-arch: hsa-runtime64 not found")
-  return()
-endif()
+set(LLVM_LINK_COMPONENTS Support)
 
 add_clang_tool(amdgpu-arch AMDGPUArch.cpp)
 
-set_target_properties(amdgpu-arch PROPERTIES INSTALL_RPATH_USE_LINK_PATH ON)
-
-clang_target_link_libraries(amdgpu-arch PRIVATE hsa-runtime64::hsa-runtime64)
+# If we find the HSA runtime we link with it directly.
+find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/rocm)
+if (${hsa-runtime64_FOUND})
+  set_target_properties(amdgpu-arch PROPERTIES INSTALL_RPATH_USE_LINK_PATH ON)
+  clang_target_link_libraries(amdgpu-arch PRIVATE hsa-runtime64::hsa-runtime64)
+endif()
Index: clang/tools/amdgpu-arch/AMDGPUArch.cpp
===
--- clang/tools/amdgpu-arch/AMDGPUArch.cpp
+++ clang/tools/amdgpu-arch/AMDGPUArch.cpp
@@ -11,6 +11,12 @@
 //
 //===--===//
 
+#include "llvm/Support/DynamicLibrary.h"
+#include "llvm/Support/Error.h"
+#include 
+#include 
+#include 
+
 #if defined(__has_include)
 #if __has_include("hsa/hsa.h")
 #define HSA_HEADER_FOUND 1
@@ -26,11 +32,62 @@
 #endif
 
 #if !HSA_HEADER_FOUND
-int main() { return 1; }
-#else
+// Forward declaration of the status enumeration used by HSA.
+typedef enum {
+  HSA_STATUS_SUCCESS = 0x0,
+} hsa_status_t;
 
-#include 
-#include 
+// Forward declaration of the device types used by HSA.
+typedef enum {
+  HSA_DEVICE_TYPE_CPU = 0,
+  HSA_DEVICE_TYPE_GPU = 1,
+} hsa_device_type_t;
+
+// Forward declaration of the agent information types we use.
+typedef enum {
+  HSA_AGENT_INFO_NAME = 0,
+  HSA_AGENT_INFO_DEVICE = 17,
+} hsa_agent_info_t;
+
+typedef struct hsa_agent_s {
+  uint64_t handle;
+} hsa_agent_t;
+
+hsa_status_t (*hsa_init)();
+hsa_status_t (*hsa_shut_down)();
+hsa_status_t (*hsa_agent_get_info)(hsa_agent_t, hsa_agent_info_t, void *);
+hsa_status_t (*hsa_iterate_agents)(hsa_status_t (*callback)(hsa_agent_t,
+void *),
+   void *);
+
+constexpr const char *DynamicHSAPath = "libhsa-runtime64.so";
+
+llvm::Error loadHSA() {
+  std::string ErrMsg;
+  auto DynlibHandle = std::make_unique(
+  llvm::sys::DynamicLibrary::getPermanentLibrary(DynamicHSAPath, ));
+  if (!DynlibHandle->isValid()) {
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "Failed to 'dlopen' %s\n", DynamicHSAPath);
+  }
+#define DYNAMIC_INIT(SYMBOL)   \
+  {\
+void *SymbolPtr = DynlibHandle->getAddressOfSymbol(#SYMBOL);   \
+if (!SymbolPtr)\
+  return llvm::createStringError(llvm::inconvertibleErrorCode(),   \
+ "Failed to 'dlsym' " #SYMBOL);\
+SYMBOL = reinterpret_cast(SymbolPtr);\
+  }
+  DYNAMIC_INIT(hsa_init);
+  DYNAMIC_INIT(hsa_shut_down);
+  DYNAMIC_INIT(hsa_agent_get_info);
+  DYNAMIC_INIT(hsa_iterate_agents);
+#undef DYNAMIC_INIT
+  return llvm::Error::success();
+}
+#else
+llvm::Error loadHSA() { return llvm::Error::success(); }
+#endif
 
 static hsa_status_t iterateAgentsCallback(hsa_agent_t Agent, void *Data) {
   hsa_device_type_t DeviceType;
@@ -53,7 +110,13 @@
   return HSA_STATUS_SUCCESS;
 }
 
-int main() {
+int main(int argc, char *argv[]) {
+  // Attempt to load the HSA runtime.
+  if (llvm::Error Err = loadHSA()) {
+logAllUnhandledErrors(std::move(Err), llvm::errs());
+return 1;
+  }
+
   hsa_status_t Status = hsa_init();
   if (Status != HSA_STATUS_SUCCESS) {
 return 1;
@@ -74,5 +137,3 @@
   hsa_shut_down();
   return 0;
 }
-
-#endif
___
cfe-commits mailing list

[clang] 9954516 - [nvptx-arch] Dynamically load the CUDA runtime if not found during the build

2023-01-16 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2023-01-16T13:13:47-06:00
New Revision: 9954516ffb10a39ae0c8517f4865eec24e07d56e

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

LOG: [nvptx-arch] Dynamically load the CUDA runtime if not found during the 
build

Much like the changes in D141859, this patch allows the `nvptx-arch`
tool to be built and provided with every distrubition of LLVM / Clang.
This will make it more reliable for our toolchains to depend on. The
changes here configure a version that dynamically loads CUDA if it was
not found at build time.

Reviewed By: tianshilei1992

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

Added: 


Modified: 
clang/tools/nvptx-arch/CMakeLists.txt
clang/tools/nvptx-arch/NVPTXArch.cpp

Removed: 




diff  --git a/clang/tools/nvptx-arch/CMakeLists.txt 
b/clang/tools/nvptx-arch/CMakeLists.txt
index 94f544a01f0e6..1b6362c8f1951 100644
--- a/clang/tools/nvptx-arch/CMakeLists.txt
+++ b/clang/tools/nvptx-arch/CMakeLists.txt
@@ -6,6 +6,8 @@
 # //
 # 
//======//
 
+set(LLVM_LINK_COMPONENTS Support)
+add_clang_tool(nvptx-arch NVPTXArch.cpp)
 
 # TODO: This is deprecated. Since CMake 3.17 we can use FindCUDAToolkit 
instead.
 find_package(CUDA QUIET)
@@ -15,14 +17,8 @@ if (NOT cuda-library AND CUDA_FOUND)
   find_library(cuda-library NAMES cuda HINTS "${CUDA_LIBDIR}/stubs")
 endif()
 
-if (NOT CUDA_FOUND OR NOT cuda-library)
-  message(STATUS "Not building nvptx-arch: cuda runtime not found")
-  return()
+# If we found the CUDA library directly we just dynamically link against it.
+if (CUDA_FOUND AND cuda-library)
+  target_include_directories(nvptx-arch PRIVATE ${CUDA_INCLUDE_DIRS})
+  target_link_libraries(nvptx-arch PRIVATE ${cuda-library})
 endif()
-
-add_clang_tool(nvptx-arch NVPTXArch.cpp)
-
-set_target_properties(nvptx-arch PROPERTIES INSTALL_RPATH_USE_LINK_PATH ON)
-target_include_directories(nvptx-arch PRIVATE ${CUDA_INCLUDE_DIRS})
-
-target_link_libraries(nvptx-arch PRIVATE ${cuda-library})

diff  --git a/clang/tools/nvptx-arch/NVPTXArch.cpp 
b/clang/tools/nvptx-arch/NVPTXArch.cpp
index f70acf9a9f5b3..acde975a34dc4 100644
--- a/clang/tools/nvptx-arch/NVPTXArch.cpp
+++ b/clang/tools/nvptx-arch/NVPTXArch.cpp
@@ -11,6 +11,12 @@
 //
 
//===--===//
 
+#include "llvm/Support/DynamicLibrary.h"
+#include "llvm/Support/Error.h"
+#include 
+#include 
+#include 
+
 #if defined(__has_include)
 #if __has_include("cuda.h")
 #include "cuda.h"
@@ -23,11 +29,53 @@
 #endif
 
 #if !CUDA_HEADER_FOUND
-int main() { return 1; }
-#else
+typedef enum cudaError_enum {
+  CUDA_SUCCESS = 0,
+  CUDA_ERROR_NO_DEVICE = 100,
+} CUresult;
 
-#include 
-#include 
+typedef enum CUdevice_attribute_enum {
+  CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR = 75,
+  CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR = 76,
+} CUdevice_attribute;
+
+typedef uint32_t CUdevice;
+
+CUresult (*cuInit)(unsigned int);
+CUresult (*cuDeviceGetCount)(int *);
+CUresult (*cuGetErrorString)(CUresult, const char **);
+CUresult (*cuDeviceGet)(CUdevice *, int);
+CUresult (*cuDeviceGetAttribute)(int *, CUdevice_attribute, CUdevice);
+
+constexpr const char *DynamicCudaPath = "libcuda.so";
+
+llvm::Error loadCUDA() {
+  std::string ErrMsg;
+  auto DynlibHandle = std::make_unique(
+  llvm::sys::DynamicLibrary::getPermanentLibrary(DynamicCudaPath, 
));
+  if (!DynlibHandle->isValid()) {
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "Failed to 'dlopen' %s\n", DynamicCudaPath);
+  }
+#define DYNAMIC_INIT(SYMBOL)   
\
+  {
\
+void *SymbolPtr = DynlibHandle->getAddressOfSymbol(#SYMBOL);   
\
+if (!SymbolPtr)
\
+  return llvm::createStringError(llvm::inconvertibleErrorCode(),   
\
+ "Failed to 'dlsym' " #SYMBOL);
\
+SYMBOL = reinterpret_cast(SymbolPtr);
\
+  }
+  DYNAMIC_INIT(cuInit);
+  DYNAMIC_INIT(cuDeviceGetCount);
+  DYNAMIC_INIT(cuGetErrorString);
+  DYNAMIC_INIT(cuDeviceGet);
+  DYNAMIC_INIT(cuDeviceGetAttribute);
+#undef DYNAMIC_INIT
+  return llvm::Error::success();
+}
+#else
+llvm::Error loadCUDA() { return llvm::Error::success(); }
+#endif
 
 static int handleError(CUresult Err) {
   const char *ErrStr = nullptr;
@@ -38,7 +86,13 @@ static int handleError(CUresult Err) {
   return EXIT_FAILURE;
 }
 
-int main() {
+int main(int argc, char *argv[]) {
+  // Attempt to load the NVPTX driver runtime.
+  if (llvm::Error Err = 

[clang] f6ace23 - [amdgpu-arch] Dynamically load the HSA runtime if not found during the build

2023-01-16 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2023-01-16T13:13:45-06:00
New Revision: f6ace23172e5930be0e7cc602f50e1e9c54d7a9a

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

LOG: [amdgpu-arch] Dynamically load the HSA runtime if not found during the 
build

We use the `amdgpu-arch` tool to query the installed GPUs at runtime.
One problem is that this tool is currently not build if the person
building the LLVM binary does not have the HSA runtime on their system.
This means that if someone built and distrubted an installation of LLVM
without HSA, then the user will not be able to use it even if they have
it on their system.

This patch makes us build this tool unconditionally and adds extra logic
to dynamically load HSA if it's present.

Reviewed By: JonChesterfield

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

Added: 


Modified: 
clang/tools/amdgpu-arch/AMDGPUArch.cpp
clang/tools/amdgpu-arch/CMakeLists.txt

Removed: 




diff  --git a/clang/tools/amdgpu-arch/AMDGPUArch.cpp 
b/clang/tools/amdgpu-arch/AMDGPUArch.cpp
index 8398f6e81a229..caf8562c4e9dc 100644
--- a/clang/tools/amdgpu-arch/AMDGPUArch.cpp
+++ b/clang/tools/amdgpu-arch/AMDGPUArch.cpp
@@ -11,6 +11,12 @@
 //
 
//===--===//
 
+#include "llvm/Support/DynamicLibrary.h"
+#include "llvm/Support/Error.h"
+#include 
+#include 
+#include 
+
 #if defined(__has_include)
 #if __has_include("hsa/hsa.h")
 #define HSA_HEADER_FOUND 1
@@ -26,11 +32,62 @@
 #endif
 
 #if !HSA_HEADER_FOUND
-int main() { return 1; }
-#else
+// Forward declaration of the status enumeration used by HSA.
+typedef enum {
+  HSA_STATUS_SUCCESS = 0x0,
+} hsa_status_t;
 
-#include 
-#include 
+// Forward declaration of the device types used by HSA.
+typedef enum {
+  HSA_DEVICE_TYPE_CPU = 0,
+  HSA_DEVICE_TYPE_GPU = 1,
+} hsa_device_type_t;
+
+// Forward declaration of the agent information types we use.
+typedef enum {
+  HSA_AGENT_INFO_NAME = 0,
+  HSA_AGENT_INFO_DEVICE = 17,
+} hsa_agent_info_t;
+
+typedef struct hsa_agent_s {
+  uint64_t handle;
+} hsa_agent_t;
+
+hsa_status_t (*hsa_init)();
+hsa_status_t (*hsa_shut_down)();
+hsa_status_t (*hsa_agent_get_info)(hsa_agent_t, hsa_agent_info_t, void *);
+hsa_status_t (*hsa_iterate_agents)(hsa_status_t (*callback)(hsa_agent_t,
+void *),
+   void *);
+
+constexpr const char *DynamicHSAPath = "libhsa-runtime64.so";
+
+llvm::Error loadHSA() {
+  std::string ErrMsg;
+  auto DynlibHandle = std::make_unique(
+  llvm::sys::DynamicLibrary::getPermanentLibrary(DynamicHSAPath, ));
+  if (!DynlibHandle->isValid()) {
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "Failed to 'dlopen' %s\n", DynamicHSAPath);
+  }
+#define DYNAMIC_INIT(SYMBOL)   
\
+  {
\
+void *SymbolPtr = DynlibHandle->getAddressOfSymbol(#SYMBOL);   
\
+if (!SymbolPtr)
\
+  return llvm::createStringError(llvm::inconvertibleErrorCode(),   
\
+ "Failed to 'dlsym' " #SYMBOL);
\
+SYMBOL = reinterpret_cast(SymbolPtr);
\
+  }
+  DYNAMIC_INIT(hsa_init);
+  DYNAMIC_INIT(hsa_shut_down);
+  DYNAMIC_INIT(hsa_agent_get_info);
+  DYNAMIC_INIT(hsa_iterate_agents);
+#undef DYNAMIC_INIT
+  return llvm::Error::success();
+}
+#else
+llvm::Error loadHSA() { return llvm::Error::success(); }
+#endif
 
 static hsa_status_t iterateAgentsCallback(hsa_agent_t Agent, void *Data) {
   hsa_device_type_t DeviceType;
@@ -53,7 +110,13 @@ static hsa_status_t iterateAgentsCallback(hsa_agent_t 
Agent, void *Data) {
   return HSA_STATUS_SUCCESS;
 }
 
-int main() {
+int main(int argc, char *argv[]) {
+  // Attempt to load the HSA runtime.
+  if (llvm::Error Err = loadHSA()) {
+logAllUnhandledErrors(std::move(Err), llvm::errs());
+return 1;
+  }
+
   hsa_status_t Status = hsa_init();
   if (Status != HSA_STATUS_SUCCESS) {
 return 1;
@@ -74,5 +137,3 @@ int main() {
   hsa_shut_down();
   return 0;
 }
-
-#endif

diff  --git a/clang/tools/amdgpu-arch/CMakeLists.txt 
b/clang/tools/amdgpu-arch/CMakeLists.txt
index caead440c5ccf..a5361e65758b1 100644
--- a/clang/tools/amdgpu-arch/CMakeLists.txt
+++ b/clang/tools/amdgpu-arch/CMakeLists.txt
@@ -6,14 +6,13 @@
 # //
 # 
//===--===//
 
-find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS 
/opt/rocm)
-if (NOT ${hsa-runtime64_FOUND})
-  message(STATUS "Not 

[PATCH] D141717: [Clang] Only emit textual LLVM-IR in device only mode

2023-01-16 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D141717#4056971 , @yaxunl wrote:

> The intention of -emit-llvm -S is usually to get LLVM assembly for all 
> targets for inspection or modification. HIP emits a bundled LLVM assembly in 
> textual format in this case. Users can modify it directly, or extract 
> assembly for each device and bundle them together again. The modified file 
> can then be passed on to the next compilation stage.

Yeah, this is part of where I'm questioning how we want to treat the 
compilation pipeline when we perform offloading. When I set up the new driver 
support I decided to eschew the idea of perfectly bundled phases and instead 
decided that if users did not want the full pipeline they should use 
`--offload-device-only` and built it for themselves. In that vein I'd prefer it 
to be where we always generate a full (To Assembler) phase and avoid textual 
formats since it's supposed to be embedded as a binary blob.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141717

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


[PATCH] D141717: [Clang] Only emit textual LLVM-IR in device only mode

2023-01-16 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

The intention of -emit-llvm -S is usually to get LLVM assembly for all targets 
for inspection or modification. HIP emits a bundled LLVM assembly in textual 
format in this case. Users can modify it directly, or extract assembly for each 
device and bundle them together again. The modified file can then be passed on 
to the next compilation stage.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141717

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


[PATCH] D141803: [Clang] Reject in-class defaulting of previously declared comparison operators

2023-01-16 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson updated this revision to Diff 489607.
royjacobson added a comment.

rebase on main


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141803

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
  clang/test/CXX/class/class.compare/class.compare.default/p2.cpp
  clang/test/CXX/class/class.compare/class.compare.default/p3.cpp

Index: clang/test/CXX/class/class.compare/class.compare.default/p3.cpp
===
--- clang/test/CXX/class/class.compare/class.compare.default/p3.cpp
+++ clang/test/CXX/class/class.compare/class.compare.default/p3.cpp
@@ -165,22 +165,22 @@
 // FIXME: This rule creates problems for reordering of declarations; is this
 // really the right model?
 struct G;
-bool operator==(const G&, const G&);
-bool operator!=(const G&, const G&);
-std::strong_ordering operator<=>(const G&, const G&);
-bool operator<(const G&, const G&);
-bool operator<=(const G&, const G&);
-bool operator>(const G&, const G&);
-bool operator>=(const G&, const G&);
+bool operator==(const G&, const G&); // expected-note {{previous declaration}}
+bool operator!=(const G&, const G&); // expected-note {{previous declaration}}
+std::strong_ordering operator<=>(const G&, const G&); // expected-note {{previous declaration}}
+bool operator<(const G&, const G&); // expected-note {{previous declaration}}
+bool operator<=(const G&, const G&); // expected-note {{previous declaration}}
+bool operator>(const G&, const G&); // expected-note {{previous declaration}}
+bool operator>=(const G&, const G&); // expected-note {{previous declaration}}
 struct G {
-  friend bool operator==(const G&, const G&) = default;
-  friend bool operator!=(const G&, const G&) = default;
-
-  friend std::strong_ordering operator<=>(const G&, const G&) = default;
-  friend bool operator<(const G&, const G&) = default;
-  friend bool operator<=(const G&, const G&) = default;
-  friend bool operator>(const G&, const G&) = default;
-  friend bool operator>=(const G&, const G&) = default;
+  friend bool operator==(const G&, const G&) = default; // expected-error {{because it was already declared outside}}
+  friend bool operator!=(const G&, const G&) = default; // expected-error {{because it was already declared outside}}
+
+  friend std::strong_ordering operator<=>(const G&, const G&) = default; // expected-error {{because it was already declared outside}}
+  friend bool operator<(const G&, const G&) = default; // expected-error {{because it was already declared outside}}
+  friend bool operator<=(const G&, const G&) = default; // expected-error {{because it was already declared outside}}
+  friend bool operator>(const G&, const G&) = default; // expected-error {{because it was already declared outside}}
+  friend bool operator>=(const G&, const G&) = default; // expected-error {{because it was already declared outside}}
 };
 bool operator==(const G&, const G&);
 bool operator!=(const G&, const G&);
Index: clang/test/CXX/class/class.compare/class.compare.default/p2.cpp
===
--- clang/test/CXX/class/class.compare/class.compare.default/p2.cpp
+++ clang/test/CXX/class/class.compare/class.compare.default/p2.cpp
@@ -139,13 +139,13 @@
 
 struct F;
 bool operator==(const F&, const F&);
-bool operator!=(const F&, const F&);
+bool operator!=(const F&, const F&); // expected-note {{previous declaration}}
 bool operator<=>(const F&, const F&);
-bool operator<(const F&, const F&);
+bool operator<(const F&, const F&); // expected-note {{previous declaration}}
 struct F {
   union { int a; };
   friend bool operator==(const F&, const F&) = default; // expected-error {{defaulting this equality comparison operator would delete it after its first declaration}} expected-note {{implicitly deleted because 'F' is a union-like class}}
-  friend bool operator!=(const F&, const F&) = default;
+  friend bool operator!=(const F&, const F&) = default; // expected-error {{because it was already declared outside}}
   friend bool operator<=>(const F&, const F&) = default; // expected-error {{defaulting this three-way comparison operator would delete it after its first declaration}} expected-note {{implicitly deleted because 'F' is a union-like class}}
-  friend bool operator<(const F&, const F&) = default;
+  friend bool operator<(const F&, const F&) = default; // expected-error {{because it was already declared outside}}
 };
Index: clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
===
--- clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
+++ clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
@@ -179,6 +179,12 @@
 struct S5;   

[PATCH] D136554: Implement CWG2631

2023-01-16 Thread Chris Bowler via Phabricator via cfe-commits
cebowleratibm added a comment.

In D136554#4056862 , @cor3ntin wrote:

> Yes please! However the warning looks correct to me in that case. A
> constructs x which constructs A etc.

https://github.com/llvm/llvm-project/issues/60082

Please set the project/labels as appropriate.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136554

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


[PATCH] D141572: [C++] [Coroutines] Deprecates the '-fcoroutines-ts' flag

2023-01-16 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik accepted this revision.
philnik added a comment.
This revision is now accepted and ready to land.

LGTM from the libc++ side of things % nit. I think @aaron.ballman should take 
another look at the Clang changes.




Comment at: libcxx/utils/generate_header_tests.py:22
 
+"coroutine": "(defined(__cpp_impl_coroutine) && __cpp_impl_coroutine >= 
201902L) || (defined(__cpp_coroutines) && __cpp_coroutines >= 201703L)",
+

A `TODO LLVM17: simplify this to __cplusplus >= 202002L` would be nice. 


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

https://reviews.llvm.org/D141572

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


[PATCH] D135495: [clang-tidy] handle pointers in `ExceptionAnalyzer`

2023-01-16 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

Also, could you open a bug report about the strange exception behavior on 
GitHub? Hopefully someone working on conformance can take a look.


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

https://reviews.llvm.org/D135495

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


[PATCH] D135495: [clang-tidy] handle pointers in `ExceptionAnalyzer`

2023-01-16 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp:60
+// Checks if T1 is convertible to T2.
+static bool isMultiLevelConvertiblePointer(QualType P1, QualType P2,
+   unsigned CurrentLevel = 0,

isuckatcs wrote:
> xazax.hun wrote:
> > xazax.hun wrote:
> > > Did you take a look at `ASTContext::hasCvrSimilarType`? I wonder if it is 
> > > already doing what you want. 
> > Oh, maybe it is not, but it might also make sense to take a look at 
> > `ASTContext::typesAreCompatible`.
> > Did you take a look at ASTContext::hasCvrSimilarType? I wonder if it is 
> > already doing what you want.
> 
> This function compares the types by removing the CVR qualifiers.
> 
> > Oh, maybe it is not, but it might also make sense to take a look at 
> > ASTContext::typesAreCompatible.
> 
> This one only compares the canonical types if the language is C++.
> 
> ```lang=c++
> if (getLangOpts().CPlusPlus)
> return hasSameType(LHS, RHS);
> 
> bool hasSameType(QualType T1, QualType T2) const {
> return getCanonicalType(T1) == getCanonicalType(T2);
>   }
> 
> ```
Could you rename the arguments like `To`, `From` or `Exception`, `Catch` or 
something to make the direction of the conversion clearer?



Comment at: clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp:95
+
+  if (P1->isArrayType() && P2->isArrayType()) {
+// At every level that array type is involved in, at least

isuckatcs wrote:
> xazax.hun wrote:
> > If none of the functions I recommended works for you, I still strongly 
> > suggest reusing utilities from ASTContext, like `UnwrapSimilarTypes` and 
> > `UnwrapSimilarArrayTypes`.
> I didn't check all of the functions inside `ASTContext`, but here we have 
> very specific rules, we need to check. One utility might help with one check 
> or two, but won't replace the need to go ove all of them. Also I think it's 
> easier to understand which section checks what, if I keep them separated.
> 
> In an ealier comment I link to [[ 
> https://en.cppreference.com/w/cpp/language/implicit_conversion#Qualification_conversions
>  | the section on cppreference ]], which discusses what these rules are. Also 
> there I found one controversial example, that's only detected by MSVC. I 
> wonder if you know why that happens.
I see. It is unfortunate that we cannot simply reuse the corresponding 
functionality from Sema. The code mostly looks good to me, apart from some nits.



Comment at: clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp:111
+// ... [or there is an array type of known bound in P1 and
+// an array type of unknown bound in P2 (since C++20)] then
+// there must be a 'const' at every single level (other than

If this rule only applies to C++20 and above, consider adding a language 
version check for LangOpts.



Comment at: clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp:130-131
+  if (!P1->isPointerType() || !P2->isPointerType())
+return convertible && P1->getUnqualifiedDesugaredType() ==
+  P2->getUnqualifiedDesugaredType();
+

Looking at the documentation of DesugaredType:
```
This takes off typedefs, typeof's etc. If the outer level of the type is 
already concrete, it returns it unmodified. This is similar to getting the 
canonical type, but it doesn't remove all typedefs. For example, it returns 
"T*" as "T*", (not as "int*"), because the pointer is concrete.
```
I wonder if we actually want to compare canonical types rather than desugared 
types.


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

https://reviews.llvm.org/D135495

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


[PATCH] D141422: [clang][sema][Matrix] Move code from try-cast to `TypeLocVisitor`. NFC intended.

2023-01-16 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141422

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


[PATCH] D139926: [clangd] Add semantic tokens for angle brackets

2023-01-16 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler added a comment.

In D139926#4056585 , @kadircet wrote:

> Especially as this comes as two different `HighlightingKind`s and they're 
> likely to get colored differently, and having your matching brackets in 
> different colors is quite annoying.

We can easily check the actual character at the given position in the client, 
so I could just merge the two highlighting kinds.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139926

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


Re: [PATCH] D136554: Implement CWG2631

2023-01-16 Thread Corentin via cfe-commits
Yes please! However the warning looks correct to me in that case. A
constructs x which constructs A etc.

On Mon, Jan 16, 2023, 18:00 Chris Bowler via Phabricator <
revi...@reviews.llvm.org> wrote:

> cebowleratibm added a comment.
>
> I've reduced a regression on:
>
> commit ca619613801233ef2def8c3cc7d311d5ed0033cb <
> https://reviews.llvm.org/rGca619613801233ef2def8c3cc7d311d5ed0033cb>
> (HEAD, refs/bisect/bad)
> Author: Corentin Jabot 
> Date:   Sun Oct 23 17:32:58 2022 +0200
>
>   template  int f(T) { return 42; }
>
>   struct A {
>  int x = f(A());
>  A() { }
>   };
>
>   void foo() { A(); }
>
>
>
>   clang++ t2.C -c
>   t2.C:4:12: warning: stack nearly exhausted; compilation time may suffer,
> and crashes due to stack overflow are likely [-Wstack-exhausted]
>  int x = f(A());
>  ^
>   Segmentation fault (core dumped)
>
> @cor3ntin would you like me to open a new issue?
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D136554/new/
>
> https://reviews.llvm.org/D136554
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141432: Add two additional float8 types to MLIR and APFloat.

2023-01-16 Thread Krzysztof Drewniak via Phabricator via cfe-commits
krzysz00 added a comment.
Herald added a reviewer: ftynse.

I think we have dueling patches that we should reconcile. I've put together 
https://reviews.llvm.org/D141863 to do the same thing. (it's just now posted 
because we were waiting to talk to y'all over at GraphCore to finalize naming, 
etc. ... but since this revision's already up I might as well go and put mine.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141432

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


[PATCH] D141861: [nvptx-arch] Dynamically load the CUDA runtime if not found during the build

2023-01-16 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 accepted this revision.
tianshilei1992 added a comment.
This revision is now accepted and ready to land.

Yeah, otherwise I suppose there will be some errors when compiling OpenMP 
program when there is no CUDA installed.




Comment at: clang/tools/nvptx-arch/NVPTXArch.cpp:89
 
 int main() {
+  // Attempt to load the NVPTX driver runtime.

unrelated: I always prefer:
```
int main(int argc, char *argv[]) {
  return 0;
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141861

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


[PATCH] D141625: [DeclContext] Sort the Decls before adding into DeclContext

2023-01-16 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added a comment.

Actually, sorting in `numberAnonymousDeclsWithin` doesn't work for some reasons.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141625

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


[PATCH] D141581: [clang] Make clangBasic and clangDriver depend on LLVMTargetParser.

2023-01-16 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added a comment.

clangBasic and clangDriver already have a dependency on TargetParser (see 
LLVM_LINK_COMPONENTS at the beginning of corresponding files). Is that not 
enough?
Will it build if you just remove the additional dependency?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141581

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


[PATCH] D141547: Fix format for `case` in .proto files

2023-01-16 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcaf393da1823: Fix format for `case` in .proto files 
(authored by fowles, committed by krasimir).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141547

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTestProto.cpp


Index: clang/unittests/Format/FormatTestProto.cpp
===
--- clang/unittests/Format/FormatTestProto.cpp
+++ clang/unittests/Format/FormatTestProto.cpp
@@ -113,6 +113,13 @@
"}");
 }
 
+TEST_F(FormatTestProto, CaseAsFieldName) {
+  verifyFormat("message SomeMessage {\n"
+   "  required string case = 1;\n"
+   "  repeated int32 fizz = 2;\n"
+   "}");
+}
+
 TEST_F(FormatTestProto, UnderstandsReturns) {
   verifyFormat("rpc Search(SearchRequest) returns (SearchResponse);");
 }
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -590,8 +590,9 @@
   [[fallthrough]];
 }
 case tok::kw_case:
-  if (Style.isVerilog() ||
+  if (Style.isProto() || Style.isVerilog() ||
   (Style.isJavaScript() && Line->MustBeDeclaration)) {
+// Proto: there are no switch/case statements
 // Verilog: Case labels don't have this word. We handle case
 // labels including default in TokenAnnotator.
 // JavaScript: A 'case: string' style field declaration.
@@ -1620,7 +1621,11 @@
 // e.g. "default void f() {}" in a Java interface.
 break;
   case tok::kw_case:
-// In Verilog switch is called case.
+// Proto: there are no switch/case statements.
+if (Style.isProto()) {
+  nextToken();
+  return;
+}
 if (Style.isVerilog()) {
   parseBlock();
   addUnwrappedLine();
@@ -2100,6 +2105,11 @@
   parseNew();
   break;
 case tok::kw_case:
+  // Proto: there are no switch/case statements.
+  if (Style.isProto()) {
+nextToken();
+return;
+  }
   // In Verilog switch is called case.
   if (Style.isVerilog()) {
 parseBlock();


Index: clang/unittests/Format/FormatTestProto.cpp
===
--- clang/unittests/Format/FormatTestProto.cpp
+++ clang/unittests/Format/FormatTestProto.cpp
@@ -113,6 +113,13 @@
"}");
 }
 
+TEST_F(FormatTestProto, CaseAsFieldName) {
+  verifyFormat("message SomeMessage {\n"
+   "  required string case = 1;\n"
+   "  repeated int32 fizz = 2;\n"
+   "}");
+}
+
 TEST_F(FormatTestProto, UnderstandsReturns) {
   verifyFormat("rpc Search(SearchRequest) returns (SearchResponse);");
 }
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -590,8 +590,9 @@
   [[fallthrough]];
 }
 case tok::kw_case:
-  if (Style.isVerilog() ||
+  if (Style.isProto() || Style.isVerilog() ||
   (Style.isJavaScript() && Line->MustBeDeclaration)) {
+// Proto: there are no switch/case statements
 // Verilog: Case labels don't have this word. We handle case
 // labels including default in TokenAnnotator.
 // JavaScript: A 'case: string' style field declaration.
@@ -1620,7 +1621,11 @@
 // e.g. "default void f() {}" in a Java interface.
 break;
   case tok::kw_case:
-// In Verilog switch is called case.
+// Proto: there are no switch/case statements.
+if (Style.isProto()) {
+  nextToken();
+  return;
+}
 if (Style.isVerilog()) {
   parseBlock();
   addUnwrappedLine();
@@ -2100,6 +2105,11 @@
   parseNew();
   break;
 case tok::kw_case:
+  // Proto: there are no switch/case statements.
+  if (Style.isProto()) {
+nextToken();
+return;
+  }
   // In Verilog switch is called case.
   if (Style.isVerilog()) {
 parseBlock();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] caf393d - Fix format for `case` in .proto files

2023-01-16 Thread Krasimir Georgiev via cfe-commits

Author: Matt Kulukundis
Date: 2023-01-16T17:43:50Z
New Revision: caf393da1823d50852f51604b3793e8f4a23c140

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

LOG: Fix format for `case` in .proto files

Fix format for `case` in .proto files

Reviewed By: krasimir, echristo

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

Added: 


Modified: 
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/FormatTestProto.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index c97ecc7821209..effb0ecb368bb 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -590,8 +590,9 @@ bool UnwrappedLineParser::parseLevel(const FormatToken 
*OpeningBrace,
   [[fallthrough]];
 }
 case tok::kw_case:
-  if (Style.isVerilog() ||
+  if (Style.isProto() || Style.isVerilog() ||
   (Style.isJavaScript() && Line->MustBeDeclaration)) {
+// Proto: there are no switch/case statements
 // Verilog: Case labels don't have this word. We handle case
 // labels including default in TokenAnnotator.
 // JavaScript: A 'case: string' style field declaration.
@@ -1620,7 +1621,11 @@ void UnwrappedLineParser::parseStructuralElement(
 // e.g. "default void f() {}" in a Java interface.
 break;
   case tok::kw_case:
-// In Verilog switch is called case.
+// Proto: there are no switch/case statements.
+if (Style.isProto()) {
+  nextToken();
+  return;
+}
 if (Style.isVerilog()) {
   parseBlock();
   addUnwrappedLine();
@@ -2100,6 +2105,11 @@ void UnwrappedLineParser::parseStructuralElement(
   parseNew();
   break;
 case tok::kw_case:
+  // Proto: there are no switch/case statements.
+  if (Style.isProto()) {
+nextToken();
+return;
+  }
   // In Verilog switch is called case.
   if (Style.isVerilog()) {
 parseBlock();

diff  --git a/clang/unittests/Format/FormatTestProto.cpp 
b/clang/unittests/Format/FormatTestProto.cpp
index 1ff7c22a6df78..5de40b6eae597 100644
--- a/clang/unittests/Format/FormatTestProto.cpp
+++ b/clang/unittests/Format/FormatTestProto.cpp
@@ -113,6 +113,13 @@ TEST_F(FormatTestProto, EnumAsFieldName) {
"}");
 }
 
+TEST_F(FormatTestProto, CaseAsFieldName) {
+  verifyFormat("message SomeMessage {\n"
+   "  required string case = 1;\n"
+   "  repeated int32 fizz = 2;\n"
+   "}");
+}
+
 TEST_F(FormatTestProto, UnderstandsReturns) {
   verifyFormat("rpc Search(SearchRequest) returns (SearchResponse);");
 }



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


[PATCH] D141581: [clang] Make clangBasic and clangDriver depend on LLVMTargetParser.

2023-01-16 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added a comment.

In D141581#4056671 , @fpetrogalli 
wrote:

> @barannikov88  - I am stuck with an incomplete explanation:

Ah, I see. The key point is that standalone build that depends on //installed// 
LLVM.
RISCVTargetParser is a custom target and it is not being installed, while 
LLVMTargetParser is a "real" target and gets installed. This is probably why 
changing the dependency fixes the issue.
The change looks good to me then.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141581

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


[PATCH] D141625: [DeclContext] Sort the Decls before adding into DeclContext

2023-01-16 Thread Steven Wu via Phabricator via cfe-commits
steven_wu updated this revision to Diff 489587.
steven_wu added a comment.

Minor touch up on the test case. Also add some comments in test to explain what 
is being tested.

I don't measure any performance regression from `-fsyntax-only` on Foundation.h 
but if there are some other performance benchmark I need to be tested first, 
let me know.
Alternatively, there can be a even safer fix by moving the sorting into 
`numberAnonymousDeclsWithin` which seems to be only used in serialization. I 
can change to that to be extra safe.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141625

Files:
  clang/lib/Parse/ParseDecl.cpp
  clang/test/Modules/decl-params-determinisim.m


Index: clang/test/Modules/decl-params-determinisim.m
===
--- /dev/null
+++ clang/test/Modules/decl-params-determinisim.m
@@ -0,0 +1,70 @@
+/// Test determinisim when serializing anonymous decls. Create enough Decls in
+/// DeclContext that can overflow the small storage of SmallPtrSet to make sure
+/// the serialization does not rely on iteration order of SmallPtrSet.
+// RUN: rm -rf %t.dir
+// RUN: split-file %s %t.dir
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps \
+// RUN:   -fmodules-cache-path=%t.dir/cache -triple x86_64-apple-macosx10.11.0 
\
+// RUN:   -I%t.dir/headers %t.dir/main.m -fdisable-module-hash -Wno-visibility
+// RUN: mv %t.dir/cache/A.pcm %t1.pcm
+// RUN: rm -rf %t.dir/cache
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps \
+// RUN:   -fmodules-cache-path=%t.dir/cache -triple x86_64-apple-macosx10.11.0 
\
+// RUN:   -I%t.dir/headers %t.dir/main.m -fdisable-module-hash -Wno-visibility
+// RUN: mv %t.dir/cache/A.pcm %t2.pcm
+// RUN: diff %t1.pcm %t2.pcm
+
+//--- headers/a.h
+void f(struct A0 *a0,
+   struct A1 *a1,
+   struct A2 *a2,
+   struct A3 *a3,
+   struct A4 *a4,
+   struct A5 *a5,
+   struct A6 *a6,
+   struct A7 *a7,
+   struct A8 *a8,
+   struct A9 *a9,
+   struct A10 *a10,
+   struct A11 *a11,
+   struct A12 *a12,
+   struct A13 *a13,
+   struct A14 *a14,
+   struct A15 *a15,
+   struct A16 *a16,
+   struct A17 *a17,
+   struct A18 *a18,
+   struct A19 *a19,
+   struct A20 *a20,
+   struct A21 *a21,
+   struct A22 *a22,
+   struct A23 *a23,
+   struct A24 *a24,
+   struct A25 *a25,
+   struct A26 *a26,
+   struct A27 *a27,
+   struct A28 *a28,
+   struct A29 *a29,
+   struct A30 *a30,
+   struct A31 *a31,
+   struct A32 *a32,
+   struct A33 *a33,
+   struct A34 *a34,
+   struct A35 *a35,
+   struct A36 *a36,
+   struct A37 *a37,
+   struct A38 *a38,
+   struct A39 *a39,
+   struct A40 *a40);
+
+
+//--- headers/module.modulemap
+
+module A {
+  header "a.h"
+}
+
+//--- main.m
+
+#import 
+
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -6986,6 +6986,15 @@
 continue;
   DeclsInPrototype.push_back(ND);
 }
+// Sort DeclsInPrototype based on raw encoding of the source location.
+// Scope::decls() is iterating over a SmallPtrSet so sort the Decls before
+// moving to DeclContext. This provides a stable ordering for traversing
+// Decls in DeclContext, which is important for tasks like ASTWriter for
+// deterministic output.
+llvm::sort(DeclsInPrototype, [](Decl *D1, Decl *D2) {
+  return D1->getLocation().getRawEncoding() <
+ D2->getLocation().getRawEncoding();
+});
   }
 
   // Remember that we parsed a function type, and remember the attributes.


Index: clang/test/Modules/decl-params-determinisim.m
===
--- /dev/null
+++ clang/test/Modules/decl-params-determinisim.m
@@ -0,0 +1,70 @@
+/// Test determinisim when serializing anonymous decls. Create enough Decls in
+/// DeclContext that can overflow the small storage of SmallPtrSet to make sure
+/// the serialization does not rely on iteration order of SmallPtrSet.
+// RUN: rm -rf %t.dir
+// RUN: split-file %s %t.dir
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps \
+// RUN:   -fmodules-cache-path=%t.dir/cache -triple x86_64-apple-macosx10.11.0 \
+// RUN:   -I%t.dir/headers %t.dir/main.m -fdisable-module-hash -Wno-visibility
+// RUN: mv %t.dir/cache/A.pcm %t1.pcm
+// RUN: rm -rf %t.dir/cache
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps \
+// RUN:   -fmodules-cache-path=%t.dir/cache -triple x86_64-apple-macosx10.11.0 \
+// RUN:   -I%t.dir/headers %t.dir/main.m -fdisable-module-hash -Wno-visibility
+// RUN: mv %t.dir/cache/A.pcm %t2.pcm
+// RUN: diff %t1.pcm %t2.pcm
+
+//--- headers/a.h
+void f(struct A0 *a0,
+   struct A1 *a1,
+   struct A2 *a2,
+   struct A3 *a3,
+   struct 

[PATCH] D141862: [clang][driver][AIX] Add OpenMP runtime if -fopenmp specified

2023-01-16 Thread Xing Xue via Phabricator via cfe-commits
xingxue created this revision.
xingxue added reviewers: daltenty, cebowleratibm, kkwli0.
xingxue added a project: LLVM.
Herald added subscribers: guansong, yaxunl.
Herald added a project: All.
xingxue requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1, MaskRay.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.

This patch adds OpenMP runtime to the linker command line if `-fopenmp` is 
specifed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141862

Files:
  clang/lib/Driver/ToolChains/AIX.cpp


Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -243,6 +243,25 @@
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
 AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
 
+// Add OpenMP runtime if -fopenmp is specified.
+if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
+ options::OPT_fno_openmp, false)) {
+  switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
+  case Driver::OMPRT_OMP:
+CmdArgs.push_back("-lomp");
+break;
+  case Driver::OMPRT_IOMP5:
+CmdArgs.push_back("-liomp5");
+break;
+  case Driver::OMPRT_GOMP:
+CmdArgs.push_back("-lgomp");
+break;
+  case Driver::OMPRT_Unknown:
+// Already diagnosed.
+break;
+  }
+}
+
 // Support POSIX threads if "-pthreads" or "-pthread" is present.
 if (Args.hasArg(options::OPT_pthreads, options::OPT_pthread))
   CmdArgs.push_back("-lpthreads");


Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -243,6 +243,25 @@
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
 AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
 
+// Add OpenMP runtime if -fopenmp is specified.
+if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
+ options::OPT_fno_openmp, false)) {
+  switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
+  case Driver::OMPRT_OMP:
+CmdArgs.push_back("-lomp");
+break;
+  case Driver::OMPRT_IOMP5:
+CmdArgs.push_back("-liomp5");
+break;
+  case Driver::OMPRT_GOMP:
+CmdArgs.push_back("-lgomp");
+break;
+  case Driver::OMPRT_Unknown:
+// Already diagnosed.
+break;
+  }
+}
+
 // Support POSIX threads if "-pthreads" or "-pthread" is present.
 if (Args.hasArg(options::OPT_pthreads, options::OPT_pthread))
   CmdArgs.push_back("-lpthreads");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141861: [nvptx-arch] Dynamically load the CUDA runtime if not found during the build

2023-01-16 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, tianshilei1992, tra, yaxunl, 
JonChesterfield.
Herald added subscribers: mattd, gchakrabarti, asavonic.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, jholewinski.
Herald added a project: clang.

Much like the changes in D141859 , this patch 
allows the `nvptx-arch`
tool to be built and provided with every distrubition of LLVM / Clang.
This will make it more reliable for our toolchains to depend on. The
changes here configure a version that dynamically loads CUDA if it was
not found at build time.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141861

Files:
  clang/tools/nvptx-arch/CMakeLists.txt
  clang/tools/nvptx-arch/NVPTXArch.cpp

Index: clang/tools/nvptx-arch/NVPTXArch.cpp
===
--- clang/tools/nvptx-arch/NVPTXArch.cpp
+++ clang/tools/nvptx-arch/NVPTXArch.cpp
@@ -11,6 +11,12 @@
 //
 //===--===//
 
+#include "llvm/Support/DynamicLibrary.h"
+#include "llvm/Support/Error.h"
+#include 
+#include 
+#include 
+
 #if defined(__has_include)
 #if __has_include("cuda.h")
 #include "cuda.h"
@@ -23,11 +29,53 @@
 #endif
 
 #if !CUDA_HEADER_FOUND
-int main() { return 1; }
-#else
+typedef enum cudaError_enum {
+  CUDA_SUCCESS = 0,
+  CUDA_ERROR_NO_DEVICE = 100,
+} CUresult;
 
-#include 
-#include 
+typedef enum CUdevice_attribute_enum {
+  CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR = 75,
+  CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR = 76,
+} CUdevice_attribute;
+
+typedef uint32_t CUdevice;
+
+CUresult (*cuInit)(unsigned int);
+CUresult (*cuDeviceGetCount)(int *);
+CUresult (*cuGetErrorString)(CUresult, const char **);
+CUresult (*cuDeviceGet)(CUdevice *, int);
+CUresult (*cuDeviceGetAttribute)(int *, CUdevice_attribute, CUdevice);
+
+constexpr const char *DynamicCudaPath = "libcuda.so";
+
+llvm::Error loadCUDA() {
+  std::string ErrMsg;
+  auto DynlibHandle = std::make_unique(
+  llvm::sys::DynamicLibrary::getPermanentLibrary(DynamicCudaPath, ));
+  if (!DynlibHandle->isValid()) {
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "Failed to 'dlopen' %s\n", DynamicCudaPath);
+  }
+#define DYNAMIC_INIT(SYMBOL)   \
+  {\
+void *SymbolPtr = DynlibHandle->getAddressOfSymbol(#SYMBOL);   \
+if (!SymbolPtr)\
+  return llvm::createStringError(llvm::inconvertibleErrorCode(),   \
+ "Failed to 'dlsym' " #SYMBOL);\
+SYMBOL = reinterpret_cast(SymbolPtr);\
+  }
+  DYNAMIC_INIT(cuInit);
+  DYNAMIC_INIT(cuDeviceGetCount);
+  DYNAMIC_INIT(cuGetErrorString);
+  DYNAMIC_INIT(cuDeviceGet);
+  DYNAMIC_INIT(cuDeviceGetAttribute);
+#undef DYNAMIC_INIT
+  return llvm::Error::success();
+}
+#else
+llvm::Error loadCUDA() { return llvm::Error::success(); }
+#endif
 
 static int handleError(CUresult Err) {
   const char *ErrStr = nullptr;
@@ -39,6 +87,12 @@
 }
 
 int main() {
+  // Attempt to load the NVPTX driver runtime.
+  if (llvm::Error Err = loadCUDA()) {
+logAllUnhandledErrors(std::move(Err), llvm::errs());
+return EXIT_FAILURE;
+  }
+
   if (CUresult Err = cuInit(0)) {
 if (Err == CUDA_ERROR_NO_DEVICE)
   return EXIT_SUCCESS;
@@ -68,5 +122,3 @@
   }
   return EXIT_SUCCESS;
 }
-
-#endif
Index: clang/tools/nvptx-arch/CMakeLists.txt
===
--- clang/tools/nvptx-arch/CMakeLists.txt
+++ clang/tools/nvptx-arch/CMakeLists.txt
@@ -6,6 +6,8 @@
 # //
 # //======//
 
+set(LLVM_LINK_COMPONENTS Support)
+add_clang_tool(nvptx-arch NVPTXArch.cpp)
 
 # TODO: This is deprecated. Since CMake 3.17 we can use FindCUDAToolkit instead.
 find_package(CUDA QUIET)
@@ -15,14 +17,8 @@
   find_library(cuda-library NAMES cuda HINTS "${CUDA_LIBDIR}/stubs")
 endif()
 
-if (NOT CUDA_FOUND OR NOT cuda-library)
-  message(STATUS "Not building nvptx-arch: cuda runtime not found")
-  return()
+# If we found the CUDA library directly we just dynamically link against it.
+if (CUDA_FOUND AND cuda-library)
+  target_include_directories(nvptx-arch PRIVATE ${CUDA_INCLUDE_DIRS})
+  target_link_libraries(nvptx-arch PRIVATE ${cuda-library})
 endif()
-
-add_clang_tool(nvptx-arch NVPTXArch.cpp)
-
-set_target_properties(nvptx-arch PROPERTIES INSTALL_RPATH_USE_LINK_PATH ON)
-target_include_directories(nvptx-arch PRIVATE ${CUDA_INCLUDE_DIRS})
-
-target_link_libraries(nvptx-arch PRIVATE ${cuda-library})
___
cfe-commits mailing list

[PATCH] D141859: [amdgpu-arch] Dynamically load the HSA runtime if not found during the build

2023-01-16 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield accepted this revision.
JonChesterfield added a comment.
This revision is now accepted and ready to land.

Yes, ok. Not thrilled about the copy from openmp but we can fix that as 
soon as we agree on a subdir to put code shared between llvm/clang/openmp and 
that has been tricky to achieve consensus on. Feature is good, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141859

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


[PATCH] D131915: [MLIR][OpenMP] Added target data, exit data, and enter data operation definition for MLIR.

2023-01-16 Thread Kiran Chandramohan via Phabricator via cfe-commits
kiranchandramohan accepted this revision.
kiranchandramohan added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks for making the changes and for your patience. Please wait a couple 
of days to give other reviewers a chance to have a look before submitting.

Could you update the Summary of this patch to specify what is in this patch and 
what is left out? Also, might be useful to specify any special modelling, like 
for the map clause.

Could you specify the co-authors in the following way?
Co-authored-by: abidmalikwaterloo 
Co-authored-by: raghavendra 




Comment at: mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td:790
+//===-===//
+// 2.12.2 target data Construct
+//===-===//

Is this number from the OpenMP 5.0 standard? I think 5.0 does not have the 
`present` map-type modifier. The printer includes this. I think we can either 
remove things that are not there in 5.0 or add comments when items from newer 
versions are included or alternatively change the number to the latest version 
and call out everything that is not implemented.



Comment at: mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td:818-820
+The $map_operands specifies operands in map clause along with it's type 
and modifiers.
+
+The $map_operand_segments specifies the segment sizes for $map_operands.

Update these two to their current meanings. (Also replace 
`map_operand_segments` with `map_types`.

Same comment for the other two operations.



Comment at: mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp:542
+// Parser, printer and verifier for Target Data
+//===--===//
+static ParseResult

Could you specify the EBNF (https://mlir.llvm.org/docs/LangRef/#notation) for 
the expected structure of the map clause?



Comment at: mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp:595
+
+if (mapTypeOp.isa())
+  mapTypeBits = mapTypeOp.cast().getInt();

Nit: Should this be an assert?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131915

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


[PATCH] D141858: [clang][Interp] Fix Pointer::toAPValue() for expressions

2023-01-16 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 489581.

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

https://reviews.llvm.org/D141858

Files:
  clang/lib/AST/Interp/Pointer.cpp


Index: clang/lib/AST/Interp/Pointer.cpp
===
--- clang/lib/AST/Interp/Pointer.cpp
+++ clang/lib/AST/Interp/Pointer.cpp
@@ -105,6 +105,10 @@
 if (isUnknownSizeArray()) {
   IsOnePastEnd = false;
   Offset = CharUnits::Zero();
+} else if (Desc->asExpr()) {
+  // Pointer pointing to a an expression.
+  IsOnePastEnd = false;
+  Offset = CharUnits::Zero();
 } else {
   // TODO: compute the offset into the object.
   Offset = CharUnits::Zero();


Index: clang/lib/AST/Interp/Pointer.cpp
===
--- clang/lib/AST/Interp/Pointer.cpp
+++ clang/lib/AST/Interp/Pointer.cpp
@@ -105,6 +105,10 @@
 if (isUnknownSizeArray()) {
   IsOnePastEnd = false;
   Offset = CharUnits::Zero();
+} else if (Desc->asExpr()) {
+  // Pointer pointing to a an expression.
+  IsOnePastEnd = false;
+  Offset = CharUnits::Zero();
 } else {
   // TODO: compute the offset into the object.
   Offset = CharUnits::Zero();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141859: [amdgpu-arch] Dynamically load the HSA runtime if not found during the build

2023-01-16 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, tianshilei1992, tra, yaxunl, 
JonChesterfield, gregrodgers.
Herald added subscribers: kosarev, kerbowa, tpr, dstuttard, jvesely, kzhuravl.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, wdng.
Herald added a project: clang.

We use the `amdgpu-arch` tool to query the installed GPUs at runtime.
One problem is that this tool is currently not build if the person
building the LLVM binary does not have the HSA runtime on their system.
This means that if someone built and distrubted an installation of LLVM
without HSA, then the user will not be able to use it even if they have
it on their system.

This patch makes us build this tool unconditionally and adds extra logic
to dynamically load HSA if it's present.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141859

Files:
  clang/tools/amdgpu-arch/AMDGPUArch.cpp
  clang/tools/amdgpu-arch/CMakeLists.txt

Index: clang/tools/amdgpu-arch/CMakeLists.txt
===
--- clang/tools/amdgpu-arch/CMakeLists.txt
+++ clang/tools/amdgpu-arch/CMakeLists.txt
@@ -6,14 +6,13 @@
 # //
 # //===--===//
 
-find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/rocm)
-if (NOT ${hsa-runtime64_FOUND})
-  message(STATUS "Not building amdgpu-arch: hsa-runtime64 not found")
-  return()
-endif()
+set(LLVM_LINK_COMPONENTS Support)
 
 add_clang_tool(amdgpu-arch AMDGPUArch.cpp)
 
-set_target_properties(amdgpu-arch PROPERTIES INSTALL_RPATH_USE_LINK_PATH ON)
-
-clang_target_link_libraries(amdgpu-arch PRIVATE hsa-runtime64::hsa-runtime64)
+# If we find the HSA runtime we link with it directly.
+find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/rocm)
+if (${hsa-runtime64_FOUND})
+  set_target_properties(amdgpu-arch PROPERTIES INSTALL_RPATH_USE_LINK_PATH ON)
+  clang_target_link_libraries(amdgpu-arch PRIVATE hsa-runtime64::hsa-runtime64)
+endif()
Index: clang/tools/amdgpu-arch/AMDGPUArch.cpp
===
--- clang/tools/amdgpu-arch/AMDGPUArch.cpp
+++ clang/tools/amdgpu-arch/AMDGPUArch.cpp
@@ -11,6 +11,12 @@
 //
 //===--===//
 
+#include "llvm/Support/DynamicLibrary.h"
+#include "llvm/Support/Error.h"
+#include 
+#include 
+#include 
+
 #if defined(__has_include)
 #if __has_include("hsa/hsa.h")
 #define HSA_HEADER_FOUND 1
@@ -26,11 +32,62 @@
 #endif
 
 #if !HSA_HEADER_FOUND
-int main() { return 1; }
-#else
+// Forward declaration of the status enumeration used by HSA.
+typedef enum {
+  HSA_STATUS_SUCCESS = 0x0,
+} hsa_status_t;
 
-#include 
-#include 
+// Forward declaration of the device types used by HSA.
+typedef enum {
+  HSA_DEVICE_TYPE_CPU = 0,
+  HSA_DEVICE_TYPE_GPU = 1,
+} hsa_device_type_t;
+
+// Forward declaration of the agent information types we use.
+typedef enum {
+  HSA_AGENT_INFO_NAME = 0,
+  HSA_AGENT_INFO_DEVICE = 17,
+} hsa_agent_info_t;
+
+typedef struct hsa_agent_s {
+  uint64_t handle;
+} hsa_agent_t;
+
+hsa_status_t (*hsa_init)();
+hsa_status_t (*hsa_shut_down)();
+hsa_status_t (*hsa_agent_get_info)(hsa_agent_t, hsa_agent_info_t, void *);
+hsa_status_t (*hsa_iterate_agents)(hsa_status_t (*callback)(hsa_agent_t,
+void *),
+   void *);
+
+constexpr const char *DynamicHSAPath = "libhsa-runtime64.so";
+
+llvm::Error loadHSA() {
+  std::string ErrMsg;
+  auto DynlibHandle = std::make_unique(
+  llvm::sys::DynamicLibrary::getPermanentLibrary(DynamicHSAPath, ));
+  if (!DynlibHandle->isValid()) {
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "Failed to 'dlopen' %s\n", DynamicHSAPath);
+  }
+#define DYNAMIC_INIT(SYMBOL)   \
+  {\
+void *SymbolPtr = DynlibHandle->getAddressOfSymbol(#SYMBOL);   \
+if (!SymbolPtr)\
+  return llvm::createStringError(llvm::inconvertibleErrorCode(),   \
+ "Failed to 'dlsym' " #SYMBOL);\
+SYMBOL = reinterpret_cast(SymbolPtr);\
+  }
+  DYNAMIC_INIT(hsa_init);
+  DYNAMIC_INIT(hsa_shut_down);
+  DYNAMIC_INIT(hsa_agent_get_info);
+  DYNAMIC_INIT(hsa_iterate_agents);
+#undef DYNAMIC_INIT
+  return llvm::Error::success();
+}
+#else
+llvm::Error loadHSA() { return llvm::Error::success(); }
+#endif
 
 static hsa_status_t iterateAgentsCallback(hsa_agent_t Agent, void *Data) {
   hsa_device_type_t DeviceType;
@@ -54,6 +111,12 @@
 }
 
 int main() {
+  // Attempt to load the HSA runtime.
+  

[PATCH] D141858: [clang][Interp] Fix Pointer::toAPValue() for expressions

2023-01-16 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.

This is now relevant because we generate pointers for expressions more often, 
since `MaterializeTemporaryExpr`s work.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141858

Files:
  clang/lib/AST/Interp/Pointer.cpp


Index: clang/lib/AST/Interp/Pointer.cpp
===
--- clang/lib/AST/Interp/Pointer.cpp
+++ clang/lib/AST/Interp/Pointer.cpp
@@ -105,6 +105,10 @@
 if (isUnknownSizeArray()) {
   IsOnePastEnd = false;
   Offset = CharUnits::Zero();
+} else if (getFieldDesc()->asExpr()) {
+  // Pointer pointing to a an expression.
+  IsOnePastEnd = false;
+  Offset = CharUnits::Zero();
 } else {
   // TODO: compute the offset into the object.
   Offset = CharUnits::Zero();


Index: clang/lib/AST/Interp/Pointer.cpp
===
--- clang/lib/AST/Interp/Pointer.cpp
+++ clang/lib/AST/Interp/Pointer.cpp
@@ -105,6 +105,10 @@
 if (isUnknownSizeArray()) {
   IsOnePastEnd = false;
   Offset = CharUnits::Zero();
+} else if (getFieldDesc()->asExpr()) {
+  // Pointer pointing to a an expression.
+  IsOnePastEnd = false;
+  Offset = CharUnits::Zero();
 } else {
   // TODO: compute the offset into the object.
   Offset = CharUnits::Zero();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136554: Implement CWG2631

2023-01-16 Thread Chris Bowler via Phabricator via cfe-commits
cebowleratibm added a comment.

I've reduced a regression on:

commit ca619613801233ef2def8c3cc7d311d5ed0033cb 
 (HEAD, 
refs/bisect/bad)
Author: Corentin Jabot 
Date:   Sun Oct 23 17:32:58 2022 +0200

  template  int f(T) { return 42; }
  
  struct A {
 int x = f(A());
 A() { }
  };
  
  void foo() { A(); }



  clang++ t2.C -c
  t2.C:4:12: warning: stack nearly exhausted; compilation time may suffer, and 
crashes due to stack overflow are likely [-Wstack-exhausted]
 int x = f(A());
 ^
  Segmentation fault (core dumped)

@cor3ntin would you like me to open a new issue?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136554

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


Re: [clang] f2d301f - Revert "[codegen] Store address of indirect arguments on the stack"

2023-01-16 Thread Roman Lebedev via cfe-commits
Reminder to please always mention the reason for the revert/recommit
in the commit message.

On Mon, Jan 16, 2023 at 7:05 PM Felipe de Azevedo Piovezan via
cfe-commits  wrote:
>
>
> Author: Felipe de Azevedo Piovezan
> Date: 2023-01-16T13:05:22-03:00
> New Revision: f2d301fe82869f881b86b51da7b4752972c66707
>
> URL: 
> https://github.com/llvm/llvm-project/commit/f2d301fe82869f881b86b51da7b4752972c66707
> DIFF: 
> https://github.com/llvm/llvm-project/commit/f2d301fe82869f881b86b51da7b4752972c66707.diff
>
> LOG: Revert "[codegen] Store address of indirect arguments on the stack"
>
> This reverts commit 7e4447a17db4a070f01c8f8a87505a4b2a1b0e3a.
>
> Added:
>
>
> Modified:
> clang/docs/ReleaseNotes.rst
> clang/lib/CodeGen/CGDebugInfo.cpp
> clang/lib/CodeGen/CGDebugInfo.h
> clang/lib/CodeGen/CGDecl.cpp
> clang/test/CodeGen/aarch64-ls64.c
> clang/test/CodeGen/atomic-arm64.c
> clang/test/CodeGenCXX/amdgcn-func-arg.cpp
> clang/test/CodeGenCXX/debug-info.cpp
> clang/test/CodeGenCXX/derived-to-base-conv.cpp
> clang/test/CodeGenCoroutines/coro-params-exp-namespace.cpp
> clang/test/CodeGenCoroutines/coro-params.cpp
> clang/test/OpenMP/for_firstprivate_codegen.cpp
> clang/test/OpenMP/parallel_firstprivate_codegen.cpp
> clang/test/OpenMP/sections_firstprivate_codegen.cpp
> clang/test/OpenMP/single_firstprivate_codegen.cpp
> clang/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp
> 
> clang/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
> 
> clang/test/OpenMP/target_teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
> clang/test/OpenMP/target_teams_distribute_simd_firstprivate_codegen.cpp
> clang/test/OpenMP/teams_distribute_firstprivate_codegen.cpp
> clang/test/OpenMP/teams_distribute_parallel_for_firstprivate_codegen.cpp
> 
> clang/test/OpenMP/teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
> clang/test/OpenMP/teams_distribute_simd_firstprivate_codegen.cpp
> clang/test/OpenMP/teams_firstprivate_codegen.cpp
>
> Removed:
>
>
>
> 
> diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
> index 731d10ac64a3f..3bbab951e8a8c 100644
> --- a/clang/docs/ReleaseNotes.rst
> +++ b/clang/docs/ReleaseNotes.rst
> @@ -500,9 +500,6 @@ Non-comprehensive list of changes in this release
>  - Clang can now generate a PCH when using ``-fdelayed-template-parsing`` for
>code with templates containing loop hint pragmas, OpenMP pragmas, and
>``#pragma unused``.
> -- Clang now saves the address of ABI-indirect function parameters on the 
> stack,
> -  improving the debug information available in programs compiled without
> -  optimizations.
>
>
>  New Compiler Flags
>
> diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
> b/clang/lib/CodeGen/CGDebugInfo.cpp
> index f2d558456fde4..f53a9d00ae5fd 100644
> --- a/clang/lib/CodeGen/CGDebugInfo.cpp
> +++ b/clang/lib/CodeGen/CGDebugInfo.cpp
> @@ -4822,10 +4822,9 @@ void CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(
>
>  llvm::DILocalVariable *
>  CGDebugInfo::EmitDeclareOfArgVariable(const VarDecl *VD, llvm::Value *AI,
> -  unsigned ArgNo, CGBuilderTy ,
> -  const bool UsePointerValue) {
> +  unsigned ArgNo, CGBuilderTy ) {
>assert(CGM.getCodeGenOpts().hasReducedDebugInfo());
> -  return EmitDeclare(VD, AI, ArgNo, Builder, UsePointerValue);
> +  return EmitDeclare(VD, AI, ArgNo, Builder);
>  }
>
>  namespace {
>
> diff  --git a/clang/lib/CodeGen/CGDebugInfo.h 
> b/clang/lib/CodeGen/CGDebugInfo.h
> index 10660a2550b56..95484a060cd88 100644
> --- a/clang/lib/CodeGen/CGDebugInfo.h
> +++ b/clang/lib/CodeGen/CGDebugInfo.h
> @@ -487,9 +487,10 @@ class CGDebugInfo {
>
>/// Emit call to \c llvm.dbg.declare for an argument variable
>/// declaration.
> -  llvm::DILocalVariable *
> -  EmitDeclareOfArgVariable(const VarDecl *Decl, llvm::Value *AI, unsigned 
> ArgNo,
> -   CGBuilderTy , bool UsePointerValue = 
> false);
> +  llvm::DILocalVariable *EmitDeclareOfArgVariable(const VarDecl *Decl,
> +  llvm::Value *AI,
> +  unsigned ArgNo,
> +  CGBuilderTy );
>
>/// Emit call to \c llvm.dbg.declare for the block-literal argument
>/// to a block invocation function.
>
> diff  --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
> index a70997f5b27b8..ceaddc4e694ac 100644
> --- a/clang/lib/CodeGen/CGDecl.cpp
> +++ b/clang/lib/CodeGen/CGDecl.cpp
> @@ -2476,8 +2476,6 @@ void CodeGenFunction::EmitParmDecl(const VarDecl , 
> ParamValue Arg,
>Address AllocaPtr = Address::invalid();
>bool DoStore = false;
>bool IsScalar = hasScalarEvaluationKind(Ty);
> -  

[PATCH] D141518: [AArch64] Move default extensions from clang Driver to TargetParser

2023-01-16 Thread Dave Green 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 rG0f422215ac63: [AArch64] Move default extensions from clang 
Driver to TargetParser (authored by dmgreen).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D141518?vs=488255=489578#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141518

Files:
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/test/Driver/aarch64-hbc.c
  clang/test/Driver/aarch64-i8mm.c
  clang/test/Driver/aarch64-mops.c
  clang/test/Driver/aarch64-v91a.c
  clang/test/Driver/aarch64-v92a.c
  llvm/include/llvm/TargetParser/AArch64TargetParser.h

Index: llvm/include/llvm/TargetParser/AArch64TargetParser.h
===
--- llvm/include/llvm/TargetParser/AArch64TargetParser.h
+++ llvm/include/llvm/TargetParser/AArch64TargetParser.h
@@ -312,12 +312,12 @@
 constexpr unsigned BaseNoCrypto = ARMV8_5A.DefaultExts ^ AArch64::AEK_CRYPTO; // 8.6 onwards has no AEK_CRYPTO
 inline constexpr ArchInfo ARMV8_6A  = { VersionTuple{8, 6}, AProfile, "armv8.6-a", "+v8.6a", (BaseNoCrypto | AArch64::AEK_SM4 | AArch64::AEK_SHA3 | AArch64::AEK_BF16 | AArch64::AEK_SHA2 | AArch64::AEK_AES | AArch64::AEK_I8MM)};
 inline constexpr ArchInfo ARMV8_7A  = { VersionTuple{8, 7}, AProfile, "armv8.7-a", "+v8.7a", (ARMV8_6A.DefaultExts)};
-inline constexpr ArchInfo ARMV8_8A  = { VersionTuple{8, 8}, AProfile, "armv8.8-a", "+v8.8a", (ARMV8_7A.DefaultExts)};
+inline constexpr ArchInfo ARMV8_8A  = { VersionTuple{8, 8}, AProfile, "armv8.8-a", "+v8.8a", (ARMV8_7A.DefaultExts | AArch64::AEK_MOPS | AArch64::AEK_HBC)};
 inline constexpr ArchInfo ARMV8_9A  = { VersionTuple{8, 9}, AProfile, "armv8.9-a", "+v8.9a", (ARMV8_8A.DefaultExts)};
 inline constexpr ArchInfo ARMV9A= { VersionTuple{9, 0}, AProfile, "armv9-a", "+v9a", (BaseNoCrypto | AArch64::AEK_SVE | AArch64::AEK_SVE2)};
 inline constexpr ArchInfo ARMV9_1A  = { VersionTuple{9, 1}, AProfile, "armv9.1-a", "+v9.1a", (ARMV9A.DefaultExts | AArch64::AEK_BF16 | AArch64::AEK_I8MM)};
 inline constexpr ArchInfo ARMV9_2A  = { VersionTuple{9, 2}, AProfile, "armv9.2-a", "+v9.2a", (ARMV9_1A.DefaultExts)};
-inline constexpr ArchInfo ARMV9_3A  = { VersionTuple{9, 3}, AProfile, "armv9.3-a", "+v9.3a", (ARMV9_2A.DefaultExts)};
+inline constexpr ArchInfo ARMV9_3A  = { VersionTuple{9, 3}, AProfile, "armv9.3-a", "+v9.3a", (ARMV9_2A.DefaultExts | AArch64::AEK_MOPS | AArch64::AEK_HBC)};
 inline constexpr ArchInfo ARMV9_4A  = { VersionTuple{9, 4}, AProfile, "armv9.4-a", "+v9.4a", (ARMV9_3A.DefaultExts)};
 // For v8-R, we do not enable crypto and align with GCC that enables a more minimal set of optional architecture extensions.
 inline constexpr ArchInfo ARMV8R= { VersionTuple{8, 0}, RProfile, "armv8-r", "+v8r", ((BaseNoCrypto ^ AArch64::AEK_LSE) | AArch64::AEK_SSBS | AArch64::AEK_FP16 | AArch64::AEK_FP16FML | AArch64::AEK_SB), };
Index: clang/test/Driver/aarch64-v92a.c
===
--- clang/test/Driver/aarch64-v92a.c
+++ clang/test/Driver/aarch64-v92a.c
@@ -4,7 +4,7 @@
 // RUN: %clang -target aarch64 -mlittle-endian -march=armv9.2-a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV92A %s
 // RUN: %clang -target aarch64_be -mlittle-endian -march=armv9.2a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV92A %s
 // RUN: %clang -target aarch64_be -mlittle-endian -march=armv9.2-a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV92A %s
-// GENERICV92A: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" "-target-feature" "+neon" "-target-feature" "+v9.2a" "-target-feature" "+i8mm" "-target-feature" "+bf16" "-target-feature" "+sve" "-target-feature" "+sve2"
+// GENERICV92A: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" "-target-feature" "+neon" "-target-feature" "+v9.2a" "-target-feature" "+sve" "-target-feature" "+sve2"
 
 // RUN: %clang -target aarch64_be -march=armv9.2a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV92A-BE %s
 // RUN: %clang -target aarch64_be -march=armv9.2-a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV92A-BE %s
@@ -12,4 +12,4 @@
 // RUN: %clang -target aarch64 -mbig-endian -march=armv9.2-a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV92A-BE %s
 // RUN: %clang -target aarch64_be -mbig-endian -march=armv9.2a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV92A-BE %s
 // RUN: %clang -target aarch64_be -mbig-endian -march=armv9.2-a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV92A-BE %s
-// GENERICV92A-BE: "-cc1"{{.*}} "-triple" "aarch64_be{{.*}}" "-target-cpu" "generic" "-target-feature" "+neon" "-target-feature" "+v9.2a" "-target-feature" "+i8mm" "-target-feature" "+bf16" "-target-feature" "+sve" "-target-feature" "+sve2"
+// GENERICV92A-BE: "-cc1"{{.*}} "-triple" 

[clang] 0f42221 - [AArch64] Move default extensions from clang Driver to TargetParser

2023-01-16 Thread David Green via cfe-commits

Author: David Green
Date: 2023-01-16T16:58:18Z
New Revision: 0f422215ac63da4cb610a21998a2d24c11703fbf

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

LOG: [AArch64] Move default extensions from clang Driver to TargetParser

The default extensions would be better added in the TargetParser, not by
the driver. This removes the addition of +i8mm and +bf16 features in the
driver as they are already added in 8.6/9.1 architectures. AEK_MOPS and
AEK_HBC have been added to 8.8/9.3 architectures to replace the need for
+hbc and +mops features.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
clang/test/Driver/aarch64-hbc.c
clang/test/Driver/aarch64-i8mm.c
clang/test/Driver/aarch64-mops.c
clang/test/Driver/aarch64-v91a.c
clang/test/Driver/aarch64-v92a.c
llvm/include/llvm/TargetParser/AArch64TargetParser.h

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index fcbf2e08d12df..2c559cc8b3b90 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -485,18 +485,6 @@ void aarch64::getAArch64TargetFeatures(const Driver ,
 }
   }
 
-  // FIXME: these insertions should ideally be automated using default
-  // extensions support from the backend target parser.
-  if (V8Version >= 6 || V9Version >= 1)
-Features.insert(std::next(Features.begin() + ArchFeatPos),
-{"+i8mm", "+bf16"});
-
-  // For Armv8.8-a/Armv9.3-a or later, FEAT_HBC and FEAT_MOPS are enabled by
-  // default.
-  if (V8Version >= 8 || V9Version >= 3)
-Features.insert(std::next(Features.begin() + ArchFeatPos),
-{"+hbc", "+mops"});
-
   if (Arg *A = Args.getLastArg(options::OPT_mno_unaligned_access,
options::OPT_munaligned_access)) {
 if (A->getOption().matches(options::OPT_mno_unaligned_access))

diff  --git a/clang/test/Driver/aarch64-hbc.c b/clang/test/Driver/aarch64-hbc.c
index b25e7c3f52809..90b11b1fd8078 100644
--- a/clang/test/Driver/aarch64-hbc.c
+++ b/clang/test/Driver/aarch64-hbc.c
@@ -1,12 +1,14 @@
 // Test that target feature hbc is implemented and available correctly
-// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.7-a+hbc   %s 
2>&1 | FileCheck %s
-// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.8-a   %s 
2>&1 | FileCheck %s
-// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.8-a+hbc   %s 
2>&1 | FileCheck %s
-// RUN: %clang -### -target aarch64-none-none-eabi -march=armv8.8-a+nohbc %s 
2>&1 | FileCheck %s --check-prefix=NO_HBC
-// RUN: %clang -### -target aarch64-none-none-eabi -march=armv9.2-a+hbc   %s 
2>&1 | FileCheck %s
-// RUN: %clang -### -target aarch64-none-none-eabi -march=armv9.3-a   %s 
2>&1 | FileCheck %s
-// RUN: %clang -### -target aarch64-none-none-eabi -march=armv9.3-a+hbc   %s 
2>&1 | FileCheck %s
-// RUN: %clang -### -target aarch64-none-none-eabi -march=armv9.3-a+nohbc %s 
2>&1 | FileCheck %s --check-prefix=NO_HBC
+// RUN: %clang -S -o - -emit-llvm -target aarch64-none-none-eabi 
-march=armv8.7-a+hbc   %s 2>&1 | FileCheck %s
+// RUN: %clang -S -o - -emit-llvm -target aarch64-none-none-eabi 
-march=armv8.8-a   %s 2>&1 | FileCheck %s
+// RUN: %clang -S -o - -emit-llvm -target aarch64-none-none-eabi 
-march=armv8.8-a+hbc   %s 2>&1 | FileCheck %s
+// RUN: %clang -S -o - -emit-llvm -target aarch64-none-none-eabi 
-march=armv8.8-a+nohbc %s 2>&1 | FileCheck %s --check-prefix=NO_HBC
+// RUN: %clang -S -o - -emit-llvm -target aarch64-none-none-eabi 
-march=armv9.2-a+hbc   %s 2>&1 | FileCheck %s
+// RUN: %clang -S -o - -emit-llvm -target aarch64-none-none-eabi 
-march=armv9.3-a   %s 2>&1 | FileCheck %s
+// RUN: %clang -S -o - -emit-llvm -target aarch64-none-none-eabi 
-march=armv9.3-a+hbc   %s 2>&1 | FileCheck %s
+// RUN: %clang -S -o - -emit-llvm -target aarch64-none-none-eabi 
-march=armv9.3-a+nohbc %s 2>&1 | FileCheck %s --check-prefix=NO_HBC
 
-// CHECK: "-target-feature" "+hbc"
-// NO_HBC: "-target-feature" "-hbc"
+// CHECK: "target-features"="{{.*}},+hbc
+// NO_HBC: "target-features"="{{.*}},-hbc
+
+void test() {}
\ No newline at end of file

diff  --git a/clang/test/Driver/aarch64-i8mm.c 
b/clang/test/Driver/aarch64-i8mm.c
index 4036996e5a3fc..a5e1c4863a273 100644
--- a/clang/test/Driver/aarch64-i8mm.c
+++ b/clang/test/Driver/aarch64-i8mm.c
@@ -1,7 +1,11 @@
 // The 8-bit integer matrix multiply extension is a mandatory component of the
 // Armv8.6-A extensions, but is permitted as an optional feature for any
 // implementation of Armv8.2-A to Armv8.5-A (inclusive)
-// RUN: %clang -target aarch64 -march=armv8.5a -### -c %s 2>&1 | 

[PATCH] D141581: [clang] Make clangBasic and clangDriver depend on LLVMTargetParser.

2023-01-16 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added a comment.

@barannikov88  - Imam stuck with an incomplete explanation:

The issue raised by @mgorny is about stand-alone 
 builds. In this 
build configuration, clang is built separately from LLVM, which is first build 
and installed in a folder.

When clang is build as a stand-alone project, clang does not have access to the 
cmake configuration of LLVM. Therefore it knows nothing about the tablegen 
target `RISCVTargetParserTableGen`.

The's why we see the following error when building stand-alone clang on `main`:

  CMake Error at 
/Users/fpetrogalli/projects/cpu-defs/install/lib/cmake/llvm/AddLLVM.cmake:536 
(add_dependencies):
The dependency target "RISCVTargetParserTableGen" of target
"obj.clangBasic" does not exist.
  Call Stack (most recent call first):
cmake/modules/AddClang.cmake:106 (llvm_add_library)
lib/Basic/CMakeLists.txt:40 (add_clang_library)

I do not know why `LLVMTargetParser` (which is also specified in the cmake 
configuration of llvm) is instead recognised as a valid dependencies of clang 
on some LLVM library. Maybe because cmake looks in the prefix folder where LLVM 
was installed and finds the object file of the library?

FWIW, I was able to reproduce the issue reported by @mgorny via the following 
script when run on `main`:

  #!/bin/sh
  
  build_llvm=`pwd`/build-llvm
  build_clang=`pwd`/build-clang
  installprefix=`pwd`/install
  llvm=`pwd`/llvm-project
  mkdir -p $build_llvm
  mkdir -p $installprefix
  
  cmake -G Ninja -S $llvm/llvm -B $build_llvm \
-DLLVM_INSTALL_UTILS=ON \
-DCMAKE_INSTALL_PREFIX=$installprefix \
-DCMAKE_BUILD_TYPE=Release
  
  
  ninja -C $build_llvm install
  
  cmake -G Ninja -S $llvm/clang -B $build_clang \
-DLLVM_EXTERNAL_LIT=$build_llvm/utils/llvm-lit \
-DLLVM_ROOT=$installprefix

Given it was an issue that cmake itself was reporting (and not a build time 
failure), I thought that its disappearance after applying this patch was a 
signal thatI was doing the right thing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141581

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


[PATCH] D141381: [codegen] Store address of indirect arguments on the stack

2023-01-16 Thread Felipe de Azevedo Piovezan via Phabricator via cfe-commits
fdeazeve added a comment.

In hindsight, this should have been obvious.
While SROA will not touch this:

  define @foo(ptr %arg) {
 call void @llvm.dbg.declare(%arg, [...], metadata !DIExpression())

It completely destroys the debug information provided by:

  define @foo(ptr %arg) {
 %ptr_storage = alloca ptr
 store ptr %arg, ptr %ptr_storage
 call void @llvm.dbg.declare(%ptr_storage, [...], metadata 
!DIExpression(DW_OP_deref))


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141381

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


[PATCH] D137058: [Driver] [Modules] Support -fmodule-output (1/2)

2023-01-16 Thread Jake Egan via Phabricator via cfe-commits
Jake-Egan added a comment.

Hi, this new test fails on AIX 
https://lab.llvm.org/buildbot/#/builders/214/builds/5351/steps/6/logs/FAIL__Clang__module-output_cppm
Could you take a look?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137058

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


[PATCH] D141581: [clang] Make clangBasic and clangDriver depend on LLVMTargetParser.

2023-01-16 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added a comment.

In D141581#4056612 , @barannikov88 
wrote:

> In D141581#4056503 , @fpetrogalli 
> wrote:
>
>> This is because the sources of clangBasic and clangDriver might be compiled 
>> before LLVMTargetParser is ready.
>
> ...
>
>> Therefore, if we say that clangDriver and clangBasic depend on 
>> LLVMTargetParser we make sure that the inclusion of the tablegen-generated 
>> file resolves correctly.
>
> Sorry, I don't follow. If I read correctly, you're saying that clang 
> libraries might begin to //compile// before their DEPENDS dependency is built 
> (implying that DEPENDS clause only guarantees that the dependency is ready at 
> //link// stage). If it is true, the proposed patch changes nothing -- the 
> sources might still start to compile before cmake decides to generate inc 
> file, because it is only needed at link stage.
> Am I missing something?

Ops, yeah, I think I am wrong. In fact , when `RISCVTargetParserTableGen` is in 
the `DEPENDS`, it should be built before the clangBasic start to compile. This 
means that I actually do not know why this change fixes the issue reported 


@mgorny - can you try this patch on your workflow? Maybe the issue disappeared 
in my local machine just because for some reason it changed the order of 
compilation?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141581

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


[PATCH] D141838: [clang-tidy] fix a false positive of `cppcoreguidelines-avoid-non-const-global-variables`

2023-01-16 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

I'm not convinced this is the correct fix.
The guildline 

 states that tools should flag all variables declared at global or namespace 
scope.
Therefore we shouldn't be flagging any class static members, no matter if they 
are public, private or protected.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141838

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


[PATCH] D141581: [clang] Make clangBasic and clangDriver depend on LLVMTargetParser.

2023-01-16 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added a comment.

In D141581#4056503 , @fpetrogalli 
wrote:

> This is because the sources of clangBasic and clangDriver might be compiled 
> before LLVMTargetParser is ready.

...

> Therefore, if we say that clangDriver and clangBasic depend on 
> LLVMTargetParser we make sure that the inclusion of the tablegen-generated 
> file resolves correctly.

Sorry, I don't follow. If I read correctly, you're saying that clang libraries 
might begin to //compile// before their DEPENDS dependency is built (implying 
that DEPENDS clause only guarantees that the dependency is ready at //link// 
stage). If it is true, the proposed patch changes nothing -- the sources might 
still start to compile before cmake decides to generate inc file, because it is 
only needed at link stage.
Am I missing something?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141581

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


[PATCH] D141586: [include-mapping] Replace the stdlib symbol maps with the newest official version from https://en.cppreference.com/w/File:html_book_20190607.zip.

2023-01-16 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo abandoned this revision.
VitaNuo added a comment.

Abandoning since we will eventually parse a newer version of the archive.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141586

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


[PATCH] D141855: [include-mapping] Parse zombie_names.html into a removed symbols map.

2023-01-16 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo created this revision.
VitaNuo added a reviewer: hokein.
Herald added a project: All.
VitaNuo requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141855

Files:
  clang/tools/include-mapping/gen_std.py


Index: clang/tools/include-mapping/gen_std.py
===
--- clang/tools/include-mapping/gen_std.py
+++ clang/tools/include-mapping/gen_std.py
@@ -64,6 +64,14 @@
   default='cpp',
   help='Generate c or cpp symbols',
   required=True)
+  parser.add_argument('-output',
+  default='SymbolMap.inc',
+  help='path to the output file for symbol map',
+  required=True)
+  parser.add_argument('-removedoutput',
+  default='RemovedSymbolMap.inc',
+  help='path to the output file for removed symbols map',
+  required=False)
   return parser.parse_args()
 
 
@@ -87,6 +95,9 @@
   (symbol_index_root, "regex_constants.html", "std::regex_constants::"),
   (symbol_index_root, "this_thread.html", "std::this_thread::"),
 ]
+removed_symbols = cppreference_parser.GetSymbols(
+  [(symbol_index_root, "zombie_names.html", "std::")])
+WriteSymbols(args.language, removed_symbols, args.removedoutput, page_root)
   elif args.language == 'c':
 page_root = os.path.join(args.cppreference, "en", "c")
 symbol_index_root = page_root
@@ -96,24 +107,28 @@
 exit("Path %s doesn't exist!" % symbol_index_root)
 
   symbols = cppreference_parser.GetSymbols(parse_pages)
+  WriteSymbols(args.language, symbols, args.output, page_root)
 
+def WriteSymbols(language, symbols, path, page_root):
   # We don't have version information from the unzipped offline HTML files.
   # so we use the modified time of the symbol_index.html as the version.
   index_page_path = os.path.join(page_root, "index.html")
   cppreference_modified_date = datetime.datetime.fromtimestamp(
 os.stat(index_page_path).st_mtime).strftime('%Y-%m-%d')
-  print(CODE_PREFIX % (args.language.upper(), cppreference_modified_date))
-  for symbol in symbols:
-if len(symbol.headers) == 1:
-  # SYMBOL(unqualified_name, namespace, header)
-  print("SYMBOL(%s, %s, %s)" % (symbol.name, symbol.namespace,
-symbol.headers[0]))
-elif len(symbol.headers) == 0:
-  sys.stderr.write("No header found for symbol %s\n" % symbol.name)
-else:
-  # FIXME: support symbols with multiple headers (e.g. std::move).
-  sys.stderr.write("Ambiguous header for symbol %s: %s\n" % (
-  symbol.name, ', '.join(symbol.headers)))
+  with open(path, "w") as f:  
+f.write(CODE_PREFIX % (language.upper(), cppreference_modified_date))
+f.write("\n")
+for symbol in symbols:
+  if len(symbol.headers) == 1:
+# SYMBOL(unqualified_name, namespace, header)
+f.write("SYMBOL(%s, %s, %s)\n" % (symbol.name, symbol.namespace,
+  symbol.headers[0]))
+  elif len(symbol.headers) == 0:
+sys.stderr.write("No header found for symbol %s\n" % symbol.name)
+  else:
+# FIXME: support symbols with multiple headers (e.g. std::move).
+sys.stderr.write("Ambiguous header for symbol %s: %s\n" % (
+symbol.name, ', '.join(symbol.headers)))
 
 
 if __name__ == '__main__':


Index: clang/tools/include-mapping/gen_std.py
===
--- clang/tools/include-mapping/gen_std.py
+++ clang/tools/include-mapping/gen_std.py
@@ -64,6 +64,14 @@
   default='cpp',
   help='Generate c or cpp symbols',
   required=True)
+  parser.add_argument('-output',
+  default='SymbolMap.inc',
+  help='path to the output file for symbol map',
+  required=True)
+  parser.add_argument('-removedoutput',
+  default='RemovedSymbolMap.inc',
+  help='path to the output file for removed symbols map',
+  required=False)
   return parser.parse_args()
 
 
@@ -87,6 +95,9 @@
   (symbol_index_root, "regex_constants.html", "std::regex_constants::"),
   (symbol_index_root, "this_thread.html", "std::this_thread::"),
 ]
+removed_symbols = cppreference_parser.GetSymbols(
+  [(symbol_index_root, "zombie_names.html", "std::")])
+WriteSymbols(args.language, removed_symbols, args.removedoutput, page_root)
   elif args.language == 'c':
 page_root = os.path.join(args.cppreference, "en", "c")
 symbol_index_root = page_root
@@ -96,24 +107,28 @@
 exit("Path %s doesn't exist!" % symbol_index_root)
 
   symbols = 

[PATCH] D139926: [clangd] Add semantic tokens for angle brackets

2023-01-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

> Note that we use this information to *animate* the matching tokens, i.e. when 
> the cursor is on one of them, both it and its counterpart get a special 
> highlighting. That's why it's so important that the language server 
> guarantees they always come in pairs.

Oh I see the argument here (somehow missed comment, probably because i had a 
stale window lying around), this totally makes sense. but I am still feeling 
uneasy due to implementation complexity (it's embarrassing but dealing with 
`>>` is quite problematic, still, with little value :/) + the UX we'll have in 
other editors by default.
Especially as this comes as two different `HighlightingKind`s and they're 
likely to get colored differently, and having your matching brackets in 
different colors is quite annoying.

I feel like editors can still have a quite good behaviour with existing 
operator highlights, as one can build an extra layer on top to provide 
"matching bracket" support, and whenever the data is broken (e.g. non-matching 
brackets) just keep using the results from last "successful" run.




Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:408
+  Position End = Begin;
+  ++End.character;
+  addToken(*LRange, HighlightingKind::AngleBracketOpen);

there can be weird cases like (same goes for -1 below):
```foo>\
>```

can you add tests to make sure we're handling these properly (or not producing 
braces for them if it complicates the logic too much, i don't think there'll be 
many cases where they pop-up).



Comment at: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp:930
+  $Class[[B]] $LocalVariable_def[[b]];
+  int $LocalVariable_def[[i]] = 
static_cast$AngleBracketOpen[[<]]int$AngleBracketClose[[>]](3.5);
+  void *$LocalVariable_def[[p]] = 
reinterpret_cast$AngleBracketOpen[[<]]void *$AngleBracketClose[[>]](0);

could you also add tests for `>>` and `>>>` to make sure they're handled 
correctly


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139926

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


[PATCH] D141381: [codegen] Store address of indirect arguments on the stack

2023-01-16 Thread Felipe de Azevedo Piovezan via Phabricator via cfe-commits
fdeazeve added a comment.

There is a real regression in 
`lldb/test/API/functionalities/param_entry_vals/basic_entry_values/` when this 
is compiled with O2 :

  __attribute__((noinline)) void func15(StructPassedViaPointerToTemporaryCopy 
S) 

It seems that, prior to this patch, `S` had debug information in O2 
 builds. I'll investigate.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141381

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


[clang] f2d301f - Revert "[codegen] Store address of indirect arguments on the stack"

2023-01-16 Thread Felipe de Azevedo Piovezan via cfe-commits

Author: Felipe de Azevedo Piovezan
Date: 2023-01-16T13:05:22-03:00
New Revision: f2d301fe82869f881b86b51da7b4752972c66707

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

LOG: Revert "[codegen] Store address of indirect arguments on the stack"

This reverts commit 7e4447a17db4a070f01c8f8a87505a4b2a1b0e3a.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDebugInfo.h
clang/lib/CodeGen/CGDecl.cpp
clang/test/CodeGen/aarch64-ls64.c
clang/test/CodeGen/atomic-arm64.c
clang/test/CodeGenCXX/amdgcn-func-arg.cpp
clang/test/CodeGenCXX/debug-info.cpp
clang/test/CodeGenCXX/derived-to-base-conv.cpp
clang/test/CodeGenCoroutines/coro-params-exp-namespace.cpp
clang/test/CodeGenCoroutines/coro-params.cpp
clang/test/OpenMP/for_firstprivate_codegen.cpp
clang/test/OpenMP/parallel_firstprivate_codegen.cpp
clang/test/OpenMP/sections_firstprivate_codegen.cpp
clang/test/OpenMP/single_firstprivate_codegen.cpp
clang/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp

clang/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp

clang/test/OpenMP/target_teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
clang/test/OpenMP/target_teams_distribute_simd_firstprivate_codegen.cpp
clang/test/OpenMP/teams_distribute_firstprivate_codegen.cpp
clang/test/OpenMP/teams_distribute_parallel_for_firstprivate_codegen.cpp

clang/test/OpenMP/teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
clang/test/OpenMP/teams_distribute_simd_firstprivate_codegen.cpp
clang/test/OpenMP/teams_firstprivate_codegen.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 731d10ac64a3f..3bbab951e8a8c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -500,9 +500,6 @@ Non-comprehensive list of changes in this release
 - Clang can now generate a PCH when using ``-fdelayed-template-parsing`` for
   code with templates containing loop hint pragmas, OpenMP pragmas, and
   ``#pragma unused``.
-- Clang now saves the address of ABI-indirect function parameters on the stack,
-  improving the debug information available in programs compiled without
-  optimizations.
 
 
 New Compiler Flags

diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index f2d558456fde4..f53a9d00ae5fd 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -4822,10 +4822,9 @@ void CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(
 
 llvm::DILocalVariable *
 CGDebugInfo::EmitDeclareOfArgVariable(const VarDecl *VD, llvm::Value *AI,
-  unsigned ArgNo, CGBuilderTy ,
-  const bool UsePointerValue) {
+  unsigned ArgNo, CGBuilderTy ) {
   assert(CGM.getCodeGenOpts().hasReducedDebugInfo());
-  return EmitDeclare(VD, AI, ArgNo, Builder, UsePointerValue);
+  return EmitDeclare(VD, AI, ArgNo, Builder);
 }
 
 namespace {

diff  --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h
index 10660a2550b56..95484a060cd88 100644
--- a/clang/lib/CodeGen/CGDebugInfo.h
+++ b/clang/lib/CodeGen/CGDebugInfo.h
@@ -487,9 +487,10 @@ class CGDebugInfo {
 
   /// Emit call to \c llvm.dbg.declare for an argument variable
   /// declaration.
-  llvm::DILocalVariable *
-  EmitDeclareOfArgVariable(const VarDecl *Decl, llvm::Value *AI, unsigned 
ArgNo,
-   CGBuilderTy , bool UsePointerValue = false);
+  llvm::DILocalVariable *EmitDeclareOfArgVariable(const VarDecl *Decl,
+  llvm::Value *AI,
+  unsigned ArgNo,
+  CGBuilderTy );
 
   /// Emit call to \c llvm.dbg.declare for the block-literal argument
   /// to a block invocation function.

diff  --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index a70997f5b27b8..ceaddc4e694ac 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -2476,8 +2476,6 @@ void CodeGenFunction::EmitParmDecl(const VarDecl , 
ParamValue Arg,
   Address AllocaPtr = Address::invalid();
   bool DoStore = false;
   bool IsScalar = hasScalarEvaluationKind(Ty);
-  bool UseIndirectDebugAddress = false;
-
   // If we already have a pointer to the argument, reuse the input pointer.
   if (Arg.isIndirect()) {
 // If we have a prettier pointer type at this point, bitcast to that.
@@ -2489,19 +2487,6 @@ void CodeGenFunction::EmitParmDecl(const VarDecl , 
ParamValue Arg,
 auto AllocaAS = CGM.getASTAllocaAddressSpace();
 auto *V = 

[PATCH] D141547: Fix format for `case` in .proto files

2023-01-16 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir accepted this revision.
krasimir added a comment.

Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141547

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


[PATCH] D141581: [clang] Make clangBasic and clangDriver depend on LLVMTargetParser.

2023-01-16 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added a comment.

In D141581#4056492 , @tschuett wrote:

> I though Clang Basic is a leaf library and must not depend on anything.

I wasn't aware of this requirement.  As of https://reviews.llvm.org/D137517 it 
depends on some auto-generated target information stored in `LLVMTargetParser` 
and `llvm/lib/Target/Target/RISCV/RISCV.td`. At the end, it is not even 
depending on the LLVMTargetParser library, it is just one header file in the 
public interface of the `TargetParser` that is needed (see explanation in 
https://reviews.llvm.org/D141581#4056503)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141581

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


[PATCH] D141581: [clang] Make clangBasic and clangDriver depend on LLVMTargetParser.

2023-01-16 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added a comment.

In D141581#4056464 , @lebedev.ri 
wrote:

> Why is it not sufficient to link to `RISCVTargetParserTableGen`, but is 
> sufficient to link to `LLVMTargetParser`?

This is because  the sources of clangBasic and clangDriver might be compiled 
before LLVMTargetParser is ready. In this case, compilation would fail because 
both libraries include the header file `llvm/TargetParser/RISCVTargetParser.h`, 
which needs the `inc` file generated by `RISCVTargetParserTableGen`.

  // quoting code from llvm/TargetParser/RISCVTargetParser.h
  enum CPUKind : unsigned {
  #define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH) CK_##ENUM,
  #define TUNE_PROC(ENUM, NAME) CK_##ENUM,
  #include "llvm/TargetParser/RISCVTargetParserDef.inc"
  };



> Does `RISCVTargetParserTableGen` itself not link to `LLVMTargetParser`?

Nope, there is no "linking" between these two components. It is just that 
`LLVMTargetParser` requires `RISCVTargetParserTableGen`. Therefore, if we say 
that `clangDriver` and `clangBasic` depend on `LLVMTargetParser` we make sure 
that the inclusion of the tablegen-generated file resolves correctly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141581

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


  1   2   >