[PATCH] D97965: [clang] Fix crash when creating deduction guide.

2021-03-07 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

Thanks!




Comment at: clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp:425
+  // This used to crash due to unparsed default arg above.
+  B(); // expected-error {{deduction guide declaration without trailing return 
type}}
+};

The diagnostic seems bogus, but I think it is at least better than crashing, 
I'd add add a FIXME to fix this bogus diagnostic here?.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97965

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


[PATCH] D72235: [clang-tidy] new altera unroll loops check

2021-03-07 Thread Frank Derry Wanye via Phabricator via cfe-commits
ffrankies updated this revision to Diff 328935.
ffrankies marked 4 inline comments as done.
ffrankies added a comment.

- Removed unnecessary braces.
- Simplified boolean return statements.


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

https://reviews.llvm.org/D72235

Files:
  clang-tools-extra/clang-tidy/altera/AlteraTidyModule.cpp
  clang-tools-extra/clang-tidy/altera/CMakeLists.txt
  clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
  clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/altera-unroll-loops.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/altera-unroll-loops.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/altera-unroll-loops.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/altera-unroll-loops.cpp
@@ -0,0 +1,518 @@
+// RUN: %check_clang_tidy %s altera-unroll-loops %t -- -config="{CheckOptions: [{key: "altera-unroll-loops.MaxLoopIterations", value: 50}]}" -header-filter=.*
+// RUN: %check_clang_tidy -check-suffix=MULT %s altera-unroll-loops %t -- -config="{CheckOptions: [{key: "altera-unroll-loops.MaxLoopIterations", value: 5}]}" -header-filter=.* "--" -DMULT
+
+#ifdef MULT
+// For loops with *= and /= increments.
+void for_loop_mult_div_increments(int *A) {
+// *=
+#pragma unroll
+for (int i = 2; i <= 32; i *= 2)
+A[i]++;  // OK
+
+#pragma unroll
+for (int i = 2; i <= 64; i *= 2)
+// CHECK-MESSAGES-MULT: :[[@LINE-1]]:5: warning: loop likely has a large number of iterations and thus cannot be fully unrolled; to partially unroll this loop, use the '#pragma unroll ' directive [altera-unroll-loops]
+A[i]++;  // Not OK
+
+// /=
+#pragma unroll
+for (int i = 32; i >= 2; i /= 2)
+A[i]++;  // OK
+
+#pragma unroll
+for (int i = 64; i >= 2; i /= 2)
+// CHECK-MESSAGES-MULT: :[[@LINE-1]]:5: warning: loop likely has a large number of iterations and thus cannot be fully unrolled; to partially unroll this loop, use the '#pragma unroll ' directive [altera-unroll-loops]
+A[i]++;  // Not OK
+}
+#else
+// Cannot determine loop bounds for while loops.
+void while_loops(int *A) {
+// Recommend unrolling loops that aren't already unrolled.
+int j = 0;
+while (j < 2000) {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: kernel performance could be improved by unrolling this loop with a '#pragma unroll' directive [altera-unroll-loops]
+A[1] += j;
+j++;
+}
+
+do {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: kernel performance could be improved by unrolling this loop with a '#pragma unroll' directive [altera-unroll-loops]
+A[2] += j;
+j++;
+} while (j < 2000);
+
+// If a while loop is fully unrolled, add a note recommending partial
+// unrolling.
+#pragma unroll
+while (j < 2000) {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: note: full unrolling requested, but loop bounds may not be known; to partially unroll this loop, use the '#pragma unroll ' directive
+A[j]++;
+}
+
+#pragma unroll
+do {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: note: full unrolling requested, but loop bounds may not be known; to partially unroll this loop, use the '#pragma unroll ' directive
+A[j]++;
+} while (j < 2000);
+
+// While loop is partially unrolled, no action needed.
+#pragma unroll 4
+while (j < 2000) {
+A[j]++;
+}
+
+#pragma unroll 4
+do {
+A[j]++;
+} while (j < 2000);
+}
+
+// Range-based for loops.
+void cxx_for_loops(int *A, int vectorSize) {
+// Loop with known array size should be unrolled.
+int a[] = { 0, 1, 2, 3, 4, 5 };
+for (int k : a) {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: kernel performance could be improved by unrolling this loop with a '#pragma unroll' directive [altera-unroll-loops]
+A[k]++;
+}
+
+// Loop with known size correctly unrolled.
+#pragma unroll
+for (int k : a) {
+A[k]++;
+}
+
+// Loop with unknown size should be partially unrolled.
+int b[vectorSize];
+#pragma unroll
+for (int k : b) {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: full unrolling requested, but loop bounds are not known; to partially unroll this loop, use the '#pragma unroll ' directive [altera-unroll-loops]
+k++;
+}
+
+// Loop with unknown size correctly unrolled.
+#pragma unroll 5
+for (int k : b) {
+k++;
+}
+
+// Loop with large size should be partially unrolled.
+int c[51];
+#pragma unroll
+for (int k : c) {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: loop likely has a large number of iterations and thus cannot be fully unrolled; to partially unroll this loop, use the '#pragma unroll ' directive [altera-unroll-loops]
+A[k]++;
+}
+
+// Loop 

[PATCH] D72235: [clang-tidy] new altera unroll loops check

2021-03-07 Thread Frank Derry Wanye via Phabricator via cfe-commits
ffrankies updated this revision to Diff 328933.
ffrankies added a comment.

- Surrounded language constructs with double back ticks in 
`clang-tools-extra/docs/clang-tidy/checks/altera-unroll-loops.rst`.
- Removed trailing whitespace.
- Added single quotes around `#pragma unroll`s in diagnostics.
- Added full stops to the comments that didn't have them in 
`clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp`


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

https://reviews.llvm.org/D72235

Files:
  clang-tools-extra/clang-tidy/altera/AlteraTidyModule.cpp
  clang-tools-extra/clang-tidy/altera/CMakeLists.txt
  clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
  clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/altera-unroll-loops.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/altera-unroll-loops.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/altera-unroll-loops.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/altera-unroll-loops.cpp
@@ -0,0 +1,518 @@
+// RUN: %check_clang_tidy %s altera-unroll-loops %t -- -config="{CheckOptions: [{key: "altera-unroll-loops.MaxLoopIterations", value: 50}]}" -header-filter=.*
+// RUN: %check_clang_tidy -check-suffix=MULT %s altera-unroll-loops %t -- -config="{CheckOptions: [{key: "altera-unroll-loops.MaxLoopIterations", value: 5}]}" -header-filter=.* "--" -DMULT
+
+#ifdef MULT
+// For loops with *= and /= increments.
+void for_loop_mult_div_increments(int *A) {
+// *=
+#pragma unroll
+for (int i = 2; i <= 32; i *= 2)
+A[i]++;  // OK
+
+#pragma unroll
+for (int i = 2; i <= 64; i *= 2)
+// CHECK-MESSAGES-MULT: :[[@LINE-1]]:5: warning: loop likely has a large number of iterations and thus cannot be fully unrolled; to partially unroll this loop, use the '#pragma unroll ' directive [altera-unroll-loops]
+A[i]++;  // Not OK
+
+// /=
+#pragma unroll
+for (int i = 32; i >= 2; i /= 2)
+A[i]++;  // OK
+
+#pragma unroll
+for (int i = 64; i >= 2; i /= 2)
+// CHECK-MESSAGES-MULT: :[[@LINE-1]]:5: warning: loop likely has a large number of iterations and thus cannot be fully unrolled; to partially unroll this loop, use the '#pragma unroll ' directive [altera-unroll-loops]
+A[i]++;  // Not OK
+}
+#else
+// Cannot determine loop bounds for while loops.
+void while_loops(int *A) {
+// Recommend unrolling loops that aren't already unrolled.
+int j = 0;
+while (j < 2000) {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: kernel performance could be improved by unrolling this loop with a '#pragma unroll' directive [altera-unroll-loops]
+A[1] += j;
+j++;
+}
+
+do {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: kernel performance could be improved by unrolling this loop with a '#pragma unroll' directive [altera-unroll-loops]
+A[2] += j;
+j++;
+} while (j < 2000);
+
+// If a while loop is fully unrolled, add a note recommending partial
+// unrolling.
+#pragma unroll
+while (j < 2000) {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: note: full unrolling requested, but loop bounds may not be known; to partially unroll this loop, use the '#pragma unroll ' directive
+A[j]++;
+}
+
+#pragma unroll
+do {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: note: full unrolling requested, but loop bounds may not be known; to partially unroll this loop, use the '#pragma unroll ' directive
+A[j]++;
+} while (j < 2000);
+
+// While loop is partially unrolled, no action needed.
+#pragma unroll 4
+while (j < 2000) {
+A[j]++;
+}
+
+#pragma unroll 4
+do {
+A[j]++;
+} while (j < 2000);
+}
+
+// Range-based for loops.
+void cxx_for_loops(int *A, int vectorSize) {
+// Loop with known array size should be unrolled.
+int a[] = { 0, 1, 2, 3, 4, 5 };
+for (int k : a) {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: kernel performance could be improved by unrolling this loop with a '#pragma unroll' directive [altera-unroll-loops]
+A[k]++;
+}
+
+// Loop with known size correctly unrolled.
+#pragma unroll
+for (int k : a) {
+A[k]++;
+}
+
+// Loop with unknown size should be partially unrolled.
+int b[vectorSize];
+#pragma unroll
+for (int k : b) {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: full unrolling requested, but loop bounds are not known; to partially unroll this loop, use the '#pragma unroll ' directive [altera-unroll-loops]
+k++;
+}
+
+// Loop with unknown size correctly unrolled.
+#pragma unroll 5
+for (int k : b) {
+k++;
+}
+
+// Loop with large size should be partially unrolled.
+int c[51];
+#pragma unroll
+for (int k : c) {
+// CHECK-MESSAGES: 

[PATCH] D96976: [analyzer] Fix reinterpret_cast handling for pointer-to-member

2021-03-07 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD updated this revision to Diff 328931.
RedDocMD added a comment.

Replaced smart-ptr dereference with direct access


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96976

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
  clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  clang/test/Analysis/reinterpret-cast-pointer-to-member.cpp

Index: clang/test/Analysis/reinterpret-cast-pointer-to-member.cpp
===
--- clang/test/Analysis/reinterpret-cast-pointer-to-member.cpp
+++ clang/test/Analysis/reinterpret-cast-pointer-to-member.cpp
@@ -1,11 +1,11 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
-// XFAIL: asserts
 
 void clang_analyzer_eval(bool);
 
-// TODO: The following test will work properly once reinterpret_cast on pointer-to-member is handled properly
 namespace testReinterpretCasting {
-struct Base {
+struct BaseOfBase {};
+
+struct Base : public BaseOfBase {
   int field;
 };
 
@@ -15,12 +15,51 @@
 
 struct Some {};
 
-void f() {
+void analyzableCasts() {
   int DoubleDerived::*ddf = ::field;
   int Base::*bf = reinterpret_cast(reinterpret_cast(reinterpret_cast(ddf)));
-  int Some::*sf = reinterpret_cast(ddf);
   Base base;
   base.field = 13;
   clang_analyzer_eval(base.*bf == 13); // expected-warning{{TRUE}}
 }
+
+void castOutsideHierarchy() {
+  int DoubleDerived::*ddf = ::field;
+  int Some::*sf = reinterpret_cast(ddf);
+  Some some;
+  some.*sf = 14;
+  clang_analyzer_eval(some.*sf == 14); // expected-warning{{UNKNOWN}}
+}
+
+void castAbove() {
+  int DoubleDerived::*ddf = ::field;
+  int BaseOfBase::*bbf = reinterpret_cast(ddf);
+  BaseOfBase bb;
+  bb.*bbf = 23;
+  clang_analyzer_eval(bb.*bbf == 23); // expected-warning{{UNKNOWN}}
+}
+
+namespace testMultipleInheritance {
+struct A {};
+struct B : public A {};
+struct C {
+  int field;
+};
+struct D : public C {};
+struct E : public B, public D {};
+struct F : public E {};
+
+void testMultiple() {
+  int F::*f = ::field;
+  int A::*a = reinterpret_cast(f);
+  int C::*c = reinterpret_cast(f);
+  A aobj;
+  C cobj;
+  aobj.*a = 13;
+  cobj.field = 29;
+  clang_analyzer_eval(aobj.*a == 13); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(cobj.*c == 29); // expected-warning{{TRUE}}
+}
+} // namespace testMultipleInheritance
+
 } // namespace testReinterpretCasting
Index: clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -522,8 +522,7 @@
 continue;
   }
   case CK_DerivedToBaseMemberPointer:
-  case CK_BaseToDerivedMemberPointer:
-  case CK_ReinterpretMemberPointer: {
+  case CK_BaseToDerivedMemberPointer: {
 SVal V = state->getSVal(Ex, LCtx);
 if (auto PTMSV = V.getAs()) {
   SVal CastedPTMSV =
@@ -537,6 +536,25 @@
 state = handleLVectorSplat(state, LCtx, CastE, Bldr, Pred);
 continue;
   }
+  case CK_ReinterpretMemberPointer: {
+SVal V = state->getSVal(Ex, LCtx);
+if (auto PTMSV = V.getAs()) {
+  if (const auto *ReinterpretE =
+  llvm::dyn_cast(CastE)) {
+if (const PointerToMemberData *Data =
+getBasicVals().basesForReinterpretCast(ReinterpretE,
+   *PTMSV)) {
+  SVal CastedPTMSV = svalBuilder.makePointerToMember(Data);
+  state = state->BindExpr(CastE, LCtx, CastedPTMSV);
+  Bldr.generateNode(CastE, Pred, state);
+  continue;
+}
+  }
+}
+// Explicitly proceed with default handler for this case cascade.
+state = handleLVectorSplat(state, LCtx, CastE, Bldr, Pred);
+continue;
+  }
   // Various C++ casts that are not handled yet.
   case CK_ToUnion:
   case CK_VectorSplat: {
Index: clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
===
--- clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
+++ clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
@@ -13,6 +13,7 @@
 //===--===//
 
 #include "clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h"
+#include "clang/AST/CXXInheritance.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/APSIntType.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/Store.h"
@@ -22,6 +23,7 @@
 #include "llvm/ADT/ImmutableList.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/SmallVector.h"
 #include 
 #include 
 #include 
@@ 

[PATCH] D97832: [X86] Refine "Support -march=alderlake"

2021-03-07 Thread Freddy, Ye via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5f9489b75405: [X86] Refine Support 
-march=alderlake (authored by FreddyYe).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97832

Files:
  clang/test/Preprocessor/predefined-arch-macros.c
  llvm/lib/Support/X86TargetParser.cpp
  llvm/lib/Target/X86/X86.td

Index: llvm/lib/Target/X86/X86.td
===
--- llvm/lib/Target/X86/X86.td
+++ llvm/lib/Target/X86/X86.td
@@ -784,17 +784,6 @@
   list SPRFeatures =
 !listconcat(ICXFeatures, SPRAdditionalFeatures);
 
-  // Alderlake
-  list ADLAdditionalFeatures = [FeatureAVXVNNI,
-  FeatureCLDEMOTE,
-  FeatureHRESET,
-  FeaturePTWRITE,
-  FeatureSERIALIZE,
-  FeatureWAITPKG];
-  list ADLTuning = SKLTuning;
-  list ADLFeatures =
-!listconcat(SKLFeatures, ADLAdditionalFeatures);
-
   // Atom
   list AtomFeatures = [FeatureX87,
  FeatureCMPXCHG8B,
@@ -873,6 +862,31 @@
   list TRMFeatures =
 !listconcat(GLPFeatures, TRMAdditionalFeatures);
 
+  // Alderlake
+  list ADLAdditionalFeatures = [FeatureSERIALIZE,
+  FeaturePCONFIG,
+  FeatureSHSTK,
+  FeatureWIDEKL,
+  FeatureINVPCID,
+  FeatureADX,
+  FeatureFMA,
+  FeatureVAES,
+  FeatureVPCLMULQDQ,
+  FeatureF16C,
+  FeatureBMI,
+  FeatureBMI2,
+  FeatureLZCNT,
+  FeatureAVXVNNI,
+  FeaturePKU,
+  FeatureHRESET,
+  FeatureCLDEMOTE,
+  FeatureMOVDIRI,
+  FeatureMOVDIR64B,
+  FeatureWAITPKG];
+  list ADLTuning = SKLTuning;
+  list ADLFeatures =
+!listconcat(TRMFeatures, ADLAdditionalFeatures);
+
   // Knights Landing
   list KNLFeatures = [FeatureX87,
 FeatureCMPXCHG8B,
Index: llvm/lib/Support/X86TargetParser.cpp
===
--- llvm/lib/Support/X86TargetParser.cpp
+++ llvm/lib/Support/X86TargetParser.cpp
@@ -205,9 +205,6 @@
 FeatureENQCMD | FeatureMOVDIR64B | FeatureMOVDIRI | FeaturePTWRITE |
 FeatureSERIALIZE | FeatureSHSTK | FeatureTSXLDTRK | FeatureUINTR |
 FeatureWAITPKG | FeatureAVXVNNI;
-constexpr FeatureBitset FeaturesAlderlake =
-FeaturesSkylakeClient | FeatureCLDEMOTE | FeatureHRESET | FeaturePTWRITE |
-FeatureSERIALIZE | FeatureWAITPKG | FeatureAVXVNNI;
 
 // Intel Atom processors.
 // Bonnell has feature parity with Core2 and adds MOVBE.
@@ -223,6 +220,12 @@
 FeaturesGoldmont | FeaturePTWRITE | FeatureRDPID | FeatureSGX;
 constexpr FeatureBitset FeaturesTremont =
 FeaturesGoldmontPlus | FeatureCLWB | FeatureGFNI;
+constexpr FeatureBitset FeaturesAlderlake =
+FeaturesTremont | FeatureADX | FeatureBMI | FeatureBMI2 | FeatureF16C |
+FeatureFMA | FeatureINVPCID | FeatureLZCNT | FeaturePCONFIG | FeaturePKU |
+FeatureSERIALIZE | FeatureSHSTK | FeatureVAES | FeatureVPCLMULQDQ |
+FeatureCLDEMOTE | FeatureMOVDIR64B | FeatureMOVDIRI | FeatureWAITPKG |
+FeatureAVXVNNI | FeatureHRESET | FeatureWIDEKL;
 
 // Geode Processor.
 constexpr FeatureBitset FeaturesGeode =
Index: clang/test/Preprocessor/predefined-arch-macros.c
===
--- clang/test/Preprocessor/predefined-arch-macros.c
+++ clang/test/Preprocessor/predefined-arch-macros.c
@@ -1791,32 +1791,53 @@
 // CHECK_ADL_M32: #define __BMI__ 1
 // CHECK_ADL_M32: #define __CLDEMOTE__ 1
 // CHECK_ADL_M32: #define __CLFLUSHOPT__ 1
+// CHECK_ADL_M32: #define __CLWB__ 1
 // CHECK_ADL_M32: #define __F16C__ 1
 // CHECK_ADL_M32: #define __FMA__ 1
+// CHECK_ADL_M32: #define __FSGSBASE__ 1
+// CHECK_ADL_M32: #define __FXSR__ 1
+// CHECK_ADL_M32: #define __GFNI__ 1
 // CHECK_ADL_M32: #define __HRESET__ 1
 // CHECK_ADL_M32: #define __INVPCID__ 1
+// CHECK_ADL_M32: #define 

[clang] 5f9489b - [X86] Refine "Support -march=alderlake"

2021-03-07 Thread Freddy Ye via cfe-commits

Author: Freddy Ye
Date: 2021-03-08T13:17:18+08:00
New Revision: 5f9489b754055da979876bcb5a357310251c6b87

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

LOG: [X86] Refine "Support -march=alderlake"

Refine "Support -march=alderlake"
Compare with tremont, it includes 25 more new features. They are
adx, aes, avx, avx2, avxvnni, bmi, bmi2, cldemote, f16c, fma, hreset, invpcid,
kl, lzcnt, movdir64b, movdiri, pclmulqdq, pconfig, pku, serialize, shstk, vaes,
vpclmulqdq, waitpkg, widekl.

Reviewed By: pengfei

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

Added: 


Modified: 
clang/test/Preprocessor/predefined-arch-macros.c
llvm/lib/Support/X86TargetParser.cpp
llvm/lib/Target/X86/X86.td

Removed: 




diff  --git a/clang/test/Preprocessor/predefined-arch-macros.c 
b/clang/test/Preprocessor/predefined-arch-macros.c
index 254ca60af846..48874fdc08f5 100644
--- a/clang/test/Preprocessor/predefined-arch-macros.c
+++ b/clang/test/Preprocessor/predefined-arch-macros.c
@@ -1791,32 +1791,53 @@
 // CHECK_ADL_M32: #define __BMI__ 1
 // CHECK_ADL_M32: #define __CLDEMOTE__ 1
 // CHECK_ADL_M32: #define __CLFLUSHOPT__ 1
+// CHECK_ADL_M32: #define __CLWB__ 1
 // CHECK_ADL_M32: #define __F16C__ 1
 // CHECK_ADL_M32: #define __FMA__ 1
+// CHECK_ADL_M32: #define __FSGSBASE__ 1
+// CHECK_ADL_M32: #define __FXSR__ 1
+// CHECK_ADL_M32: #define __GFNI__ 1
 // CHECK_ADL_M32: #define __HRESET__ 1
 // CHECK_ADL_M32: #define __INVPCID__ 1
+// CHECK_ADL_M32: #define __KL__ 1
 // CHECK_ADL_M32: #define __LZCNT__ 1
 // CHECK_ADL_M32: #define __MMX__ 1
 // CHECK_ADL_M32: #define __MOVBE__ 1
+// CHECK_ADL_M32: #define __MOVDIR64B__ 1
+// CHECK_ADL_M32: #define __MOVDIRI__ 1
 // CHECK_ADL_M32: #define __PCLMUL__ 1
+// CHECK_ADL_M32: #define __PCONFIG__ 1
+// CHECK_ADL_M32: #define __PKU__ 1
 // CHECK_ADL_M32: #define __POPCNT__ 1
 // CHECK_ADL_M32: #define __PRFCHW__ 1
 // CHECK_ADL_M32: #define __PTWRITE__ 1
+// CHECK_ADL_M32: #define __RDPID__ 1
 // CHECK_ADL_M32: #define __RDRND__ 1
 // CHECK_ADL_M32: #define __RDSEED__ 1
 // CHECK_ADL_M32: #define __SERIALIZE__ 1
 // CHECK_ADL_M32: #define __SGX__ 1
+// CHECK_ADL_M32: #define __SHA__ 1
+// CHECK_ADL_M32: #define __SHSTK__ 1
 // CHECK_ADL_M32: #define __SSE2__ 1
 // CHECK_ADL_M32: #define __SSE3__ 1
 // CHECK_ADL_M32: #define __SSE4_1__ 1
 // CHECK_ADL_M32: #define __SSE4_2__ 1
+// CHECK_ADL_M32: #define __SSE_MATH__ 1
 // CHECK_ADL_M32: #define __SSE__ 1
 // CHECK_ADL_M32: #define __SSSE3__ 1
+// CHECK_ADL_M32: #define __VAES__ 1
+// CHECK_ADL_M32: #define __VPCLMULQDQ__ 1
 // CHECK_ADL_M32: #define __WAITPKG__ 1
+// CHECK_ADL_M32: #define __WIDEKL__ 1
 // CHECK_ADL_M32: #define __XSAVEC__ 1
 // CHECK_ADL_M32: #define __XSAVEOPT__ 1
 // CHECK_ADL_M32: #define __XSAVES__ 1
 // CHECK_ADL_M32: #define __XSAVE__ 1
+// CHECK_ADL_M32: #define __corei7 1
+// CHECK_ADL_M32: #define __corei7__ 1
+// CHECK_ADL_M32: #define __i386 1
+// CHECK_ADL_M32: #define __i386__ 1
+// CHECK_ADL_M32: #define __tune_corei7__ 1
 // CHECK_ADL_M32: #define i386 1
 
 // RUN: %clang -march=alderlake -m64 -E -dM %s -o - 2>&1 \
@@ -1832,21 +1853,33 @@
 // CHECK_ADL_M64: #define __BMI__ 1
 // CHECK_ADL_M64: #define __CLDEMOTE__ 1
 // CHECK_ADL_M64: #define __CLFLUSHOPT__ 1
+// CHECK_ADL_M64: #define __CLWB__ 1
 // CHECK_ADL_M64: #define __F16C__ 1
 // CHECK_ADL_M64: #define __FMA__ 1
+// CHECK_ADL_M64: #define __FSGSBASE__ 1
+// CHECK_ADL_M64: #define __FXSR__ 1
+// CHECK_ADL_M64: #define __GFNI__ 1
 // CHECK_ADL_M64: #define __HRESET__ 1
 // CHECK_ADL_M64: #define __INVPCID__ 1
+// CHECK_ADL_M64: #define __KL__ 1
 // CHECK_ADL_M64: #define __LZCNT__ 1
 // CHECK_ADL_M64: #define __MMX__ 1
 // CHECK_ADL_M64: #define __MOVBE__ 1
+// CHECK_ADL_M64: #define __MOVDIR64B__ 1
+// CHECK_ADL_M64: #define __MOVDIRI__ 1
 // CHECK_ADL_M64: #define __PCLMUL__ 1
+// CHECK_ADL_M64: #define __PCONFIG__ 1
+// CHECK_ADL_M64: #define __PKU__ 1
 // CHECK_ADL_M64: #define __POPCNT__ 1
 // CHECK_ADL_M64: #define __PRFCHW__ 1
 // CHECK_ADL_M64: #define __PTWRITE__ 1
+// CHECK_ADL_M64: #define __RDPID__ 1
 // CHECK_ADL_M64: #define __RDRND__ 1
 // CHECK_ADL_M64: #define __RDSEED__ 1
 // CHECK_ADL_M64: #define __SERIALIZE__ 1
 // CHECK_ADL_M64: #define __SGX__ 1
+// CHECK_ADL_M64: #define __SHA__ 1
+// CHECK_ADL_M64: #define __SHSTK__ 1
 // CHECK_ADL_M64: #define __SSE2_MATH__ 1
 // CHECK_ADL_M64: #define __SSE2__ 1
 // CHECK_ADL_M64: #define __SSE3__ 1
@@ -1855,13 +1888,19 @@
 // CHECK_ADL_M64: #define __SSE_MATH__ 1
 // CHECK_ADL_M64: #define __SSE__ 1
 // CHECK_ADL_M64: #define __SSSE3__ 1
+// CHECK_ADL_M64: #define __VAES__ 1
+// CHECK_ADL_M64: #define __VPCLMULQDQ__ 1
 // CHECK_ADL_M64: #define __WAITPKG__ 1
+// CHECK_ADL_M64: #define __WIDEKL__ 1
 // CHECK_ADL_M64: #define __XSAVEC__ 1
 // 

[PATCH] D96976: [analyzer] Fix reinterpret_cast handling for pointer-to-member

2021-03-07 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD added a comment.

In D96976#2605815 , @steakhal wrote:

> What is that caveat?

The second point in the link I gave above.

> Do you have anything specific in mind about implementing the 3rd option?
> Why do you think it's //significantly complex//?

The modelling is not so complex. We need to store in the pointer-to-member a 
bool to remember that it was reinterpret_casted, and a  CXXRecordDecl pointer 
to store where it was reinterpret_casted from. If it is reinterpret_casted back 
properly, then these are reset. If we do further reinterpret_casting or 
static_cast on this, then we can store in a bool that the pointer-to-member is 
unsafe to de-reference.
The problem is utilizing this fact (that pointer-to-member is safe or not to 
de-reference). This, I reckon, is a big refactor.
@steakhal, @vsavchenko, @NoQ what do you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96976

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


[PATCH] D93938: [clang-format] Fixed AfterEnum handling

2021-03-07 Thread Ally Tiritoglu via Phabricator via cfe-commits
atirit added a comment.

Has anyone had the chance to review this yet? (not trying to be pushy, just 
curious)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93938

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


[PATCH] D97265: [clang] Allow clang-check to customize analyzer output file or dir name

2021-03-07 Thread Ella Ma via Phabricator via cfe-commits
OikawaKirie updated this revision to Diff 328927.
OikawaKirie added a comment.

Replace concatenating the output from clang-check and plist with separated 
checks to workaround the test failure on Windows.


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

https://reviews.llvm.org/D97265

Files:
  clang/test/Tooling/clang-check-set-analyzer-output-path.cpp
  clang/tools/clang-check/ClangCheck.cpp


Index: clang/tools/clang-check/ClangCheck.cpp
===
--- clang/tools/clang-check/ClangCheck.cpp
+++ clang/tools/clang-check/ClangCheck.cpp
@@ -76,7 +76,10 @@
 Analyze("analyze",
 cl::desc(Options.getOptionHelpText(options::OPT_analyze)),
 cl::cat(ClangCheckCategory));
-
+static cl::opt
+AnalyzerOutput("analyzer-output-path",
+   cl::desc(Options.getOptionHelpText(options::OPT_o)),
+   cl::cat(ClangCheckCategory));
 static cl::opt
 Fixit("fixit", cl::desc(Options.getOptionHelpText(options::OPT_fixit)),
   cl::cat(ClangCheckCategory));
@@ -206,7 +209,19 @@
 
   // Clear adjusters because -fsyntax-only is inserted by the default chain.
   Tool.clearArgumentsAdjusters();
-  Tool.appendArgumentsAdjuster(getClangStripOutputAdjuster());
+
+  // Reset output path if is provided by user.
+  Tool.appendArgumentsAdjuster(
+  Analyze ? [&](const CommandLineArguments , StringRef File) {
+  auto Ret = getClangStripOutputAdjuster()(Args, File);
+  if (!AnalyzerOutput.empty()) {
+Ret.emplace_back("-o");
+Ret.emplace_back(AnalyzerOutput);
+  }
+  return Ret;
+}
+  : getClangStripOutputAdjuster());
+
   Tool.appendArgumentsAdjuster(getClangStripDependencyFileAdjuster());
 
   // Running the analyzer requires --analyze. Other modes can work with the
Index: clang/test/Tooling/clang-check-set-analyzer-output-path.cpp
===
--- /dev/null
+++ clang/test/Tooling/clang-check-set-analyzer-output-path.cpp
@@ -0,0 +1,14 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: cd %t
+// RUN: echo '[{"directory":".","command":"clang++ -c %t/test.cpp -o foo 
-ofoo","file":"%t/test.cpp"}]' | sed -e 's/\\/\//g' > %t/compile_commands.json
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: echo '// CHECK: {{qwerty}}' > %t/cclog-check
+// RUN: clang-check -p "%t" "%t/test.cpp" -analyze 
-analyzer-output-path=%t/qwerty -extra-arg=-v -extra-arg=-Xclang 
-extra-arg=-verify 2>&1 | FileCheck %t/cclog-check
+// RUN: FileCheck %s --input-file=%t/qwerty
+
+// CHECK: DOCTYPE plist
+// CHECK: Division by zero
+int f() {
+  return 1 / 0; // expected-warning {{Division by zero}}
+}


Index: clang/tools/clang-check/ClangCheck.cpp
===
--- clang/tools/clang-check/ClangCheck.cpp
+++ clang/tools/clang-check/ClangCheck.cpp
@@ -76,7 +76,10 @@
 Analyze("analyze",
 cl::desc(Options.getOptionHelpText(options::OPT_analyze)),
 cl::cat(ClangCheckCategory));
-
+static cl::opt
+AnalyzerOutput("analyzer-output-path",
+   cl::desc(Options.getOptionHelpText(options::OPT_o)),
+   cl::cat(ClangCheckCategory));
 static cl::opt
 Fixit("fixit", cl::desc(Options.getOptionHelpText(options::OPT_fixit)),
   cl::cat(ClangCheckCategory));
@@ -206,7 +209,19 @@
 
   // Clear adjusters because -fsyntax-only is inserted by the default chain.
   Tool.clearArgumentsAdjusters();
-  Tool.appendArgumentsAdjuster(getClangStripOutputAdjuster());
+
+  // Reset output path if is provided by user.
+  Tool.appendArgumentsAdjuster(
+  Analyze ? [&](const CommandLineArguments , StringRef File) {
+  auto Ret = getClangStripOutputAdjuster()(Args, File);
+  if (!AnalyzerOutput.empty()) {
+Ret.emplace_back("-o");
+Ret.emplace_back(AnalyzerOutput);
+  }
+  return Ret;
+}
+  : getClangStripOutputAdjuster());
+
   Tool.appendArgumentsAdjuster(getClangStripDependencyFileAdjuster());
 
   // Running the analyzer requires --analyze. Other modes can work with the
Index: clang/test/Tooling/clang-check-set-analyzer-output-path.cpp
===
--- /dev/null
+++ clang/test/Tooling/clang-check-set-analyzer-output-path.cpp
@@ -0,0 +1,14 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: cd %t
+// RUN: echo '[{"directory":".","command":"clang++ -c %t/test.cpp -o foo -ofoo","file":"%t/test.cpp"}]' | sed -e 's/\\/\//g' > %t/compile_commands.json
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: echo '// CHECK: {{qwerty}}' > %t/cclog-check
+// RUN: clang-check -p "%t" "%t/test.cpp" -analyze -analyzer-output-path=%t/qwerty -extra-arg=-v -extra-arg=-Xclang -extra-arg=-verify 2>&1 | 

[PATCH] D97198: [OpenMP][Clang][NVPTX] Only build one bitcode library for each SM

2021-03-07 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert 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/D97198/new/

https://reviews.llvm.org/D97198

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


[PATCH] D97198: [OpenMP][Clang][NVPTX] Only build one bitcode library for each SM

2021-03-07 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 328926.
tianshilei1992 added a comment.

rebase and ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97198

Files:
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/test/Driver/Inputs/libomptarget/libomptarget-nvptx-cuda_102-sm_35.bc
  clang/test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_35.bc
  clang/test/Driver/openmp-offload-gpu.c
  openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
  openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu

Index: openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu
===
--- openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu
+++ openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu
@@ -53,46 +53,28 @@
   return (double)nsecs * __kmpc_impl_get_wtick();
 }
 
-// In Cuda 9.0, __ballot(1) from Cuda 8.0 is replaced with __activemask().
 DEVICE __kmpc_impl_lanemask_t __kmpc_impl_activemask() {
-#if CUDA_VERSION < 9020
-  return __nvvm_vote_ballot(1);
-#else
   unsigned int Mask;
   asm volatile("activemask.b32 %0;" : "=r"(Mask));
   return Mask;
-#endif
 }
 
-// In Cuda 9.0, the *_sync() version takes an extra argument 'mask'.
 DEVICE int32_t __kmpc_impl_shfl_sync(__kmpc_impl_lanemask_t Mask, int32_t Var,
  int32_t SrcLane) {
-#if CUDA_VERSION >= 9000
   return __nvvm_shfl_sync_idx_i32(Mask, Var, SrcLane, 0x1f);
-#else
-  return __nvvm_shfl_idx_i32(Var, SrcLane, 0x1f);
-#endif // CUDA_VERSION
 }
 
 DEVICE int32_t __kmpc_impl_shfl_down_sync(__kmpc_impl_lanemask_t Mask,
   int32_t Var, uint32_t Delta,
   int32_t Width) {
   int32_t T = ((WARPSIZE - Width) << 8) | 0x1f;
-#if CUDA_VERSION >= 9000
   return __nvvm_shfl_sync_down_i32(Mask, Var, Delta, T);
-#else
-  return __nvvm_shfl_down_i32(Var, Delta, T);
-#endif // CUDA_VERSION
 }
 
 DEVICE void __kmpc_impl_syncthreads() { __syncthreads(); }
 
 DEVICE void __kmpc_impl_syncwarp(__kmpc_impl_lanemask_t Mask) {
-#if CUDA_VERSION >= 9000
   __nvvm_bar_warp_sync(Mask);
-#else
-  // In Cuda < 9.0 no need to sync threads in warps.
-#endif // CUDA_VERSION
 }
 
 // NVPTX specific kernel initialization
Index: openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
===
--- openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
+++ openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
@@ -137,6 +137,7 @@
  -Xclang -emit-llvm-bc
  -Xclang -aux-triple -Xclang ${aux_triple}
  -fopenmp -fopenmp-cuda-mode -Xclang -fopenmp-is-device
+ -Xclang -target-feature -Xclang +ptx61
  -D__CUDACC__
  -I${devicertl_base_directory}
  -I${devicertl_nvptx_directory}/src)
@@ -150,81 +151,51 @@
 # Create target to build all Bitcode libraries.
 add_custom_target(omptarget-nvptx-bc)
 
-# This map is from clang/lib/Driver/ToolChains/Cuda.cpp.
-# The last element is the default case.
-set(cuda_version_list 112 111 110 102 101 100 92 91 90 80)
-set(ptx_feature_list 70 70 70 65 64 63 61 61 60 42)
-# The following two lines of ugly code is not needed when the minimal CMake
-# version requirement is 3.17+.
-list(LENGTH cuda_version_list num_version_supported)
-math(EXPR loop_range "${num_version_supported} - 1")
-
-# Generate a Bitcode library for all the compute capabilities the user
-# requested and all PTX version we know for now.
+# Generate a Bitcode library for all the compute capabilities the user requested
 foreach(sm ${nvptx_sm_list})
-  set(sm_flags -Xclang -target-cpu -Xclang sm_${sm} "-D__CUDA_ARCH__=${sm}0")
-
-  # Uncomment the following code and remove those ugly part if the feature
-  # is available.
-  # foreach(cuda_version ptx_num IN ZIP_LISTS cuda_version_list ptx_feature_list)
-  foreach(itr RANGE ${loop_range})
-list(GET cuda_version_list ${itr} cuda_version)
-list(GET ptx_feature_list ${itr} ptx_num)
-set(cuda_flags ${sm_flags})
-list(APPEND cuda_flags -Xclang -target-feature -Xclang +ptx${ptx_num})
-if("${cuda_version}" MATCHES "^([0-9]+)([0-9])$")
-  set(cuda_version_major ${CMAKE_MATCH_1})
-  set(cuda_version_minor ${CMAKE_MATCH_2})
-else()
-  libomptarget_error_say(
-"Unrecognized CUDA version format: ${cuda_version}")
-endif()
-list(APPEND cuda_flags
-  "-DCUDA_VERSION=${cuda_version_major}0${cuda_version_minor}0")
-
-set(bc_files "")
-foreach(src ${cuda_src_files})
-  get_filename_component(infile ${src} ABSOLUTE)
-  get_filename_component(outfile ${src} NAME)
-  set(outfile "${outfile}-cuda_${cuda_version}-sm_${sm}.bc")
-
-  add_custom_command(OUTPUT ${outfile}
-COMMAND ${cuda_compiler} ${bc_flags}
-  ${cuda_flags} ${MAX_SM_DEFINITION} ${infile} -o ${outfile}
-DEPENDS ${infile}
-  

[PATCH] D98160: [clang] Use decltype((E)) for compound requirement type constraint

2021-03-07 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: clang/lib/Sema/SemaType.cpp:8838
+/// that expression, without accounting for the rules.
+static QualType getBaseDecltypeForExpr(Sema , Expr *E) {
+  // C++11 [dcl.type.simple]p4:

I think a better name for this might be `getDecltypeForNonIdentifierExpr` 
and/or `getDecltypeForParenthesizedExpr`.
Depending on the mental model you want people to have, `ImplicitParens` might 
be better named `AsNonIdentifier`.
The thing we're enabling/disabling here is "whether to treat an 
//id-expression// differently from any other kind of expression."

Also, FYI and FWIW, I have a proposal in the pipeline for C++23 that will make 
"the decltype of" the //id-expression// in `return x` into an rvalue (for the 
purposes of `decltype(auto)` return types). So it might be worth thinking about 
what that codepath would look like, since it's another example of "treating 
//id-expressions// differently from other kinds of expressions (but in a 
different way from how we already do)."
http://quuxplusone.github.io/draft/d2266-implicit-move-rvalue-ref.html
If I ran the zoo, I'd have a primitive function for "get the decltype of this 
expression, ignoring all crazy //id-expression// rules," and then I'd layer 
various helper functions on top of it that did, like, "if (is id-expression) 
craziness; else call the primitive function."

Finally, your comment on line 8837 ought to indicate //what// rules it's not 
accounting for. "The rules" is pretty vague. ;)



Comment at: 
clang/test/CXX/expr/expr.prim/expr.prim.req/compound-requirement.cpp:97
 template
-concept Large = sizeof(T) >= 4; // expected-note{{because 'sizeof(short) >= 4' 
(2 >= 4) evaluated to false}}
+concept LargeRef = sizeof(typename reference::type) >= 4;
+// expected-note@-1{{because 'sizeof(typename reference::type) >= 4' 
(2 >= 4) evaluated to false}}

I think this is too large of a change. How about just keeping the old test code 
but changing it to
```
template
concept Large = sizeof(std::decay_t) >= 4; // expected-note{{because... etc}}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98160

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


[PATCH] D98095: [clang] Fix ICE on invalid type parameters for concepts

2021-03-07 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 328919.
mizvekov added a comment.

Repush, no changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98095

Files:
  clang/lib/Sema/SemaType.cpp
  clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp

Index: clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp
===
--- clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp
+++ clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp
@@ -68,3 +68,11 @@
   True decltype(auto) h = (b);
   static_assert(is_same_v);
 }
+
+namespace PR48593 {
+  template  concept a = true; // expected-note{{template parameter is declared here}}
+  a auto c = 0; // expected-error{{template argument for template type parameter must be a type}}
+
+  template concept d = true;
+  d<,> auto e = 0; // expected-error{{expected expression}}
+}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1256,25 +1256,6 @@
   return OpenCLAccessAttr::Keyword_read_only;
 }
 
-static QualType ConvertConstrainedAutoDeclSpecToType(Sema , DeclSpec ,
- AutoTypeKeyword AutoKW) {
-  assert(DS.isConstrainedAuto());
-  TemplateIdAnnotation *TemplateId = DS.getRepAsTemplateId();
-  TemplateArgumentListInfo TemplateArgsInfo;
-  TemplateArgsInfo.setLAngleLoc(TemplateId->LAngleLoc);
-  TemplateArgsInfo.setRAngleLoc(TemplateId->RAngleLoc);
-  ASTTemplateArgsPtr TemplateArgsPtr(TemplateId->getTemplateArgs(),
- TemplateId->NumArgs);
-  S.translateTemplateArguments(TemplateArgsPtr, TemplateArgsInfo);
-  llvm::SmallVector TemplateArgs;
-  for (auto  : TemplateArgsInfo.arguments())
-TemplateArgs.push_back(ArgLoc.getArgument());
-  return S.Context.getAutoType(
-  QualType(), AutoKW, false, /*IsPack=*/false,
-  cast(TemplateId->Template.get().getAsTemplateDecl()),
-  TemplateArgs);
-}
-
 /// Convert the specified declspec to the appropriate type
 /// object.
 /// \param state Specifies the declarator containing the declaration specifier
@@ -1655,29 +1636,39 @@
 break;
 
   case DeclSpec::TST_auto:
+  case DeclSpec::TST_decltype_auto: {
+auto AutoKW = DS.getTypeSpecType() == DeclSpec::TST_decltype_auto
+  ? AutoTypeKeyword::DecltypeAuto
+  : AutoTypeKeyword::Auto;
+
+TemplateIdAnnotation *TemplateId = DS.getRepAsTemplateId();
+ConceptDecl *TypeConstraintConcept = nullptr;
+llvm::SmallVector TemplateArgs;
 if (DS.isConstrainedAuto()) {
-  Result = ConvertConstrainedAutoDeclSpecToType(S, DS,
-AutoTypeKeyword::Auto);
-  break;
+  if (TemplateId) {
+TypeConstraintConcept =
+cast(TemplateId->Template.get().getAsTemplateDecl());
+TemplateArgumentListInfo TemplateArgsInfo;
+TemplateArgsInfo.setLAngleLoc(TemplateId->LAngleLoc);
+TemplateArgsInfo.setRAngleLoc(TemplateId->RAngleLoc);
+ASTTemplateArgsPtr TemplateArgsPtr(TemplateId->getTemplateArgs(),
+   TemplateId->NumArgs);
+S.translateTemplateArguments(TemplateArgsPtr, TemplateArgsInfo);
+for (auto  : TemplateArgsInfo.arguments())
+  TemplateArgs.push_back(ArgLoc.getArgument());
+  } else
+declarator.setInvalidType(true);
 }
-Result = Context.getAutoType(QualType(), AutoTypeKeyword::Auto, false);
+Result = S.Context.getAutoType(QualType(), AutoKW,
+   /*IsDependent*/ false, /*IsPack=*/false,
+   TypeConstraintConcept, TemplateArgs);
 break;
+  }
 
   case DeclSpec::TST_auto_type:
 Result = Context.getAutoType(QualType(), AutoTypeKeyword::GNUAutoType, false);
 break;
 
-  case DeclSpec::TST_decltype_auto:
-if (DS.isConstrainedAuto()) {
-  Result =
-  ConvertConstrainedAutoDeclSpecToType(S, DS,
-   AutoTypeKeyword::DecltypeAuto);
-  break;
-}
-Result = Context.getAutoType(QualType(), AutoTypeKeyword::DecltypeAuto,
- /*IsDependent*/ false);
-break;
-
   case DeclSpec::TST_unknown_anytype:
 Result = Context.UnknownAnyTy;
 break;
@@ -5955,15 +5946,17 @@
   TL.setNameLoc(DS.getTypeSpecTypeLoc());
   if (!DS.isConstrainedAuto())
 return;
-  TemplateIdAnnotation *TemplateId = DS.getRepAsTemplateId();
   if (DS.getTypeSpecScope().isNotEmpty())
 TL.setNestedNameSpecifierLoc(
 DS.getTypeSpecScope().getWithLocInContext(Context));
   else
 TL.setNestedNameSpecifierLoc(NestedNameSpecifierLoc());
+  TL.setFoundDecl(nullptr);
+  TemplateIdAnnotation 

[PATCH] D98160: [clang] Use decltype((E)) for compound requirement type constraint

2021-03-07 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov created this revision.
mizvekov requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Compound requirement type constraints were using decltype(E) instead of
decltype((E)), as per `[expr.prim.req]p1.3.3`.

Signed-off-by: Matheus Izvekov 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98160

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.req/compound-requirement.cpp

Index: clang/test/CXX/expr/expr.prim/expr.prim.req/compound-requirement.cpp
===
--- clang/test/CXX/expr/expr.prim/expr.prim.req/compound-requirement.cpp
+++ clang/test/CXX/expr/expr.prim/expr.prim.req/compound-requirement.cpp
@@ -79,19 +79,34 @@
 template
 constexpr bool is_same_v = true;
 
+template struct reference {
+	using type = T;
+	static constexpr bool value = false;
+};
+template struct reference {
+	using type = T;
+	static constexpr bool value = true;
+};
+
 template
 concept Same = is_same_v;
 
+template concept Ref = reference::value;
+
 template
-concept Large = sizeof(T) >= 4; // expected-note{{because 'sizeof(short) >= 4' (2 >= 4) evaluated to false}}
+concept LargeRef = sizeof(typename reference::type) >= 4;
+// expected-note@-1{{because 'sizeof(typename reference::type) >= 4' (2 >= 4) evaluated to false}}
 
-template requires requires (T t) { { t } -> Large; } // expected-note{{because 'decltype(t)' (aka 'short') does not satisfy 'Large':}}
+template requires requires (T t) {
+  { t } -> Ref;
+  { t } -> LargeRef; // expected-note{{because 'decltype((t))' (aka 'short &') does not satisfy 'LargeRef':}}
+}
 struct r7 {};
 
 using r7i1 = r7;
 using r7i2 = r7; // expected-error{{constraints not satisfied for class template 'r7' [with T = short]}}
 
-template requires requires (T t) { { t } -> Same; }
+template requires requires (T t) { { t } -> Same; }
 struct r8 {};
 
 using r8i1 = r8;
@@ -99,7 +114,8 @@
 
 // Substitution failure in type constraint
 
-template requires requires (T t) { { t } -> Same; } // expected-note{{because 'Same' would be invalid: type 'int' cannot be used prior to '::' because it has no members}}
+template requires requires (T t) { { t } -> Same; }
+// expected-note@-1{{because 'Same' would be invalid: type 'int' cannot be used prior to '::' because it has no members}}
 struct r9 {};
 
 struct M { using type = M; };
@@ -172,4 +188,4 @@
   static_assert(C5);
   template struct C5_check {}; // expected-note{{because 'short' does not satisfy 'C5'}}
   using c5 = C5_check; // expected-error{{constraints not satisfied for class template 'C5_check' [with T = short]}}
-}
\ No newline at end of file
+}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -8833,13 +8833,35 @@
   return Context.getTypeOfExprType(E);
 }
 
+/// getBaseDecltypeForExpr - Given an expr, will return the decltype for
+/// that expression, without accounting for the rules.
+static QualType getBaseDecltypeForExpr(Sema , Expr *E) {
+  // C++11 [dcl.type.simple]p4:
+  //   [...]
+  QualType T = E->getType();
+  switch (E->getValueKind()) {
+  // - otherwise, if e is an xvalue, decltype(e) is T&&, where T is the
+  //   type of e;
+  case VK_XValue:
+T = S.Context.getRValueReferenceType(T);
+break;
+  // - otherwise, if e is an lvalue, decltype(e) is T&, where T is the
+  //   type of e;
+  case VK_LValue:
+T = S.Context.getLValueReferenceType(T);
+break;
+  //  - otherwise, decltype(e) is the type of e.
+  case VK_RValue:
+break;
+  }
+
+  return T;
+}
+
 /// getDecltypeForExpr - Given an expr, will return the decltype for
 /// that expression, according to the rules in C++11
 /// [dcl.type.simple]p4 and C++11 [expr.lambda.prim]p18.
 static QualType getDecltypeForExpr(Sema , Expr *E) {
-  if (E->isTypeDependent())
-return S.Context.DependentTy;
-
   // C++11 [dcl.type.simple]p4:
   //   The type denoted by decltype(e) is defined as follows:
 
@@ -8897,26 +8919,11 @@
 }
   }
 
-
-  // C++11 [dcl.type.simple]p4:
-  //   [...]
-  QualType T = E->getType();
-  switch (E->getValueKind()) {
-  // - otherwise, if e is an xvalue, decltype(e) is T&&, where T is the
-  //   type of e;
-  case VK_XValue: T = S.Context.getRValueReferenceType(T); break;
-  // - otherwise, if e is an lvalue, decltype(e) is T&, where T is the
-  //   type of e;
-  case VK_LValue: T = S.Context.getLValueReferenceType(T); break;
-  //  - otherwise, decltype(e) is the type of e.
-  case VK_RValue: break;
-  }
-
-  return T;
+  return getBaseDecltypeForExpr(S, E);
 }
 
 

[PATCH] D98158: [Driver] Pass --unwindlib=platform to tests that check unwinder

2021-03-07 Thread Petr Hosek 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 rG7514f1a31275: [Driver] Pass --unwindlib=platform to tests 
that check unwinder (authored by phosek).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98158

Files:
  clang/test/Driver/linux-ld.c


Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -328,7 +328,7 @@
 //
 // Check that flags can be combined. The -static dominates.
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: --target=x86_64-unknown-linux -rtlib=platform \
+// RUN: --target=x86_64-unknown-linux -rtlib=platform --unwindlib=platform 
\
 // RUN: -static-libgcc -static \
 // RUN: --gcc-toolchain="" \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
@@ -2055,7 +2055,7 @@
 // CHECK-LD-GENTOO: "-lc"
 // CHECK-LD-GENTOO: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: --target=i686-unknown-linux-gnu -rtlib=platform \
+// RUN: --target=i686-unknown-linux-gnu -rtlib=platform 
--unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/gentoo_linux_gcc_multi_version_tree \
 // RUN: --gcc-toolchain="" \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-GENTOO-32 %s


Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -328,7 +328,7 @@
 //
 // Check that flags can be combined. The -static dominates.
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: --target=x86_64-unknown-linux -rtlib=platform \
+// RUN: --target=x86_64-unknown-linux -rtlib=platform --unwindlib=platform \
 // RUN: -static-libgcc -static \
 // RUN: --gcc-toolchain="" \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
@@ -2055,7 +2055,7 @@
 // CHECK-LD-GENTOO: "-lc"
 // CHECK-LD-GENTOO: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: --target=i686-unknown-linux-gnu -rtlib=platform \
+// RUN: --target=i686-unknown-linux-gnu -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/gentoo_linux_gcc_multi_version_tree \
 // RUN: --gcc-toolchain="" \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-GENTOO-32 %s
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7514f1a - [Driver] Pass --unwindlib=platform to tests that check unwinder

2021-03-07 Thread Petr Hosek via cfe-commits

Author: Petr Hosek
Date: 2021-03-07T17:28:34-08:00
New Revision: 7514f1a312751089ef25df02eaf638a5a5192da3

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

LOG: [Driver] Pass --unwindlib=platform to tests that check unwinder

There are two additional cases that were missed in D98131.

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

Added: 


Modified: 
clang/test/Driver/linux-ld.c

Removed: 




diff  --git a/clang/test/Driver/linux-ld.c b/clang/test/Driver/linux-ld.c
index 77d2c82ee3d4..5263928ff3b9 100644
--- a/clang/test/Driver/linux-ld.c
+++ b/clang/test/Driver/linux-ld.c
@@ -328,7 +328,7 @@
 //
 // Check that flags can be combined. The -static dominates.
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: --target=x86_64-unknown-linux -rtlib=platform \
+// RUN: --target=x86_64-unknown-linux -rtlib=platform --unwindlib=platform 
\
 // RUN: -static-libgcc -static \
 // RUN: --gcc-toolchain="" \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
@@ -2055,7 +2055,7 @@
 // CHECK-LD-GENTOO: "-lc"
 // CHECK-LD-GENTOO: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: --target=i686-unknown-linux-gnu -rtlib=platform \
+// RUN: --target=i686-unknown-linux-gnu -rtlib=platform 
--unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/gentoo_linux_gcc_multi_version_tree \
 // RUN: --gcc-toolchain="" \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-GENTOO-32 %s



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


[PATCH] D97832: [X86] Refine "Support -march=alderlake"

2021-03-07 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe added a comment.

No more comments?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97832

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


[PATCH] D98104: Update __is_unsigned builtin to match the Standard.

2021-03-07 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

LGTM now, mod the (important!) typo in the test.




Comment at: clang/test/SemaCXX/type-traits.cpp:1444
   int t27[F(__is_signed(UnionAr))];
+  int t28[F(__is_unsigned(UnsignedEnum))];
 }

s/is_unsigned/is_signed/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98104

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


[PATCH] D97915: [Coroutines] Handle overaligned frame allocation

2021-03-07 Thread Lewis Baker via Phabricator via cfe-commits
lewissbaker added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:4450
+Value *Extra = Builder.CreateSelect(Cmp, Diff, Zero);
+return RValue::get(Builder.CreateAdd(SizeCall, Extra));
   }

rjmccall wrote:
> lewissbaker wrote:
> > ychen wrote:
> > > rjmccall wrote:
> > > > ychen wrote:
> > > > > ychen wrote:
> > > > > > rjmccall wrote:
> > > > > > > Okay, so you're implicitly increasing the coroutine size to allow 
> > > > > > > you to round up to get an aligned frame.  But how do you round 
> > > > > > > back down to get the actual pointer that you need to delete?  
> > > > > > > This just doesn't work.
> > > > > > > 
> > > > > > > You really ought to just be using the aligned `operator new` 
> > > > > > > instead when the required alignment is too high.  If that means 
> > > > > > > checking the alignment "dynamically" before calling `operator 
> > > > > > > new` / `operator delete`, so be it.  In practice, it will not be 
> > > > > > > dynamic because lowering will replace the `coro.align` call with 
> > > > > > > a constant, at which point the branch will be foldable.
> > > > > > > 
> > > > > > > I don't know what to suggest if the aligned `operator new` isn't 
> > > > > > > reliably available on the target OS.  You could outline a 
> > > > > > > function to pick the best allocator/deallocator, I suppose.
> > > > > > Thanks for the review!
> > > > > > 
> > > > > > > Okay, so you're implicitly increasing the coroutine size to allow 
> > > > > > > you to round up to get an aligned frame. But how do you round 
> > > > > > > back down to get the actual pointer that you need to delete? This 
> > > > > > > just doesn't work.
> > > > > > 
> > > > > > Hmm, you're right that I missed the `delete` part, thanks. The 
> > > > > > adjusted amount is constant, I could just dial it down in 
> > > > > > `coro.free`, right?
> > > > > > 
> > > > > > >  You really ought to just be using the aligned operator new 
> > > > > > > instead when the required alignment is too high. If that means 
> > > > > > > checking the alignment "dynamically" before calling operator new 
> > > > > > > / operator delete, so be it. In practice, it will not be dynamic 
> > > > > > > because lowering will replace the coro.align call with a 
> > > > > > > constant, at which point the branch will be foldable.
> > > > > >  
> > > > > > That's my intuition at first. But spec is written in a way 
> > > > > > suggesting (IMHO) that the aligned version should not be used? What 
> > > > > > if the user specify their own allocator, then which one they should 
> > > > > > use?
> > > > > Sorry, I meant the adjusted amount is coro.align - std::max_align_t,  
> > > > > I could subtract it in `coro.free` . I think it should work?
> > > > No, because the adjustment you have to do in `coro.alloc` isn't just an 
> > > > addition, it's an addition plus a mask, which isn't reversible.  
> > > > Suppose the frame needs to be 32-byte-aligned, but the allocator only 
> > > > promises 8-byte alignment.  The problem is that when you go to free a 
> > > > frame pointer, and you see that it's 32-byte-aligned (which, again, it 
> > > > always will be), the pointer you got from the allocator might be the 
> > > > frame pointer minus any of 8, 16, or 24 — or it might be exactly the 
> > > > same.  The only way to reverse that is to store some sort of cookie, 
> > > > either the amount to subtract or even just the original pointer.
> > > > 
> > > > Now, if you could change the entire coroutine ABI, you could make the 
> > > > frame handle that you pass around be the unadjusted pointer and then 
> > > > just repeat the adjustment every time you enter the coroutine.  But 
> > > > that doesn't work because the ABI relies on things like the promise 
> > > > being at a reliable offset from the frame handle.
> > > > 
> > > > I think the best solution would be to figure out a way to use an 
> > > > aligned allocator, which at worst does this in a more systematic way 
> > > > and at best can actually just satisfy your requirement directly without 
> > > > any overhead.  If you can't do that, adding an offset to the frame 
> > > > would be best; if you can't do that, doing it as a cookie is okay.
> > > > 
> > > > > That's my intuition at first. But spec is written in a way suggesting 
> > > > > (IMHO) that the aligned version should not be used? What if the user 
> > > > > specify their own allocator, then which one they should use?
> > > > 
> > > > It seems like a spec bug that this doesn't use aligned allocators even 
> > > > when they're available.  If there's an aligned allocator available, I 
> > > > think this should essentially do dynamically what it would normally do 
> > > > statically, i.e.:
> > > > 
> > > > ```
> > > > void *allocation = alignment > __STDCPP_DEFAULT_NEW_ALIGNMENT__ ? 
> > > > operator new(size, align_val_t(alignment)) : operator new(size);
> > > > ```
> > > > 
> > > > This would ODR-use both 

[PATCH] D98158: [Driver] Pass --unwindlib=platform to tests that check unwinder

2021-03-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay 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/D98158/new/

https://reviews.llvm.org/D98158

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


[PATCH] D98158: [Driver] Pass --unwindlib=platform to tests that check unwinder

2021-03-07 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

I forgot to do a clean build and missed two more cases, after this everything 
seems to be green.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98158

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


[PATCH] D98158: [Driver] Pass --unwindlib=platform to tests that check unwinder

2021-03-07 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: MaskRay, mstorsjo.
phosek requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

There are two additional cases that were missed in D98131 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98158

Files:
  clang/test/Driver/linux-ld.c


Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -328,7 +328,7 @@
 //
 // Check that flags can be combined. The -static dominates.
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: --target=x86_64-unknown-linux -rtlib=platform \
+// RUN: --target=x86_64-unknown-linux -rtlib=platform --unwindlib=platform 
\
 // RUN: -static-libgcc -static \
 // RUN: --gcc-toolchain="" \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
@@ -2055,7 +2055,7 @@
 // CHECK-LD-GENTOO: "-lc"
 // CHECK-LD-GENTOO: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: --target=i686-unknown-linux-gnu -rtlib=platform \
+// RUN: --target=i686-unknown-linux-gnu -rtlib=platform 
--unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/gentoo_linux_gcc_multi_version_tree \
 // RUN: --gcc-toolchain="" \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-GENTOO-32 %s


Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -328,7 +328,7 @@
 //
 // Check that flags can be combined. The -static dominates.
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: --target=x86_64-unknown-linux -rtlib=platform \
+// RUN: --target=x86_64-unknown-linux -rtlib=platform --unwindlib=platform \
 // RUN: -static-libgcc -static \
 // RUN: --gcc-toolchain="" \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
@@ -2055,7 +2055,7 @@
 // CHECK-LD-GENTOO: "-lc"
 // CHECK-LD-GENTOO: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: --target=i686-unknown-linux-gnu -rtlib=platform \
+// RUN: --target=i686-unknown-linux-gnu -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/gentoo_linux_gcc_multi_version_tree \
 // RUN: --gcc-toolchain="" \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-GENTOO-32 %s
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98146: OpaquePtr: Turn inalloca into a type attribute

2021-03-07 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: llvm/lib/IR/Attributes.cpp:490
 if (Type *Ty = getValueAsType()) {
-  raw_string_ostream OS(Result);
+  // FIXME: This should never be null
   Result += '(';

dblaikie wrote:
> Is it? Could you replace this with an assertion instead? 
It should never be null, but it is in some cases (I think there are some 
situations still where callsite attributes are missing byval)



Comment at: llvm/test/Bitcode/compatibility-3.6.ll:408-409
 ; CHECK: declare void @f.param.byval({ i8, i8 }* byval({ i8, i8 }))
-declare void @f.param.inalloca(i8* inalloca)
-; CHECK: declare void @f.param.inalloca(i8* inalloca)
+declare void @f.param.inalloca(i8* inalloca(i8))
+; CHECK: declare void @f.param.inalloca(i8* inalloca(i8))
 declare void @f.param.sret(i8* sret(i8))

dblaikie wrote:
> It's confusing to me (though seems to be consistent with the byval change 
> here - but maybe that's a mistake too) why the textual IR in this file is 
> being modified - it has no effect (the textual IR is not used by the test) 
> and the intent is to test compatibility with old IR (which is in the .bc file 
> that is used) - so maybe it's best to leave the text here in a form that 
> matches the old bitcode that the test is running against?
> 
> (similarly in the other compatibility tests updated in this patch)
Why do these tests have textual IR in them at all then? I don't think the 
concept of the text IR corresponding to the old bitcode really exists. I would 
expect to see the current syntax, but I don't actually see why this has a .ll 
suffix and isn't just a plain text file with check lines



Comment at: llvm/test/Bitcode/inalloca-upgrade.test:1-7
+RUN: llvm-dis %p/Inputs/inalloca-upgrade.bc -o - | FileCheck %s
+
+Make sure we upgrade old-style IntAttribute inalloca records to a
+fully typed version correctly.
+
+CHECK: call void @bar({ i32*, i8 }* inalloca({ i32*, i8 }) %ptr)
+CHECK: invoke void @bar({ i32*, i8 }* inalloca({ i32*, i8 }) %ptr)

dblaikie wrote:
> Isn't this tested by all the compatibility tests already? (since they contain 
> the old-style inalloca, and verify that when read in it's upgraded to the 
> new-style) Though I don't mind terribly having a separate test, but each 
> file/tool execution does add up & it's nice to keep them to a minimum when 
> test coverage isn't otherwise compromised.
I was following along with byval, which has its own test like this. I also 
generally hate the all-in-one style of testing features that are really 
unrelated. It makes it harder to know what actually broke when one fails.


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

https://reviews.llvm.org/D98146

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


[PATCH] D98156: [clang/mac] Accept -why_load and make -whyload an alias for it

2021-03-07 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: hans.
Herald added subscribers: jansvoboda11, dang.
thakis requested review of this revision.

>From `man ld`:

  -why_load   Log why each object file in a static library is loaded.
  That is, what symbol was needed.
  Also called -whyload for compatibility.

So `-why_load` is the spelling preferred by the linker and `-whyload` and old
compatibility setting. clang should accept the preferred form, and map both
forms to the preferred form.


https://reviews.llvm.org/D98156

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Darwin.cpp


Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -417,7 +417,7 @@
   Args.AddAllArgs(CmdArgs, options::OPT_sectalign);
   Args.AddAllArgs(CmdArgs, options::OPT_sectobjectsymbols);
   Args.AddAllArgs(CmdArgs, options::OPT_segcreate);
-  Args.AddLastArg(CmdArgs, options::OPT_whyload);
+  Args.AddLastArg(CmdArgs, options::OPT_why_load);
   Args.AddLastArg(CmdArgs, options::OPT_whatsloaded);
   Args.AddAllArgs(CmdArgs, options::OPT_dylinker__install__name);
   Args.AddLastArg(CmdArgs, options::OPT_dylinker);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3700,7 +3700,8 @@
 def weak__library : Separate<["-"], "weak_library">, Flags<[LinkerInput]>;
 def weak__reference__mismatches : Separate<["-"], "weak_reference_mismatches">;
 def whatsloaded : Flag<["-"], "whatsloaded">;
-def whyload : Flag<["-"], "whyload">;
+def why_load : Flag<["-"], "why_load">;
+def whyload : Flag<["-"], "whyload">, Alias;
 def w : Flag<["-"], "w">, HelpText<"Suppress all warnings">, 
Flags<[CC1Option]>,
   MarshallingInfoFlag>;
 def x : JoinedOrSeparate<["-"], "x">, Flags<[NoXarchOption,CC1Option]>,


Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -417,7 +417,7 @@
   Args.AddAllArgs(CmdArgs, options::OPT_sectalign);
   Args.AddAllArgs(CmdArgs, options::OPT_sectobjectsymbols);
   Args.AddAllArgs(CmdArgs, options::OPT_segcreate);
-  Args.AddLastArg(CmdArgs, options::OPT_whyload);
+  Args.AddLastArg(CmdArgs, options::OPT_why_load);
   Args.AddLastArg(CmdArgs, options::OPT_whatsloaded);
   Args.AddAllArgs(CmdArgs, options::OPT_dylinker__install__name);
   Args.AddLastArg(CmdArgs, options::OPT_dylinker);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3700,7 +3700,8 @@
 def weak__library : Separate<["-"], "weak_library">, Flags<[LinkerInput]>;
 def weak__reference__mismatches : Separate<["-"], "weak_reference_mismatches">;
 def whatsloaded : Flag<["-"], "whatsloaded">;
-def whyload : Flag<["-"], "whyload">;
+def why_load : Flag<["-"], "why_load">;
+def whyload : Flag<["-"], "whyload">, Alias;
 def w : Flag<["-"], "w">, HelpText<"Suppress all warnings">, Flags<[CC1Option]>,
   MarshallingInfoFlag>;
 def x : JoinedOrSeparate<["-"], "x">, Flags<[NoXarchOption,CC1Option]>,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98104: Update __is_unsigned builtin to match the Standard.

2021-03-07 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver updated this revision to Diff 328905.
zoecarver added a comment.

- Address Arthur's comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98104

Files:
  clang/docs/LanguageExtensions.rst
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaCXX/type-traits.cpp


Index: clang/test/SemaCXX/type-traits.cpp
===
--- clang/test/SemaCXX/type-traits.cpp
+++ clang/test/SemaCXX/type-traits.cpp
@@ -13,6 +13,7 @@
 // PODs
 enum Enum { EV };
 enum SignedEnum : signed int { };
+enum UnsignedEnum : unsigned int { };
 struct POD { Enum e; int i; float f; NonPOD* p; };
 struct Empty {};
 struct IncompleteStruct;
@@ -1440,6 +1441,7 @@
   int t25[F(__is_signed(IntArNB))];
   int t26[F(__is_signed(Union))];
   int t27[F(__is_signed(UnionAr))];
+  int t28[F(__is_unsigned(UnsignedEnum))];
 }
 
 void is_unsigned()
@@ -1450,7 +1452,6 @@
   int t04[T(__is_unsigned(unsigned int))];
   int t05[T(__is_unsigned(unsigned long))];
   int t06[T(__is_unsigned(unsigned long long))];
-  int t07[T(__is_unsigned(Enum))];
 
   int t10[F(__is_unsigned(void))];
   int t11[F(__is_unsigned(cvoid))];
@@ -1468,6 +1469,9 @@
   int t24[F(__is_unsigned(Derives))];
   int t25[F(__is_unsigned(ClassType))];
   int t26[F(__is_unsigned(IntArNB))];
+  int t27[F(__is_unsigned(Enum))];
+  int t28[F(__is_unsigned(UnsignedEnum))];
+  int t29[F(__is_unsigned(SignedEnum))];
 }
 
 typedef Int& IntRef;
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -4831,9 +4831,10 @@
   case UTT_IsSigned:
 // Enum types should always return false.
 // Floating points should always return true.
-return !T->isEnumeralType() && (T->isFloatingType() || 
T->isSignedIntegerType());
+return T->isFloatingType() || (T->isSignedIntegerType() && 
!T->isEnumeralType());
   case UTT_IsUnsigned:
-return T->isUnsignedIntegerType();
+// Enum types should always return false.
+return T->isUnsignedIntegerType() && !T->isEnumeralType();
 
 // Type trait expressions which query classes regarding their construction,
 // destruction, and copying. Rather than being based directly on the
Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -1194,7 +1194,9 @@
 * ``__is_sealed`` (Microsoft):
   Synonym for ``__is_final``.
 * ``__is_signed`` (C++, Embarcadero):
-  Returns false for enumeration types, and returns true for floating-point 
types. Note, before Clang 10, returned true for enumeration types if the 
underlying type was signed, and returned false for floating-point types.
+  Returns false for enumeration types, and returns true for floating-point
+  types. Note, before Clang 10, returned true for enumeration types if the
+  underlying type was signed, and returned false for floating-point types.
 * ``__is_standard_layout`` (C++, GNU, Microsoft, Embarcadero)
 * ``__is_trivial`` (C++, GNU, Microsoft, Embarcadero)
 * ``__is_trivially_assignable`` (C++, GNU, Microsoft)
@@ -1203,9 +1205,8 @@
 * ``__is_trivially_destructible`` (C++, MSVC 2013)
 * ``__is_union`` (C++, GNU, Microsoft, Embarcadero)
 * ``__is_unsigned`` (C++, Embarcadero)
-  Note that this currently returns true for enumeration types if the underlying
-  type is unsigned, in violation of the requirements for ``std::is_unsigned``.
-  This behavior is likely to change in a future version of Clang.
+  Returns false for enumeration types. Note, before Clang 13, returned true for
+  enumeration types if the underlying type was unsigned.
 * ``__is_void`` (C++, Embarcadero)
 * ``__is_volatile`` (C++, Embarcadero)
 * ``__reference_binds_to_temporary(T, U)`` (Clang):  Determines whether a


Index: clang/test/SemaCXX/type-traits.cpp
===
--- clang/test/SemaCXX/type-traits.cpp
+++ clang/test/SemaCXX/type-traits.cpp
@@ -13,6 +13,7 @@
 // PODs
 enum Enum { EV };
 enum SignedEnum : signed int { };
+enum UnsignedEnum : unsigned int { };
 struct POD { Enum e; int i; float f; NonPOD* p; };
 struct Empty {};
 struct IncompleteStruct;
@@ -1440,6 +1441,7 @@
   int t25[F(__is_signed(IntArNB))];
   int t26[F(__is_signed(Union))];
   int t27[F(__is_signed(UnionAr))];
+  int t28[F(__is_unsigned(UnsignedEnum))];
 }
 
 void is_unsigned()
@@ -1450,7 +1452,6 @@
   int t04[T(__is_unsigned(unsigned int))];
   int t05[T(__is_unsigned(unsigned long))];
   int t06[T(__is_unsigned(unsigned long long))];
-  int t07[T(__is_unsigned(Enum))];
 
   int t10[F(__is_unsigned(void))];
   int t11[F(__is_unsigned(cvoid))];
@@ -1468,6 +1469,9 @@
   int t24[F(__is_unsigned(Derives))];
   int t25[F(__is_unsigned(ClassType))];
   int t26[F(__is_unsigned(IntArNB))];
+  int 

[PATCH] D98104: Update __is_unsigned builtin to match the Standard.

2021-03-07 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver added inline comments.



Comment at: clang/lib/Sema/SemaExprCXX.cpp:4837
+// Enum types should always return false (same as UTT_IsSigned).
+return !T->isEnumeralType() && T->isUnsignedIntegerType();
 

Quuxplusone wrote:
> FWIW, I'd lose the parenthetical comment, and I'd write the conditions as 
> respectively
> 
> return T->isUnsignedIntegerType() && !T->isEnumeralType();
> 
> return T->isFloatingType() || (T->isSignedIntegerType() && 
> !T->isEnumeralType());
> 
> both because "T not being an enum type" is expected to be usually true, and 
> because I think `(!x && y)` runs the risk of being misread as `!(x && y)`, 
> whereas `(x && !y)` is easy on the brain.
Fair enough. I originally was thinking, if we have to perform this check 
roughly 50% of this time, either way, it makes sense to do the much faster 
check first. But, if we assume that we almost never receive an enum type, then 
what you're saying makes sense. I'll fix it. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98104

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


[PATCH] D70638: [Diagnostic] add a warning which warns about misleading indentation

2021-03-07 Thread Dave Lee via Phabricator via cfe-commits
kastiglione added a comment.

@Tyker Hi, I noticed a case that isn't caught by `-Wmisleading-indentation`. In 
code that uses two space indents, there's a corner case that isn't caught when 
the preceding `if` uses curly braces. I've noticed a couple instances of this 
in lldb.

For example:

  if (cond) {
then1();
then2();
// ...
  } else
else1();
else2();

The `else2();` statement doesn't trigger the warning.

It seems that the logic is to use the column of the `else` keyword, not the 
column of the right brace. When using a four space indent (any indent != 2), 
the warning is emitted:

  } else
  else1();
  else2();


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70638

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


[PATCH] D97068: Run non-filechecked commands in update_cc_test_checks.py

2021-03-07 Thread Giorgis Georgakoudis via Phabricator via cfe-commits
ggeorgakoudis updated this revision to Diff 328887.
ggeorgakoudis added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Update implementation to support running non-clang runlines, add tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97068

Files:
  clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c
  clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected
  clang/test/utils/update_cc_test_checks/exec-all-runlines.test
  llvm/utils/update_cc_test_checks.py

Index: llvm/utils/update_cc_test_checks.py
===
--- llvm/utils/update_cc_test_checks.py
+++ llvm/utils/update_cc_test_checks.py
@@ -203,6 +203,14 @@
   'are discouraged in Clang testsuite.', file=sys.stderr)
 sys.exit(1)
 
+def exec_run_line(exe):
+  popen = subprocess.Popen(exe, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
+  stdout, stderr = popen.communicate()
+  if popen.returncode != 0:
+sys.stderr.write('Failed to run ' + ' '.join(exe) + '\n')
+sys.stderr.write(stderr)
+sys.stderr.write(stdout)
+sys.exit(3)
 
 def main():
   initial_args, parser = config()
@@ -221,25 +229,31 @@
   if m:
 triple_in_cmd = m.groups()[0]
 
-  # Apply %clang substitution rule, replace %s by `filename`, and append args.clang_args
-  clang_args = shlex.split(commands[0])
-  if clang_args[0] not in SUBST:
-print('WARNING: Skipping non-clang RUN line: ' + l, file=sys.stderr)
+  # Parse executable args.
+  exec_args = shlex.split(commands[0])
+  # Execute non-clang runline.
+  if exec_args[0] not in SUBST:
+print('NOTE: Executing non-clang RUN line: ' + l, file=sys.stderr)
+# Replace %s by `filename`.
+exec_args = [i.replace('%s', ti.path) if '%s' in i else i for i in exec_args]
+exec_run_line(exec_args)
 continue
+  # This is a clang runline, apply %clang substitution rule, replace %s by `filename`,
+  # and append args.clang_args
+  clang_args = exec_args
   clang_args[0:1] = SUBST[clang_args[0]]
-  clang_args = [ti.path if i == '%s' else i for i in clang_args] + ti.args.clang_args
-
-  # Permit piping the output through opt
-  if not (len(commands) == 2 or
-  (len(commands) == 3 and commands[1].startswith('opt'))):
-print('WARNING: Skipping non-clang RUN line: ' + l, file=sys.stderr)
+  clang_args = [i.replace('%s', ti.path) if '%s' in i else i for i in clang_args] + ti.args.clang_args
 
   # Extract -check-prefix in FileCheck args
   filecheck_cmd = commands[-1]
   common.verify_filecheck_prefixes(filecheck_cmd)
   if not filecheck_cmd.startswith('FileCheck '):
-print('WARNING: Skipping non-FileChecked RUN line: ' + l, file=sys.stderr)
+print('NOTE: Executing non-FileChecked clang RUN line: ' + l, file=sys.stderr)
+# Execute non-filechecked clang runline.
+exe = [ti.args.clang] + clang_args
+exec_run_line(exe)
 continue
+
   check_prefixes = [item for m in common.CHECK_PREFIX_RE.finditer(filecheck_cmd)
for item in m.group(1).split(',')]
   if not check_prefixes:
Index: clang/test/utils/update_cc_test_checks/exec-all-runlines.test
===
--- /dev/null
+++ clang/test/utils/update_cc_test_checks/exec-all-runlines.test
@@ -0,0 +1,8 @@
+## Test that non-clang/non-filechecked runlines execute
+
+# RUN: cp %S/Inputs/exec-all-runlines.c %t-generated.c && %update_cc_test_checks %t-generated.c
+# RUN: diff -u %S/Inputs/exec-all-runlines.c.expected %t-generated.c
+
+## Check that re-running update_cc_test_checks doesn't change the output
+# RUN: %update_cc_test_checks %t-generated.c
+# RUN: diff -u %S/Inputs/exec-all-runlines.c.expected %t-generated.c
Index: clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected
===
--- /dev/null
+++ clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected
@@ -0,0 +1,17 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// Check that the non-clang/non-filechecked runlines execute
+// RUN: cp %s %s.copy.c
+// RUN: %clang_cc1 -fopenmp %s.copy.c -emit-llvm-bc -o %t-host.bc
+// RUN: %clang_cc1 -fopenmp -fopenmp-host-ir-file-path %t-host.bc %s.copy.c -emit-llvm -o - | FileCheck %s
+
+void use(int);
+
+// CHECK-LABEL: @test(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4
+// CHECK-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
+// CHECK-NEXT:ret void
+//
+void test(int a)
+{
+}
Index: clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c

[PATCH] D98146: OpaquePtr: Turn inalloca into a type attribute

2021-03-07 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

> I think byval/sret and the others are close to being able to rip out the code 
> to support the missing type case. A lot of this code is shared with inalloca, 
> so catch this up to the others so that can happen.

I'm a bit confused by the phrasing here - which code supporting the "missing 
type case" are you referring to? (might be good to have a few more words about 
which bits of code in particular - though I agree this is the right direction 
in any case)

Generally looks good to me - but would like @rnk's sign off as well before this 
is committed.




Comment at: llvm/lib/IR/Attributes.cpp:490
 if (Type *Ty = getValueAsType()) {
-  raw_string_ostream OS(Result);
+  // FIXME: This should never be null
   Result += '(';

Is it? Could you replace this with an assertion instead? 



Comment at: llvm/test/Bitcode/compatibility-3.6.ll:408-409
 ; CHECK: declare void @f.param.byval({ i8, i8 }* byval({ i8, i8 }))
-declare void @f.param.inalloca(i8* inalloca)
-; CHECK: declare void @f.param.inalloca(i8* inalloca)
+declare void @f.param.inalloca(i8* inalloca(i8))
+; CHECK: declare void @f.param.inalloca(i8* inalloca(i8))
 declare void @f.param.sret(i8* sret(i8))

It's confusing to me (though seems to be consistent with the byval change here 
- but maybe that's a mistake too) why the textual IR in this file is being 
modified - it has no effect (the textual IR is not used by the test) and the 
intent is to test compatibility with old IR (which is in the .bc file that is 
used) - so maybe it's best to leave the text here in a form that matches the 
old bitcode that the test is running against?

(similarly in the other compatibility tests updated in this patch)



Comment at: llvm/test/Bitcode/inalloca-upgrade.test:1-7
+RUN: llvm-dis %p/Inputs/inalloca-upgrade.bc -o - | FileCheck %s
+
+Make sure we upgrade old-style IntAttribute inalloca records to a
+fully typed version correctly.
+
+CHECK: call void @bar({ i32*, i8 }* inalloca({ i32*, i8 }) %ptr)
+CHECK: invoke void @bar({ i32*, i8 }* inalloca({ i32*, i8 }) %ptr)

Isn't this tested by all the compatibility tests already? (since they contain 
the old-style inalloca, and verify that when read in it's upgraded to the 
new-style) Though I don't mind terribly having a separate test, but each 
file/tool execution does add up & it's nice to keep them to a minimum when test 
coverage isn't otherwise compromised.


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

https://reviews.llvm.org/D98146

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


[PATCH] D98143: [HIP] Diagnose aggregate args containing half types

2021-03-07 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: tra.
Herald added subscribers: jansvoboda11, dexonsmith, dang.
yaxunl requested review of this revision.

gcc and clang currently do not have a consistent ABI
for half precision types. Passing aggregate args containing half precision
types between clang and gcc can cause UB.

This patch adds an option -fhip-allow-half-arg. When off, clang
will diagnose aggregate arguments containing half precision
types in host functions.


https://reviews.llvm.org/D98143

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/Headers/__clang_hip_cmath.h
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaCUDA/half-arg.cu

Index: clang/test/SemaCUDA/half-arg.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/half-arg.cu
@@ -0,0 +1,136 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -x hip %s
+// RUN: %clang_cc1 -std=c++11 -fcuda-is-device -fsyntax-only -verify -x hip %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify=allow -fhip-allow-half-arg -x hip %s
+
+// allow-no-diagnostics
+
+#include "Inputs/cuda.h"
+
+// Check _Float16/__fp16 or structs containing them are not allowed as function
+// parameter in HIP host functions.
+
+typedef _Float16 half;
+
+typedef _Float16 half2 __attribute__((ext_vector_type(2)));
+
+struct A { // expected-note 4{{within field or base class of type 'A' declared here}}
+  _Float16 x; // expected-note 7{{field of illegal type '_Float16' declared here}}
+};
+
+struct B { // expected-note {{within field or base class of type 'B' declared here}}
+  _Float16 x[2]; // expected-note {{field of illegal type '_Float16 [2]' declared here}}
+};
+
+struct C { // expected-note {{within field or base class of type 'C' declared here}}
+  _Float16 x[2][2]; // expected-note {{field of illegal type '_Float16 [2][2]' declared here}}
+};
+
+struct D { // expected-note {{within field or base class of type 'D' declared here}}
+  A x; // expected-note {{within field or base class of type 'A' declared here}}
+};
+
+struct E : public A { // expected-note {{within field or base class of type 'E' declared here}}
+};
+
+struct F : virtual public A { // expected-note {{within field or base class of type 'F' declared here}}
+};
+
+struct G { // expected-note {{within field or base class of type 'G' declared here}}
+  __fp16 x; // expected-note {{field of illegal type '__fp16' declared here}}
+};
+
+struct H {
+  void f(A x);
+  // expected-error@-1 {{Invalid function parameter type: 'A'}}
+};
+
+template
+struct I {
+  T x;
+  void f(T x);
+  // expected-error@-1 {{Invalid function parameter type: 'A'}}
+};
+
+struct J { // expected-note {{within field or base class of type 'J' declared here}}
+  half2 v; // expected-note {{field of illegal type 'half2' (vector of 2 '_Float16' values) declared here}}
+};
+
+struct empty {};
+
+struct K : public empty {
+  int x;
+};
+
+struct undefined;
+
+void fa1(_Float16 x);
+// expected-error@-1 {{Invalid function parameter type: '_Float16'}}
+
+void fa2(A x);
+// expected-error@-1 {{Invalid function parameter type: 'A'}}
+
+void fa3(B x);
+// expected-error@-1 {{Invalid function parameter type: 'B'}}
+
+void fa4(C x);
+// expected-error@-1 {{Invalid function parameter type: 'C'}}
+
+void fa5(D x);
+// expected-error@-1 {{Invalid function parameter type: 'D'}}
+
+void fa6(E x);
+// expected-error@-1 {{Invalid function parameter type: 'E'}}
+
+void fa7(F x);
+// expected-error@-1 {{Invalid function parameter type: 'F'}}
+
+void fa8(G x);
+// expected-error@-1 {{Invalid function parameter type: 'G'}}
+
+template void fa9(T x);
+// expected-error@-1 {{Invalid function parameter type: 'A'}}
+// expected-note@-2 {{candidate template ignored: substitution failure [with T = A]}}
+void fa9_caller() {
+  A x;
+  fa9(x);
+  // expected-error@-1 {{no matching function for call to 'fa9'}}
+  // expected-note@-2 {{in instantiation of function template specialization 'fa9' requested here}}
+}
+
+void fa10() {
+  I x;
+  // expected-note@-1 {{in instantiation of template class 'I' requested here}}
+}
+
+void fa11(half x);
+// expected-error@-1 {{Invalid function parameter type: 'half' (aka '_Float16')}}
+
+void fa12(half2 x);
+// expected-error@-1 {{Invalid function parameter type: 'half2' (vector of 2 '_Float16' values)}}
+
+void fa13(J x);
+// expected-error@-1 {{Invalid function parameter type: 'J'}}
+
+void fa14(int x, _Float16 y);
+// expected-error@-1 {{Invalid function parameter type: '_Float16'}}
+
+_Float16 fa15();
+// expected-error@-1 {{Invalid function return type: '_Float16'}}
+
+void fa16(K x);
+
+undefined fa17();
+
+// Check reference or pointers to _Float16/__fp16 or structs containing
+// them are allowed as function parameters in HIP host functions.
+
+void fb1(_Float16 );
+void fb2(_Float16 *x);
+void fb3(A );
+void fb4(A *x);
+
+// Check device function can use 

[PATCH] D91281: [CUDA][HIP] Diagnose reference of host variable

2021-03-07 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D91281#2607082 , @yaxunl wrote:

> @tra I got some issue with this patch. There are cases that an expression 
> using a host variable is compile-time constant, e.g.
>
>   int x;
>   __device__ void fun() {
> sizeof(x);
>   }
>
> Do we want to allow that? Thanks.

It seems we should only diagnose ODR-use 
(https://en.cppreference.com/w/cpp/language/definition) of host variable in 
device functions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91281

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


[PATCH] D96975: [Sema] Add some basic lambda capture fix-its

2021-03-07 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 328859.
njames93 added a comment.

Add check to prevent emitting copy capture fixes for non-copyable types


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96975

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/CXX/drs/dr6xx.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p2-generic-lambda-1y.cpp
  clang/test/SemaCXX/cxx1y-generic-lambdas-capturing.cpp
  clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
  clang/test/SemaCXX/cxx1y-init-captures.cpp
  clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
  clang/test/SemaCXX/lambda-expressions.cpp
  clang/test/SemaCXX/lambda-invalid-capture.cpp
  clang/test/SemaObjCXX/capturing-flexible-array-in-block.mm

Index: clang/test/SemaObjCXX/capturing-flexible-array-in-block.mm
===
--- clang/test/SemaObjCXX/capturing-flexible-array-in-block.mm
+++ clang/test/SemaObjCXX/capturing-flexible-array-in-block.mm
@@ -5,5 +5,5 @@
   struct { int x; int y[]; } a; // expected-note 3 {{'a' declared here}}
   ^{return a.x;}(); // expected-error {{cannot refer to declaration of structure variable with flexible array member inside block}}
   [=] {return a.x;}(); // expected-error {{variable 'a' with flexible array member cannot be captured in a lambda expression}}
-  [] {return a.x;}(); // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default}} expected-note {{here}}
+  [] { return a.x; }(); // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default}} expected-note {{here}} expected-note 4 {{capture}}
 }
Index: clang/test/SemaCXX/lambda-invalid-capture.cpp
===
--- clang/test/SemaCXX/lambda-invalid-capture.cpp
+++ clang/test/SemaCXX/lambda-invalid-capture.cpp
@@ -18,7 +18,7 @@
 }
 
 int pr43080(int i) { // expected-note {{declared here}}
-  return [] { // expected-note {{begins here}}
+  return [] {// expected-note {{begins here}} expected-note 4 {{capture}}
 return sizeof i <
   i; // expected-error {{variable 'i' cannot be implicitly captured in a lambda with no capture-default specified}}
   }();
Index: clang/test/SemaCXX/lambda-expressions.cpp
===
--- clang/test/SemaCXX/lambda-expressions.cpp
+++ clang/test/SemaCXX/lambda-expressions.cpp
@@ -12,17 +12,17 @@
 virtual C& Overload(float);
 
 void ImplicitThisCapture() {
-  [](){(void)Member;}; // expected-error {{'this' cannot be implicitly captured in this context}}
-  const int var = [](){(void)Member; return 0;}(); // expected-error {{'this' cannot be implicitly captured in this context}}
+  []() { (void)Member; }; // expected-error {{'this' cannot be implicitly captured in this context}} expected-note {{explicitly capture 'this'}}
+  const int var = []() {(void)Member; return 0; }(); // expected-error {{'this' cannot be implicitly captured in this context}} expected-note {{explicitly capture 'this'}}
   [&](){(void)Member;};
 
   [this](){(void)Member;};
   [this]{[this]{};};
   []{[this]{};};// expected-error {{'this' cannot be implicitly captured in this context}}
   []{Overload(3);};
-  []{Overload();}; // expected-error {{'this' cannot be implicitly captured in this context}}
+  [] { Overload(); }; // expected-error {{'this' cannot be implicitly captured in this context}} expected-note {{explicitly capture 'this'}}
   []{(void)typeid(Overload());};
-  []{(void)typeid(Overload(.5f));};// expected-error {{'this' cannot be implicitly captured in this context}}
+  [] { (void)typeid(Overload(.5f)); }; // expected-error {{'this' cannot be implicitly captured in this context}} expected-note {{explicitly capture 'this'}}
 }
   };
 
@@ -47,14 +47,14 @@
 namespace ImplicitCapture {
   void test() {
 int a = 0; // expected-note 5 {{declared}}
-[]() { return a; }; // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{begins here}}
+[]() { return a; }; // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{begins here}} expected-note 4 {{capture}}
 [&]() { return a; };
 [=]() { return a; };
 [=]() { int* b =  }; // expected-error {{cannot initialize a variable of type 'int *' with an rvalue of type 'const int *'}}
 [=]() { return [&]() { return a; }; };
-[]() { return [&]() { return a; }; }; // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}}
-

[PATCH] D98142: [clang] Don't set CLANG_DEFAULT_UNWINDLIB to none if rtlib is set to compiler-rt

2021-03-07 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: phosek, MaskRay, saugustine.
Herald added subscribers: mgorny, dberris.
mstorsjo requested review of this revision.
Herald added a project: clang.

002dd47bdd674fad8186650f07458b1e062545df 
 was meant 
to not be any
functional change, but it turned out it was.

With CLANG_DEFAULT_RTLIB set to compiler-rt, CLANG_DEFAULT_UNWINDLIB used
to bet set to an empty string, but now was set to "none".

If one only overrode rtlib to libgcc, one previously would get libgcc
as unwind lib, but now didn't. This caused test failures, fixed in
41476d89b82647c1ff690fdc805c859262d571e5 
.

Secondly, for the android target, the previous default was to link
libunwind, which this now changed.

Reinstate the exact same behaviour as before (removing the previously
typoed cmake check) and fix the option comment in one place to match
the other one above.

Or shoulf we just remove the default-inferring logic (currently only
setting unwindlib=libgcc) altogether, as the simpler default (empty
string, equal to -unwindlib=platform) does the same anyway?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98142

Files:
  clang/CMakeLists.txt


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -262,8 +262,6 @@
 if (CLANG_DEFAULT_UNWINDLIB STREQUAL "")
   if (CLANG_DEFAULT_RTLIB STREQUAL "libgcc")
 set (CLANG_DEFAULT_UNWINDLIB "libgcc" CACHE STRING "" FORCE)
-  elseif (CLANG_DEFAULT_RTLIB STREQUAL "compiler-rt")
-set (CLANG_DEFAULT_UNWINDLIB "none" CACHE STRING "" FORCE)
   endif()
 endif()
 
@@ -273,7 +271,7 @@
 CLANG_DEFAULT_UNWINDLIB STREQUAL "libunwind"))
   message(WARNING "Resetting default unwindlib to use platform default")
   set(CLANG_DEFAULT_UNWINDLIB "" CACHE STRING
-"Default unwind library to use (\"none\" \"libgcc\" or \"libunwind\", 
empty for none)" FORCE)
+"Default unwind library to use (\"none\" \"libgcc\" or \"libunwind\", 
empty to match runtime library.)" FORCE)
 endif()
 
 set(CLANG_DEFAULT_OBJCOPY "objcopy" CACHE STRING


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -262,8 +262,6 @@
 if (CLANG_DEFAULT_UNWINDLIB STREQUAL "")
   if (CLANG_DEFAULT_RTLIB STREQUAL "libgcc")
 set (CLANG_DEFAULT_UNWINDLIB "libgcc" CACHE STRING "" FORCE)
-  elseif (CLANG_DEFAULT_RTLIB STREQUAL "compiler-rt")
-set (CLANG_DEFAULT_UNWINDLIB "none" CACHE STRING "" FORCE)
   endif()
 endif()
 
@@ -273,7 +271,7 @@
 CLANG_DEFAULT_UNWINDLIB STREQUAL "libunwind"))
   message(WARNING "Resetting default unwindlib to use platform default")
   set(CLANG_DEFAULT_UNWINDLIB "" CACHE STRING
-"Default unwind library to use (\"none\" \"libgcc\" or \"libunwind\", empty for none)" FORCE)
+"Default unwind library to use (\"none\" \"libgcc\" or \"libunwind\", empty to match runtime library.)" FORCE)
 endif()
 
 set(CLANG_DEFAULT_OBJCOPY "objcopy" CACHE STRING
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98075: [Matrix] Implement += and -= for MatrixType

2021-03-07 Thread Florian Hahn via Phabricator via cfe-commits
fhahn accepted this revision.
fhahn added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98075

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


[PATCH] D98075: [Matrix] Implement += and -= for MatrixType

2021-03-07 Thread Saurabh Jha via Phabricator via cfe-commits
SaurabhJha added inline comments.



Comment at: clang/test/Sema/matrix-type-operators.c:22
   // expected-error@-2 {{casting 'sx10x5_t *' (aka 'float  
__attribute__((matrix_type(10, 5)))*') to incompatible type 'float'}}
+
+  b -= 

xbolva00 wrote:
> +=?
Right, thanks for pointing it out, fixed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98075

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


[PATCH] D98075: [Matrix] Implement += and -= for MatrixType

2021-03-07 Thread Saurabh Jha via Phabricator via cfe-commits
SaurabhJha updated this revision to Diff 328850.
SaurabhJha added a comment.

Fix mistake in Sema/matrix-type-operators.c's add test -= -> +=


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98075

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/matrix-type-operators.c
  clang/test/Sema/matrix-type-operators.c

Index: clang/test/Sema/matrix-type-operators.c
===
--- clang/test/Sema/matrix-type-operators.c
+++ clang/test/Sema/matrix-type-operators.c
@@ -8,6 +8,9 @@
   a = b + c;
   // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'sx10x5_t' (aka 'float __attribute__((matrix_type(10, 5)))'))}}
 
+  b += c;
+  // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'sx10x5_t' (aka 'float __attribute__((matrix_type(10, 5)))'))}}
+
   a = b + b; // expected-error {{assigning to 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') from incompatible type 'sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))')}}
 
   a = 10 + b;
@@ -16,12 +19,19 @@
   a = b + 
   // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'sx10x5_t *' (aka 'float  __attribute__((matrix_type(10, 5)))*'))}}
   // expected-error@-2 {{casting 'sx10x5_t *' (aka 'float  __attribute__((matrix_type(10, 5)))*') to incompatible type 'float'}}
+
+  b += 
+  // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'sx10x5_t *' (aka 'float  __attribute__((matrix_type(10, 5)))*'))}}
+  // expected-error@-2 {{casting 'sx10x5_t *' (aka 'float  __attribute__((matrix_type(10, 5)))*') to incompatible type 'float'}}
 }
 
 void sub(sx10x10_t a, sx5x10_t b, sx10x5_t c) {
   a = b - c;
   // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'sx10x5_t' (aka 'float __attribute__((matrix_type(10, 5)))'))}}
 
+  b -= c;
+  // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'sx10x5_t' (aka 'float __attribute__((matrix_type(10, 5)))'))}}
+
   a = b - b; // expected-error {{assigning to 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') from incompatible type 'sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))')}}
 
   a = 10 - b;
@@ -30,6 +40,10 @@
   a = b - 
   // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'sx10x5_t *' (aka 'float  __attribute__((matrix_type(10, 5)))*'))}}
   // expected-error@-2 {{casting 'sx10x5_t *' (aka 'float  __attribute__((matrix_type(10, 5)))*') to incompatible type 'float'}}
+
+  b -= 
+  // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'sx10x5_t *' (aka 'float  __attribute__((matrix_type(10, 5)))*'))}}
+  // expected-error@-2 {{casting 'sx10x5_t *' (aka 'float  __attribute__((matrix_type(10, 5)))*') to incompatible type 'float'}}
 }
 
 typedef int ix10x5_t __attribute__((matrix_type(10, 5)));
@@ -39,12 +53,16 @@
   // Check dimension mismatches.
   a = a * b;
   // expected-error@-1 {{invalid operands to binary expression ('sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') and 'sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))'))}}
+  a *= b;
+  // expected-error@-1 {{invalid operands to binary expression ('sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') and 'sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))'))}}
   b = a * a;
   // expected-error@-1 {{assigning to 'sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') from incompatible type 'float __attribute__((matrix_type(10, 10)))'}}
 
   // Check element type mismatches.
   a = b * c;
   // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'ix10x5_t' (aka 'int __attribute__((matrix_type(10, 5)))'))}}
+  b *= c;
+  // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'ix10x5_t' (aka 'int __attribute__((matrix_type(10, 5)))'))}}
   d = a * a;
   // expected-error@-1 {{assigning to 'ix10x10_t' (aka 'int __attribute__((matrix_type(10, 10)))') from incompatible type 'float __attribute__((matrix_type(10, 10)))'}}
 
@@ -62,9 +80,15 @@
   a = a * p;
   // expected-error@-1 {{casting 'char *' to incompatible type 'float'}}
   // expected-error@-2 {{invalid operands to binary expression ('sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') and 'char *')}}
+  a *= p;
+  // expected-error@-1 {{casting 'char *' to 

[PATCH] D98075: [Matrix] Implement += and -= for MatrixType

2021-03-07 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added inline comments.



Comment at: clang/test/Sema/matrix-type-operators.c:22
   // expected-error@-2 {{casting 'sx10x5_t *' (aka 'float  
__attribute__((matrix_type(10, 5)))*') to incompatible type 'float'}}
+
+  b -= 

+=?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98075

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


[PATCH] D98075: [Matrix] Implement += and -= for MatrixType

2021-03-07 Thread Saurabh Jha via Phabricator via cfe-commits
SaurabhJha added a comment.

In D98075#2609074 , @fhahn wrote:

> Thanks for the patch! Could you also extend the Sema `matrix-type-operators` 
> tests with checks for `+=` & `-=`?
>
> It looks like the handling for multiply is slightly different and already 
> works but is missing test coverage. It would be great if you could also 
> extend the tests to check for `*=`.

Thanks for the review. I have addressed your comments.

We don't need to add anything to `CodeGenCXX/matrix-type-operators.cpp` and 
`SemaCXX/matrix-type-operators.cpp`, right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98075

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


[PATCH] D98075: [Matrix] Implement += and -= for MatrixType

2021-03-07 Thread Saurabh Jha via Phabricator via cfe-commits
SaurabhJha updated this revision to Diff 328849.
SaurabhJha edited the summary of this revision.
SaurabhJha added a comment.

Implement tests for *= for matrices code gen and add tests in Sema for compound 
assignments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98075

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/matrix-type-operators.c
  clang/test/Sema/matrix-type-operators.c

Index: clang/test/Sema/matrix-type-operators.c
===
--- clang/test/Sema/matrix-type-operators.c
+++ clang/test/Sema/matrix-type-operators.c
@@ -8,6 +8,9 @@
   a = b + c;
   // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'sx10x5_t' (aka 'float __attribute__((matrix_type(10, 5)))'))}}
 
+  b += c;
+  // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'sx10x5_t' (aka 'float __attribute__((matrix_type(10, 5)))'))}}
+
   a = b + b; // expected-error {{assigning to 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') from incompatible type 'sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))')}}
 
   a = 10 + b;
@@ -16,12 +19,19 @@
   a = b + 
   // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'sx10x5_t *' (aka 'float  __attribute__((matrix_type(10, 5)))*'))}}
   // expected-error@-2 {{casting 'sx10x5_t *' (aka 'float  __attribute__((matrix_type(10, 5)))*') to incompatible type 'float'}}
+
+  b -= 
+  // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'sx10x5_t *' (aka 'float  __attribute__((matrix_type(10, 5)))*'))}}
+  // expected-error@-2 {{casting 'sx10x5_t *' (aka 'float  __attribute__((matrix_type(10, 5)))*') to incompatible type 'float'}}
 }
 
 void sub(sx10x10_t a, sx5x10_t b, sx10x5_t c) {
   a = b - c;
   // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'sx10x5_t' (aka 'float __attribute__((matrix_type(10, 5)))'))}}
 
+  b -= c;
+  // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'sx10x5_t' (aka 'float __attribute__((matrix_type(10, 5)))'))}}
+
   a = b - b; // expected-error {{assigning to 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') from incompatible type 'sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))')}}
 
   a = 10 - b;
@@ -30,6 +40,10 @@
   a = b - 
   // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'sx10x5_t *' (aka 'float  __attribute__((matrix_type(10, 5)))*'))}}
   // expected-error@-2 {{casting 'sx10x5_t *' (aka 'float  __attribute__((matrix_type(10, 5)))*') to incompatible type 'float'}}
+
+  b -= 
+  // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'sx10x5_t *' (aka 'float  __attribute__((matrix_type(10, 5)))*'))}}
+  // expected-error@-2 {{casting 'sx10x5_t *' (aka 'float  __attribute__((matrix_type(10, 5)))*') to incompatible type 'float'}}
 }
 
 typedef int ix10x5_t __attribute__((matrix_type(10, 5)));
@@ -39,12 +53,16 @@
   // Check dimension mismatches.
   a = a * b;
   // expected-error@-1 {{invalid operands to binary expression ('sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') and 'sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))'))}}
+  a *= b;
+  // expected-error@-1 {{invalid operands to binary expression ('sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') and 'sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))'))}}
   b = a * a;
   // expected-error@-1 {{assigning to 'sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') from incompatible type 'float __attribute__((matrix_type(10, 10)))'}}
 
   // Check element type mismatches.
   a = b * c;
   // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'ix10x5_t' (aka 'int __attribute__((matrix_type(10, 5)))'))}}
+  b *= c;
+  // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'ix10x5_t' (aka 'int __attribute__((matrix_type(10, 5)))'))}}
   d = a * a;
   // expected-error@-1 {{assigning to 'ix10x10_t' (aka 'int __attribute__((matrix_type(10, 10)))') from incompatible type 'float __attribute__((matrix_type(10, 10)))'}}
 
@@ -62,9 +80,15 @@
   a = a * p;
   // expected-error@-1 {{casting 'char *' to incompatible type 'float'}}
   // expected-error@-2 {{invalid operands to binary expression ('sx10x10_t' (aka 'float __attribute__((matrix_type(10, 

[libunwind] 39ad160 - [libunwind] Install the DLL when doing "ninja install"

2021-03-07 Thread Martin Storsjö via cfe-commits

Author: Martin Storsjö
Date: 2021-03-07T10:36:22+02:00
New Revision: 39ad160468e2b6acaa0b2b1ab353079eca4a3b03

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

LOG: [libunwind] Install the DLL when doing "ninja install"

This matches how install(... RUNTIME) is used in e.g. libcxx.

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

Added: 


Modified: 
libunwind/src/CMakeLists.txt

Removed: 




diff  --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt
index f59dfdde9f03..f341b21e6016 100644
--- a/libunwind/src/CMakeLists.txt
+++ b/libunwind/src/CMakeLists.txt
@@ -183,7 +183,8 @@ add_custom_target(unwind DEPENDS ${LIBUNWIND_BUILD_TARGETS})
 if (LIBUNWIND_INSTALL_LIBRARY)
   install(TARGETS ${LIBUNWIND_INSTALL_TARGETS}
 LIBRARY DESTINATION 
${LIBUNWIND_INSTALL_PREFIX}${LIBUNWIND_INSTALL_LIBRARY_DIR} COMPONENT unwind
-ARCHIVE DESTINATION 
${LIBUNWIND_INSTALL_PREFIX}${LIBUNWIND_INSTALL_LIBRARY_DIR} COMPONENT unwind)
+ARCHIVE DESTINATION 
${LIBUNWIND_INSTALL_PREFIX}${LIBUNWIND_INSTALL_LIBRARY_DIR} COMPONENT unwind
+RUNTIME DESTINATION ${LIBUNWIND_INSTALL_PREFIX}bin COMPONENT unwind)
 endif()
 
 if (NOT CMAKE_CONFIGURATION_TYPES AND LIBUNWIND_INSTALL_LIBRARY)



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


[PATCH] D97107: Replace func name with regex in update_cc_test_checks

2021-03-07 Thread Giorgis Georgakoudis via Phabricator via cfe-commits
ggeorgakoudis updated this revision to Diff 328845.
ggeorgakoudis added a comment.

Fix (another) for multiple capture groups


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97107

Files:
  clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c
  clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c.expected
  clang/test/utils/update_cc_test_checks/generated-funcs-regex.test
  llvm/utils/UpdateTestChecks/common.py

Index: llvm/utils/UpdateTestChecks/common.py
===
--- llvm/utils/UpdateTestChecks/common.py
+++ llvm/utils/UpdateTestChecks/common.py
@@ -30,6 +30,8 @@
help='Activate CHECK line generation from this point forward')
   parser.add_argument('--disable', action='store_false', dest='enabled',
   help='Deactivate CHECK line generation from this point forward')
+  parser.add_argument('--replace-function-regex', nargs='+', default=[],
+  help='List of regular expressions to replace matching function names')
   args = parser.parse_args()
   global _verbose
   _verbose = args.verbose
@@ -264,6 +266,8 @@
 self._record_args = flags.function_signature
 self._check_attributes = flags.check_attributes
 self._scrubber_args = scrubber_args
+# Strip double-quotes if input was read by UTC_ARGS
+self._replace_function_regex = list(map(lambda x: x.strip('"'), flags.replace_function_regex))
 self._func_dict = {}
 self._func_order = {}
 for tuple in run_list:
@@ -331,6 +335,30 @@
   self._func_dict[prefix][func] = None
   continue
 
+# Replace function names matching the regex.
+for regex in self._replace_function_regex:
+  # Pattern that matches capture groups in the regex in leftmost order.
+  group_regex = re.compile('\(.*?\)')
+  # Replace function name with regex.
+  match = re.match(regex, func)
+  if match:
+func_repl = regex
+# Replace any capture groups with their matched strings.
+for g in match.groups():
+  func_repl = group_regex.sub(g, func_repl, count=1)
+func = '{{' + func_repl + '}}'
+
+  # Replace all calls to regex matching functions.
+  matches = re.finditer(regex, scrubbed_body)
+  for match in matches:
+func_repl = regex
+# Replace any capture groups with their matched strings.
+for g in match.groups():
+func_repl = group_regex.sub(g, func_repl, count=1)
+# Substitute function call names that match the regex with the same
+# capture groups set.
+scrubbed_body = re.sub(func_repl, '{{' + func_repl + '}}', scrubbed_body)
+
 self._func_dict[prefix][func] = function_body(
 scrubbed_body, scrubbed_extra, args_and_sig, attrs)
 self._func_order[prefix].append(func)
@@ -633,6 +661,8 @@
   continue  # Don't add default values
 autogenerated_note_args += action.option_strings[0] + ' '
 if action.const is None:  # action takes a parameter
+  if action.nargs == '+':
+value = ' '.join(map(lambda v: '"' + v.strip('"') + '"', value))
   autogenerated_note_args += '%s ' % value
   if autogenerated_note_args:
 autogenerated_note_args = ' %s %s' % (UTC_ARGS_KEY, autogenerated_note_args[:-1])
Index: clang/test/utils/update_cc_test_checks/generated-funcs-regex.test
===
--- /dev/null
+++ clang/test/utils/update_cc_test_checks/generated-funcs-regex.test
@@ -0,0 +1,9 @@
+## Test that CHECK lines are generated for clang-generated functions replaced
+## by regex
+
+## RUN: cp %S/Inputs/generated-funcs-regex.c %t-generated-funcs-regex.c && %update_cc_test_checks --include-generated-funcs --replace-function-regex "__([a-z]+)_offloading_[0-9]+_[a-z0-9]+_(.*)_l[0-9]+" -- %t-generated-funcs-regex.c
+# RUN: diff -u %S/Inputs/generated-funcs-regex.c.expected %t-generated-funcs-regex.c
+
+## Check that re-running update_cc_test_checks doesn't change the output
+# RUN: %update_cc_test_checks %t-generated-funcs-regex.c
+# RUN: diff -u %S/Inputs/generated-funcs-regex.c.expected %t-generated-funcs-regex.c
Index: clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c.expected
===
--- /dev/null
+++ clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c.expected
@@ -0,0 +1,36 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --include-generated-funcs --replace-function-regex "__([a-z]+)_offloading_[0-9]+_[a-z0-9]+_(.*)_l[0-9]+"
+// RUN: %clang_cc1 -fopenmp %s -emit-llvm -o - | FileCheck %s
+
+void __test_offloading_42_abcdef_bar_l123();
+void use(int);
+
+void