[PATCH] D106333: [AArch64][SVE] Handle svbool_t VLST <-> VLAT/GNUT conversion

2021-07-21 Thread JunMa 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 rG599b2f00370e: [AArch64][SVE] Handle svbool_t VLST - 
VLAT/GNUT conversion (authored by junparser).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106333

Files:
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/attr-arm-sve-vector-bits-codegen.c
  clang/test/SemaCXX/aarch64-sve-explicit-casts-fixed-size.cpp
  clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp
  clang/test/SemaCXX/attr-arm-sve-vector-bits.cpp

Index: clang/test/SemaCXX/attr-arm-sve-vector-bits.cpp
===
--- clang/test/SemaCXX/attr-arm-sve-vector-bits.cpp
+++ clang/test/SemaCXX/attr-arm-sve-vector-bits.cpp
@@ -9,6 +9,10 @@
 typedef svint8_t fixed_int8_t __attribute__((arm_sve_vector_bits(N)));
 typedef int8_t gnu_int8_t __attribute__((vector_size(N / 8)));
 
+typedef __SVBool_t svbool_t;
+typedef svbool_t fixed_bool_t __attribute__((arm_sve_vector_bits(N)));
+typedef int8_t gnu_bool_t __attribute__((vector_size(N / 64)));
+
 template struct S { T var; };
 
 S s;
@@ -24,3 +28,11 @@
 // Test implicit casts between GNU and VLS vectors
 fixed_int8_t to_fixed_int8_t__from_gnu_int8_t(gnu_int8_t x) { return x; }
 gnu_int8_t from_fixed_int8_t__to_gnu_int8_t(fixed_int8_t x) { return x; }
+
+// Test implicit casts between VLA and VLS predicates
+svbool_t to_svbool_t(fixed_bool_t x) { return x; }
+fixed_bool_t from_svbool_t(svbool_t x) { return x; }
+
+// Test implicit casts between GNU and VLA predicates
+svbool_t to_svbool_t__from_gnu_bool_t(gnu_bool_t x) { return x; }
+gnu_bool_t from_svbool_t__to_gnu_bool_t(svbool_t x) { return x; }
Index: clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp
===
--- clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp
+++ clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp
@@ -2,22 +2,25 @@
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=integer -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify=lax-vector-integer %s
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=all -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify=lax-vector-all %s
 
-// lax-vector-all-no-diagnostics
-
 #include 
 
 #define N __ARM_FEATURE_SVE_BITS
 #define SVE_FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))
 #define GNU_FIXED_ATTR __attribute__((vector_size(N / 8)))
+#define GNU_BOOL_FIXED_ATTR __attribute__((vector_size(N / 64)))
 
 typedef svfloat32_t sve_fixed_float32_t SVE_FIXED_ATTR;
 typedef svint32_t sve_fixed_int32_t SVE_FIXED_ATTR;
+typedef svbool_t sve_fixed_bool_t SVE_FIXED_ATTR;
 typedef float gnu_fixed_float32_t GNU_FIXED_ATTR;
 typedef int gnu_fixed_int32_t GNU_FIXED_ATTR;
+typedef int8_t gnu_fixed_bool_t GNU_BOOL_FIXED_ATTR;
 
 void sve_allowed_with_integer_lax_conversions() {
   sve_fixed_int32_t fi32;
   svint64_t si64;
+  svbool_t sb8;
+  sve_fixed_bool_t fb8;
 
   // The implicit cast here should fail if -flax-vector-conversions=none, but pass if
   // -flax-vector-conversions={integer,all}.
@@ -25,6 +28,25 @@
   // lax-vector-none-error@-1 {{assigning to 'sve_fixed_int32_t' (vector of 16 'int' values) from incompatible type}}
   si64 = fi32;
   // lax-vector-none-error@-1 {{assigning to 'svint64_t' (aka '__SVInt64_t') from incompatible type}}
+
+  fi32 = sb8;
+  // lax-vector-none-error@-1 {{assigning to 'sve_fixed_int32_t' (vector of 16 'int' values) from incompatible type}}
+  // lax-vector-integer-error@-2 {{assigning to 'sve_fixed_int32_t' (vector of 16 'int' values) from incompatible type}}
+  // lax-vector-all-error@-3 {{assigning to 'sve_fixed_int32_t' (vector of 16 'int' values) from incompatible type}}
+  sb8 = fi32;
+  // lax-vector-none-error@-1 {{assigning to 'svbool_t' (aka '__SVBool_t') from incompatible type}}
+  // lax-vector-integer-error@-2 {{assigning to 'svbool_t' (aka '__SVBool_t') from incompatible type}}
+  // lax-vector-all-error@-3 {{assigning to 'svbool_t' (aka '__SVBool_t') from incompatible type}}
+
+  si64 = fb8;
+  // lax-vector-none-error@-1 {{assigning to 'svint64_t' (aka '__SVInt64_t') from incompatible type}}
+  // lax-vector-integer-error@-2 {{assigning to 'svint64_t' (aka '__SVInt64_t') from incompatible type}}
+  // lax-vector-all-error@-3 {{assigning to 'svint64_t' (aka '__SVInt64_t') from incompatible type}}
+
+  fb8 = si64;
+  // lax-vector-none-error@-1 {{assigning to 'sve_fixed_bool_t' (vector of 8 'unsigned char' values) from incompatible type}}
+  // lax-vector-integer-error@-2 {{assigning to 'sve_fixed_bool_t' (vector of 8 'unsigned char' values) from incompatible type}}
+  // 

[clang] 599b2f0 - [AArch64][SVE] Handle svbool_t VLST <-> VLAT/GNUT conversion

2021-07-21 Thread Jun Ma via cfe-commits

Author: Jun Ma
Date: 2021-07-22T13:55:08+08:00
New Revision: 599b2f00370ee79e812d2776f2af57fae36d02e9

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

LOG: [AArch64][SVE] Handle svbool_t VLST <-> VLAT/GNUT conversion

According to https://godbolt.org/z/q5rME1naY and acle, we found that
there are different SVE conversion behaviours between clang and gcc. It turns
out that llvm does not handle SVE predicates width properly.

This patch 1) checks SVE predicates width rightly with svbool_t type.
2) removes warning on svbool_t VLST <-> VLAT/GNUT conversion.
3) disables VLST <-> VLAT/GNUT conversion between SVE vectors and predicates
due to different width.

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

Added: 


Modified: 
clang/lib/AST/ASTContext.cpp
clang/lib/Sema/SemaChecking.cpp
clang/test/CodeGen/attr-arm-sve-vector-bits-codegen.c
clang/test/SemaCXX/aarch64-sve-explicit-casts-fixed-size.cpp
clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp
clang/test/SemaCXX/attr-arm-sve-vector-bits.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 46b778d2834a8..e102a3ba508d4 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -8670,6 +8670,14 @@ bool ASTContext::areCompatibleVectorTypes(QualType 
FirstVec,
   return false;
 }
 
+/// getSVETypeSize - Return SVE vector or predicate register size.
+static uint64_t getSVETypeSize(ASTContext , const BuiltinType *Ty) {
+  assert(Ty->isVLSTBuiltinType() && "Invalid SVE Type");
+  return Ty->getKind() == BuiltinType::SveBool
+ ? Context.getLangOpts().ArmSveVectorBits / Context.getCharWidth()
+ : Context.getLangOpts().ArmSveVectorBits;
+}
+
 bool ASTContext::areCompatibleSveTypes(QualType FirstType,
QualType SecondType) {
   assert(((FirstType->isSizelessBuiltinType() && SecondType->isVectorType()) ||
@@ -8687,7 +8695,7 @@ bool ASTContext::areCompatibleSveTypes(QualType FirstType,
   return VT->getElementType().getCanonicalType() ==
  FirstType->getSveEltType(*this);
 else if (VT->getVectorKind() == VectorType::GenericVector)
-  return getTypeSize(SecondType) == getLangOpts().ArmSveVectorBits &&
+  return getTypeSize(SecondType) == getSVETypeSize(*this, BT) &&
  hasSameType(VT->getElementType(),
  getBuiltinVectorTypeInfo(BT).ElementType);
   }
@@ -8706,7 +8714,8 @@ bool ASTContext::areLaxCompatibleSveTypes(QualType 
FirstType,
  "Expected SVE builtin type and vector type!");
 
   auto IsLaxCompatible = [this](QualType FirstType, QualType SecondType) {
-if (!FirstType->getAs())
+const auto *BT = FirstType->getAs();
+if (!BT)
   return false;
 
 const auto *VecTy = SecondType->getAs();
@@ -8716,13 +8725,19 @@ bool ASTContext::areLaxCompatibleSveTypes(QualType 
FirstType,
   const LangOptions::LaxVectorConversionKind LVCKind =
   getLangOpts().getLaxVectorConversions();
 
+  // Can not convert between sve predicates and sve vectors because of
+  // 
diff erent size.
+  if (BT->getKind() == BuiltinType::SveBool &&
+  VecTy->getVectorKind() == VectorType::SveFixedLengthDataVector)
+return false;
+
   // If __ARM_FEATURE_SVE_BITS != N do not allow GNU vector lax conversion.
   // "Whenever __ARM_FEATURE_SVE_BITS==N, GNUT implicitly
   // converts to VLAT and VLAT implicitly converts to GNUT."
   // ACLE Spec Version 00bet6, 3.7.3.2. Behavior common to vectors and
   // predicates.
   if (VecTy->getVectorKind() == VectorType::GenericVector &&
-  getTypeSize(SecondType) != getLangOpts().ArmSveVectorBits)
+  getTypeSize(SecondType) != getSVETypeSize(*this, BT))
 return false;
 
   // If -flax-vector-conversions=all is specified, the types are

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 242c2968da45f..02da39c11d7f9 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -12570,15 +12570,13 @@ static void CheckImplicitConversion(Sema , Expr *E, 
QualType T,
 checkObjCDictionaryLiteral(S, QualType(Target, 0), DictionaryLiteral);
 
   // Strip vector types.
-  if (const auto *SourceVT = dyn_cast(Source)) {
-if (Target->isVLSTBuiltinType()) {
-  auto SourceVectorKind = SourceVT->getVectorKind();
-  if (SourceVectorKind == VectorType::SveFixedLengthDataVector ||
-  SourceVectorKind == VectorType::SveFixedLengthPredicateVector ||
-  (SourceVectorKind == VectorType::GenericVector &&
-   S.Context.getTypeSize(Source) == S.getLangOpts().ArmSveVectorBits))
-

[PATCH] D106344: [PowerPC] Implement XL compatible behavior of __compare_and_swap

2021-07-21 Thread Kai Luo via Phabricator via cfe-commits
lkail updated this revision to Diff 360699.
lkail added a comment.
Herald added a project: LLVM.

Discussed with @jsji about the details of codegen and inspect XL's codegen at 
different opt level, add an `opt` test from jinsong to demonstrate the store 
can be eliminated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106344

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-ppc-xlcompat-cas.c
  llvm/test/CodeGen/PowerPC/opt-builtins-ppc-xlcompat-cas.ll


Index: llvm/test/CodeGen/PowerPC/opt-builtins-ppc-xlcompat-cas.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/opt-builtins-ppc-xlcompat-cas.ll
@@ -0,0 +1,25 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -enable-new-pm=1 -S -passes='default' %s -o - | FileCheck %s
+define void @test_builtin_ppc_compare_and_swaplp(i64 %a, i64 %b, i64 %c) #0 {
+; CHECK-LABEL: @test_builtin_ppc_compare_and_swaplp(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[A_ADDR:%.*]] = alloca i64, align 8
+; CHECK-NEXT:store i64 [[A:%.*]], i64* [[A_ADDR]], align 8
+; CHECK-NEXT:[[TMP0:%.*]] = cmpxchg weak volatile i64* [[A_ADDR]], i64 
[[B:%.*]], i64 [[C:%.*]] monotonic monotonic, align 8
+; CHECK-NEXT:ret void
+;
+entry:
+  %a.addr = alloca i64, align 8
+  %b.addr = alloca i64, align 8
+  %c.addr = alloca i64, align 8
+  store i64 %a, i64* %a.addr, align 8
+  store i64 %b, i64* %b.addr, align 8
+  store i64 %c, i64* %c.addr, align 8
+  %0 = load i64, i64* %c.addr, align 8
+  %1 = load i64, i64* %b.addr, align 8
+  %2 = cmpxchg weak volatile i64* %a.addr, i64 %1, i64 %0 monotonic monotonic, 
align 8
+  %3 = extractvalue { i64, i1 } %2, 0
+  %4 = extractvalue { i64, i1 } %2, 1
+  store i64 %3, i64* %b.addr, align 8
+  ret void
+}
Index: clang/test/CodeGen/builtins-ppc-xlcompat-cas.c
===
--- clang/test/CodeGen/builtins-ppc-xlcompat-cas.c
+++ clang/test/CodeGen/builtins-ppc-xlcompat-cas.c
@@ -19,6 +19,7 @@
 // CHECK-NEXT:[[TMP2:%.*]] = cmpxchg weak volatile i32* [[A_ADDR]], i32 
[[TMP1]], i32 [[TMP0]] monotonic monotonic, align 4
 // CHECK-NEXT:[[TMP3:%.*]] = extractvalue { i32, i1 } [[TMP2]], 0
 // CHECK-NEXT:[[TMP4:%.*]] = extractvalue { i32, i1 } [[TMP2]], 1
+// CHECK-NEXT:store i32 [[TMP3]], i32* [[B_ADDR]], align 4
 // CHECK-NEXT:ret void
 //
 void test_builtin_ppc_compare_and_swap(int a, int b, int c) {
@@ -39,6 +40,7 @@
 // CHECK-NEXT:[[TMP2:%.*]] = cmpxchg weak volatile i64* [[A_ADDR]], i64 
[[TMP1]], i64 [[TMP0]] monotonic monotonic, align 8
 // CHECK-NEXT:[[TMP3:%.*]] = extractvalue { i64, i1 } [[TMP2]], 0
 // CHECK-NEXT:[[TMP4:%.*]] = extractvalue { i64, i1 } [[TMP2]], 1
+// CHECK-NEXT:store i64 [[TMP3]], i64* [[B_ADDR]], align 8
 // CHECK-NEXT:ret void
 //
 void test_builtin_ppc_compare_and_swaplp(long a, long b, long c) {
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -15662,6 +15662,15 @@
 auto Pair = EmitAtomicCompareExchange(
 LV, RValue::get(OldVal), RValue::get(Ops[2]), E->getExprLoc(),
 llvm::AtomicOrdering::Monotonic, llvm::AtomicOrdering::Monotonic, 
true);
+// Unlike c11's atomic_compare_exchange, accroding to
+// 
https://www.ibm.com/docs/en/xl-c-and-cpp-aix/16.1?topic=functions-compare-swap-compare-swaplp
+// > In either case, the contents of the memory location specified by addr
+// > are copied into the memory location specified by old_val_addr.
+// But it hasn't specified storing to OldValAddr is atomic or not and
+// which order to use. Now following XL's codegen, treat it as a normal
+// store.
+Value *LoadedVal = Pair.first.getScalarVal();
+Builder.CreateStore(LoadedVal, OldValAddr);
 return Pair.second;
   }
   case PPC::BI__builtin_ppc_fetch_and_add:


Index: llvm/test/CodeGen/PowerPC/opt-builtins-ppc-xlcompat-cas.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/opt-builtins-ppc-xlcompat-cas.ll
@@ -0,0 +1,25 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -enable-new-pm=1 -S -passes='default' %s -o - | FileCheck %s
+define void @test_builtin_ppc_compare_and_swaplp(i64 %a, i64 %b, i64 %c) #0 {
+; CHECK-LABEL: @test_builtin_ppc_compare_and_swaplp(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[A_ADDR:%.*]] = alloca i64, align 8
+; CHECK-NEXT:store i64 [[A:%.*]], i64* [[A_ADDR]], align 8
+; CHECK-NEXT:[[TMP0:%.*]] = cmpxchg weak volatile i64* [[A_ADDR]], i64 [[B:%.*]], i64 [[C:%.*]] monotonic monotonic, align 8
+; CHECK-NEXT:ret void
+;
+entry:
+  %a.addr = alloca i64, align 8
+  %b.addr = alloca i64, align 8
+  %c.addr = alloca 

[PATCH] D106371: [AIX] Generate large code model relocations when mcmodel=medium on AIX

2021-07-21 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

In D106371#2894736 , @anjankgk wrote:

> Anjan Kumar Guttahalli Krishna 
>
> Thank you!

I running a build with this now -- I'll check its status in the morning.


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

https://reviews.llvm.org/D106371

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


[PATCH] D106333: [AArch64][SVE] Handle svbool_t VLST <-> VLAT/GNUT conversion

2021-07-21 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma 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/D106333/new/

https://reviews.llvm.org/D106333

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


[PATCH] D106518: [RISCV] Disable EEW=64 for index values when XLEN=32.

2021-07-21 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added inline comments.



Comment at: clang/include/clang/Basic/riscv_vector.td:555
 
+defvar Xlen32EEWList = [["8", "(Log2EEW:3)"],
+["16", "(Log2EEW:4)"],

Ignoring whether the change is actually correct, this should be capitalised as 
XLen32EEWList, but really this should actually be RV32 not XLen32 as that's not 
a term we use.



Comment at: clang/include/clang/Basic/riscv_vector.td:693
+let Name = op # eew64 # "_v", IRName = op, IRNameMask = op # "_mask",
+RequiredExtensions = ["Xlen64"] in {
+def: RVVBuiltin<"v", "vPCe" # eew64_type # "Uv", type>;

Xlen64 is not an extension. Nor is RV64I, even, it is a base ISA, but that 
would at least be somewhat defensible. In fact, Xlen64 would be parsed as a 
valid non-standard extension called "Xlen" with major version 64 and minor 
version 0, just like any other Xfoo.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106518

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


[PATCH] D106518: [RISCV] Disable EEW=64 for index values when XLEN=32.

2021-07-21 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Why do they need to be disabled? Doesn’t the spec define them to truncate?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106518

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


[PATCH] D106333: [AArch64][SVE] Handle svbool_t VLST <-> VLAT/GNUT conversion

2021-07-21 Thread JunMa via Phabricator via cfe-commits
junparser updated this revision to Diff 360690.
junparser added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106333

Files:
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/attr-arm-sve-vector-bits-codegen.c
  clang/test/SemaCXX/aarch64-sve-explicit-casts-fixed-size.cpp
  clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp
  clang/test/SemaCXX/attr-arm-sve-vector-bits.cpp

Index: clang/test/SemaCXX/attr-arm-sve-vector-bits.cpp
===
--- clang/test/SemaCXX/attr-arm-sve-vector-bits.cpp
+++ clang/test/SemaCXX/attr-arm-sve-vector-bits.cpp
@@ -9,6 +9,10 @@
 typedef svint8_t fixed_int8_t __attribute__((arm_sve_vector_bits(N)));
 typedef int8_t gnu_int8_t __attribute__((vector_size(N / 8)));
 
+typedef __SVBool_t svbool_t;
+typedef svbool_t fixed_bool_t __attribute__((arm_sve_vector_bits(N)));
+typedef int8_t gnu_bool_t __attribute__((vector_size(N / 64)));
+
 template struct S { T var; };
 
 S s;
@@ -24,3 +28,11 @@
 // Test implicit casts between GNU and VLS vectors
 fixed_int8_t to_fixed_int8_t__from_gnu_int8_t(gnu_int8_t x) { return x; }
 gnu_int8_t from_fixed_int8_t__to_gnu_int8_t(fixed_int8_t x) { return x; }
+
+// Test implicit casts between VLA and VLS predicates
+svbool_t to_svbool_t(fixed_bool_t x) { return x; }
+fixed_bool_t from_svbool_t(svbool_t x) { return x; }
+
+// Test implicit casts between GNU and VLA predicates
+svbool_t to_svbool_t__from_gnu_bool_t(gnu_bool_t x) { return x; }
+gnu_bool_t from_svbool_t__to_gnu_bool_t(svbool_t x) { return x; }
Index: clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp
===
--- clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp
+++ clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp
@@ -2,22 +2,25 @@
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=integer -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify=lax-vector-integer %s
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=all -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify=lax-vector-all %s
 
-// lax-vector-all-no-diagnostics
-
 #include 
 
 #define N __ARM_FEATURE_SVE_BITS
 #define SVE_FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))
 #define GNU_FIXED_ATTR __attribute__((vector_size(N / 8)))
+#define GNU_BOOL_FIXED_ATTR __attribute__((vector_size(N / 64)))
 
 typedef svfloat32_t sve_fixed_float32_t SVE_FIXED_ATTR;
 typedef svint32_t sve_fixed_int32_t SVE_FIXED_ATTR;
+typedef svbool_t sve_fixed_bool_t SVE_FIXED_ATTR;
 typedef float gnu_fixed_float32_t GNU_FIXED_ATTR;
 typedef int gnu_fixed_int32_t GNU_FIXED_ATTR;
+typedef int8_t gnu_fixed_bool_t GNU_BOOL_FIXED_ATTR;
 
 void sve_allowed_with_integer_lax_conversions() {
   sve_fixed_int32_t fi32;
   svint64_t si64;
+  svbool_t sb8;
+  sve_fixed_bool_t fb8;
 
   // The implicit cast here should fail if -flax-vector-conversions=none, but pass if
   // -flax-vector-conversions={integer,all}.
@@ -25,6 +28,25 @@
   // lax-vector-none-error@-1 {{assigning to 'sve_fixed_int32_t' (vector of 16 'int' values) from incompatible type}}
   si64 = fi32;
   // lax-vector-none-error@-1 {{assigning to 'svint64_t' (aka '__SVInt64_t') from incompatible type}}
+
+  fi32 = sb8;
+  // lax-vector-none-error@-1 {{assigning to 'sve_fixed_int32_t' (vector of 16 'int' values) from incompatible type}}
+  // lax-vector-integer-error@-2 {{assigning to 'sve_fixed_int32_t' (vector of 16 'int' values) from incompatible type}}
+  // lax-vector-all-error@-3 {{assigning to 'sve_fixed_int32_t' (vector of 16 'int' values) from incompatible type}}
+  sb8 = fi32;
+  // lax-vector-none-error@-1 {{assigning to 'svbool_t' (aka '__SVBool_t') from incompatible type}}
+  // lax-vector-integer-error@-2 {{assigning to 'svbool_t' (aka '__SVBool_t') from incompatible type}}
+  // lax-vector-all-error@-3 {{assigning to 'svbool_t' (aka '__SVBool_t') from incompatible type}}
+
+  si64 = fb8;
+  // lax-vector-none-error@-1 {{assigning to 'svint64_t' (aka '__SVInt64_t') from incompatible type}}
+  // lax-vector-integer-error@-2 {{assigning to 'svint64_t' (aka '__SVInt64_t') from incompatible type}}
+  // lax-vector-all-error@-3 {{assigning to 'svint64_t' (aka '__SVInt64_t') from incompatible type}}
+
+  fb8 = si64;
+  // lax-vector-none-error@-1 {{assigning to 'sve_fixed_bool_t' (vector of 8 'unsigned char' values) from incompatible type}}
+  // lax-vector-integer-error@-2 {{assigning to 'sve_fixed_bool_t' (vector of 8 'unsigned char' values) from incompatible type}}
+  // lax-vector-all-error@-3 {{assigning to 'sve_fixed_bool_t' (vector of 8 'unsigned char' values) from incompatible type}}
 }
 
 void 

[PATCH] D106516: to run test only

2021-07-21 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh updated this revision to Diff 360688.

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

https://reviews.llvm.org/D106516

Files:
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang/include/clang/ASTMatchers/ASTMatchFinder.h
  clang/include/clang/Frontend/MultiplexConsumer.h


Index: clang/include/clang/Frontend/MultiplexConsumer.h
===
--- clang/include/clang/Frontend/MultiplexConsumer.h
+++ clang/include/clang/Frontend/MultiplexConsumer.h
@@ -10,6 +10,8 @@
 //  multiplex ASTConsumer and SemaConsumer messages to many consumers.
 //
 
//===--===//
+//
+// To run all tests.
 
 #ifndef LLVM_CLANG_FRONTEND_MULTIPLEXCONSUMER_H
 #define LLVM_CLANG_FRONTEND_MULTIPLEXCONSUMER_H
Index: clang/include/clang/ASTMatchers/ASTMatchFinder.h
===
--- clang/include/clang/ASTMatchers/ASTMatchFinder.h
+++ clang/include/clang/ASTMatchers/ASTMatchFinder.h
@@ -37,6 +37,8 @@
 //
 
//===--===//
 
+// To run all tests.
+//
 #ifndef LLVM_CLANG_ASTMATCHERS_ASTMATCHFINDER_H
 #define LLVM_CLANG_ASTMATCHERS_ASTMATCHFINDER_H
 
Index: clang-tools-extra/clang-tidy/ClangTidy.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -14,6 +14,8 @@
 ///
 
//===--===//
 
+// Check with latest clang/llvm tests.
+
 #include "ClangTidy.h"
 #include "ClangTidyCheck.h"
 #include "ClangTidyDiagnosticConsumer.h"


Index: clang/include/clang/Frontend/MultiplexConsumer.h
===
--- clang/include/clang/Frontend/MultiplexConsumer.h
+++ clang/include/clang/Frontend/MultiplexConsumer.h
@@ -10,6 +10,8 @@
 //  multiplex ASTConsumer and SemaConsumer messages to many consumers.
 //
 //===--===//
+//
+// To run all tests.
 
 #ifndef LLVM_CLANG_FRONTEND_MULTIPLEXCONSUMER_H
 #define LLVM_CLANG_FRONTEND_MULTIPLEXCONSUMER_H
Index: clang/include/clang/ASTMatchers/ASTMatchFinder.h
===
--- clang/include/clang/ASTMatchers/ASTMatchFinder.h
+++ clang/include/clang/ASTMatchers/ASTMatchFinder.h
@@ -37,6 +37,8 @@
 //
 //===--===//
 
+// To run all tests.
+//
 #ifndef LLVM_CLANG_ASTMATCHERS_ASTMATCHFINDER_H
 #define LLVM_CLANG_ASTMATCHERS_ASTMATCHFINDER_H
 
Index: clang-tools-extra/clang-tidy/ClangTidy.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -14,6 +14,8 @@
 ///
 //===--===//
 
+// Check with latest clang/llvm tests.
+
 #include "ClangTidy.h"
 #include "ClangTidyCheck.h"
 #include "ClangTidyDiagnosticConsumer.h"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106344: [PowerPC] Implement XL compatible behavior of __compare_and_swap

2021-07-21 Thread Kai Luo via Phabricator via cfe-commits
lkail added a comment.

In D106344#2894755 , @jsji wrote:

> Doesn't look good enough to me,  the assembly code sequence generated is not 
> clean enough.

I'm assuming you mean the second `stdcx.`, that looks like a historical issue 
which exists for 13yrs. According to 
https://www.cl.cam.ac.uk/~pes20/cpp/cpp0xmappings.html and what xlc generates 
for CAS, it should not exist.

  commit 166d6cb1fad159b1aedb3801ecaecb62000979d1
  Author: Dale Johannesen 
  Date:   Mon Aug 25 18:53:26 2008 +
  
  It's important for the cmp-and-swap to balance
  loads and stores but it's even more important for
  it to store the right value.:(
  
  llvm-svn: 55319


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106344

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


[PATCH] D106516: to run test only

2021-07-21 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh created this revision.
chh requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

DO NOT SUBMIT.
Only to run tests.


https://reviews.llvm.org/D106516

Files:
  clang-tools-extra/clang-tidy/ClangTidy.cpp


Index: clang-tools-extra/clang-tidy/ClangTidy.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -14,6 +14,8 @@
 ///
 
//===--===//
 
+// Check with latest clang/llvm tests.
+
 #include "ClangTidy.h"
 #include "ClangTidyCheck.h"
 #include "ClangTidyDiagnosticConsumer.h"


Index: clang-tools-extra/clang-tidy/ClangTidy.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -14,6 +14,8 @@
 ///
 //===--===//
 
+// Check with latest clang/llvm tests.
+
 #include "ClangTidy.h"
 #include "ClangTidyCheck.h"
 #include "ClangTidyDiagnosticConsumer.h"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D103873: [Clang][RISCV] Implement vsoxseg and vsuxseg.

2021-07-21 Thread Hsiangkai Wang 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 rG698f288fa16c: [Clang][RISCV] Implement vsoxseg and vsuxseg. 
(authored by HsiangKai).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103873

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsoxseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsuxseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vsoxseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vsuxseg.c

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


[PATCH] D103809: [Clang][RISCV] Implement vloxseg and vluxseg.

2021-07-21 Thread Hsiangkai Wang 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 rG1c55033ea16f: [Clang][RISCV] Implement vloxseg and vluxseg. 
(authored by HsiangKai).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103809

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/test/CodeGen/RISCV/rvv-intrinsics/vloxseg.c

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


[PATCH] D103796: [Clang][RISCV] Implement vlsseg.

2021-07-21 Thread Hsiangkai Wang 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 rGa9de8f7a5391: [Clang][RISCV] Implement vlsseg. (authored by 
HsiangKai).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103796

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vlsseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vlsseg.c

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


[clang] 754eb1c - [OpenMP] Change `__kmpc_free_shared` to include the paired allocation size

2021-07-21 Thread via cfe-commits

Author: Joseph Huber
Date: 2021-07-21T20:56:21-04:00
New Revision: 754eb1c210d865234292df7a983636e2ff49e2c8

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

LOG: [OpenMP] Change `__kmpc_free_shared` to include the paired allocation size

This patch changes `__kmpc_free_shared` to take an additional argument
corresponding to the associated allocation's size. This makes it easier to
implement the allocator in the runtime.

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
clang/test/OpenMP/declare_target_codegen_globalization.cpp
clang/test/OpenMP/nvptx_data_sharing.cpp
clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
clang/test/OpenMP/nvptx_parallel_codegen.cpp
clang/test/OpenMP/nvptx_parallel_for_codegen.cpp
clang/test/OpenMP/nvptx_target_codegen.cpp
clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
clang/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp
clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp

clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
clang/test/OpenMP/nvptx_teams_codegen.cpp
clang/test/OpenMP/nvptx_teams_reduction_codegen.cpp
llvm/include/llvm/Analysis/TargetLibraryInfo.def
llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
llvm/lib/Analysis/MemoryBuiltins.cpp
llvm/lib/Analysis/TargetLibraryInfo.cpp
llvm/test/Transforms/OpenMP/remove_globalization.ll
llvm/test/Transforms/OpenMP/replace_globalization.ll
llvm/unittests/Analysis/TargetLibraryInfoTest.cpp
openmp/libomptarget/deviceRTLs/common/src/data_sharing.cu
openmp/libomptarget/deviceRTLs/interface.h

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
index 1ad1460be7112..63fecedc6fb77 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -1437,7 +1437,9 @@ void 
CGOpenMPRuntimeGPU::emitGenericVarsProlog(CodeGenFunction ,
 CGM.getModule(), OMPRTL___kmpc_alloc_shared),
 AllocArgs, VD->getName());
 
-I->getSecond().EscapedVariableLengthDeclsAddrs.emplace_back(VoidPtr);
+I->getSecond().EscapedVariableLengthDeclsAddrs.emplace_back(
+std::pair(
+{VoidPtr, CGF.getTypeSize(VD->getType())}));
 LValue Base = CGF.MakeAddrLValue(VoidPtr, VD->getType(),
  CGM.getContext().getDeclAlign(VD),
  AlignmentSource::Decl);
@@ -1456,19 +1458,22 @@ void 
CGOpenMPRuntimeGPU::emitGenericVarsEpilog(CodeGenFunction ,
   const auto I = FunctionGlobalizedDecls.find(CGF.CurFn);
   if (I != FunctionGlobalizedDecls.end()) {
 // Deallocate the memory for each globalized VLA object
-for (llvm::Value *Addr :
+for (auto AddrSizePair :
  llvm::reverse(I->getSecond().EscapedVariableLengthDeclsAddrs)) {
   CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction(
   CGM.getModule(), OMPRTL___kmpc_free_shared),
-  Addr);
+  {AddrSizePair.first, AddrSizePair.second});
 }
 // Deallocate the memory for each globalized value
 for (auto  : llvm::reverse(I->getSecond().LocalVarData)) {
+  const auto *VD = cast(Rec.first);
   I->getSecond().MappedParams->restore(CGF);
 
+  llvm::Value *FreeArgs[] = {Rec.second.GlobalizedVal,
+ CGF.getTypeSize(VD->getType())};
   CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction(
   CGM.getModule(), OMPRTL___kmpc_free_shared),
-  {Rec.second.GlobalizedVal});
+  FreeArgs);
 }
   }
 }

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.h 
b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
index 464af1294b46e..b5f1b843c46b8 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
@@ -423,7 +423,8 @@ class CGOpenMPRuntimeGPU : public CGOpenMPRuntime {
 llvm::Optional SecondaryLocalVarData = llvm::None;
 EscapedParamsTy EscapedParameters;
 llvm::SmallVector EscapedVariableLengthDecls;
-llvm::SmallVector EscapedVariableLengthDeclsAddrs;
+llvm::SmallVector, 4>
+EscapedVariableLengthDeclsAddrs;
 llvm::Value *IsInSPMDModeFlag = nullptr;
 std::unique_ptr MappedParams;
   };

diff  --git a/clang/test/OpenMP/declare_target_codegen_globalization.cpp 
b/clang/test/OpenMP/declare_target_codegen_globalization.cpp
index 

[PATCH] D106496: [OpenMP] Change `__kmpc_free_shared` to include the paired allocation size

2021-07-21 Thread Joseph Huber via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG754eb1c210d8: [OpenMP] Change `__kmpc_free_shared` to 
include the paired allocation size (authored by jhuber6).

Changed prior to commit:
  https://reviews.llvm.org/D106496?vs=360610=360664#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106496

Files:
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
  clang/test/OpenMP/declare_target_codegen_globalization.cpp
  clang/test/OpenMP/nvptx_data_sharing.cpp
  clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_target_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/nvptx_teams_codegen.cpp
  clang/test/OpenMP/nvptx_teams_reduction_codegen.cpp
  llvm/include/llvm/Analysis/TargetLibraryInfo.def
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Analysis/MemoryBuiltins.cpp
  llvm/lib/Analysis/TargetLibraryInfo.cpp
  llvm/test/Transforms/OpenMP/remove_globalization.ll
  llvm/test/Transforms/OpenMP/replace_globalization.ll
  llvm/unittests/Analysis/TargetLibraryInfoTest.cpp
  openmp/libomptarget/deviceRTLs/common/src/data_sharing.cu
  openmp/libomptarget/deviceRTLs/interface.h

Index: openmp/libomptarget/deviceRTLs/interface.h
===
--- openmp/libomptarget/deviceRTLs/interface.h
+++ openmp/libomptarget/deviceRTLs/interface.h
@@ -467,7 +467,8 @@
 
 /// Deallocate \p Ptr. Needs to be called balanced with __kmpc_alloc_shared like
 /// a stack (push/pop). Can be called by any thread. \p Ptr must be allocated by
-/// __kmpc_alloc_shared by the same thread.
-EXTERN void __kmpc_free_shared(void *Ptr);
+/// __kmpc_alloc_shared by the same thread. \p Bytes contains the size of the
+/// paired allocation to make memory management easier.
+EXTERN void __kmpc_free_shared(void *Ptr, size_t Bytes);
 
 #endif
Index: openmp/libomptarget/deviceRTLs/common/src/data_sharing.cu
===
--- openmp/libomptarget/deviceRTLs/common/src/data_sharing.cu
+++ openmp/libomptarget/deviceRTLs/common/src/data_sharing.cu
@@ -95,7 +95,7 @@
   return __kmpc_alloc_for_warp(AllocGlobal, Bytes, WarpBytes);
 }
 
-EXTERN void __kmpc_free_shared(void *Ptr) {
+EXTERN void __kmpc_free_shared(void *Ptr, size_t /* Bytes */) {
   __kmpc_impl_lanemask_t CurActive = __kmpc_impl_activemask();
   unsigned LeaderID = __kmpc_impl_ffs(CurActive) - 1;
   bool IsWarpLeader =
Index: llvm/unittests/Analysis/TargetLibraryInfoTest.cpp
===
--- llvm/unittests/Analysis/TargetLibraryInfoTest.cpp
+++ llvm/unittests/Analysis/TargetLibraryInfoTest.cpp
@@ -589,7 +589,7 @@
 
   // These functions are OpenMP Offloading allocation / free routines
   "declare i8* @__kmpc_alloc_shared(i64)\n"
-  "declare void @__kmpc_free_shared(i8*)\n"
+  "declare void @__kmpc_free_shared(i8*, i64)\n"
   );
 
   for (unsigned FI = 0; FI != LibFunc::NumLibFuncs; ++FI) {
Index: llvm/test/Transforms/OpenMP/replace_globalization.ll
===
--- llvm/test/Transforms/OpenMP/replace_globalization.ll
+++ llvm/test/Transforms/OpenMP/replace_globalization.ll
@@ -25,7 +25,7 @@
   %x_on_stack = bitcast i8* %x to i32*
   %0 = bitcast i32* %x_on_stack to i8*
   call void @use(i8* %0)
-  call void @__kmpc_free_shared(i8* %x)
+  call void @__kmpc_free_shared(i8* %x, i64 4)
   call void @__kmpc_target_deinit(%struct.ident_t* @1, i1 false, i1 true)
   ret void
 }
@@ -50,7 +50,7 @@
   %x_on_stack = bitcast i8* %x to [4 x i32]*
   %0 = bitcast [4 x i32]* %x_on_stack to i8*
   call void @use(i8* %0)
-  call void @__kmpc_free_shared(i8* %x)
+  call void @__kmpc_free_shared(i8* %x, i64 16)
   br label %exit
 exit:
   ret void
@@ -67,7 +67,7 @@
   %y_on_stack = bitcast i8* %y to [4 x i32]*
   %1 = bitcast [4 x i32]* %y_on_stack to i8*
   call void @use(i8* %1)
-  call void @__kmpc_free_shared(i8* %y)
+  call void @__kmpc_free_shared(i8* %y, i64 4)
   br label %exit
 exit:
   ret void
@@ -79,11 +79,11 @@
   %0 = icmp eq i32 %call, -1
   br i1 %0, label %master, label %exit
 master:
-  %y = call i8* @__kmpc_alloc_shared(i64 6), !dbg !12
+  %y = call i8* @__kmpc_alloc_shared(i64 24), !dbg !12
   %y_on_stack = bitcast i8* %y to [6 x i32]*
   %1 = bitcast [6 x i32]* %y_on_stack to i8*
   call void @use(i8* %1)
-  call void 

[PATCH] D105703: [hwasan] Use stack safety analysis.

2021-07-21 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka accepted this revision.
vitalybuka added inline comments.



Comment at: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp:409
+// analysis.
+// This is so we don't need to plumb TargetTriple all the way to here.
+if (mightUseStackSafetyAnalysis(DisableOptimization))

I think this function without comment is clear enough. But up to you.



Comment at: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp:410
+Dummy.setArch(Triple::aarch64);
+if (shouldUseStackSafetyAnalysis(Dummy, DisableOptimization))
+  AU.addRequired();

fmayer wrote:
> fmayer wrote:
> > vitalybuka wrote:
> > > Why not just:
> > > ```
> > > if (!DisableOptimization || ClUseStackSafety)
> > >   AU.addRequired();
> > > ```
> > Because `ClUseStackSafety` defaults to true, so this will be quite useless 
> > except if the user explicitly sets it to false. So then you end up 
> > duplicating the logic in `shouldUseStackSafetyAnalysis`, which is why I 
> > went for the Dummy (thinking about it, we don't actually need to setArch on 
> > it).
> How about this (mightUseStackSafetyAnalysis)? This seems like a nice tradeoff 
> without duplication of the logic.
LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105703

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


[PATCH] D105951: [clang] P2266 implicit moves STL workaround

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

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105951

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/SemaCXX/cxx2b-p2266-disable-with-msvc-compat.cpp

Index: clang/test/SemaCXX/cxx2b-p2266-disable-with-msvc-compat.cpp
===
--- clang/test/SemaCXX/cxx2b-p2266-disable-with-msvc-compat.cpp
+++ clang/test/SemaCXX/cxx2b-p2266-disable-with-msvc-compat.cpp
@@ -1,52 +1,153 @@
-// RUN: %clang_cc1 -std=c++2b -fsyntax-only -fcxx-exceptions-verify=new %s
-// RUN: %clang_cc1 -std=c++2b -fsyntax-only -fcxx-exceptions -fms-compatibility -verify=old %s
-// RUN: %clang_cc1 -std=c++20 -fsyntax-only -fcxx-exceptions-verify=old %s
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only-verify=cxx2b,new %s
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -fms-compatibility -verify=cxx2b,old %s
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only-verify=cxx20,old %s
 
 // FIXME: This is a test for a temporary workaround where we disable simpler implicit moves
-//when compiling with -fms-compatibility, because the MSVC STL does not compile.
-//A better workaround is under discussion.
-//The test cases here are just a copy from `CXX/class/class.init/class.copy.elision/p3.cpp`,
-//so feel free to delete this file when the workaround is not needed anymore.
-
-struct CopyOnly {
-  CopyOnly(); // new-note {{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
-  // new-note@-1 {{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
-  CopyOnly(CopyOnly &); // new-note {{candidate constructor not viable: expects an lvalue for 1st argument}}
-  // new-note@-1 {{candidate constructor not viable: expects an lvalue for 1st argument}}
-};
-struct MoveOnly {
-  MoveOnly();
-  MoveOnly(MoveOnly &&);
+//in the STL when compiling with -fms-compatibility, because of issues with the
+//implementation there.
+//Feel free to delete this file when the workaround is not needed anymore.
+
+#if __INCLUDE_LEVEL__ == 0
+
+#if __cpluscplus > 202002L && __cpp_implicit_move < 202011L
+#error "__cpp_implicit_move not defined correctly"
+#endif
+
+struct nocopy {
+  nocopy(nocopy &&);
 };
-MoveOnly &();
-
-MoveOnly &(MoveOnly &) {
-  return w; // old-error {{cannot bind to lvalue of type}}
-}
-
-CopyOnly test2(bool b) {
-  static CopyOnly w1;
-  CopyOnly w2;
-  if (b) {
-return w1;
-  } else {
-return w2; // new-error {{no matching constructor for initialization}}
-  }
-}
-
-template  T &(T &) { return x; } // old-error {{cannot bind to lvalue of type}}
-template MoveOnly (MoveOnly &);
-template MoveOnly &(MoveOnly &&); // old-note {{in instantiation of function template specialization}}
-
-MoveOnly &() {
-  MoveOnly & = rref();
-  return x; // old-error {{cannot bind to lvalue of type}}
-}
-
-void test5() try {
-  CopyOnly x;
-  throw x; // new-error {{no matching constructor for initialization}}
-} catch (...) {
-}
-
-MoveOnly test6(MoveOnly x) { return x; }
+
+int &(int &) { return x; } // cxx20-error {{cannot bind to lvalue}}
+int (int &) { return x; }  // cxx2b-error {{cannot bind to a temporary}}
+nocopy mt3(nocopy x) { return x; }
+
+namespace {
+int &(int &) { return x; } // cxx20-error {{cannot bind to lvalue}}
+int (int &) { return x; }  // cxx2b-error {{cannot bind to a temporary}}
+nocopy mt3(nocopy x) { return x; }
+} // namespace
+
+namespace foo {
+int &(int &) { return x; } // cxx20-error {{cannot bind to lvalue}}
+int (int &) { return x; }  // cxx2b-error {{cannot bind to a temporary}}
+namespace std {
+int &(int &) { return x; } // cxx20-error {{cannot bind to lvalue}}
+int (int &) { return x; }  // cxx2b-error {{cannot bind to a temporary}}
+nocopy mt3(nocopy x) { return x; }
+} // namespace std
+} // namespace foo
+
+namespace std {
+
+int &(int &) { return x; } // cxx20-error {{cannot bind to lvalue}}
+int (int &) { return x; }  // cxx2b-error {{cannot bind to a temporary}}
+nocopy mt3(nocopy x) { return x; }
+
+namespace {
+int &(int &) { return x; } // cxx20-error {{cannot bind to lvalue}}
+int (int &) { return x; }  // cxx2b-error {{cannot bind to a temporary}}
+nocopy mt3(nocopy x) { return x; }
+} // namespace
+
+namespace foo {
+int &(int &) { return x; } // cxx20-error {{cannot bind to lvalue}}
+int (int &) { return x; }  // cxx2b-error {{cannot bind to a temporary}}
+nocopy mt3(nocopy x) { return x; }
+} // namespace foo
+
+} // namespace std
+
+#include __FILE__
+
+#define SYSTEM
+#include __FILE__
+
+#elif !defined(SYSTEM)
+
+int &(int &) { return x; } // cxx20-error {{cannot bind to lvalue}}
+int (int &) { return x; }  // 

[PATCH] D105092: [PoC][RISCV] Add the tail policy argument to builtins/intrinsics.

2021-07-21 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td:25
 
+defvar TAIL_AGNOSTIC = 0;
+defvar TAIL_UNDISTURBED = 1;

Why are these the opposite polarity of what's in C?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105092

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


[clang-tools-extra] a46c63c - Fix assigned-but-unused (except in an assert) warning with a void cast

2021-07-21 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-07-21T17:12:22-07:00
New Revision: a46c63c878a9e82ac2646926bb3d8237293ad15d

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

LOG: Fix assigned-but-unused (except in an assert) warning with a void cast

Added: 


Modified: 
clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp
index 9e3f0883ccd9a..f58cc06987fe8 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp
@@ -192,6 +192,7 @@ void OwningMemoryCheck::check(const 
MatchFinder::MatchResult ) {
   CheckExecuted |= handleReturnValues(Nodes);
   CheckExecuted |= handleOwnerMembers(Nodes);
 
+  (void)CheckExecuted;
   assert(CheckExecuted &&
  "None of the subroutines executed, logic error in matcher!");
 }



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


[PATCH] D105527: libclang.so: Make SONAME independent from LLVM version

2021-07-21 Thread Tom Stellard via Phabricator via cfe-commits
tstellar updated this revision to Diff 360656.
tstellar added a comment.

Add missing file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105527

Files:
  clang/test/CMakeLists.txt
  clang/test/LibClang/lit.local.cfg
  clang/test/LibClang/symbols.test
  clang/test/lit.site.cfg.py.in
  clang/tools/libclang/CMakeLists.txt
  clang/tools/libclang/CXString.cpp
  clang/tools/libclang/libclang.exports
  clang/tools/libclang/libclang.map
  clang/tools/libclang/linker-script-to-export-list.py

Index: clang/tools/libclang/linker-script-to-export-list.py
===
--- /dev/null
+++ clang/tools/libclang/linker-script-to-export-list.py
@@ -0,0 +1,10 @@
+import re
+import os
+
+input_file = open(sys.argv[1])
+output_file = open(sys.argv[2])
+
+for line in input_file:
+m = re.search('clang_[^;]+', line)
+if m:
+output_file.write(m.group(0))
Index: clang/tools/libclang/libclang.map
===
--- /dev/null
+++ clang/tools/libclang/libclang.map
@@ -0,0 +1,414 @@
+/* If you add a symbol to this file, make sure to add it with the correct
+ * version.  For example, if the LLVM main branch is LLVM 14.0.0, add new
+ * symbols with the version LLVM_14.
+ * On platforms where versions scripts are not used, this file will be used to
+ * generate a list of exports for libclang.so
+ */
+
+
+LLVM_13 {
+  global:
+clang_BlockCommandComment_getArgText;
+clang_BlockCommandComment_getCommandName;
+clang_BlockCommandComment_getNumArgs;
+clang_BlockCommandComment_getParagraph;
+clang_CXCursorSet_contains;
+clang_CXCursorSet_insert;
+clang_CXIndex_getGlobalOptions;
+clang_CXIndex_setGlobalOptions;
+clang_CXIndex_setInvocationEmissionPathOption;
+clang_CXRewriter_create;
+clang_CXRewriter_dispose;
+clang_CXRewriter_insertTextBefore;
+clang_CXRewriter_overwriteChangedFiles;
+clang_CXRewriter_removeText;
+clang_CXRewriter_replaceText;
+clang_CXRewriter_writeMainFileToStdOut;
+clang_CXXConstructor_isConvertingConstructor;
+clang_CXXConstructor_isCopyConstructor;
+clang_CXXConstructor_isDefaultConstructor;
+clang_CXXConstructor_isMoveConstructor;
+clang_CXXField_isMutable;
+clang_CXXMethod_isConst;
+clang_CXXMethod_isDefaulted;
+clang_CXXMethod_isPureVirtual;
+clang_CXXMethod_isStatic;
+clang_CXXMethod_isVirtual;
+clang_CXXRecord_isAbstract;
+clang_Comment_getChild;
+clang_Comment_getKind;
+clang_Comment_getNumChildren;
+clang_Comment_isWhitespace;
+clang_CompilationDatabase_dispose;
+clang_CompilationDatabase_fromDirectory;
+clang_CompilationDatabase_getAllCompileCommands;
+clang_CompilationDatabase_getCompileCommands;
+clang_CompileCommand_getArg;
+clang_CompileCommand_getDirectory;
+clang_CompileCommand_getFilename;
+clang_CompileCommand_getMappedSourceContent;
+clang_CompileCommand_getMappedSourcePath;
+clang_CompileCommand_getNumArgs;
+clang_CompileCommands_dispose;
+clang_CompileCommands_getCommand;
+clang_CompileCommands_getSize;
+clang_Cursor_Evaluate;
+clang_Cursor_getArgument;
+clang_Cursor_getBriefCommentText;
+clang_Cursor_getCXXManglings;
+clang_Cursor_getCommentRange;
+clang_Cursor_getMangling;
+clang_Cursor_getModule;
+clang_Cursor_getNumArguments;
+clang_Cursor_getNumTemplateArguments;
+clang_Cursor_getObjCDeclQualifiers;
+clang_Cursor_getObjCManglings;
+clang_Cursor_getObjCPropertyAttributes;
+clang_Cursor_getObjCPropertyGetterName;
+clang_Cursor_getObjCPropertySetterName;
+clang_Cursor_getObjCSelectorIndex;
+clang_Cursor_getOffsetOfField;
+clang_Cursor_getParsedComment;
+clang_Cursor_getRawCommentText;
+clang_Cursor_getReceiverType;
+clang_Cursor_getSpellingNameRange;
+clang_Cursor_getStorageClass;
+clang_Cursor_getTemplateArgumentKind;
+clang_Cursor_getTemplateArgumentType;
+clang_Cursor_getTemplateArgumentUnsignedValue;
+clang_Cursor_getTemplateArgumentValue;
+clang_Cursor_getTranslationUnit;
+clang_Cursor_getVarDeclInitializer;
+clang_Cursor_hasAttrs;
+clang_Cursor_hasVarDeclExternalStorage;
+clang_Cursor_hasVarDeclGlobalStorage;
+clang_Cursor_isAnonymous;
+clang_Cursor_isAnonymousRecordDecl;
+clang_Cursor_isBitField;
+clang_Cursor_isDynamicCall;
+clang_Cursor_isExternalSymbol;
+clang_Cursor_isFunctionInlined;
+clang_Cursor_isInlineNamespace;
+clang_Cursor_isMacroBuiltin;
+clang_Cursor_isMacroFunctionLike;
+clang_Cursor_isNull;
+clang_Cursor_isObjCOptional;
+clang_Cursor_isVariadic;
+clang_EnumDecl_isScoped;
+clang_EvalResult_dispose;
+clang_EvalResult_getAsDouble;
+clang_EvalResult_getAsInt;
+clang_EvalResult_getAsLongLong;
+

[PATCH] D105527: libclang.so: Make SONAME independent from LLVM version

2021-07-21 Thread Tom Stellard via Phabricator via cfe-commits
tstellar updated this revision to Diff 360654.
tstellar added a comment.

Added a test case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105527

Files:
  clang/test/CMakeLists.txt
  clang/test/LibClang/lit.local.cfg
  clang/test/lit.site.cfg.py.in
  clang/tools/libclang/CMakeLists.txt
  clang/tools/libclang/CXString.cpp
  clang/tools/libclang/libclang.exports
  clang/tools/libclang/libclang.map
  clang/tools/libclang/linker-script-to-export-list.py

Index: clang/tools/libclang/linker-script-to-export-list.py
===
--- /dev/null
+++ clang/tools/libclang/linker-script-to-export-list.py
@@ -0,0 +1,10 @@
+import re
+import os
+
+input_file = open(sys.argv[1])
+output_file = open(sys.argv[2])
+
+for line in input_file:
+m = re.search('clang_[^;]+', line)
+if m:
+output_file.write(m.group(0))
Index: clang/tools/libclang/libclang.map
===
--- /dev/null
+++ clang/tools/libclang/libclang.map
@@ -0,0 +1,414 @@
+/* If you add a symbol to this file, make sure to add it with the correct
+ * version.  For example, if the LLVM main branch is LLVM 14.0.0, add new
+ * symbols with the version LLVM_14.
+ * On platforms where versions scripts are not used, this file will be used to
+ * generate a list of exports for libclang.so
+ */
+
+
+LLVM_13 {
+  global:
+clang_BlockCommandComment_getArgText;
+clang_BlockCommandComment_getCommandName;
+clang_BlockCommandComment_getNumArgs;
+clang_BlockCommandComment_getParagraph;
+clang_CXCursorSet_contains;
+clang_CXCursorSet_insert;
+clang_CXIndex_getGlobalOptions;
+clang_CXIndex_setGlobalOptions;
+clang_CXIndex_setInvocationEmissionPathOption;
+clang_CXRewriter_create;
+clang_CXRewriter_dispose;
+clang_CXRewriter_insertTextBefore;
+clang_CXRewriter_overwriteChangedFiles;
+clang_CXRewriter_removeText;
+clang_CXRewriter_replaceText;
+clang_CXRewriter_writeMainFileToStdOut;
+clang_CXXConstructor_isConvertingConstructor;
+clang_CXXConstructor_isCopyConstructor;
+clang_CXXConstructor_isDefaultConstructor;
+clang_CXXConstructor_isMoveConstructor;
+clang_CXXField_isMutable;
+clang_CXXMethod_isConst;
+clang_CXXMethod_isDefaulted;
+clang_CXXMethod_isPureVirtual;
+clang_CXXMethod_isStatic;
+clang_CXXMethod_isVirtual;
+clang_CXXRecord_isAbstract;
+clang_Comment_getChild;
+clang_Comment_getKind;
+clang_Comment_getNumChildren;
+clang_Comment_isWhitespace;
+clang_CompilationDatabase_dispose;
+clang_CompilationDatabase_fromDirectory;
+clang_CompilationDatabase_getAllCompileCommands;
+clang_CompilationDatabase_getCompileCommands;
+clang_CompileCommand_getArg;
+clang_CompileCommand_getDirectory;
+clang_CompileCommand_getFilename;
+clang_CompileCommand_getMappedSourceContent;
+clang_CompileCommand_getMappedSourcePath;
+clang_CompileCommand_getNumArgs;
+clang_CompileCommands_dispose;
+clang_CompileCommands_getCommand;
+clang_CompileCommands_getSize;
+clang_Cursor_Evaluate;
+clang_Cursor_getArgument;
+clang_Cursor_getBriefCommentText;
+clang_Cursor_getCXXManglings;
+clang_Cursor_getCommentRange;
+clang_Cursor_getMangling;
+clang_Cursor_getModule;
+clang_Cursor_getNumArguments;
+clang_Cursor_getNumTemplateArguments;
+clang_Cursor_getObjCDeclQualifiers;
+clang_Cursor_getObjCManglings;
+clang_Cursor_getObjCPropertyAttributes;
+clang_Cursor_getObjCPropertyGetterName;
+clang_Cursor_getObjCPropertySetterName;
+clang_Cursor_getObjCSelectorIndex;
+clang_Cursor_getOffsetOfField;
+clang_Cursor_getParsedComment;
+clang_Cursor_getRawCommentText;
+clang_Cursor_getReceiverType;
+clang_Cursor_getSpellingNameRange;
+clang_Cursor_getStorageClass;
+clang_Cursor_getTemplateArgumentKind;
+clang_Cursor_getTemplateArgumentType;
+clang_Cursor_getTemplateArgumentUnsignedValue;
+clang_Cursor_getTemplateArgumentValue;
+clang_Cursor_getTranslationUnit;
+clang_Cursor_getVarDeclInitializer;
+clang_Cursor_hasAttrs;
+clang_Cursor_hasVarDeclExternalStorage;
+clang_Cursor_hasVarDeclGlobalStorage;
+clang_Cursor_isAnonymous;
+clang_Cursor_isAnonymousRecordDecl;
+clang_Cursor_isBitField;
+clang_Cursor_isDynamicCall;
+clang_Cursor_isExternalSymbol;
+clang_Cursor_isFunctionInlined;
+clang_Cursor_isInlineNamespace;
+clang_Cursor_isMacroBuiltin;
+clang_Cursor_isMacroFunctionLike;
+clang_Cursor_isNull;
+clang_Cursor_isObjCOptional;
+clang_Cursor_isVariadic;
+clang_EnumDecl_isScoped;
+clang_EvalResult_dispose;
+clang_EvalResult_getAsDouble;
+clang_EvalResult_getAsInt;
+clang_EvalResult_getAsLongLong;
+clang_EvalResult_getAsStr;
+

[PATCH] D98710: [clang-tidy] New feature --skip-headers, part 1, setTraversalScope

2021-07-21 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh updated this revision to Diff 360651.
chh edited the summary of this revision.
chh added a comment.

Add one more skip-headers-2.cpp test, which shows desired check at a top-level 
Decl but not at nested Decl. Checking locations of only top-level Decls will 
miss the opportunity to skip nested Decls.


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

https://reviews.llvm.org/D98710

Files:
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/bugprone-forward-declaration-namespace/a.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/bugprone-forward-declaration-namespace/b.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/skip-headers/a.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/skip-headers/b.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/skip-headers/my_header1.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/skip-headers/my_header2.h
  clang-tools-extra/test/clang-tidy/checkers/abseil-no-internal-dependencies.cpp
  
clang-tools-extra/test/clang-tidy/checkers/abseil-upgrade-duration-conversions.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-forward-declaration-namespace-header.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-forward-declaration-namespace.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-interfaces-global-init.cpp
  clang-tools-extra/test/clang-tidy/checkers/google-namespaces.cpp
  clang-tools-extra/test/clang-tidy/checkers/google-objc-function-naming.m
  clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
  
clang-tools-extra/test/clang-tidy/checkers/llvm-prefer-register-over-unsigned.cpp
  
clang-tools-extra/test/clang-tidy/checkers/llvmlibc-implementation-in-namespace.cpp
  
clang-tools-extra/test/clang-tidy/checkers/llvmlibc-restrict-system-libc-headers.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc-no-recursion.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-cxx03.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-cxx11.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-pass-by-value-header.cpp
  
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-allow.cpp
  
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-disallow.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr-chained-conditional-assignment.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr-chained-conditional-return.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr-members.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr.cpp
  clang-tools-extra/test/clang-tidy/checkers/skip-headers-2.cpp
  clang-tools-extra/test/clang-tidy/checkers/skip-headers.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/file-filter-symlinks.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/file-filter.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/line-filter.cpp
  clang/include/clang/Frontend/MultiplexConsumer.h

Index: clang/include/clang/Frontend/MultiplexConsumer.h
===
--- clang/include/clang/Frontend/MultiplexConsumer.h
+++ clang/include/clang/Frontend/MultiplexConsumer.h
@@ -77,8 +77,9 @@
   void InitializeSema(Sema ) override;
   void ForgetSema() override;
 
-private:
+protected:
   std::vector> Consumers; // Owns these.
+private:
   std::unique_ptr MutationListener;
   std::unique_ptr DeserializationListener;
 };
Index: clang-tools-extra/test/clang-tidy/infrastructure/line-filter.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/line-filter.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/line-filter.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-tidy -checks='-*,google-explicit-constructor' -line-filter='[{"name":"line-filter.cpp","lines":[[18,18],[22,22]]},{"name":"header1.h","lines":[[1,2]]},{"name":"header2.h"},{"name":"header3.h"}]' -header-filter='header[12]\.h$' %s -- -I %S/Inputs/line-filter 2>&1 | FileCheck %s
+// RUN: clang-tidy --skip-headers=0 -checks='-*,google-explicit-constructor' -line-filter='[{"name":"line-filter.cpp","lines":[[18,18],[22,22]]},{"name":"header1.h","lines":[[1,2]]},{"name":"header2.h"},{"name":"header3.h"}]' -header-filter='header[12]\.h$' %s -- -I %S/Inputs/line-filter 2>&1 | FileCheck %s
 
 #include "header1.h"
 // CHECK-NOT: header1.h:{{.*}} warning
Index: 

[PATCH] D98709: [clang-tidy] New feature --skip-headers, part 1, skip Decls

2021-07-21 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh updated this revision to Diff 360649.
chh edited the summary of this revision.
chh added a comment.

Add one more skip-headers-2.cpp test.


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

https://reviews.llvm.org/D98709

Files:
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/bugprone-forward-declaration-namespace/a.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/bugprone-forward-declaration-namespace/b.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/skip-headers/a.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/skip-headers/b.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/skip-headers/my_header1.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/skip-headers/my_header2.h
  clang-tools-extra/test/clang-tidy/checkers/abseil-no-internal-dependencies.cpp
  
clang-tools-extra/test/clang-tidy/checkers/abseil-upgrade-duration-conversions.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-forward-declaration-namespace-header.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-forward-declaration-namespace.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-interfaces-global-init.cpp
  clang-tools-extra/test/clang-tidy/checkers/google-namespaces.cpp
  clang-tools-extra/test/clang-tidy/checkers/google-objc-function-naming.m
  clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
  
clang-tools-extra/test/clang-tidy/checkers/llvm-prefer-register-over-unsigned.cpp
  
clang-tools-extra/test/clang-tidy/checkers/llvmlibc-implementation-in-namespace.cpp
  
clang-tools-extra/test/clang-tidy/checkers/llvmlibc-restrict-system-libc-headers.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc-no-recursion.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-cxx03.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-cxx11.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-pass-by-value-header.cpp
  
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-allow.cpp
  
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-disallow.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr-chained-conditional-assignment.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr-chained-conditional-return.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr-members.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr.cpp
  clang-tools-extra/test/clang-tidy/checkers/skip-headers-2.cpp
  clang-tools-extra/test/clang-tidy/checkers/skip-headers.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/file-filter-symlinks.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/file-filter.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/line-filter.cpp
  clang/include/clang/ASTMatchers/ASTMatchFinder.h
  clang/lib/ASTMatchers/ASTMatchFinder.cpp

Index: clang/lib/ASTMatchers/ASTMatchFinder.cpp
===
--- clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -1202,6 +1202,8 @@
   if (!DeclNode) {
 return true;
   }
+  if (Options.Filter && Options.Filter->skipDecl(DeclNode))
+return true;
 
   bool ScopedTraversal =
   TraversingASTNodeNotSpelledInSource || DeclNode->isImplicit();
@@ -1454,5 +1456,8 @@
   return llvm::None;
 }
 
+// Out of line key method.
+MatchFinder::MatchFinderOptions::DeclFilter::~DeclFilter() = default;
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: clang/include/clang/ASTMatchers/ASTMatchFinder.h
===
--- clang/include/clang/ASTMatchers/ASTMatchFinder.h
+++ clang/include/clang/ASTMatchers/ASTMatchFinder.h
@@ -133,11 +133,19 @@
   /// Per bucket timing information.
   llvm::StringMap 
 };
+struct DeclFilter {
+  virtual bool skipDecl(const Decl *) = 0;
+  virtual bool skipLocation(SourceLocation) = 0;
+  virtual ~DeclFilter();
+};
 
 /// Enables per-check timers.
 ///
 /// It prints a report after match.
 llvm::Optional CheckProfiling;
+
+/// Check if a Decl should be skipped.
+std::shared_ptr Filter;
   };
 
   MatchFinder(MatchFinderOptions Options = MatchFinderOptions());
Index: clang-tools-extra/test/clang-tidy/infrastructure/line-filter.cpp
===
--- 

[PATCH] D105320: [CodeView] Saturate values bigger than supported by APInt.

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

.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105320

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-codeview-int128.cpp
  llvm/include/llvm/IR/DIBuilder.h
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h
  llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp
  llvm/lib/IR/DIBuilder.cpp

Index: llvm/lib/IR/DIBuilder.cpp
===
--- llvm/lib/IR/DIBuilder.cpp
+++ llvm/lib/IR/DIBuilder.cpp
@@ -243,7 +243,7 @@
   return MF;
 }
 
-DIEnumerator *DIBuilder::createEnumerator(StringRef Name, int64_t Val,
+DIEnumerator *DIBuilder::createEnumerator(StringRef Name, uint64_t Val,
   bool IsUnsigned) {
   assert(!Name.empty() && "Unable to create enumerator without name");
   return DIEnumerator::get(VMContext, APInt(64, Val, !IsUnsigned), IsUnsigned,
Index: llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp
===
--- llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp
+++ llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp
@@ -188,14 +188,21 @@
 
 Error CodeViewRecordIO::mapEncodedInteger(APSInt , const Twine ) {
   if (isStreaming()) {
+// FIXME: We also need to handle big values here, but it's
+//not clear how we can excercise this code path yet.
 if (Value.isSigned())
   emitEncodedSignedInteger(Value.getSExtValue(), Comment);
 else
   emitEncodedUnsignedInteger(Value.getZExtValue(), Comment);
   } else if (isWriting()) {
-if (Value.isSigned())
-  return writeEncodedSignedInteger(Value.getSExtValue());
-return writeEncodedUnsignedInteger(Value.getZExtValue());
+if (Value.isSigned()) {
+  int64_t Val =
+  Value.getNumWords() <= 1U ? Value.getSExtValue() : INT64_MIN;
+  return writeEncodedSignedInteger(Val);
+}
+uint64_t Val =
+Value.getNumWords() <= 1U ? Value.getZExtValue() : UINT64_MAX;
+return writeEncodedUnsignedInteger(Val);
   } else
 return consume(*Reader, Value);
   return Error::success();
@@ -273,6 +280,7 @@
 
 void CodeViewRecordIO::emitEncodedSignedInteger(const int64_t ,
 const Twine ) {
+  // FIXME: There are no test cases covering this function.
   if (Value >= std::numeric_limits::min()) {
 Streamer->emitIntValue(LF_CHAR, 2);
 emitComment(Comment);
@@ -291,8 +299,8 @@
   } else {
 Streamer->emitIntValue(LF_QUADWORD, 2);
 emitComment(Comment);
-Streamer->emitIntValue(Value, 4);
-incrStreamedLen(6);
+Streamer->emitIntValue(Value, 4); // FIXME: Why not 8 (size of quadword)?
+incrStreamedLen(6);   // FIXME: Why not 10 (8 + 2)?
   }
 }
 
@@ -313,10 +321,11 @@
 Streamer->emitIntValue(Value, 4);
 incrStreamedLen(6);
   } else {
+// FIXME: There are no test cases covering this block.
 Streamer->emitIntValue(LF_UQUADWORD, 2);
 emitComment(Comment);
 Streamer->emitIntValue(Value, 8);
-incrStreamedLen(6);
+incrStreamedLen(6); // FIXME: Why not 10 (8 + 2)?
   }
 }
 
Index: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h
===
--- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h
+++ llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h
@@ -315,6 +315,8 @@
   void collectDebugInfoForGlobals();
   void emitDebugInfoForGlobals();
   void emitGlobalVariableList(ArrayRef Globals);
+  void emitConstantSymbolRecord(const DIType *DTy, APSInt ,
+const std::string );
   void emitDebugInfoForGlobal(const CVGlobalVariable );
   void emitStaticConstMemberList();
 
Index: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -3157,6 +3157,28 @@
   }
 }
 
+void CodeViewDebug::emitConstantSymbolRecord(const DIType *DTy, APSInt ,
+ const std::string ) {
+  MCSymbol *SConstantEnd = beginSymbolRecord(SymbolKind::S_CONSTANT);
+  OS.AddComment("Type");
+  OS.emitInt32(getTypeIndex(DTy).getIndex());
+
+  // TODO: Need to support bigger ints like __int128.
+  OS.AddComment("Value");
+
+  // Encoded integers shouldn't need more than 10 bytes.
+  uint8_t Data[10];
+  BinaryStreamWriter Writer(Data, llvm::support::endianness::little);
+  CodeViewRecordIO IO(Writer);
+  cantFail(IO.mapEncodedInteger(Value));
+  StringRef SRef((char *)Data, Writer.getOffset());
+  OS.emitBinaryData(SRef);
+
+  OS.AddComment("Name");
+  emitNullTerminatedSymbolName(OS, QualifiedName);
+  endSymbolRecord(SConstantEnd);
+}
+
 void CodeViewDebug::emitStaticConstMemberList() {
   for (const 

[PATCH] D100810: Use `GNUInstallDirs` to support custom installation dirs. -- LLVM

2021-07-21 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 updated this revision to Diff 360647.
Ericson2314 added a comment.

rebase, fixing conflicts


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100810

Files:
  clang/tools/scan-build/CMakeLists.txt
  libclc/CMakeLists.txt
  lldb/cmake/modules/FindLibEdit.cmake
  llvm/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/AddSphinxTarget.cmake
  llvm/cmake/modules/CMakeLists.txt
  llvm/cmake/modules/LLVMInstallSymlink.cmake
  llvm/docs/CMake.rst
  llvm/examples/Bye/CMakeLists.txt
  llvm/include/llvm/CMakeLists.txt
  llvm/tools/llvm-config/BuildVariables.inc.in
  llvm/tools/llvm-config/llvm-config.cpp
  llvm/tools/lto/CMakeLists.txt
  llvm/tools/opt-viewer/CMakeLists.txt
  llvm/tools/remarks-shlib/CMakeLists.txt
  openmp/runtime/src/CMakeLists.txt

Index: openmp/runtime/src/CMakeLists.txt
===
--- openmp/runtime/src/CMakeLists.txt
+++ openmp/runtime/src/CMakeLists.txt
@@ -323,7 +323,7 @@
 install(CODE "execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E copy \"${LIBOMP_LIB_FILE}\"
   \"${alias}${LIBOMP_LIBRARY_SUFFIX}\" WORKING_DIRECTORY \${CMAKE_INSTALL_PREFIX}/bin)")
 install(CODE "execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E copy \"${LIBOMP_IMP_LIB_FILE}\"
-  \"${alias}${CMAKE_STATIC_LIBRARY_SUFFIX}\" WORKING_DIRECTORY \${CMAKE_INSTALL_PREFIX}/${OPENMP_INSTALL_LIBDIR})")
+  \"${alias}${CMAKE_STATIC_LIBRARY_SUFFIX}\" WORKING_DIRECTORY \"\${CMAKE_INSTALL_PREFIX}/${OPENMP_INSTALL_LIBDIR}\")")
   endforeach()
 else()
 
@@ -335,7 +335,7 @@
 foreach(alias IN LISTS LIBOMP_ALIASES)
   install(CODE "execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E create_symlink \"${LIBOMP_LIB_FILE}\"
 \"${alias}${LIBOMP_LIBRARY_SUFFIX}\" WORKING_DIRECTORY
-\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${OPENMP_INSTALL_LIBDIR})")
+\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${OPENMP_INSTALL_LIBDIR}\")")
 endforeach()
   endif()
 endif()
Index: llvm/tools/remarks-shlib/CMakeLists.txt
===
--- llvm/tools/remarks-shlib/CMakeLists.txt
+++ llvm/tools/remarks-shlib/CMakeLists.txt
@@ -19,7 +19,7 @@
   endif()
   
   install(FILES ${LLVM_MAIN_INCLUDE_DIR}/llvm-c/Remarks.h
-DESTINATION include/llvm-c
+DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/llvm-c"
 COMPONENT Remarks)
 
   if (APPLE)
Index: llvm/tools/opt-viewer/CMakeLists.txt
===
--- llvm/tools/opt-viewer/CMakeLists.txt
+++ llvm/tools/opt-viewer/CMakeLists.txt
@@ -8,7 +8,7 @@
 
 foreach (file ${files})
   install(PROGRAMS ${file}
-DESTINATION share/opt-viewer
+DESTINATION "${CMAKE_INSTALL_DATADIR}/opt-viewer"
 COMPONENT opt-viewer)
 endforeach (file)
 
Index: llvm/tools/lto/CMakeLists.txt
===
--- llvm/tools/lto/CMakeLists.txt
+++ llvm/tools/lto/CMakeLists.txt
@@ -33,7 +33,7 @@
 ${SOURCES} DEPENDS intrinsics_gen)
 
 install(FILES ${LLVM_MAIN_INCLUDE_DIR}/llvm-c/lto.h
-  DESTINATION include/llvm-c
+  DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/llvm-c"
   COMPONENT LTO)
 
 if (APPLE)
Index: llvm/tools/llvm-config/llvm-config.cpp
===
--- llvm/tools/llvm-config/llvm-config.cpp
+++ llvm/tools/llvm-config/llvm-config.cpp
@@ -357,10 +357,16 @@
 ("-I" + ActiveIncludeDir + " " + "-I" + ActiveObjRoot + "/include");
   } else {
 ActivePrefix = CurrentExecPrefix;
-ActiveIncludeDir = ActivePrefix + "/include";
-SmallString<256> path(StringRef(LLVM_TOOLS_INSTALL_DIR));
-sys::fs::make_absolute(ActivePrefix, path);
-ActiveBinDir = std::string(path.str());
+{
+  SmallString<256> Path(StringRef(LLVM_INSTALL_INCLUDEDIR));
+  sys::fs::make_absolute(ActivePrefix, Path);
+  ActiveIncludeDir = std::string(Path.str());
+}
+{
+  SmallString<256> Path(StringRef(LLVM_INSTALL_BINDIR));
+  sys::fs::make_absolute(ActivePrefix, Path);
+  ActiveBinDir = std::string(Path.str());
+}
 ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX;
 ActiveCMakeDir = ActiveLibDir + "/cmake/llvm";
 ActiveIncludeOption = "-I" + ActiveIncludeDir;
Index: llvm/tools/llvm-config/BuildVariables.inc.in
===
--- llvm/tools/llvm-config/BuildVariables.inc.in
+++ llvm/tools/llvm-config/BuildVariables.inc.in
@@ -23,6 +23,8 @@
 #define LLVM_CXXFLAGS "@LLVM_CXXFLAGS@"
 #define LLVM_BUILDMODE "@LLVM_BUILDMODE@"
 #define LLVM_LIBDIR_SUFFIX "@LLVM_LIBDIR_SUFFIX@"
+#define LLVM_INSTALL_BINDIR "@CMAKE_INSTALL_BINDIR@"
+#define LLVM_INSTALL_INCLUDEDIR "@CMAKE_INSTALL_INCLUDEDIR@"
 #define LLVM_TARGETS_BUILT "@LLVM_TARGETS_BUILT@"
 #define LLVM_SYSTEM_LIBS "@LLVM_SYSTEM_LIBS@"
 #define LLVM_BUILD_SYSTEM 

[PATCH] D100810: Use `GNUInstallDirs` to support custom installation dirs. -- LLVM

2021-07-21 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 updated this revision to Diff 360646.
Ericson2314 added a comment.

Rebase, fixing conflicts


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100810

Files:
  clang/tools/scan-build/CMakeLists.txt
  libclc/CMakeLists.txt
  lldb/cmake/modules/FindLibEdit.cmake
  llvm/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/AddSphinxTarget.cmake
  llvm/cmake/modules/CMakeLists.txt
  llvm/cmake/modules/LLVMInstallSymlink.cmake
  llvm/docs/CMake.rst
  llvm/examples/Bye/CMakeLists.txt
  llvm/include/llvm/CMakeLists.txt
  llvm/tools/llvm-config/BuildVariables.inc.in
  llvm/tools/llvm-config/llvm-config.cpp
  llvm/tools/lto/CMakeLists.txt
  llvm/tools/opt-viewer/CMakeLists.txt
  llvm/tools/remarks-shlib/CMakeLists.txt
  openmp/runtime/src/CMakeLists.txt

Index: openmp/runtime/src/CMakeLists.txt
===
--- openmp/runtime/src/CMakeLists.txt
+++ openmp/runtime/src/CMakeLists.txt
@@ -323,7 +323,7 @@
 install(CODE "execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E copy \"${LIBOMP_LIB_FILE}\"
   \"${alias}${LIBOMP_LIBRARY_SUFFIX}\" WORKING_DIRECTORY \${CMAKE_INSTALL_PREFIX}/bin)")
 install(CODE "execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E copy \"${LIBOMP_IMP_LIB_FILE}\"
-  \"${alias}${CMAKE_STATIC_LIBRARY_SUFFIX}\" WORKING_DIRECTORY \${CMAKE_INSTALL_PREFIX}/${OPENMP_INSTALL_LIBDIR})")
+  \"${alias}${CMAKE_STATIC_LIBRARY_SUFFIX}\" WORKING_DIRECTORY \"\${CMAKE_INSTALL_PREFIX}/${OPENMP_INSTALL_LIBDIR}\")")
   endforeach()
 else()
 
@@ -335,7 +335,7 @@
 foreach(alias IN LISTS LIBOMP_ALIASES)
   install(CODE "execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E create_symlink \"${LIBOMP_LIB_FILE}\"
 \"${alias}${LIBOMP_LIBRARY_SUFFIX}\" WORKING_DIRECTORY
-\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${OPENMP_INSTALL_LIBDIR})")
+\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${OPENMP_INSTALL_LIBDIR}\")")
 endforeach()
   endif()
 endif()
Index: llvm/tools/remarks-shlib/CMakeLists.txt
===
--- llvm/tools/remarks-shlib/CMakeLists.txt
+++ llvm/tools/remarks-shlib/CMakeLists.txt
@@ -19,7 +19,7 @@
   endif()
   
   install(FILES ${LLVM_MAIN_INCLUDE_DIR}/llvm-c/Remarks.h
-DESTINATION include/llvm-c
+DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/llvm-c"
 COMPONENT Remarks)
 
   if (APPLE)
Index: llvm/tools/opt-viewer/CMakeLists.txt
===
--- llvm/tools/opt-viewer/CMakeLists.txt
+++ llvm/tools/opt-viewer/CMakeLists.txt
@@ -8,7 +8,7 @@
 
 foreach (file ${files})
   install(PROGRAMS ${file}
-DESTINATION share/opt-viewer
+DESTINATION "${CMAKE_INSTALL_DATADIR}/opt-viewer"
 COMPONENT opt-viewer)
 endforeach (file)
 
Index: llvm/tools/lto/CMakeLists.txt
===
--- llvm/tools/lto/CMakeLists.txt
+++ llvm/tools/lto/CMakeLists.txt
@@ -33,7 +33,7 @@
 ${SOURCES} DEPENDS intrinsics_gen)
 
 install(FILES ${LLVM_MAIN_INCLUDE_DIR}/llvm-c/lto.h
-  DESTINATION include/llvm-c
+  DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/llvm-c"
   COMPONENT LTO)
 
 if (APPLE)
Index: llvm/tools/llvm-config/llvm-config.cpp
===
--- llvm/tools/llvm-config/llvm-config.cpp
+++ llvm/tools/llvm-config/llvm-config.cpp
@@ -357,10 +357,16 @@
 ("-I" + ActiveIncludeDir + " " + "-I" + ActiveObjRoot + "/include");
   } else {
 ActivePrefix = CurrentExecPrefix;
-ActiveIncludeDir = ActivePrefix + "/include";
-SmallString<256> path(StringRef(LLVM_TOOLS_INSTALL_DIR));
-sys::fs::make_absolute(ActivePrefix, path);
-ActiveBinDir = std::string(path.str());
+{
+  SmallString<256> Path(StringRef(LLVM_INSTALL_INCLUDEDIR));
+  sys::fs::make_absolute(ActivePrefix, Path);
+  ActiveIncludeDir = std::string(Path.str());
+}
+{
+  SmallString<256> Path(StringRef(LLVM_INSTALL_BINDIR));
+  sys::fs::make_absolute(ActivePrefix, Path);
+  ActiveBinDir = std::string(Path.str());
+}
 ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX;
 ActiveCMakeDir = ActiveLibDir + "/cmake/llvm";
 ActiveIncludeOption = "-I" + ActiveIncludeDir;
Index: llvm/tools/llvm-config/BuildVariables.inc.in
===
--- llvm/tools/llvm-config/BuildVariables.inc.in
+++ llvm/tools/llvm-config/BuildVariables.inc.in
@@ -23,6 +23,8 @@
 #define LLVM_CXXFLAGS "@LLVM_CXXFLAGS@"
 #define LLVM_BUILDMODE "@LLVM_BUILDMODE@"
 #define LLVM_LIBDIR_SUFFIX "@LLVM_LIBDIR_SUFFIX@"
+#define LLVM_INSTALL_BINDIR "@CMAKE_INSTALL_BINDIR@"
+#define LLVM_INSTALL_INCLUDEDIR "@CMAKE_INSTALL_INCLUDEDIR@"
 #define LLVM_TARGETS_BUILT "@LLVM_TARGETS_BUILT@"
 #define LLVM_SYSTEM_LIBS "@LLVM_SYSTEM_LIBS@"
 #define LLVM_BUILD_SYSTEM 

[PATCH] D105320: [CodeView] Saturate values bigger than supported by APInt.

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

- Really `git add` the test case this time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105320

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-codeview-int128.cpp
  llvm/include/llvm/IR/DIBuilder.h
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h
  llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp
  llvm/lib/IR/DIBuilder.cpp

Index: llvm/lib/IR/DIBuilder.cpp
===
--- llvm/lib/IR/DIBuilder.cpp
+++ llvm/lib/IR/DIBuilder.cpp
@@ -243,7 +243,7 @@
   return MF;
 }
 
-DIEnumerator *DIBuilder::createEnumerator(StringRef Name, int64_t Val,
+DIEnumerator *DIBuilder::createEnumerator(StringRef Name, uint64_t Val,
   bool IsUnsigned) {
   assert(!Name.empty() && "Unable to create enumerator without name");
   return DIEnumerator::get(VMContext, APInt(64, Val, !IsUnsigned), IsUnsigned,
Index: llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp
===
--- llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp
+++ llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp
@@ -188,14 +188,21 @@
 
 Error CodeViewRecordIO::mapEncodedInteger(APSInt , const Twine ) {
   if (isStreaming()) {
+// FIXME: We also need to handle big values here, but it's
+//not clear how we can excercise this code path yet.
 if (Value.isSigned())
   emitEncodedSignedInteger(Value.getSExtValue(), Comment);
 else
   emitEncodedUnsignedInteger(Value.getZExtValue(), Comment);
   } else if (isWriting()) {
-if (Value.isSigned())
-  return writeEncodedSignedInteger(Value.getSExtValue());
-return writeEncodedUnsignedInteger(Value.getZExtValue());
+if (Value.isSigned()) {
+  int64_t Val =
+  Value.getNumWords() <= 1U ? Value.getSExtValue() : INT64_MIN;
+  return writeEncodedSignedInteger(Val);
+}
+uint64_t Val =
+Value.getNumWords() <= 1U ? Value.getZExtValue() : UINT64_MAX;
+return writeEncodedUnsignedInteger(Val);
   } else
 return consume(*Reader, Value);
   return Error::success();
@@ -273,6 +280,7 @@
 
 void CodeViewRecordIO::emitEncodedSignedInteger(const int64_t ,
 const Twine ) {
+  // FIXME: There are no test cases covering this function.
   if (Value >= std::numeric_limits::min()) {
 Streamer->emitIntValue(LF_CHAR, 2);
 emitComment(Comment);
@@ -291,8 +299,8 @@
   } else {
 Streamer->emitIntValue(LF_QUADWORD, 2);
 emitComment(Comment);
-Streamer->emitIntValue(Value, 4);
-incrStreamedLen(6);
+Streamer->emitIntValue(Value, 4); // FIXME: Why not 8 (size of quadword)?
+incrStreamedLen(6);   // FIXME: Why not 10 (8 + 2)?
   }
 }
 
@@ -313,10 +321,11 @@
 Streamer->emitIntValue(Value, 4);
 incrStreamedLen(6);
   } else {
+// FIXME: There are no test cases covering this block.
 Streamer->emitIntValue(LF_UQUADWORD, 2);
 emitComment(Comment);
 Streamer->emitIntValue(Value, 8);
-incrStreamedLen(6);
+incrStreamedLen(6); // FIXME: Why not 10 (8 + 2)?
   }
 }
 
Index: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h
===
--- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h
+++ llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h
@@ -315,6 +315,8 @@
   void collectDebugInfoForGlobals();
   void emitDebugInfoForGlobals();
   void emitGlobalVariableList(ArrayRef Globals);
+  void emitConstantSymbolRecord(const DIType *DTy, APSInt ,
+const std::string );
   void emitDebugInfoForGlobal(const CVGlobalVariable );
   void emitStaticConstMemberList();
 
Index: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -3157,6 +3157,28 @@
   }
 }
 
+void CodeViewDebug::emitConstantSymbolRecord(const DIType *DTy, APSInt ,
+ const std::string ) {
+  MCSymbol *SConstantEnd = beginSymbolRecord(SymbolKind::S_CONSTANT);
+  OS.AddComment("Type");
+  OS.emitInt32(getTypeIndex(DTy).getIndex());
+
+  // TODO: Need to support bigger ints like __int128.
+  OS.AddComment("Value");
+
+  // Encoded integers shouldn't need more than 10 bytes.
+  uint8_t Data[10];
+  BinaryStreamWriter Writer(Data, llvm::support::endianness::little);
+  CodeViewRecordIO IO(Writer);
+  cantFail(IO.mapEncodedInteger(Value));
+  StringRef SRef((char *)Data, Writer.getOffset());
+  OS.emitBinaryData(SRef);
+
+  OS.AddComment("Name");
+  emitNullTerminatedSymbolName(OS, QualifiedName);
+  endSymbolRecord(SConstantEnd);
+}
+
 void 

[PATCH] D105491: [clang] Use i64 for the !srcloc metadata on asm IR nodes.

2021-07-21 Thread Chris Lattner via Phabricator via cfe-commits
lattner added a comment.

  > cat f.c
  
  void x() {
asm("bogus");
  }
  > clang f.c
  f.c:3:7: error: invalid instruction mnemonic 'bogus'
asm("bogus");
^
  :1:2: note: instantiated into assembly here
  bogus
  ^
  1 error generated.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105491

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


[PATCH] D106506: [WebAssembly] Replace @llvm.wasm.popcnt with @llvm.ctpop.v16i8

2021-07-21 Thread Thomas Lively 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 rG8af333cf1a77: [WebAssembly] Replace @llvm.wasm.popcnt with 
@llvm.ctpop.v16i8 (authored by tlively).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106506

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-wasm.c
  clang/test/Headers/wasm.c
  llvm/include/llvm/IR/IntrinsicsWebAssembly.td
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
  llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
  llvm/test/CodeGen/WebAssembly/simd-unsupported.ll

Index: llvm/test/CodeGen/WebAssembly/simd-unsupported.ll
===
--- llvm/test/CodeGen/WebAssembly/simd-unsupported.ll
+++ llvm/test/CodeGen/WebAssembly/simd-unsupported.ll
@@ -10,7 +10,7 @@
 ; ==
 
 ; CHECK-LABEL: ctlz_v16i8:
-; CHECK: i32.clz
+; CHECK: i8x16.popcnt
 declare <16 x i8> @llvm.ctlz.v16i8(<16 x i8>, i1)
 define <16 x i8> @ctlz_v16i8(<16 x i8> %x) {
   %v = call <16 x i8> @llvm.ctlz.v16i8(<16 x i8> %x, i1 false)
@@ -18,14 +18,14 @@
 }
 
 ; CHECK-LABEL: ctlz_v16i8_undef:
-; CHECK: i32.clz
+; CHECK: i8x16.popcnt
 define <16 x i8> @ctlz_v16i8_undef(<16 x i8> %x) {
   %v = call <16 x i8> @llvm.ctlz.v16i8(<16 x i8> %x, i1 true)
   ret <16 x i8> %v
 }
 
 ; CHECK-LABEL: cttz_v16i8:
-; CHECK: i32.ctz
+; CHECK: i8x16.popcnt
 declare <16 x i8> @llvm.cttz.v16i8(<16 x i8>, i1)
 define <16 x i8> @cttz_v16i8(<16 x i8> %x) {
   %v = call <16 x i8> @llvm.cttz.v16i8(<16 x i8> %x, i1 false)
@@ -33,21 +33,12 @@
 }
 
 ; CHECK-LABEL: cttz_v16i8_undef:
-; CHECK: i32.ctz
+; CHECK: i8x16.popcnt
 define <16 x i8> @cttz_v16i8_undef(<16 x i8> %x) {
   %v = call <16 x i8> @llvm.cttz.v16i8(<16 x i8> %x, i1 true)
   ret <16 x i8> %v
 }
 
-; CHECK-LABEL: ctpop_v16i8:
-; Note: expansion does not use i32.popcnt
-; CHECK: v128.and
-declare <16 x i8> @llvm.ctpop.v16i8(<16 x i8>)
-define <16 x i8> @ctpop_v16i8(<16 x i8> %x) {
-  %v = call <16 x i8> @llvm.ctpop.v16i8(<16 x i8> %x)
-  ret <16 x i8> %v
-}
-
 ; CHECK-LABEL: sdiv_v16i8:
 ; CHECK: i32.div_s
 define <16 x i8> @sdiv_v16i8(<16 x i8> %x, <16 x i8> %y) {
Index: llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
===
--- llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
+++ llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
@@ -78,9 +78,9 @@
 ; CHECK-NEXT: .functype popcnt_v16i8 (v128) -> (v128){{$}}
 ; CHECK-NEXT: i8x16.popcnt $push[[R:[0-9]+]]=, $0{{$}}
 ; CHECK-NEXT: return $pop[[R]]{{$}}
-declare <16 x i8> @llvm.wasm.popcnt(<16 x i8>)
+declare <16 x i8> @llvm.ctpop.v16i8(<16 x i8>)
 define <16 x i8> @popcnt_v16i8(<16 x i8> %x) {
- %a = call <16 x i8> @llvm.wasm.popcnt(<16 x i8> %x)
+ %a = call <16 x i8> @llvm.ctpop.v16i8(<16 x i8> %x)
  ret <16 x i8> %a
 }
 
Index: llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
===
--- llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
+++ llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
@@ -833,7 +833,7 @@
 defm NEG : SIMDUnaryInt;
 
 // Population count: popcnt
-defm POPCNT : SIMDUnary;
+defm POPCNT : SIMDUnary;
 
 // Any lane true: any_true
 defm ANYTRUE : SIMD_I<(outs I32:$dst), (ins V128:$vec), (outs), (ins), [],
Index: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
@@ -212,6 +212,9 @@
   for (auto T : {MVT::v16i8, MVT::v8i16, MVT::v4i32})
 setOperationAction(Op, T, Legal);
 
+// And we have popcnt for i8x16
+setOperationAction(ISD::CTPOP, MVT::v16i8, Legal);
+
 // Expand float operations supported for scalars but not SIMD
 for (auto Op : {ISD::FCOPYSIGN, ISD::FLOG, ISD::FLOG2, ISD::FLOG10,
 ISD::FEXP, ISD::FEXP2, ISD::FRINT})
Index: llvm/include/llvm/IR/IntrinsicsWebAssembly.td
===
--- llvm/include/llvm/IR/IntrinsicsWebAssembly.td
+++ llvm/include/llvm/IR/IntrinsicsWebAssembly.td
@@ -172,11 +172,6 @@
 [LLVMMatchType<0>, LLVMMatchType<0>],
 [IntrNoMem, IntrSpeculatable]>;
 
-// TODO: Replace this intrinsic with normal ISel patterns once popcnt is merged
-// to the proposal.
-def int_wasm_popcnt :
-  Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty], [IntrNoMem, IntrSpeculatable]>;
-
 def int_wasm_extmul_low_signed :
   Intrinsic<[llvm_anyvector_ty],
 [LLVMSubdivide2VectorType<0>, LLVMSubdivide2VectorType<0>],
Index: clang/test/Headers/wasm.c

[clang] 8af333c - [WebAssembly] Replace @llvm.wasm.popcnt with @llvm.ctpop.v16i8

2021-07-21 Thread Thomas Lively via cfe-commits

Author: Thomas Lively
Date: 2021-07-21T16:45:54-07:00
New Revision: 8af333cf1a77f72ed3ccf14afa96a4f8f12e40c4

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

LOG: [WebAssembly] Replace @llvm.wasm.popcnt with @llvm.ctpop.v16i8

Use the standard target-independent intrinsic to take advantage of standard
optimizations.

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

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/builtins-wasm.c
clang/test/Headers/wasm.c
llvm/include/llvm/IR/IntrinsicsWebAssembly.td
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
llvm/test/CodeGen/WebAssembly/simd-unsupported.ll

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 7a7e9a1b3b31b..a4d0d87f2cbcb 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -17815,7 +17815,8 @@ Value 
*CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
   }
   case WebAssembly::BI__builtin_wasm_popcnt_i8x16: {
 Value *Vec = EmitScalarExpr(E->getArg(0));
-Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_popcnt);
+Function *Callee =
+CGM.getIntrinsic(Intrinsic::ctpop, ConvertType(E->getType()));
 return Builder.CreateCall(Callee, {Vec});
   }
   case WebAssembly::BI__builtin_wasm_any_true_v128:

diff  --git a/clang/test/CodeGen/builtins-wasm.c 
b/clang/test/CodeGen/builtins-wasm.c
index ea2beed5cd8ea..f25797882b487 100644
--- a/clang/test/CodeGen/builtins-wasm.c
+++ b/clang/test/CodeGen/builtins-wasm.c
@@ -506,7 +506,7 @@ i32x4 bitselect(i32x4 x, i32x4 y, i32x4 c) {
 
 i8x16 popcnt(i8x16 x) {
   return __builtin_wasm_popcnt_i8x16(x);
-  // WEBASSEMBLY: call <16 x i8> @llvm.wasm.popcnt(<16 x i8> %x)
+  // WEBASSEMBLY: call <16 x i8> @llvm.ctpop.v16i8(<16 x i8> %x)
   // WEBASSEMBLY-NEXT: ret
 }
 

diff  --git a/clang/test/Headers/wasm.c b/clang/test/Headers/wasm.c
index 7f279725192a4..bcf48a7c37ffb 100644
--- a/clang/test/Headers/wasm.c
+++ b/clang/test/Headers/wasm.c
@@ -1352,7 +1352,7 @@ int32_t test_i8x16_bitmask(v128_t a) {
 // CHECK-LABEL: @test_i8x16_popcnt(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i32> [[A:%.*]] to <16 x i8>
-// CHECK-NEXT:[[TMP1:%.*]] = tail call <16 x i8> @llvm.wasm.popcnt(<16 x 
i8> [[TMP0]]) #[[ATTR6]]
+// CHECK-NEXT:[[TMP1:%.*]] = tail call <16 x i8> @llvm.ctpop.v16i8(<16 x 
i8> [[TMP0]]) #[[ATTR6]]
 // CHECK-NEXT:[[TMP2:%.*]] = bitcast <16 x i8> [[TMP1]] to <4 x i32>
 // CHECK-NEXT:ret <4 x i32> [[TMP2]]
 //

diff  --git a/llvm/include/llvm/IR/IntrinsicsWebAssembly.td 
b/llvm/include/llvm/IR/IntrinsicsWebAssembly.td
index bc93137af5fa0..4ce74d84a721e 100644
--- a/llvm/include/llvm/IR/IntrinsicsWebAssembly.td
+++ b/llvm/include/llvm/IR/IntrinsicsWebAssembly.td
@@ -172,11 +172,6 @@ def int_wasm_pmax :
 [LLVMMatchType<0>, LLVMMatchType<0>],
 [IntrNoMem, IntrSpeculatable]>;
 
-// TODO: Replace this intrinsic with normal ISel patterns once popcnt is merged
-// to the proposal.
-def int_wasm_popcnt :
-  Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty], [IntrNoMem, IntrSpeculatable]>;
-
 def int_wasm_extmul_low_signed :
   Intrinsic<[llvm_anyvector_ty],
 [LLVMSubdivide2VectorType<0>, LLVMSubdivide2VectorType<0>],

diff  --git a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp 
b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
index 32f8b5df25c3e..1cff336cb3e4e 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
@@ -212,6 +212,9 @@ WebAssemblyTargetLowering::WebAssemblyTargetLowering(
   for (auto T : {MVT::v16i8, MVT::v8i16, MVT::v4i32})
 setOperationAction(Op, T, Legal);
 
+// And we have popcnt for i8x16
+setOperationAction(ISD::CTPOP, MVT::v16i8, Legal);
+
 // Expand float operations supported for scalars but not SIMD
 for (auto Op : {ISD::FCOPYSIGN, ISD::FLOG, ISD::FLOG2, ISD::FLOG10,
 ISD::FEXP, ISD::FEXP2, ISD::FRINT})

diff  --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td 
b/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
index ff7c7deed233b..bf05b82237430 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
@@ -833,7 +833,7 @@ defm ABS : SIMDUnaryInt;
 defm NEG : SIMDUnaryInt;
 
 // Population count: popcnt
-defm POPCNT : SIMDUnary;
+defm POPCNT : SIMDUnary;
 
 // Any lane true: any_true
 defm ANYTRUE : SIMD_I<(outs I32:$dst), (ins V128:$vec), (outs), (ins), [],

diff  --git 

[PATCH] D105491: [clang] Use i64 for the !srcloc metadata on asm IR nodes.

2021-07-21 Thread Chris Lattner via Phabricator via cfe-commits
lattner added a comment.

The usecase for this is to get good diagnostics out of the integrated 
assembler.  Try doing something like: `asm("bogus");`,  GCC would produce an 
error pointing to the generated .s file.  Clang should point to the C file 
(including macros expanded etc).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105491

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


[PATCH] D105320: [CodeView] Skip emitting values bigger than supported by APInt.

2021-07-21 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 360643.
mizvekov edited the summary of this revision.
mizvekov added a comment.
Herald added subscribers: cfe-commits, dexonsmith.
Herald added a project: clang.

- Fixes more issues.
- Add test cases.
- Add some FIXME notes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105320

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  llvm/include/llvm/IR/DIBuilder.h
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h
  llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp
  llvm/lib/IR/DIBuilder.cpp

Index: llvm/lib/IR/DIBuilder.cpp
===
--- llvm/lib/IR/DIBuilder.cpp
+++ llvm/lib/IR/DIBuilder.cpp
@@ -243,7 +243,7 @@
   return MF;
 }
 
-DIEnumerator *DIBuilder::createEnumerator(StringRef Name, int64_t Val,
+DIEnumerator *DIBuilder::createEnumerator(StringRef Name, uint64_t Val,
   bool IsUnsigned) {
   assert(!Name.empty() && "Unable to create enumerator without name");
   return DIEnumerator::get(VMContext, APInt(64, Val, !IsUnsigned), IsUnsigned,
Index: llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp
===
--- llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp
+++ llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp
@@ -188,14 +188,21 @@
 
 Error CodeViewRecordIO::mapEncodedInteger(APSInt , const Twine ) {
   if (isStreaming()) {
+// FIXME: We also need to handle big values here, but it's
+//not clear how we can excercise this code path yet.
 if (Value.isSigned())
   emitEncodedSignedInteger(Value.getSExtValue(), Comment);
 else
   emitEncodedUnsignedInteger(Value.getZExtValue(), Comment);
   } else if (isWriting()) {
-if (Value.isSigned())
-  return writeEncodedSignedInteger(Value.getSExtValue());
-return writeEncodedUnsignedInteger(Value.getZExtValue());
+if (Value.isSigned()) {
+  int64_t Val =
+  Value.getNumWords() <= 1U ? Value.getSExtValue() : INT64_MIN;
+  return writeEncodedSignedInteger(Val);
+}
+uint64_t Val =
+Value.getNumWords() <= 1U ? Value.getZExtValue() : UINT64_MAX;
+return writeEncodedUnsignedInteger(Val);
   } else
 return consume(*Reader, Value);
   return Error::success();
@@ -273,6 +280,7 @@
 
 void CodeViewRecordIO::emitEncodedSignedInteger(const int64_t ,
 const Twine ) {
+  // FIXME: There are no test cases covering this function.
   if (Value >= std::numeric_limits::min()) {
 Streamer->emitIntValue(LF_CHAR, 2);
 emitComment(Comment);
@@ -291,8 +299,8 @@
   } else {
 Streamer->emitIntValue(LF_QUADWORD, 2);
 emitComment(Comment);
-Streamer->emitIntValue(Value, 4);
-incrStreamedLen(6);
+Streamer->emitIntValue(Value, 4); // FIXME: Why not 8 (size of quadword)?
+incrStreamedLen(6);   // FIXME: Why not 10 (8 + 2)?
   }
 }
 
@@ -313,10 +321,11 @@
 Streamer->emitIntValue(Value, 4);
 incrStreamedLen(6);
   } else {
+// FIXME: There are no test cases covering this block.
 Streamer->emitIntValue(LF_UQUADWORD, 2);
 emitComment(Comment);
 Streamer->emitIntValue(Value, 8);
-incrStreamedLen(6);
+incrStreamedLen(6); // FIXME: Why not 10 (8 + 2)?
   }
 }
 
Index: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h
===
--- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h
+++ llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h
@@ -315,6 +315,8 @@
   void collectDebugInfoForGlobals();
   void emitDebugInfoForGlobals();
   void emitGlobalVariableList(ArrayRef Globals);
+  void emitConstantSymbolRecord(const DIType *DTy, APSInt ,
+const std::string );
   void emitDebugInfoForGlobal(const CVGlobalVariable );
   void emitStaticConstMemberList();
 
Index: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -3157,6 +3157,28 @@
   }
 }
 
+void CodeViewDebug::emitConstantSymbolRecord(const DIType *DTy, APSInt ,
+ const std::string ) {
+  MCSymbol *SConstantEnd = beginSymbolRecord(SymbolKind::S_CONSTANT);
+  OS.AddComment("Type");
+  OS.emitInt32(getTypeIndex(DTy).getIndex());
+
+  // TODO: Need to support bigger ints like __int128.
+  OS.AddComment("Value");
+
+  // Encoded integers shouldn't need more than 10 bytes.
+  uint8_t Data[10];
+  BinaryStreamWriter Writer(Data, llvm::support::endianness::little);
+  CodeViewRecordIO IO(Writer);
+  cantFail(IO.mapEncodedInteger(Value));
+  StringRef SRef((char *)Data, Writer.getOffset());
+  OS.emitBinaryData(SRef);
+
+  OS.AddComment("Name");
+  

[PATCH] D106506: [WebAssembly] Replace @llvm.wasm.popcnt with @llvm.ctpop.v16i8

2021-07-21 Thread Thomas Lively via Phabricator via cfe-commits
tlively added inline comments.



Comment at: llvm/test/CodeGen/WebAssembly/simd-unsupported.ll:13
 ; CHECK-LABEL: ctlz_v16i8:
-; CHECK: i32.clz
+; CHECK: i8x16.popcnt
 declare <16 x i8> @llvm.ctlz.v16i8(<16 x i8>, i1)

aheejin wrote:
> Aren't these now... "supported"? (This file's name is simd-unsupported.ll, 
> so...)
No, I would say these are still unsupported because they don't map down to a 
single SIMD instruction. The i8x16.popcnt is still just part of a rather large 
expansion of the operation. Having i8x16.popcnt available makes the expansion 
better than before, though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106506

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


[PATCH] D106506: [WebAssembly] Replace @llvm.wasm.popcnt with @llvm.ctpop.v16i8

2021-07-21 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin accepted this revision.
aheejin added inline comments.
This revision is now accepted and ready to land.



Comment at: llvm/test/CodeGen/WebAssembly/simd-unsupported.ll:13
 ; CHECK-LABEL: ctlz_v16i8:
-; CHECK: i32.clz
+; CHECK: i8x16.popcnt
 declare <16 x i8> @llvm.ctlz.v16i8(<16 x i8>, i1)

Aren't these now... "supported"? (This file's name is simd-unsupported.ll, 
so...)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106506

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


[PATCH] D106484: [PowerPC] Add PowerPC "__stbcx" builtin and intrinsic for XL compatibility

2021-07-21 Thread Lei Huang via Phabricator via cfe-commits
lei added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsPPC.def:116
 BUILTIN(__builtin_ppc_fres, "ff", "")
+BUILTIN(__builtin_ppc_stbcx, "icD*i", "")
 

maybe move this up to where `__builtin_ppc_stdcx` is defined.  To match what 
you did in `PPC.cpp`



Comment at: clang/test/CodeGen/builtins-ppc-xlcompat-pwr8.c:31
+  return __builtin_ppc_stbcx(c_addr, c);
+}

Why not just add this tc to 
`clang/test/CodeGen/builtins-ppc-xlcompat-LoadReseve-StoreCond.c`?
The other related store functions are tested there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106484

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


[PATCH] D105951: [clang] P2266 implicit moves STL workaround

2021-07-21 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

In D105951#2894888 , @STL_MSFT wrote:

> FYI, we merged https://github.com/microsoft/STL/pull/2025 fixing the 2 
> affected `return _Istr;` occurrences in `` and `` for VS 
> 2022 17.0 Preview 4. If you find any other affected return statements, please 
> let us know ASAP (as the VS release process locks down the release branch far 
> in advance).

Thanks!

We could relax the workaround even more, and apply them just to those affected 
member functions.
That would help finding more issues, if there are any.
But at the same time we are super close to creating the release branch...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105951

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


[PATCH] D106500: [WebAssembly] Remove clang builtins for extract_lane and replace_lane

2021-07-21 Thread Thomas Lively 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 rGdb7efcab7dd9: [WebAssembly] Remove clang builtins for 
extract_lane and replace_lane (authored by tlively).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106500

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/wasm_simd128.h
  clang/test/CodeGen/builtins-wasm.c

Index: clang/test/CodeGen/builtins-wasm.c
===
--- clang/test/CodeGen/builtins-wasm.c
+++ clang/test/CodeGen/builtins-wasm.c
@@ -193,99 +193,9 @@
   // WEBASSEMBLY-NEXT: ret
 }
 
-int extract_lane_s_i8x16(i8x16 v) {
-  return __builtin_wasm_extract_lane_s_i8x16(v, 13);
-  // MISSING-SIMD: error: '__builtin_wasm_extract_lane_s_i8x16' needs target feature simd128
-  // WEBASSEMBLY: extractelement <16 x i8> %v, i32 13
-  // WEBASSEMBLY-NEXT: sext
-  // WEBASSEMBLY-NEXT: ret
-}
-
-int extract_lane_u_i8x16(u8x16 v) {
-  return __builtin_wasm_extract_lane_u_i8x16(v, 13);
-  // WEBASSEMBLY: extractelement <16 x i8> %v, i32 13
-  // WEBASSEMBLY-NEXT: zext
-  // WEBASSEMBLY-NEXT: ret
-}
-
-int extract_lane_s_i16x8(i16x8 v) {
-  return __builtin_wasm_extract_lane_s_i16x8(v, 7);
-  // WEBASSEMBLY: extractelement <8 x i16> %v, i32 7
-  // WEBASSEMBLY-NEXT: sext
-  // WEBASSEMBLY-NEXT: ret
-}
-
-int extract_lane_u_i16x8(u16x8 v) {
-  return __builtin_wasm_extract_lane_u_i16x8(v, 7);
-  // WEBASSEMBLY: extractelement <8 x i16> %v, i32 7
-  // WEBASSEMBLY-NEXT: zext
-  // WEBASSEMBLY-NEXT: ret
-}
-
-int extract_lane_i32x4(i32x4 v) {
-  return __builtin_wasm_extract_lane_i32x4(v, 3);
-  // WEBASSEMBLY: extractelement <4 x i32> %v, i32 3
-  // WEBASSEMBLY-NEXT: ret
-}
-
-long long extract_lane_i64x2(i64x2 v) {
-  return __builtin_wasm_extract_lane_i64x2(v, 1);
-  // WEBASSEMBLY: extractelement <2 x i64> %v, i32 1
-  // WEBASSEMBLY-NEXT: ret
-}
-
-float extract_lane_f32x4(f32x4 v) {
-  return __builtin_wasm_extract_lane_f32x4(v, 3);
-  // WEBASSEMBLY: extractelement <4 x float> %v, i32 3
-  // WEBASSEMBLY-NEXT: ret
-}
-
-double extract_lane_f64x2(f64x2 v) {
-  return __builtin_wasm_extract_lane_f64x2(v, 1);
-  // WEBASSEMBLY: extractelement <2 x double> %v, i32 1
-  // WEBASSEMBLY-NEXT: ret
-}
-
-i8x16 replace_lane_i8x16(i8x16 v, int x) {
-  return __builtin_wasm_replace_lane_i8x16(v, 13, x);
-  // WEBASSEMBLY: trunc i32 %x to i8
-  // WEBASSEMBLY-NEXT: insertelement <16 x i8> %v, i8 %{{.*}}, i32 13
-  // WEBASSEMBLY-NEXT: ret
-}
-
-i16x8 replace_lane_i16x8(i16x8 v, int x) {
-  return __builtin_wasm_replace_lane_i16x8(v, 7, x);
-  // WEBASSEMBLY: trunc i32 %x to i16
-  // WEBASSEMBLY-NEXT: insertelement <8 x i16> %v, i16 %{{.*}}, i32 7
-  // WEBASSEMBLY-NEXT: ret
-}
-
-i32x4 replace_lane_i32x4(i32x4 v, int x) {
-  return __builtin_wasm_replace_lane_i32x4(v, 3, x);
-  // WEBASSEMBLY: insertelement <4 x i32> %v, i32 %x, i32 3
-  // WEBASSEMBLY-NEXT: ret
-}
-
-i64x2 replace_lane_i64x2(i64x2 v, long long x) {
-  return __builtin_wasm_replace_lane_i64x2(v, 1, x);
-  // WEBASSEMBLY: insertelement <2 x i64> %v, i64 %x, i32 1
-  // WEBASSEMBLY-NEXT: ret
-}
-
-f32x4 replace_lane_f32x4(f32x4 v, float x) {
-  return __builtin_wasm_replace_lane_f32x4(v, 3, x);
-  // WEBASSEMBLY: insertelement <4 x float> %v, float %x, i32 3
-  // WEBASSEMBLY-NEXT: ret
-}
-
-f64x2 replace_lane_f64x2(f64x2 v, double x) {
-  return __builtin_wasm_replace_lane_f64x2(v, 1, x);
-  // WEBASSEMBLY: insertelement <2 x double> %v, double %x, i32 1
-  // WEBASSEMBLY-NEXT: ret
-}
-
 i8x16 add_sat_s_i8x16(i8x16 x, i8x16 y) {
   return __builtin_wasm_add_sat_s_i8x16(x, y);
+  // MISSING-SIMD: error: '__builtin_wasm_add_sat_s_i8x16' needs target feature simd128
   // WEBASSEMBLY: call <16 x i8> @llvm.sadd.sat.v16i8(
   // WEBASSEMBLY-SAME: <16 x i8> %x, <16 x i8> %y)
   // WEBASSEMBLY-NEXT: ret
Index: clang/lib/Headers/wasm_simd128.h
===
--- clang/lib/Headers/wasm_simd128.h
+++ clang/lib/Headers/wasm_simd128.h
@@ -396,67 +396,126 @@
__a, __a, __a, __a, __a, __a, __a, __a};
 }
 
-#define wasm_i8x16_extract_lane(__a, __i)  \
-  (__builtin_wasm_extract_lane_s_i8x16((__i8x16)(__a), __i))
+static __inline__ int8_t __DEFAULT_FN_ATTRS wasm_i8x16_extract_lane(v128_t __a,
+int __i)
+__REQUIRE_CONSTANT(__i) {
+  return ((__i8x16)__a)[__i];
+}
 
-#define wasm_u8x16_extract_lane(__a, __i)  \
-  (__builtin_wasm_extract_lane_u_i8x16((__u8x16)(__a), __i))
+static __inline__ uint8_t __DEFAULT_FN_ATTRS wasm_u8x16_extract_lane(v128_t __a,
+ int __i)
+

[clang] db7efca - [WebAssembly] Remove clang builtins for extract_lane and replace_lane

2021-07-21 Thread Thomas Lively via cfe-commits

Author: Thomas Lively
Date: 2021-07-21T16:11:00-07:00
New Revision: db7efcab7dd9c969179a86fb27149743a0f1f491

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

LOG: [WebAssembly] Remove clang builtins for extract_lane and replace_lane

These builtins were added to capture the fact that the underlying Wasm
instructions return i32s and implicitly sign or zero extend the extracted lanes
in the case of the i8x16 and i16x8 variants. But we do sufficient optimizations
during code gen that these low-level details do not need to be exposed to users.

This commit replaces the use of the builtins in wasm_simd128.h with normal
target-independent vector code. As a result, we can switch the relevant
intrinsics to use functions rather than macros and can use more user-friendly
return types rather than trying to precisely expose the underlying Wasm types.
Note, however, that the generated LLVM IR is no different after this change.

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

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsWebAssembly.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Headers/wasm_simd128.h
clang/test/CodeGen/builtins-wasm.c

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsWebAssembly.def 
b/clang/include/clang/Basic/BuiltinsWebAssembly.def
index 72ba83300a5d..07c368a0431d 100644
--- a/clang/include/clang/Basic/BuiltinsWebAssembly.def
+++ b/clang/include/clang/Basic/BuiltinsWebAssembly.def
@@ -68,22 +68,6 @@ TARGET_BUILTIN(__builtin_wasm_trunc_saturate_u_i64_f64, 
"LLid", "nc", "nontrappi
 // SIMD builtins
 TARGET_BUILTIN(__builtin_wasm_swizzle_i8x16, "V16ScV16ScV16Sc", "nc", 
"simd128")
 
-TARGET_BUILTIN(__builtin_wasm_extract_lane_s_i8x16, "iV16ScIi", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_extract_lane_u_i8x16, "iV16UcIUi", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_extract_lane_s_i16x8, "iV8sIi", "nc", "simd128")
-TARGET_BUILTIN(__builtin_wasm_extract_lane_u_i16x8, "iV8UsIUi", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_extract_lane_i32x4, "iV4iIi", "nc", "simd128")
-TARGET_BUILTIN(__builtin_wasm_extract_lane_i64x2, "LLiV2LLiIi", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_extract_lane_f32x4, "fV4fIi", "nc", "simd128")
-TARGET_BUILTIN(__builtin_wasm_extract_lane_f64x2, "dV2dIi", "nc", "simd128")
-
-TARGET_BUILTIN(__builtin_wasm_replace_lane_i8x16, "V16ScV16ScIii", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_replace_lane_i16x8, "V8sV8sIii", "nc", "simd128")
-TARGET_BUILTIN(__builtin_wasm_replace_lane_i32x4, "V4iV4iIii", "nc", "simd128")
-TARGET_BUILTIN(__builtin_wasm_replace_lane_i64x2, "V2LLiV2LLiIiLLi", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_replace_lane_f32x4, "V4fV4fIif", "nc", "simd128")
-TARGET_BUILTIN(__builtin_wasm_replace_lane_f64x2, "V2dV2dIid", "nc", "simd128")
-
 TARGET_BUILTIN(__builtin_wasm_add_sat_s_i8x16, "V16ScV16ScV16Sc", "nc", 
"simd128")
 TARGET_BUILTIN(__builtin_wasm_add_sat_u_i8x16, "V16UcV16UcV16Uc", "nc", 
"simd128")
 TARGET_BUILTIN(__builtin_wasm_add_sat_s_i16x8, "V8sV8sV8s", "nc", "simd128")

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index ad0fc96f2e67..7a7e9a1b3b31 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -17635,63 +17635,6 @@ Value 
*CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
 Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_swizzle);
 return Builder.CreateCall(Callee, {Src, Indices});
   }
-  case WebAssembly::BI__builtin_wasm_extract_lane_s_i8x16:
-  case WebAssembly::BI__builtin_wasm_extract_lane_u_i8x16:
-  case WebAssembly::BI__builtin_wasm_extract_lane_s_i16x8:
-  case WebAssembly::BI__builtin_wasm_extract_lane_u_i16x8:
-  case WebAssembly::BI__builtin_wasm_extract_lane_i32x4:
-  case WebAssembly::BI__builtin_wasm_extract_lane_i64x2:
-  case WebAssembly::BI__builtin_wasm_extract_lane_f32x4:
-  case WebAssembly::BI__builtin_wasm_extract_lane_f64x2: {
-llvm::APSInt LaneConst =
-*E->getArg(1)->getIntegerConstantExpr(getContext());
-Value *Vec = EmitScalarExpr(E->getArg(0));
-Value *Lane = llvm::ConstantInt::get(getLLVMContext(), LaneConst);
-Value *Extract = Builder.CreateExtractElement(Vec, Lane);
-switch (BuiltinID) {
-case WebAssembly::BI__builtin_wasm_extract_lane_s_i8x16:
-case WebAssembly::BI__builtin_wasm_extract_lane_s_i16x8:
-  return Builder.CreateSExt(Extract, ConvertType(E->getType()));
-case WebAssembly::BI__builtin_wasm_extract_lane_u_i8x16:
-case WebAssembly::BI__builtin_wasm_extract_lane_u_i16x8:
-  return Builder.CreateZExt(Extract, ConvertType(E->getType()));
-case WebAssembly::BI__builtin_wasm_extract_lane_i32x4:
-case WebAssembly::BI__builtin_wasm_extract_lane_i64x2:
-

[PATCH] D106506: [WebAssembly] Replace @llvm.wasm.popcnt with @llvm.ctpop.v16i8

2021-07-21 Thread Thomas Lively via Phabricator via cfe-commits
tlively created this revision.
tlively added reviewers: aheejin, dschuff.
Herald added subscribers: wingo, ecnelises, sunfish, hiraditya, 
jgravelle-google, sbc100.
tlively requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Use the standard target-independent intrinsic to take advantage of standard
optimizations.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106506

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-wasm.c
  clang/test/Headers/wasm.c
  llvm/include/llvm/IR/IntrinsicsWebAssembly.td
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
  llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
  llvm/test/CodeGen/WebAssembly/simd-unsupported.ll

Index: llvm/test/CodeGen/WebAssembly/simd-unsupported.ll
===
--- llvm/test/CodeGen/WebAssembly/simd-unsupported.ll
+++ llvm/test/CodeGen/WebAssembly/simd-unsupported.ll
@@ -10,7 +10,7 @@
 ; ==
 
 ; CHECK-LABEL: ctlz_v16i8:
-; CHECK: i32.clz
+; CHECK: i8x16.popcnt
 declare <16 x i8> @llvm.ctlz.v16i8(<16 x i8>, i1)
 define <16 x i8> @ctlz_v16i8(<16 x i8> %x) {
   %v = call <16 x i8> @llvm.ctlz.v16i8(<16 x i8> %x, i1 false)
@@ -18,14 +18,14 @@
 }
 
 ; CHECK-LABEL: ctlz_v16i8_undef:
-; CHECK: i32.clz
+; CHECK: i8x16.popcnt
 define <16 x i8> @ctlz_v16i8_undef(<16 x i8> %x) {
   %v = call <16 x i8> @llvm.ctlz.v16i8(<16 x i8> %x, i1 true)
   ret <16 x i8> %v
 }
 
 ; CHECK-LABEL: cttz_v16i8:
-; CHECK: i32.ctz
+; CHECK: i8x16.popcnt
 declare <16 x i8> @llvm.cttz.v16i8(<16 x i8>, i1)
 define <16 x i8> @cttz_v16i8(<16 x i8> %x) {
   %v = call <16 x i8> @llvm.cttz.v16i8(<16 x i8> %x, i1 false)
@@ -33,21 +33,12 @@
 }
 
 ; CHECK-LABEL: cttz_v16i8_undef:
-; CHECK: i32.ctz
+; CHECK: i8x16.popcnt
 define <16 x i8> @cttz_v16i8_undef(<16 x i8> %x) {
   %v = call <16 x i8> @llvm.cttz.v16i8(<16 x i8> %x, i1 true)
   ret <16 x i8> %v
 }
 
-; CHECK-LABEL: ctpop_v16i8:
-; Note: expansion does not use i32.popcnt
-; CHECK: v128.and
-declare <16 x i8> @llvm.ctpop.v16i8(<16 x i8>)
-define <16 x i8> @ctpop_v16i8(<16 x i8> %x) {
-  %v = call <16 x i8> @llvm.ctpop.v16i8(<16 x i8> %x)
-  ret <16 x i8> %v
-}
-
 ; CHECK-LABEL: sdiv_v16i8:
 ; CHECK: i32.div_s
 define <16 x i8> @sdiv_v16i8(<16 x i8> %x, <16 x i8> %y) {
Index: llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
===
--- llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
+++ llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
@@ -78,9 +78,9 @@
 ; CHECK-NEXT: .functype popcnt_v16i8 (v128) -> (v128){{$}}
 ; CHECK-NEXT: i8x16.popcnt $push[[R:[0-9]+]]=, $0{{$}}
 ; CHECK-NEXT: return $pop[[R]]{{$}}
-declare <16 x i8> @llvm.wasm.popcnt(<16 x i8>)
+declare <16 x i8> @llvm.ctpop.v16i8(<16 x i8>)
 define <16 x i8> @popcnt_v16i8(<16 x i8> %x) {
- %a = call <16 x i8> @llvm.wasm.popcnt(<16 x i8> %x)
+ %a = call <16 x i8> @llvm.ctpop.v16i8(<16 x i8> %x)
  ret <16 x i8> %a
 }
 
Index: llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
===
--- llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
+++ llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
@@ -833,7 +833,7 @@
 defm NEG : SIMDUnaryInt;
 
 // Population count: popcnt
-defm POPCNT : SIMDUnary;
+defm POPCNT : SIMDUnary;
 
 // Any lane true: any_true
 defm ANYTRUE : SIMD_I<(outs I32:$dst), (ins V128:$vec), (outs), (ins), [],
Index: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
@@ -212,6 +212,9 @@
   for (auto T : {MVT::v16i8, MVT::v8i16, MVT::v4i32})
 setOperationAction(Op, T, Legal);
 
+// And we have popcnt for i8x16
+setOperationAction(ISD::CTPOP, MVT::v16i8, Legal);
+
 // Expand float operations supported for scalars but not SIMD
 for (auto Op : {ISD::FCOPYSIGN, ISD::FLOG, ISD::FLOG2, ISD::FLOG10,
 ISD::FEXP, ISD::FEXP2, ISD::FRINT})
Index: llvm/include/llvm/IR/IntrinsicsWebAssembly.td
===
--- llvm/include/llvm/IR/IntrinsicsWebAssembly.td
+++ llvm/include/llvm/IR/IntrinsicsWebAssembly.td
@@ -172,11 +172,6 @@
 [LLVMMatchType<0>, LLVMMatchType<0>],
 [IntrNoMem, IntrSpeculatable]>;
 
-// TODO: Replace this intrinsic with normal ISel patterns once popcnt is merged
-// to the proposal.
-def int_wasm_popcnt :
-  Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty], [IntrNoMem, IntrSpeculatable]>;
-
 def int_wasm_extmul_low_signed :
   Intrinsic<[llvm_anyvector_ty],
 [LLVMSubdivide2VectorType<0>, LLVMSubdivide2VectorType<0>],
Index: 

[PATCH] D106084: [DebugInfo] Switch to using constructor homing (-debug-info-kind=constructor) by default when debug info is enabled

2021-07-21 Thread Amy Huang via Phabricator via cfe-commits
akhuang added a comment.

Realized it's probably a good idea to add an opt out flag (counterpart to 
fuse-ctor-homing). Also, maybe in a separate patch, maybe should make these 
clang flags instead of cc1 flags-


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106084

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


[PATCH] D105951: [clang] P2266 implicit moves STL workaround

2021-07-21 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT added a comment.

FYI, we merged https://github.com/microsoft/STL/pull/2025 fixing the 2 affected 
`return _Istr;` occurrences in `` and `` for VS 2022 17.0 
Preview 4. If you find any other affected return statements, please let us know 
ASAP (as the VS release process locks down the release branch far in advance).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105951

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


[PATCH] D106504: [OpenCL] Change default standard version to CL1.2

2021-07-21 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.
Anastasia added reviewers: svenvh, azabaznov.
Herald added subscribers: ebevhan, yaxunl.
Anastasia requested review of this revision.

As suggested in RFC: 
https://lists.llvm.org/pipermail/cfe-dev/2021-June/068318.html set default 
version OpenCL C  to 1.2. This means that the absence of any standard flag will 
be equivalent to passing `-cl-std=CL1.2`.

Note that this patch also fixes incorrect version check for the pointer to 
pointer kernel arguments.


https://reviews.llvm.org/D106504

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGenOpenCL/spir_version.cl
  clang/test/Parser/opencl-atomics-cl20.cl
  clang/test/Parser/opencl-cl20.cl
  clang/test/Parser/opencl-storage-class.cl
  clang/test/Preprocessor/predefined-macros.c
  clang/test/SemaOpenCL/fp64-fp16-options.cl
  clang/test/SemaOpenCL/func.cl

Index: clang/test/SemaOpenCL/func.cl
===
--- clang/test/SemaOpenCL/func.cl
+++ clang/test/SemaOpenCL/func.cl
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -triple spir-unknown-unknown
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -triple spir-unknown-unknown -DFUNCPTREXT
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -triple spir-unknown-unknown -DVARARGEXT
+// RUN: %clang_cc1 %s -cl-std=CL1.0 -verify -pedantic -fsyntax-only -triple spir-unknown-unknown
+// RUN: %clang_cc1 %s -cl-std=CL1.0 -verify -pedantic -fsyntax-only -triple spir-unknown-unknown -DFUNCPTREXT
+// RUN: %clang_cc1 %s -cl-std=CL1.0 -verify -pedantic -fsyntax-only -triple spir-unknown-unknown -DVARARGEXT
 
 #ifdef FUNCPTREXT
 #pragma OPENCL EXTENSION __cl_clang_function_pointers : enable
Index: clang/test/SemaOpenCL/fp64-fp16-options.cl
===
--- clang/test/SemaOpenCL/fp64-fp16-options.cl
+++ clang/test/SemaOpenCL/fp64-fp16-options.cl
@@ -1,30 +1,30 @@
-// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL1.0
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL1.1
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -fsyntax-only -cl-std=CL1.1 -DNOPEDANTIC
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL1.2 -DFP64
 
 // Test with a target not supporting fp64.
-// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64 -DNOFP16
+// RUN: %clang_cc1 %s -cl-std=CL1.0 -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64 -DNOFP16
 // RUN: %clang_cc1 -cl-std=CL3.0 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64 -DNOFP16
 
 // Test with some extensions enabled or disabled by cmd-line args
 //
 // Target does not support fp64 and fp16 - override it
-// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+cl_khr_fp64,+cl_khr_fp16
+// RUN: %clang_cc1 %s -cl-std=CL1.0 -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+cl_khr_fp64,+cl_khr_fp16
 //
 // Disable or enable all extensions
-// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -DNOFP64 -DNOFP16
-// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all
-// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all,-cl_khr_fp64 -DNOFP64
-// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=-all,+cl_khr_fp64 -DNOFP16
+// RUN: %clang_cc1 %s -cl-std=CL1.0 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -DNOFP64 -DNOFP16
+// RUN: %clang_cc1 %s -cl-std=CL1.0 -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all
+// RUN: %clang_cc1 %s -cl-std=CL1.0 -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all,-cl_khr_fp64 -DNOFP64
+// RUN: %clang_cc1 %s -cl-std=CL1.0 -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=-all,+cl_khr_fp64 -DNOFP16
 // RUN: %clang_cc1 -cl-std=CL3.0 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -DNOFP64 -DNOFP16
 // RUN: %clang_cc1 -cl-std=CL3.0 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all -DFP64
 // RUN: %clang_cc1 -cl-std=CL3.0 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all,-__opencl_c_fp64,-cl_khr_fp64 -DNOFP64
 //
 // Concatenating
-// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-cl_khr_fp64 

[PATCH] D105703: [hwasan] Use stack safety analysis.

2021-07-21 Thread Florian Mayer via Phabricator via cfe-commits
fmayer added inline comments.



Comment at: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp:410
+Dummy.setArch(Triple::aarch64);
+if (shouldUseStackSafetyAnalysis(Dummy, DisableOptimization))
+  AU.addRequired();

fmayer wrote:
> vitalybuka wrote:
> > Why not just:
> > ```
> > if (!DisableOptimization || ClUseStackSafety)
> >   AU.addRequired();
> > ```
> Because `ClUseStackSafety` defaults to true, so this will be quite useless 
> except if the user explicitly sets it to false. So then you end up 
> duplicating the logic in `shouldUseStackSafetyAnalysis`, which is why I went 
> for the Dummy (thinking about it, we don't actually need to setArch on it).
How about this (mightUseStackSafetyAnalysis)? This seems like a nice tradeoff 
without duplication of the logic.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105703

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


[PATCH] D105703: [hwasan] Use stack safety analysis.

2021-07-21 Thread Florian Mayer via Phabricator via cfe-commits
fmayer updated this revision to Diff 360623.
fmayer added a comment.

more flag parsing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105703

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/hwasan-stack-safety-analysis.c
  llvm/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h
  llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
  llvm/test/Instrumentation/HWAddressSanitizer/stack-safety-analysis.ll

Index: llvm/test/Instrumentation/HWAddressSanitizer/stack-safety-analysis.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/HWAddressSanitizer/stack-safety-analysis.ll
@@ -0,0 +1,42 @@
+; RUN: opt -hwasan -hwasan-use-stack-safety=1 -hwasan-generate-tags-with-calls -S < %s | FileCheck %s --check-prefixes=SAFETY
+; RUN: opt -hwasan -hwasan-use-stack-safety=0 -hwasan-generate-tags-with-calls -S < %s | FileCheck %s --check-prefixes=NOSAFETY
+
+target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
+target triple = "aarch64-unknown-linux-gnu"
+
+; Check a safe alloca to ensure it does not get a tag.
+define i32 @test_load(i32* %a) sanitize_hwaddress {
+entry:
+  ; NOSAFETY: call {{.*}}__hwasan_generate_tag
+  ; SAFETY-NOT: call {{.*}}__hwasan_generate_tag
+  %buf.sroa.0 = alloca i8, align 4
+  call void @llvm.lifetime.start.p0i8(i64 1, i8* nonnull %buf.sroa.0)
+  store volatile i8 0, i8* %buf.sroa.0, align 4, !tbaa !8
+  call void @llvm.lifetime.end.p0i8(i64 1, i8* nonnull %buf.sroa.0)
+  ret i32 0
+}
+
+; Check a non-safe alloca to ensure it gets a tag.
+define i32 @test_use(i32* %a) sanitize_hwaddress {
+entry:
+  ; NOSAFETY: call {{.*}}__hwasan_generate_tag
+  ; SAFETY: call {{.*}}__hwasan_generate_tag
+  %buf.sroa.0 = alloca i8, align 4
+  call void @use(i8* nonnull %buf.sroa.0)
+  call void @llvm.lifetime.start.p0i8(i64 1, i8* nonnull %buf.sroa.0)
+  store volatile i8 0, i8* %buf.sroa.0, align 4, !tbaa !8
+  call void @llvm.lifetime.end.p0i8(i64 1, i8* nonnull %buf.sroa.0)
+  ret i32 0
+}
+
+; Function Attrs: argmemonly mustprogress nofree nosync nounwind willreturn
+declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture)
+
+; Function Attrs: argmemonly mustprogress nofree nosync nounwind willreturn
+declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture)
+
+declare void @use(i8* nocapture)
+
+!8 = !{!9, !9, i64 0}
+!9 = !{!"omnipotent char", !10, i64 0}
+!10 = !{!"Simple C/C++ TBAA"}
Index: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -17,6 +17,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Triple.h"
+#include "llvm/Analysis/StackSafetyAnalysis.h"
 #include "llvm/BinaryFormat/ELF.h"
 #include "llvm/IR/Attributes.h"
 #include "llvm/IR/BasicBlock.h"
@@ -109,6 +110,11 @@
cl::desc("instrument stack (allocas)"),
cl::Hidden, cl::init(true));
 
+static cl::opt
+ClUseStackSafety("hwasan-use-stack-safety", cl::Hidden, cl::init(true),
+ cl::Hidden, cl::desc("Use Stack Safety analysis results"),
+ cl::Optional);
+
 static cl::opt ClUARRetagToZero(
 "hwasan-uar-retag-to-zero",
 cl::desc("Clear alloca tags before returning from the function to allow "
@@ -216,11 +222,22 @@
 #endif
 }
 
+bool mightUseStackSafetyAnalysis(bool DisableOptimization) {
+  return ClUseStackSafety.getNumOccurrences() ? ClUseStackSafety
+  : !DisableOptimization;
+}
+
+bool shouldUseStackSafetyAnalysis(const Triple ,
+  bool DisableOptimization) {
+  return shouldInstrumentStack(TargetTriple) && mightUseStackSafetyAnalysis(DisableOptimization);
+}
 /// An instrumentation pass implementing detection of addressability bugs
 /// using tagged pointers.
 class HWAddressSanitizer {
 public:
-  HWAddressSanitizer(Module , bool CompileKernel, bool Recover) : M(M) {
+  HWAddressSanitizer(Module , bool CompileKernel, bool Recover,
+ const StackSafetyGlobalInfo *SSI)
+  : M(M), SSI(SSI) {
 this->Recover = ClRecover.getNumOccurrences() > 0 ? ClRecover : Recover;
 this->CompileKernel = ClEnableKhwasan.getNumOccurrences() > 0
   ? ClEnableKhwasan
@@ -229,6 +246,8 @@
 initializeModule();
   }
 
+  void setSSI(const StackSafetyGlobalInfo *S) { SSI = S; }
+
   bool sanitizeFunction(Function );
   void initializeModule();
   void createHwasanCtorComdat();
@@ -281,6 +300,7 @@
 private:
   LLVMContext *C;
   Module 
+  const StackSafetyGlobalInfo *SSI;
   Triple TargetTriple;
   FunctionCallee HWAsanMemmove, HWAsanMemcpy, 

[PATCH] D106084: [DebugInfo] Switch to using constructor homing (-debug-info-kind=constructor) by default when debug info is enabled

2021-07-21 Thread Amy Huang via Phabricator via cfe-commits
akhuang updated this revision to Diff 360621.
akhuang added a comment.
Herald added a subscriber: dang.

Add an opt out flag: fno-use-ctor-homing


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106084

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/DebugInfoOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp
  clang/test/CodeGenCXX/debug-info-template-deduction-guide.cpp
  clang/test/Driver/cl-options.c
  clang/test/Driver/clang-g-opts.c
  clang/test/Driver/cuda-dwarf-2.cu
  clang/test/Driver/debug-options-as.c
  clang/test/Driver/debug-options.c
  clang/test/Driver/integrated-as.s
  clang/test/Driver/myriad-toolchain.c
  clang/test/Driver/openmp-offload-gpu.c
  clang/test/Driver/split-debug.c
  lldb/test/Shell/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp

Index: lldb/test/Shell/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp
===
--- lldb/test/Shell/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp
+++ lldb/test/Shell/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp
@@ -106,6 +106,9 @@
 int main() {
   MemberTest::Base B1;
   B1.Get();
+  // Create instance of C1 so that it has debug info (due to constructor
+  // homing).
+  MemberTest::Class C1;
   MemberTest::Class::StaticMemberFunc(1, 10, 2);
   return 0;
 }
Index: clang/test/Driver/split-debug.c
===
--- clang/test/Driver/split-debug.c
+++ clang/test/Driver/split-debug.c
@@ -9,7 +9,7 @@
 
 // INLINE: "-fsplit-dwarf-inlining"
 // NOINLINE-NOT: "-fsplit-dwarf-inlining"
-// SPLIT:  "-debug-info-kind=limited"
+// SPLIT:  "-debug-info-kind=constructor"
 // SPLIT-SAME: "-ggnu-pubnames"
 // SPLIT-SAME: "-split-dwarf-file" "split-debug.dwo" "-split-dwarf-output" "split-debug.dwo"
 
@@ -38,14 +38,14 @@
 // RUN: %clang -### -c -target x86_64 -gsplit-dwarf=single -g -gno-split-dwarf %s 2>&1 | FileCheck %s --check-prefix=NOSPLIT
 // RUN: %clang -### -c -target x86_64 -gno-split-dwarf -g -gsplit-dwarf %s 2>&1 | FileCheck %s --check-prefixes=NOINLINE,SPLIT
 
-// NOSPLIT: "-debug-info-kind=limited"
+// NOSPLIT: "-debug-info-kind=constructor"
 // NOSPLIT-NOT: "-ggnu-pubnames"
 // NOSPLIT-NOT: "-split-dwarf
 
 /// Test -gsplit-dwarf=single.
 // RUN: %clang -### -c -target x86_64 -gsplit-dwarf=single -g %s 2>&1 | FileCheck %s --check-prefix=SINGLE
 
-// SINGLE: "-debug-info-kind=limited"
+// SINGLE: "-debug-info-kind=constructor"
 // SINGLE: "-split-dwarf-file" "split-debug.o"
 // SINGLE-NOT: "-split-dwarf-output"
 
@@ -62,7 +62,7 @@
 
 // RUN: %clang -### -c -target x86_64 -gsplit-dwarf=split -g -gno-pubnames %s 2>&1 | FileCheck %s --check-prefixes=NOPUBNAMES
 // RUN: %clang -### -c -target x86_64 -gsplit-dwarf=split -g -gno-gnu-pubnames %s 2>&1 | FileCheck %s --check-prefixes=NOPUBNAMES
-// NOPUBNAMES:  "-debug-info-kind=limited"
+// NOPUBNAMES:  "-debug-info-kind=constructor"
 // NOPUBNAMES-NOT:  "-ggnu-pubnames"
 // NOPUBNAMES-SAME: "-split-dwarf-file" "split-debug.dwo" "-split-dwarf-output" "split-debug.dwo"
 
Index: clang/test/Driver/openmp-offload-gpu.c
===
--- clang/test/Driver/openmp-offload-gpu.c
+++ clang/test/Driver/openmp-offload-gpu.c
@@ -248,7 +248,7 @@
 
 // HAS_DEBUG-NOT: warning: debug
 // HAS_DEBUG: "-triple" "nvptx64-nvidia-cuda"
-// HAS_DEBUG-SAME: "-debug-info-kind={{limited|line-tables-only}}"
+// HAS_DEBUG-SAME: "-debug-info-kind={{constructor|line-tables-only}}"
 // HAS_DEBUG-SAME: "-dwarf-version=2"
 // HAS_DEBUG-SAME: "-fopenmp-is-device"
 // HAS_DEBUG: ptxas
Index: clang/test/Driver/myriad-toolchain.c
===
--- clang/test/Driver/myriad-toolchain.c
+++ clang/test/Driver/myriad-toolchain.c
@@ -83,7 +83,7 @@
 // NOSTDLIB-NOT: "-lc"
 
 // RUN: %clang -### -c -g %s -target sparc-myriad 2>&1 | FileCheck -check-prefix=G_SPARC %s
-// G_SPARC: "-debug-info-kind=limited" "-dwarf-version=2"
+// G_SPARC: "-debug-info-kind=constructor" "-dwarf-version=2"
 
 // RUN: %clang -### -c %s -target sparc-myriad-rtems -fuse-init-array 2>&1 \
 // RUN: | FileCheck -check-prefix=USE-INIT-ARRAY %s
Index: clang/test/Driver/integrated-as.s
===
--- clang/test/Driver/integrated-as.s
+++ clang/test/Driver/integrated-as.s
@@ -27,19 +27,19 @@
 // XA_INCLUDE2: "-Ifoo_dir"
 
 // RUN: %clang -### -target x86_64--- -c -integrated-as %s -gdwarf-4 -gdwarf-2 2>&1 | FileCheck --check-prefix=DWARF2 %s
-// DWARF2: "-debug-info-kind=limited" "-dwarf-version=2"
+// DWARF2: "-debug-info-kind=constructor" "-dwarf-version=2"
 
 // RUN: %clang -### -target x86_64--- -c -integrated-as %s -gdwarf-3 2>&1 | FileCheck --check-prefix=DWARF3 %s

[PATCH] D104058: ThinLTO: Fix inline assembly references to static functions with CFI

2021-07-21 Thread Sami Tolvanen via Phabricator via cfe-commits
samitolvanen updated this revision to Diff 360615.
samitolvanen added a comment.
This revision is now accepted and ready to land.

As we only care about fixing inline assembly references, mangled names are
not that important in the first place. This version skips any functions
that have unusual characters in their names that would otherwise require
quotes, which includes any functions with MSVC compatible name mangling.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104058

Files:
  llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
  llvm/test/ThinLTO/X86/devirt2.ll
  llvm/test/Transforms/ThinLTOBitcodeWriter/cfi-icall-static-inline-asm.ll
  llvm/test/Transforms/ThinLTOBitcodeWriter/split-internal2.ll
  llvm/test/Transforms/ThinLTOBitcodeWriter/split-vfunc-internal.ll

Index: llvm/test/Transforms/ThinLTOBitcodeWriter/split-vfunc-internal.ll
===
--- llvm/test/Transforms/ThinLTOBitcodeWriter/split-vfunc-internal.ll
+++ llvm/test/Transforms/ThinLTOBitcodeWriter/split-vfunc-internal.ll
@@ -1,7 +1,10 @@
+; REQUIRES: x86-registered-target
 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t %s
 ; RUN: llvm-modextract -b -n 0 -o - %t | llvm-dis | FileCheck --check-prefix=M0 %s
 ; RUN: llvm-modextract -b -n 1 -o - %t | llvm-dis | FileCheck --check-prefix=M1 %s
 
+target triple = "x86_64-unknown-linux-gnu"
+
 define [1 x i8*]* @source() {
   ret [1 x i8*]* @g
 }
Index: llvm/test/Transforms/ThinLTOBitcodeWriter/split-internal2.ll
===
--- llvm/test/Transforms/ThinLTOBitcodeWriter/split-internal2.ll
+++ llvm/test/Transforms/ThinLTOBitcodeWriter/split-internal2.ll
@@ -1,3 +1,4 @@
+; REQUIRES: x86-registered-target
 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t %s
 ; RUN: llvm-modextract -b -n 0 -o %t0 %t
 ; RUN: llvm-modextract -b -n 1 -o %t1 %t
@@ -7,6 +8,8 @@
 ; RUN: llvm-bcanalyzer -dump %t0 | FileCheck --check-prefix=BCA0 %s
 ; RUN: llvm-bcanalyzer -dump %t1 | FileCheck --check-prefix=BCA1 %s
 
+target triple = "x86_64-unknown-linux-gnu"
+
 ; ERROR: llvm-modextract: error: module index out of range; bitcode file contains 2 module(s)
 
 ; BCA0: setName(NewName);
   ImportGV->setVisibility(GlobalValue::HiddenVisibility);
 }
+
+if (isa() && allowPromotionAlias(OldName)) {
+  // Create a local alias with the original name to avoid breaking
+  // references from inline assembly.
+  std::string Alias = ".set " + OldName + "," + NewName + "\n";
+  ExportM.appendModuleInlineAsm(Alias);
+}
   }
 
   if (!RenamedComdats.empty())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105092: [PoC][RISCV] Add the tail policy argument to builtins/intrinsics.

2021-07-21 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Does lowerRISCVVMachineInstrToMCInst in RISCVMCInstLower.cpp need to know to 
skip the policy op?




Comment at: llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp:405
   if (RISCVII::hasVLOp(TSFlags)) {
 const MachineOperand  = MI.getOperand(MI.getNumExplicitOperands() - 
2);
 if (VLOp.isImm())

Why doesn't this need to be updated?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105092

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


[PATCH] D106496: [OpenMP] Change `__kmpc_free_shared` to include the paired allocation size

2021-07-21 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/D106496/new/

https://reviews.llvm.org/D106496

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


[PATCH] D106500: [WebAssembly] Remove clang builtins for extract_lane and replace_lane

2021-07-21 Thread Thomas Lively via Phabricator via cfe-commits
tlively created this revision.
tlively added reviewers: aheejin, dschuff.
Herald added subscribers: wingo, ecnelises, sunfish, jgravelle-google, sbc100.
tlively requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

These builtins were added to capture the fact that the underlying Wasm
instructions return i32s and implicitly sign or zero extend the extracted lanes
in the case of the i8x16 and i16x8 variants. But we do sufficient optimizations
during code gen that these low-level details do not need to be exposed to users.

This commit replaces the use of the builtins in wasm_simd128.h with normal
target-independent vector code. As a result, we can switch the relevant
intrinsics to use functions rather than macros and can use more user-friendly
return types rather than trying to precisely expose the underlying Wasm types.
Note, however, that the generated LLVM IR is no different after this change.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106500

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/wasm_simd128.h
  clang/test/CodeGen/builtins-wasm.c

Index: clang/test/CodeGen/builtins-wasm.c
===
--- clang/test/CodeGen/builtins-wasm.c
+++ clang/test/CodeGen/builtins-wasm.c
@@ -193,99 +193,9 @@
   // WEBASSEMBLY-NEXT: ret
 }
 
-int extract_lane_s_i8x16(i8x16 v) {
-  return __builtin_wasm_extract_lane_s_i8x16(v, 13);
-  // MISSING-SIMD: error: '__builtin_wasm_extract_lane_s_i8x16' needs target feature simd128
-  // WEBASSEMBLY: extractelement <16 x i8> %v, i32 13
-  // WEBASSEMBLY-NEXT: sext
-  // WEBASSEMBLY-NEXT: ret
-}
-
-int extract_lane_u_i8x16(u8x16 v) {
-  return __builtin_wasm_extract_lane_u_i8x16(v, 13);
-  // WEBASSEMBLY: extractelement <16 x i8> %v, i32 13
-  // WEBASSEMBLY-NEXT: zext
-  // WEBASSEMBLY-NEXT: ret
-}
-
-int extract_lane_s_i16x8(i16x8 v) {
-  return __builtin_wasm_extract_lane_s_i16x8(v, 7);
-  // WEBASSEMBLY: extractelement <8 x i16> %v, i32 7
-  // WEBASSEMBLY-NEXT: sext
-  // WEBASSEMBLY-NEXT: ret
-}
-
-int extract_lane_u_i16x8(u16x8 v) {
-  return __builtin_wasm_extract_lane_u_i16x8(v, 7);
-  // WEBASSEMBLY: extractelement <8 x i16> %v, i32 7
-  // WEBASSEMBLY-NEXT: zext
-  // WEBASSEMBLY-NEXT: ret
-}
-
-int extract_lane_i32x4(i32x4 v) {
-  return __builtin_wasm_extract_lane_i32x4(v, 3);
-  // WEBASSEMBLY: extractelement <4 x i32> %v, i32 3
-  // WEBASSEMBLY-NEXT: ret
-}
-
-long long extract_lane_i64x2(i64x2 v) {
-  return __builtin_wasm_extract_lane_i64x2(v, 1);
-  // WEBASSEMBLY: extractelement <2 x i64> %v, i32 1
-  // WEBASSEMBLY-NEXT: ret
-}
-
-float extract_lane_f32x4(f32x4 v) {
-  return __builtin_wasm_extract_lane_f32x4(v, 3);
-  // WEBASSEMBLY: extractelement <4 x float> %v, i32 3
-  // WEBASSEMBLY-NEXT: ret
-}
-
-double extract_lane_f64x2(f64x2 v) {
-  return __builtin_wasm_extract_lane_f64x2(v, 1);
-  // WEBASSEMBLY: extractelement <2 x double> %v, i32 1
-  // WEBASSEMBLY-NEXT: ret
-}
-
-i8x16 replace_lane_i8x16(i8x16 v, int x) {
-  return __builtin_wasm_replace_lane_i8x16(v, 13, x);
-  // WEBASSEMBLY: trunc i32 %x to i8
-  // WEBASSEMBLY-NEXT: insertelement <16 x i8> %v, i8 %{{.*}}, i32 13
-  // WEBASSEMBLY-NEXT: ret
-}
-
-i16x8 replace_lane_i16x8(i16x8 v, int x) {
-  return __builtin_wasm_replace_lane_i16x8(v, 7, x);
-  // WEBASSEMBLY: trunc i32 %x to i16
-  // WEBASSEMBLY-NEXT: insertelement <8 x i16> %v, i16 %{{.*}}, i32 7
-  // WEBASSEMBLY-NEXT: ret
-}
-
-i32x4 replace_lane_i32x4(i32x4 v, int x) {
-  return __builtin_wasm_replace_lane_i32x4(v, 3, x);
-  // WEBASSEMBLY: insertelement <4 x i32> %v, i32 %x, i32 3
-  // WEBASSEMBLY-NEXT: ret
-}
-
-i64x2 replace_lane_i64x2(i64x2 v, long long x) {
-  return __builtin_wasm_replace_lane_i64x2(v, 1, x);
-  // WEBASSEMBLY: insertelement <2 x i64> %v, i64 %x, i32 1
-  // WEBASSEMBLY-NEXT: ret
-}
-
-f32x4 replace_lane_f32x4(f32x4 v, float x) {
-  return __builtin_wasm_replace_lane_f32x4(v, 3, x);
-  // WEBASSEMBLY: insertelement <4 x float> %v, float %x, i32 3
-  // WEBASSEMBLY-NEXT: ret
-}
-
-f64x2 replace_lane_f64x2(f64x2 v, double x) {
-  return __builtin_wasm_replace_lane_f64x2(v, 1, x);
-  // WEBASSEMBLY: insertelement <2 x double> %v, double %x, i32 1
-  // WEBASSEMBLY-NEXT: ret
-}
-
 i8x16 add_sat_s_i8x16(i8x16 x, i8x16 y) {
   return __builtin_wasm_add_sat_s_i8x16(x, y);
+  // MISSING-SIMD: error: '__builtin_wasm_add_sat_s_i8x16' needs target feature simd128
   // WEBASSEMBLY: call <16 x i8> @llvm.sadd.sat.v16i8(
   // WEBASSEMBLY-SAME: <16 x i8> %x, <16 x i8> %y)
   // WEBASSEMBLY-NEXT: ret
Index: clang/lib/Headers/wasm_simd128.h
===
--- clang/lib/Headers/wasm_simd128.h
+++ clang/lib/Headers/wasm_simd128.h
@@ -396,67 +396,126 @@
__a, __a, __a, __a, __a, __a, __a, __a};
 }
 
-#define wasm_i8x16_extract_lane(__a, __i)

[PATCH] D106344: [PowerPC] Implement XL compatible behavior of __compare_and_swap

2021-07-21 Thread Jinsong Ji via Phabricator via cfe-commits
jsji added a comment.

Doesn't look like good enough to me,  the code sequence generated is not clean 
enough.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106344

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


[PATCH] D106496: [OpenMP] Change `__kmpc_free_shared` to include the paired allocation size

2021-07-21 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 360610.
jhuber6 added a comment.

Fixing free shared expecting the incorrect number of args.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106496

Files:
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
  clang/test/OpenMP/declare_target_codegen_globalization.cpp
  clang/test/OpenMP/nvptx_data_sharing.cpp
  clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_target_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/nvptx_teams_codegen.cpp
  clang/test/OpenMP/nvptx_teams_reduction_codegen.cpp
  llvm/include/llvm/Analysis/TargetLibraryInfo.def
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Analysis/MemoryBuiltins.cpp
  llvm/lib/Analysis/TargetLibraryInfo.cpp
  llvm/test/Transforms/OpenMP/remove_globalization.ll
  llvm/test/Transforms/OpenMP/replace_globalization.ll
  llvm/unittests/Analysis/TargetLibraryInfoTest.cpp
  openmp/libomptarget/deviceRTLs/common/src/data_sharing.cu
  openmp/libomptarget/deviceRTLs/interface.h

Index: openmp/libomptarget/deviceRTLs/interface.h
===
--- openmp/libomptarget/deviceRTLs/interface.h
+++ openmp/libomptarget/deviceRTLs/interface.h
@@ -467,7 +467,8 @@
 
 /// Deallocate \p Ptr. Needs to be called balanced with __kmpc_alloc_shared like
 /// a stack (push/pop). Can be called by any thread. \p Ptr must be allocated by
-/// __kmpc_alloc_shared by the same thread.
-EXTERN void __kmpc_free_shared(void *Ptr);
+/// __kmpc_alloc_shared by the same thread. \p Bytes contains the size of the
+/// paired allocation to make memory management easier.
+EXTERN void __kmpc_free_shared(void *Ptr, size_t Bytes);
 
 #endif
Index: openmp/libomptarget/deviceRTLs/common/src/data_sharing.cu
===
--- openmp/libomptarget/deviceRTLs/common/src/data_sharing.cu
+++ openmp/libomptarget/deviceRTLs/common/src/data_sharing.cu
@@ -94,7 +94,7 @@
   return __kmpc_alloc_for_warp(AllocGlobal, Bytes, WarpBytes);
 }
 
-EXTERN void __kmpc_free_shared(void *Ptr) {
+EXTERN void __kmpc_free_shared(void *Ptr, size_t /* Bytes */) {
   __kmpc_impl_lanemask_t CurActive = __kmpc_impl_activemask();
   unsigned LeaderID = __kmpc_impl_ffs(CurActive) - 1;
   bool IsWarpLeader = (GetThreadIdInBlock() % WARPSIZE) == LeaderID;
Index: llvm/unittests/Analysis/TargetLibraryInfoTest.cpp
===
--- llvm/unittests/Analysis/TargetLibraryInfoTest.cpp
+++ llvm/unittests/Analysis/TargetLibraryInfoTest.cpp
@@ -589,7 +589,7 @@
 
   // These functions are OpenMP Offloading allocation / free routines
   "declare i8* @__kmpc_alloc_shared(i64)\n"
-  "declare void @__kmpc_free_shared(i8*)\n"
+  "declare void @__kmpc_free_shared(i8*, i64)\n"
   );
 
   for (unsigned FI = 0; FI != LibFunc::NumLibFuncs; ++FI) {
Index: llvm/test/Transforms/OpenMP/replace_globalization.ll
===
--- llvm/test/Transforms/OpenMP/replace_globalization.ll
+++ llvm/test/Transforms/OpenMP/replace_globalization.ll
@@ -25,7 +25,7 @@
   %x_on_stack = bitcast i8* %x to i32*
   %0 = bitcast i32* %x_on_stack to i8*
   call void @use(i8* %0)
-  call void @__kmpc_free_shared(i8* %x)
+  call void @__kmpc_free_shared(i8* %x, i64 4)
   call void @__kmpc_target_deinit(%struct.ident_t* @1, i1 false, i1 true)
   ret void
 }
@@ -50,7 +50,7 @@
   %x_on_stack = bitcast i8* %x to [4 x i32]*
   %0 = bitcast [4 x i32]* %x_on_stack to i8*
   call void @use(i8* %0)
-  call void @__kmpc_free_shared(i8* %x)
+  call void @__kmpc_free_shared(i8* %x, i64 16)
   br label %exit
 exit:
   ret void
@@ -67,7 +67,7 @@
   %y_on_stack = bitcast i8* %y to [4 x i32]*
   %1 = bitcast [4 x i32]* %y_on_stack to i8*
   call void @use(i8* %1)
-  call void @__kmpc_free_shared(i8* %y)
+  call void @__kmpc_free_shared(i8* %y, i64 4)
   br label %exit
 exit:
   ret void
@@ -79,11 +79,11 @@
   %0 = icmp eq i32 %call, -1
   br i1 %0, label %master, label %exit
 master:
-  %y = call i8* @__kmpc_alloc_shared(i64 6), !dbg !12
+  %y = call i8* @__kmpc_alloc_shared(i64 24), !dbg !12
   %y_on_stack = bitcast i8* %y to [6 x i32]*
   %1 = bitcast [6 x i32]* %y_on_stack to i8*
   call void @use(i8* %1)
-  call void @__kmpc_free_shared(i8* %y)
+  call void @__kmpc_free_shared(i8* %y, i64 24)
   br label %exit
 exit:
   ret void
@@ -98,7 +98,7 @@
 
 declare i8* @__kmpc_alloc_shared(i64)
 

[PATCH] D106371: [AIX] Generate large code model relocations when mcmodel=medium on AIX

2021-07-21 Thread Anjan Kumar via Phabricator via cfe-commits
anjankgk added a comment.

Anjan Kumar Guttahalli Krishna 

Thank you!


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

https://reviews.llvm.org/D106371

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


[PATCH] D102728: [clang][Sema] removes -Wfree-nonheap-object reference param false positive

2021-07-21 Thread Christopher Di Bella 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 rG9a72580a548d: [clang][Sema] removes -Wfree-nonheap-object 
reference param false positive (authored by cjdb).

Changed prior to commit:
  https://reviews.llvm.org/D102728?vs=360016=360602#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102728

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/warn-free-nonheap-object.cpp


Index: clang/test/Sema/warn-free-nonheap-object.cpp
===
--- clang/test/Sema/warn-free-nonheap-object.cpp
+++ clang/test/Sema/warn-free-nonheap-object.cpp
@@ -10,23 +10,34 @@
 
 int GI;
 
+void free_reference(char ) { ::free(); }
+void free_reference(char &) { ::free(); }
+void std_free_reference(char ) { std::free(); }
+void std_free_reference(char &) { std::free(); }
+
 struct S {
-  operator char *() { return ptr; }
+  operator char *() { return ptr1; }
 
   void CFree() {
-::free(); // expected-warning {{attempt to call free on non-heap 
object 'ptr'}}
-::free();   // expected-warning {{attempt to call free on non-heap 
object 'I'}}
-::free(ptr);
+::free(); // expected-warning {{attempt to call free on non-heap 
object 'ptr1'}}
+::free();// expected-warning {{attempt to call free on non-heap 
object 'I'}}
+::free(ptr1);
+free_reference(*ptr2);
+free_reference(static_cast(*ptr3));
   }
 
   void CXXFree() {
-std::free(); // expected-warning {{attempt to call std::free on 
non-heap object 'ptr'}}
-std::free();   // expected-warning {{attempt to call std::free on 
non-heap object 'I'}}
-std::free(ptr);
+std::free(); // expected-warning {{attempt to call std::free on 
non-heap object 'ptr1'}}
+std::free();// expected-warning {{attempt to call std::free on 
non-heap object 'I'}}
+std::free(ptr1);
+std_free_reference(*ptr2);
+std_free_reference(static_cast(*ptr3));
   }
 
 private:
-  char *ptr = (char *)std::malloc(10);
+  char *ptr1 = (char *)std::malloc(10);
+  char *ptr2 = (char *)std::malloc(10);
+  char *ptr3 = (char *)std::malloc(10);
   static int I;
 };
 
@@ -93,6 +104,14 @@
 void *P = std::malloc(8);
 std::free(P);
   }
+  {
+char* P = (char *)std::malloc(2);
+std_free_reference(*P);
+  }
+  {
+char* P = (char *)std::malloc(2);
+std_free_reference(static_cast(*P));
+  }
   {
 int A[] = {0, 1, 2, 3};
 std::free(A); // expected-warning {{attempt to call std::free on non-heap 
object 'A'}}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -10726,8 +10726,9 @@
  const UnaryOperator *UnaryExpr) {
   if (const auto *Lvalue = dyn_cast(UnaryExpr->getSubExpr())) {
 const Decl *D = Lvalue->getDecl();
-if (isa(D))
-  return CheckFreeArgumentsOnLvalue(S, CalleeName, UnaryExpr, D);
+if (isa(D))
+  if (!dyn_cast(D)->getType()->isReferenceType())
+return CheckFreeArgumentsOnLvalue(S, CalleeName, UnaryExpr, D);
   }
 
   if (const auto *Lvalue = dyn_cast(UnaryExpr->getSubExpr()))


Index: clang/test/Sema/warn-free-nonheap-object.cpp
===
--- clang/test/Sema/warn-free-nonheap-object.cpp
+++ clang/test/Sema/warn-free-nonheap-object.cpp
@@ -10,23 +10,34 @@
 
 int GI;
 
+void free_reference(char ) { ::free(); }
+void free_reference(char &) { ::free(); }
+void std_free_reference(char ) { std::free(); }
+void std_free_reference(char &) { std::free(); }
+
 struct S {
-  operator char *() { return ptr; }
+  operator char *() { return ptr1; }
 
   void CFree() {
-::free(); // expected-warning {{attempt to call free on non-heap object 'ptr'}}
-::free();   // expected-warning {{attempt to call free on non-heap object 'I'}}
-::free(ptr);
+::free(); // expected-warning {{attempt to call free on non-heap object 'ptr1'}}
+::free();// expected-warning {{attempt to call free on non-heap object 'I'}}
+::free(ptr1);
+free_reference(*ptr2);
+free_reference(static_cast(*ptr3));
   }
 
   void CXXFree() {
-std::free(); // expected-warning {{attempt to call std::free on non-heap object 'ptr'}}
-std::free();   // expected-warning {{attempt to call std::free on non-heap object 'I'}}
-std::free(ptr);
+std::free(); // expected-warning {{attempt to call std::free on non-heap object 'ptr1'}}
+std::free();// expected-warning {{attempt to call std::free on non-heap object 'I'}}
+std::free(ptr1);
+std_free_reference(*ptr2);
+std_free_reference(static_cast(*ptr3));
   }
 
 private:
-  char *ptr = (char *)std::malloc(10);
+  char *ptr1 = (char *)std::malloc(10);
+  char *ptr2 = (char 

[clang] 9a72580 - [clang][Sema] removes -Wfree-nonheap-object reference param false positive

2021-07-21 Thread Christopher Di Bella via cfe-commits

Author: Christopher Di Bella
Date: 2021-07-21T21:30:16Z
New Revision: 9a72580a548da8008dca479ec50e4eb75e56db71

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

LOG: [clang][Sema] removes -Wfree-nonheap-object reference param false positive

Taking the address of a reference parameter might be valid, and without
CFA, false positives are going to be more trouble than they're worth.

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

Added: 


Modified: 
clang/lib/Sema/SemaChecking.cpp
clang/test/Sema/warn-free-nonheap-object.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 075fad6476ef..242c2968da45 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -10726,8 +10726,9 @@ void CheckFreeArgumentsAddressof(Sema , const 
std::string ,
  const UnaryOperator *UnaryExpr) {
   if (const auto *Lvalue = dyn_cast(UnaryExpr->getSubExpr())) {
 const Decl *D = Lvalue->getDecl();
-if (isa(D))
-  return CheckFreeArgumentsOnLvalue(S, CalleeName, UnaryExpr, D);
+if (isa(D))
+  if (!dyn_cast(D)->getType()->isReferenceType())
+return CheckFreeArgumentsOnLvalue(S, CalleeName, UnaryExpr, D);
   }
 
   if (const auto *Lvalue = dyn_cast(UnaryExpr->getSubExpr()))

diff  --git a/clang/test/Sema/warn-free-nonheap-object.cpp 
b/clang/test/Sema/warn-free-nonheap-object.cpp
index 9347709a23ca..37dc0fdaad93 100644
--- a/clang/test/Sema/warn-free-nonheap-object.cpp
+++ b/clang/test/Sema/warn-free-nonheap-object.cpp
@@ -10,23 +10,34 @@ void free(void *p);
 
 int GI;
 
+void free_reference(char ) { ::free(); }
+void free_reference(char &) { ::free(); }
+void std_free_reference(char ) { std::free(); }
+void std_free_reference(char &) { std::free(); }
+
 struct S {
-  operator char *() { return ptr; }
+  operator char *() { return ptr1; }
 
   void CFree() {
-::free(); // expected-warning {{attempt to call free on non-heap 
object 'ptr'}}
-::free();   // expected-warning {{attempt to call free on non-heap 
object 'I'}}
-::free(ptr);
+::free(); // expected-warning {{attempt to call free on non-heap 
object 'ptr1'}}
+::free();// expected-warning {{attempt to call free on non-heap 
object 'I'}}
+::free(ptr1);
+free_reference(*ptr2);
+free_reference(static_cast(*ptr3));
   }
 
   void CXXFree() {
-std::free(); // expected-warning {{attempt to call std::free on 
non-heap object 'ptr'}}
-std::free();   // expected-warning {{attempt to call std::free on 
non-heap object 'I'}}
-std::free(ptr);
+std::free(); // expected-warning {{attempt to call std::free on 
non-heap object 'ptr1'}}
+std::free();// expected-warning {{attempt to call std::free on 
non-heap object 'I'}}
+std::free(ptr1);
+std_free_reference(*ptr2);
+std_free_reference(static_cast(*ptr3));
   }
 
 private:
-  char *ptr = (char *)std::malloc(10);
+  char *ptr1 = (char *)std::malloc(10);
+  char *ptr2 = (char *)std::malloc(10);
+  char *ptr3 = (char *)std::malloc(10);
   static int I;
 };
 
@@ -93,6 +104,14 @@ void test2() {
 void *P = std::malloc(8);
 std::free(P);
   }
+  {
+char* P = (char *)std::malloc(2);
+std_free_reference(*P);
+  }
+  {
+char* P = (char *)std::malloc(2);
+std_free_reference(static_cast(*P));
+  }
   {
 int A[] = {0, 1, 2, 3};
 std::free(A); // expected-warning {{attempt to call std::free on non-heap 
object 'A'}}



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


[PATCH] D106005: [Docs] Define matrix initialisation in MatrixTypes documentation

2021-07-21 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/docs/MatrixTypes.rst:279
+The number of constituent arrays must equal the number rows in the matrix type 
M and the number of elements
+in each constituent array must equal the number of columns in the matrix type.
+

This is contradicted by your first example.  I think you want to say something 
like

> A value of matrix type `M` can be initialized with an initializer list:
>
> (examples)
>
> If the initializer list is empty, all elements of the matrix are 
> zero-initialized.  Otherwise, the initializer list must consist of `M::rows` 
> initializer lists, each of which must consist of `M::columns` expressions, 
> each of which is used to initialize the corresponding element of the matrix 
> (that is, `m[i][j]` is initialized by the `j`th expression of the `i`th 
> initializer list in the initializer).  Element designators are not allowed.

That's assuming you want to allow `{}`, but I think that's probably a good 
idea.  At the very least, you already have to define how objects of static 
storage duration are zero-initialized, and having a way to do that explicitly 
always seems wise to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106005

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


[PATCH] D106496: [OpenMP] Change `__kmpc_free_shared` to include the paired allocation size

2021-07-21 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: llvm/test/Transforms/OpenMP/remove_globalization.ll:41
 ; CHECK-NEXT:[[TMP0:%.*]] = alloca i8, i64 4, align 1
+; CHECK-NEXT:call void @__kmpc_free_shared(i8* nocapture [[TMP0]], i64 
noundef 4) #[[ATTR0]]
 ; CHECK-NEXT:ret void

this should not be here. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106496

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


[PATCH] D105703: [hwasan] Use stack safety analysis.

2021-07-21 Thread Florian Mayer via Phabricator via cfe-commits
fmayer added inline comments.



Comment at: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp:410
+Dummy.setArch(Triple::aarch64);
+if (shouldUseStackSafetyAnalysis(Dummy, DisableOptimization))
+  AU.addRequired();

vitalybuka wrote:
> Why not just:
> ```
> if (!DisableOptimization || ClUseStackSafety)
>   AU.addRequired();
> ```
Because `ClUseStackSafety` defaults to true, so this will be quite useless 
except if the user explicitly sets it to false. So then you end up duplicating 
the logic in `shouldUseStackSafetyAnalysis`, which is why I went for the Dummy 
(thinking about it, we don't actually need to setArch on it).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105703

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


[PATCH] D106496: [OpenMP] Change `__kmpc_free_shared` to include the paired allocation size

2021-07-21 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added a reviewer: jdoerfert.
Herald added subscribers: guansong, hiraditya, yaxunl.
jhuber6 requested review of this revision.
Herald added subscribers: llvm-commits, openmp-commits, cfe-commits, sstefan1.
Herald added projects: clang, OpenMP, LLVM.

This patch changes `__kmpc_free_shared` to take an additional argument
corresponding to the associated allocation's size. This makes it easier to
implement the allocator in the runtime.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106496

Files:
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
  clang/test/OpenMP/declare_target_codegen_globalization.cpp
  clang/test/OpenMP/nvptx_data_sharing.cpp
  clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_target_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/nvptx_teams_codegen.cpp
  clang/test/OpenMP/nvptx_teams_reduction_codegen.cpp
  llvm/include/llvm/Analysis/TargetLibraryInfo.def
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Analysis/TargetLibraryInfo.cpp
  llvm/test/Transforms/OpenMP/remove_globalization.ll
  llvm/test/Transforms/OpenMP/replace_globalization.ll
  llvm/unittests/Analysis/TargetLibraryInfoTest.cpp
  openmp/libomptarget/deviceRTLs/common/src/data_sharing.cu
  openmp/libomptarget/deviceRTLs/interface.h

Index: openmp/libomptarget/deviceRTLs/interface.h
===
--- openmp/libomptarget/deviceRTLs/interface.h
+++ openmp/libomptarget/deviceRTLs/interface.h
@@ -467,7 +467,8 @@
 
 /// Deallocate \p Ptr. Needs to be called balanced with __kmpc_alloc_shared like
 /// a stack (push/pop). Can be called by any thread. \p Ptr must be allocated by
-/// __kmpc_alloc_shared by the same thread.
-EXTERN void __kmpc_free_shared(void *Ptr);
+/// __kmpc_alloc_shared by the same thread. \p Bytes contains the size of the
+/// paired allocation to make memory management easier.
+EXTERN void __kmpc_free_shared(void *Ptr, size_t Bytes);
 
 #endif
Index: openmp/libomptarget/deviceRTLs/common/src/data_sharing.cu
===
--- openmp/libomptarget/deviceRTLs/common/src/data_sharing.cu
+++ openmp/libomptarget/deviceRTLs/common/src/data_sharing.cu
@@ -94,7 +94,7 @@
   return __kmpc_alloc_for_warp(AllocGlobal, Bytes, WarpBytes);
 }
 
-EXTERN void __kmpc_free_shared(void *Ptr) {
+EXTERN void __kmpc_free_shared(void *Ptr, size_t /* Bytes */) {
   __kmpc_impl_lanemask_t CurActive = __kmpc_impl_activemask();
   unsigned LeaderID = __kmpc_impl_ffs(CurActive) - 1;
   bool IsWarpLeader = (GetThreadIdInBlock() % WARPSIZE) == LeaderID;
Index: llvm/unittests/Analysis/TargetLibraryInfoTest.cpp
===
--- llvm/unittests/Analysis/TargetLibraryInfoTest.cpp
+++ llvm/unittests/Analysis/TargetLibraryInfoTest.cpp
@@ -589,7 +589,7 @@
 
   // These functions are OpenMP Offloading allocation / free routines
   "declare i8* @__kmpc_alloc_shared(i64)\n"
-  "declare void @__kmpc_free_shared(i8*)\n"
+  "declare void @__kmpc_free_shared(i8*, i64)\n"
   );
 
   for (unsigned FI = 0; FI != LibFunc::NumLibFuncs; ++FI) {
Index: llvm/test/Transforms/OpenMP/replace_globalization.ll
===
--- llvm/test/Transforms/OpenMP/replace_globalization.ll
+++ llvm/test/Transforms/OpenMP/replace_globalization.ll
@@ -25,7 +25,7 @@
   %x_on_stack = bitcast i8* %x to i32*
   %0 = bitcast i32* %x_on_stack to i8*
   call void @use(i8* %0)
-  call void @__kmpc_free_shared(i8* %x)
+  call void @__kmpc_free_shared(i8* %x, i64 4)
   call void @__kmpc_target_deinit(%struct.ident_t* @1, i1 false, i1 true)
   ret void
 }
@@ -50,7 +50,7 @@
   %x_on_stack = bitcast i8* %x to [4 x i32]*
   %0 = bitcast [4 x i32]* %x_on_stack to i8*
   call void @use(i8* %0)
-  call void @__kmpc_free_shared(i8* %x)
+  call void @__kmpc_free_shared(i8* %x, i64 16)
   br label %exit
 exit:
   ret void
@@ -67,7 +67,7 @@
   %y_on_stack = bitcast i8* %y to [4 x i32]*
   %1 = bitcast [4 x i32]* %y_on_stack to i8*
   call void @use(i8* %1)
-  call void @__kmpc_free_shared(i8* %y)
+  call void @__kmpc_free_shared(i8* %y, i64 4)
   br label %exit
 exit:
   ret void
@@ -79,11 +79,11 @@
   %0 = icmp eq i32 %call, -1
   br i1 %0, label %master, label %exit
 master:
-  %y = call i8* @__kmpc_alloc_shared(i64 6), !dbg !12
+  %y = call i8* @__kmpc_alloc_shared(i64 24), !dbg !12
   %y_on_stack = bitcast i8* %y to [6 x i32]*
   %1 = bitcast [6 x 

[PATCH] D105594: cmake: Allow shared libraries to customize the soname using LLVM_ABI_REVISION

2021-07-21 Thread serge via Phabricator via cfe-commits
serge-sans-paille added inline comments.



Comment at: clang/tools/clang-shlib/CMakeLists.txt:2
+# In the main branch, LLVM_ABI_REVISION should always be 0.  In the release
+# branches, this should be incremented before each release candidate every
+# time the ABI of libclang-cpp.so changes.

This comment is a bit misleading: should it be for each RC *or* for each RC 
that implies an ABI change? And what about the (very rare) minor version 
release, like 11.1.0? My understanding is that they implie an SONAME bump, 
maybe that should be stated somewhere?

I think it would be great to have that ABI policy documented somewhere in the 
official doc, and not only as a cmake comment, as every project linking with 
clang or llvm is impacted.



Comment at: llvm/cmake/modules/AddLLVM.cmake:595
 # Since 4.0.0, the ABI version is indicated by the major version
-SOVERSION ${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX}
-VERSION ${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX})
+   SOVERSION ${LLVM_VERSION_MAJOR}.${LLVM_ABI_REVISION}
+   VERSION ${LLVM_VERSION_MAJOR}.${LLVM_ABI_REVISION})

Nit: strange indent.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105594

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


[PATCH] D105703: [hwasan] Use stack safety analysis.

2021-07-21 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp:410
+Dummy.setArch(Triple::aarch64);
+if (shouldUseStackSafetyAnalysis(Dummy, DisableOptimization))
+  AU.addRequired();

Why not just:
```
if (!DisableOptimization || ClUseStackSafety)
  AU.addRequired();
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105703

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


[PATCH] D105491: [clang] Use i64 for the !srcloc metadata on asm IR nodes.

2021-07-21 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In D105491#2893632 , @simon_tatham 
wrote:

> In D105491#2891860 , @dexonsmith 
> wrote:
>
>> although it'd be good to get someone more involved in lib/CodeGen to take a 
>> quick look / sign off (ideally someone that knows the use case for 
>> `!srcloc`...).
>
> Any idea who that might be? Looking through the logs, @lattner seems to have 
> made all the commits that set up `!srcloc` in the first place, and nobody 
> seems to have modified the mechanism much since then.

I wonder if this is even reachable anymore, given that the one testcase is 
inline asm (I believe the frontend catches inline asm errors now) -- I mean, 
CGStmt still attaches these, but maybe the backend never fires a diagnostic in 
practice because the frontend error checking is good enough to avoid emitting 
IR that's broken. (Could be useful for other frontends, maybe, though...)

Anyway, I'm comfortable signing off; feel free to commit without finding 
someone else (remember to add a comment to the testcase).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105491

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


[PATCH] D99350: [OPENMP]Fix PR49649: The introduction of $ref globals is not always valid.

2021-07-21 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 360577.
ABataev added a comment.
Herald added subscribers: openmp-commits, sstefan1.
Herald added a project: OpenMP.

Added runtime test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99350

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/declare_target_codegen.cpp
  openmp/libomptarget/test/offloading/ref_to_shared.cpp


Index: openmp/libomptarget/test/offloading/ref_to_shared.cpp
===
--- /dev/null
+++ openmp/libomptarget/test/offloading/ref_to_shared.cpp
@@ -0,0 +1,17 @@
+// RUN: %libomptarget-compilexx-run-and-check-nvptx64-nvidia-cuda
+// REQUIRES: nvptx64-nvidia-cuda
+
+#include 
+#include 
+#pragma omp declare target
+
+static int X;
+#pragma omp allocate(X) allocator(omp_pteam_mem_alloc)
+
+int main() {
+  // CHECK: PASS
+  std::cout << "PASS\n";
+  return 0;
+}
+
+#pragma omp end declare target
Index: clang/test/OpenMP/declare_target_codegen.cpp
===
--- clang/test/OpenMP/declare_target_codegen.cpp
+++ clang/test/OpenMP/declare_target_codegen.cpp
@@ -43,10 +43,10 @@
 // CHECK-DAG: @c = external global i32,
 // CHECK-DAG: @globals ={{ hidden | }}global %struct.S zeroinitializer,
 // CHECK-DAG: [[STAT:@.+stat]] = internal global %struct.S zeroinitializer,
-// CHECK-DAG: [[STAT_REF:@.+]] = internal constant %struct.S* [[STAT]]
+// CHECK-DAG: [[STAT_REF:@.+]] = internal constant i8* bitcast (%struct.S* 
[[STAT]] to i8*)
 // CHECK-DAG: @out_decl_target ={{ hidden | }}global i32 0,
 // CHECK-DAG: @llvm.used = appending global [2 x i8*] [i8* bitcast (void ()* 
@__omp_offloading__{{.+}}_globals_l[[@LINE+84]]_ctor to i8*), i8* bitcast (void 
()* @__omp_offloading__{{.+}}_stat_l[[@LINE+85]]_ctor to i8*)],
-// CHECK-DAG: @llvm.compiler.used = appending global [1 x i8*] [i8* bitcast 
(%struct.S** [[STAT_REF]] to i8*)],
+// CHECK-DAG: @llvm.compiler.used = appending global [1 x i8*] [i8* bitcast 
(i8** [[STAT_REF]] to i8*)],
 
 // CHECK-DAG: define {{.*}}i32 @{{.*}}{{foo|bar|baz2|baz3|FA|f_method}}{{.*}}()
 // CHECK-DAG: define {{.*}}void 
@{{.*}}TemplateClass{{.*}}(%class.TemplateClass* {{[^,]*}} %{{.*}})
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -10630,11 +10630,13 @@
   std::string RefName = getName({VarName, "ref"});
   if (!CGM.GetGlobalValue(RefName)) {
 llvm::Constant *AddrRef =
-getOrCreateInternalVariable(Addr->getType(), RefName);
+getOrCreateInternalVariable(CGM.VoidPtrTy, RefName);
 auto *GVAddrRef = cast(AddrRef);
 GVAddrRef->setConstant(/*Val=*/true);
 GVAddrRef->setLinkage(llvm::GlobalValue::InternalLinkage);
-GVAddrRef->setInitializer(Addr);
+GVAddrRef->setInitializer(
+llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(
+Addr, CGM.VoidPtrTy));
 CGM.addCompilerUsedGlobal(GVAddrRef);
   }
 }


Index: openmp/libomptarget/test/offloading/ref_to_shared.cpp
===
--- /dev/null
+++ openmp/libomptarget/test/offloading/ref_to_shared.cpp
@@ -0,0 +1,17 @@
+// RUN: %libomptarget-compilexx-run-and-check-nvptx64-nvidia-cuda
+// REQUIRES: nvptx64-nvidia-cuda
+
+#include 
+#include 
+#pragma omp declare target
+
+static int X;
+#pragma omp allocate(X) allocator(omp_pteam_mem_alloc)
+
+int main() {
+  // CHECK: PASS
+  std::cout << "PASS\n";
+  return 0;
+}
+
+#pragma omp end declare target
Index: clang/test/OpenMP/declare_target_codegen.cpp
===
--- clang/test/OpenMP/declare_target_codegen.cpp
+++ clang/test/OpenMP/declare_target_codegen.cpp
@@ -43,10 +43,10 @@
 // CHECK-DAG: @c = external global i32,
 // CHECK-DAG: @globals ={{ hidden | }}global %struct.S zeroinitializer,
 // CHECK-DAG: [[STAT:@.+stat]] = internal global %struct.S zeroinitializer,
-// CHECK-DAG: [[STAT_REF:@.+]] = internal constant %struct.S* [[STAT]]
+// CHECK-DAG: [[STAT_REF:@.+]] = internal constant i8* bitcast (%struct.S* [[STAT]] to i8*)
 // CHECK-DAG: @out_decl_target ={{ hidden | }}global i32 0,
 // CHECK-DAG: @llvm.used = appending global [2 x i8*] [i8* bitcast (void ()* @__omp_offloading__{{.+}}_globals_l[[@LINE+84]]_ctor to i8*), i8* bitcast (void ()* @__omp_offloading__{{.+}}_stat_l[[@LINE+85]]_ctor to i8*)],
-// CHECK-DAG: @llvm.compiler.used = appending global [1 x i8*] [i8* bitcast (%struct.S** [[STAT_REF]] to i8*)],
+// CHECK-DAG: @llvm.compiler.used = appending global [1 x i8*] [i8* bitcast (i8** [[STAT_REF]] to i8*)],
 
 // CHECK-DAG: define {{.*}}i32 @{{.*}}{{foo|bar|baz2|baz3|FA|f_method}}{{.*}}()
 // CHECK-DAG: define {{.*}}void 

[PATCH] D105151: [OPENMP]Fix PR50733: unexpected final value of list-item in linear clause in loop construct.

2021-07-21 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 360573.
ABataev added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105151

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/for_linear_codegen.cpp
  clang/test/OpenMP/for_simd_codegen.cpp
  clang/test/OpenMP/parallel_for_linear_codegen.cpp
  clang/test/OpenMP/parallel_for_simd_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/simd_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp

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


[PATCH] D106349: [clang-format] respect AfterEnum for enums

2021-07-21 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

In D106349#2893672 , @MyDeveloperDay 
wrote:

> This feels like there is some overlap with D93938: [clang-format] Fixed 
> AfterEnum handling 

Yeah that may be, but it is stale for over a month, with I think open 
questions. So if this here fixes at least one bug with no obvious new ones, I 
think we should go for it.

Regarding the patch: Please upload it with the context available. 
https://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106349

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


[PATCH] D106394: [clang][pp] adds '#pragma include_instead'

2021-07-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D106394#2893457 , @ldionne wrote:

> In D106394#2892832 , @sammccall 
> wrote:
>
>> Eventually this seems like a reasonable thing to want for user code. What 
>> are your motivations for restricting it to system headers? (And do you think 
>> people in future will be tempted to lift them?)
>
> The problem with extending this to non-system headers is that you need a way 
> to tell which headers are allowed to include the detail headers and which 
> ones are not.

Ah, of course. It's a shame if this is a fatal reason because it seems like a 
small thing.

IWYU defines a whole bunch of other "pragmas", and one is "IWYU pragma: friend" 
for this purpose. This works but adds complexity to the source code (I didn't 
see it being as heavy as defining modules, but I haven't thought about it much) 
and also to consuming tools (we don't support it in clangd for this reason).

Annotating the include site instead like `#include "internals.h" // friend` 
seems almost tempting but magic-comments issues aside doesn't solve all the 
questions tools have (like what include to insert if none exists yet).

> Hmm... I like prior art. That clangd supports it suggests that there's a 
> section of code I can look at for inspiration if we were to replace this 
> pragma with the IWYU comment-pragma

Sure, there's nothing terribly interesting to see though. Clangd doesn't yet 
use it for warnings, but sometimes when we encounter an indexed symbol we 
consider inserting an `#include` for it (code completion, fixit for missing 
symbol). At indexing time the IWYU pragma is used to determine which insertable 
header we'll record for that symbol.

Indexing 1 

 - parse an IWYU comment. Note that it always produces a quoted string, which 
means a verbatim `#include` spelling, rather than a resolved file path, thus 
the FIXME.
Indexing 2 

 - determine the includable header for symbols from a FileID.
(The code completion and diagnostic fixit code isn't terribly interesting or 
readable...)

> (I wonder why they didn't just go with #pragma IWYU ...?).

Historically, it may have been the principled reason @Quuxplusone mentioned, or 
it may simply have been that as an *out-of-tree* clang-based tool, it's easier 
to hook comments in PPCallbacks than it is to hook an unknown pragma. (Of 
course these reasons are connected)

> If IWYU has already developed a de facto standard for this information, I 
> would recommend libc++ just use it (perhaps with no changes needed in clang 
> at all).

One hesitation I'd have about adopting this convention is that while the "IWYU 
pragma: friend" subset seems to coincide exactly with the design you want, the 
full set of IWYU pragmas are a rich/complicated set that I'm less confident in 
the design of.
Supporting only this subset will cause *some* confusion/pressure for more, but 
later choosing to extend the model will force a choice between adopting more 
IWYU pragmas (may be the wrong design) or doing something else with overlapping 
functionality (lots of confusion).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106394

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


[PATCH] D104556: [InstrProfiling] Make CountersPtr in __profd_ relative

2021-07-21 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

@davidxl @vsk 

I am happy to postpone this after 13.0.0 is branched - so that we can adjust 
the format while only bumping the version once.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104556

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


[PATCH] D106484: [PowerPC] Add PowerPC "__stbcx" builtin and intrinsic for XL compatibility

2021-07-21 Thread Victor Huang via Phabricator via cfe-commits
NeHuang created this revision.
NeHuang added reviewers: nemanjai, PowerPC.
NeHuang added a project: LLVM.
Herald added subscribers: shchenz, kbarton, hiraditya.
NeHuang requested review of this revision.
Herald added a project: clang.
Herald added subscribers: llvm-commits, cfe-commits.

This patch is in a series of patches to provide builtins for compatibility with 
the XL compiler. 
This patch adds the builtin and intrinsic for  "__stbcx".


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106484

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-ppc-xlcompat-pwr8.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstrInfo.td
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond.ll

Index: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond.ll
===
--- llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond.ll
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond.ll
@@ -50,3 +50,25 @@
   %1 = tail call i32 @llvm.ppc.stwcx(i8* %0, i32 %b)
   ret i32 %1
 }
+
+declare i32 @llvm.ppc.stbcx(i8*, i32)
+define signext i32 @test_stbcx(i8* %addr, i8 signext %val) {
+; CHECK-64-LABEL: test_stbcx:
+; CHECK-64:   # %bb.0: # %entry
+; CHECK-64-NEXT:stbcx. 4, 0, 3
+; CHECK-64-NEXT:mfocrf 3, 128
+; CHECK-64-NEXT:srwi 3, 3, 28
+; CHECK-64-NEXT:extsw 3, 3
+; CHECK-64-NEXT:blr
+;
+; CHECK-32-LABEL: test_stbcx:
+; CHECK-32:   # %bb.0: # %entry
+; CHECK-32-NEXT:stbcx. 4, 0, 3
+; CHECK-32-NEXT:mfocrf 3, 128
+; CHECK-32-NEXT:srwi 3, 3, 28
+; CHECK-32-NEXT:blr
+entry:
+  %conv = sext i8 %val to i32
+  %0 = tail call i32 @llvm.ppc.stbcx(i8* %addr, i32 %conv)
+  ret i32 %0
+}
Index: llvm/lib/Target/PowerPC/PPCInstrInfo.td
===
--- llvm/lib/Target/PowerPC/PPCInstrInfo.td
+++ llvm/lib/Target/PowerPC/PPCInstrInfo.td
@@ -5459,6 +5459,8 @@
 
 def : Pat<(int_ppc_stwcx ForceXForm:$dst, gprc:$A),
   (STWCX gprc:$A, ForceXForm:$dst)>;
+def : Pat<(int_ppc_stbcx ForceXForm:$dst, gprc:$A),
+  (STBCX gprc:$A, ForceXForm:$dst)>;
 def : Pat<(int_ppc_tw gprc:$A, gprc:$B, i32:$IMM),
   (TW $IMM, $A, $B)>;
 def : Pat<(int_ppc_trap gprc:$A),
Index: llvm/include/llvm/IR/IntrinsicsPowerPC.td
===
--- llvm/include/llvm/IR/IntrinsicsPowerPC.td
+++ llvm/include/llvm/IR/IntrinsicsPowerPC.td
@@ -1559,6 +1559,9 @@
   Intrinsic<[],[],[]>;
   def int_ppc_iospace_eieio : GCCBuiltin<"__builtin_ppc_iospace_eieio">,
   Intrinsic<[],[],[]>;
+  def int_ppc_stbcx : GCCBuiltin<"__builtin_ppc_stbcx">,
+  Intrinsic<[llvm_i32_ty], [llvm_ptr_ty, llvm_i32_ty],
+[IntrWriteMem]>;
   def int_ppc_stdcx : GCCBuiltin<"__builtin_ppc_stdcx">,
   Intrinsic<[llvm_i32_ty], [llvm_ptr_ty, llvm_i64_ty],
 [IntrWriteMem]>;
Index: clang/test/CodeGen/builtins-ppc-xlcompat-pwr8.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-ppc-xlcompat-pwr8.c
@@ -0,0 +1,31 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -emit-llvm %s \
+// RUN:   -target-cpu pwr8 -o - | FileCheck %s --check-prefix=CHECK-PWR8
+// RUN: %clang_cc1 -triple powerpc64le-unknown-unknown -emit-llvm %s \
+// RUN:   -target-cpu pwr8 -o - | FileCheck %s --check-prefix=CHECK-PWR8
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix -emit-llvm %s \
+// RUN:   -target-cpu pwr8 -o - | FileCheck %s --check-prefix=CHECK-PWR8
+// RUN: %clang_cc1 -triple powerpc-unknown-aix %s -emit-llvm %s \
+// RUN:   -target-cpu pwr8 -o - | FileCheck %s --check-prefix=CHECK-PWR8
+// RUN: not %clang_cc1 -triple powerpc64-unknown-unknown -emit-llvm %s \
+// RUN:   -target-cpu pwr7 -o - 2>&1 | FileCheck %s -check-prefix=CHECK-NOPWR8
+// RUN: not %clang_cc1 -triple powerpc64-unknown-aix -emit-llvm %s \
+// RUN:   -target-cpu pwr7 -o - 2>&1 | FileCheck %s -check-prefix=CHECK-NOPWR8
+// RUN: not %clang_cc1 -triple powerpc-unknown-aix %s -emit-llvm %s \
+// RUN:   -target-cpu pwr7 -o - 2>&1 | FileCheck %s -check-prefix=CHECK-NOPWR8
+
+extern volatile char *c_addr;
+extern char c;
+
+// CHECK-PWR8-LABEL: @test_builtin_ppc_stbcx(
+// CHECK-PWR8: [[TMP0:%.*]] = load i8*, i8** @c_addr, align {{[0-9]+}}
+// CHECK-PWR8-NEXT:[[TMP1:%.*]] = load i8, i8* @c, align 1
+// CHECK-PWR8-NEXT:[[TMP2:%.*]] = sext i8 [[TMP1]] to i32
+// CHECK-PWR8-NEXT:[[TMP3:%.*]] = call i32 @llvm.ppc.stbcx(i8* [[TMP0]], i32 [[TMP2]])
+// CHECK-PWR8-NEXT:ret i32 [[TMP3]]
+
+// CHECK-NOPWR8: error: this builtin is only valid on POWER8 or later CPUs
+

[PATCH] D99350: [OPENMP]Fix PR49649: The introduction of $ref globals is not always valid.

2021-07-21 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D99350#2894305 , @jdoerfert wrote:

> I don't understand why the cast makes ptxas happy, can you include a test in 
> the runtime so we can make sure that stays that way and is not some ptxas 
> artifact. After all, we still point to a shared memory symbol from global 
> memory which doesn't make too much sense.

Here is the related info 
https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#initializers. 
Take a look at the Examples:

.const  .u32 foo = 42;
  ...
.global .u32 p2 = generic(foo); // generic address of foo

After the patch, we have this:

  .shared .align 4 .u32 _ZL1X;
  .global .align 8 .u64 __ZL1X$ref = generic(_ZL1X);

which is similar to the example.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99350

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


[clang] 9643d11 - [clang][sema] NFC, include DarwinSDKInfo header instead of using the forward reference

2021-07-21 Thread Alex Lorenz via cfe-commits

Author: Alex Lorenz
Date: 2021-07-21T12:46:52-07:00
New Revision: 9643d11e1d7f918c0e5184c9488935720d591c90

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

LOG: [clang][sema] NFC, include DarwinSDKInfo header instead of using the 
forward reference

This fixes a build issue with an older libc++ on some bots: 
clang-cmake-x86_64-avx2-linux and clang-ppc64be-linux

Added: 


Modified: 
clang/include/clang/Sema/Sema.h

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index c200b9b24681..013722cfbe1e 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -37,6 +37,7 @@
 #include "clang/AST/TypeOrdering.h"
 #include "clang/Basic/BitmaskEnum.h"
 #include "clang/Basic/Builtins.h"
+#include "clang/Basic/DarwinSDKInfo.h"
 #include "clang/Basic/ExpressionTraits.h"
 #include "clang/Basic/Module.h"
 #include "clang/Basic/OpenCLOptions.h"
@@ -115,7 +116,6 @@ namespace clang {
   class CodeCompletionTUInfo;
   class CodeCompletionResult;
   class CoroutineBodyStmt;
-  class DarwinSDKInfo;
   class Decl;
   class DeclAccessPair;
   class DeclContext;



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


[PATCH] D105297: [OPENMP]Fix PR50347: Mapping of global scope deep object fails.

2021-07-21 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 360563.
ABataev added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105297

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/target_codegen.cpp
  clang/test/OpenMP/target_data_codegen.cpp
  clang/test/OpenMP/target_data_map_pointer_array_subscript_codegen.cpp
  clang/test/OpenMP/target_data_use_device_addr_codegen.cpp
  clang/test/OpenMP/target_defaultmap_codegen_01.cpp
  clang/test/OpenMP/target_enter_data_codegen.cpp
  clang/test/OpenMP/target_enter_data_depend_codegen.cpp
  clang/test/OpenMP/target_exit_data_codegen.cpp
  clang/test/OpenMP/target_exit_data_depend_codegen.cpp
  clang/test/OpenMP/target_firstprivate_codegen.cpp
  clang/test/OpenMP/target_map_codegen_12.cpp
  clang/test/OpenMP/target_map_codegen_13.cpp
  clang/test/OpenMP/target_map_codegen_14.cpp
  clang/test/OpenMP/target_map_codegen_18.inc
  clang/test/OpenMP/target_map_codegen_20.cpp
  clang/test/OpenMP/target_map_codegen_23.cpp
  clang/test/OpenMP/target_map_codegen_28.cpp
  clang/test/OpenMP/target_map_codegen_29.cpp
  clang/test/OpenMP/target_map_codegen_31.cpp
  clang/test/OpenMP/target_map_codegen_32.cpp
  clang/test/OpenMP/target_map_codegen_34.cpp
  clang/test/OpenMP/target_map_codegen_35.cpp
  clang/test/OpenMP/target_map_member_expr_array_section_codegen.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_simd_codegen.cpp
  clang/test/OpenMP/target_teams_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_dist_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_collapse_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_dist_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_schedule_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_collapse_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_dist_schedule_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_dist_schedule_codegen.cpp
  clang/test/OpenMP/target_update_codegen.cpp
  clang/test/OpenMP/target_update_depend_codegen.cpp
  clang/test/OpenMP/teams_distribute_codegen.cpp
  clang/test/OpenMP/teams_distribute_collapse_codegen.cpp
  clang/test/OpenMP/teams_distribute_dist_schedule_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_collapse_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_dist_schedule_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_schedule_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_collapse_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_dist_schedule_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_schedule_codegen.cpp
  clang/test/OpenMP/teams_distribute_simd_codegen.cpp
  clang/test/OpenMP/teams_distribute_simd_collapse_codegen.cpp
  clang/test/OpenMP/teams_distribute_simd_dist_schedule_codegen.cpp
  clang/test/OpenMP/teams_firstprivate_codegen.cpp

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


[PATCH] D99350: [OPENMP]Fix PR49649: The introduction of $ref globals is not always valid.

2021-07-21 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

I don't understand why the cast makes ptxas happy, can you include a test in 
the runtime so we can make sure that stays that way and is not some ptxas 
artifact. After all, we still point to a shared memory symbol from global 
memory which doesn't make too much sense.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99350

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


[PATCH] D106069: [HIP] Add test with_fopenmp.hip

2021-07-21 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rTd9107edc1a4e: [HIP] Add test with_fopenmp.hip (authored by 
yaxunl).

Repository:
  rT test-suite

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

https://reviews.llvm.org/D106069

Files:
  External/HIP/CMakeLists.txt
  External/HIP/with-fopenmp.hip
  External/HIP/with-fopenmp.reference_output


Index: External/HIP/with-fopenmp.reference_output
===
--- /dev/null
+++ External/HIP/with-fopenmp.reference_output
@@ -0,0 +1,2 @@
+PASSED!
+exit 0
Index: External/HIP/with-fopenmp.hip
===
--- /dev/null
+++ External/HIP/with-fopenmp.hip
@@ -0,0 +1,33 @@
+#include 
+#include 
+
+// Test use of std::isnan in device and host code.
+
+namespace TestIsNan {
+__device__ bool DevPass = false;
+
+__global__ void kernel() {
+  double X = 1.0;
+  DevPass = !std::isnan(X);
+}
+
+bool test() {
+  double X = 1.0;
+  kernel<<<1, 1>>>();
+  bool Pass;
+  hipMemcpyFromSymbol(, DevPass, sizeof(DevPass));
+  return Pass & !std::isnan(X);
+}
+}
+
+int main() {
+  bool Pass = TestIsNan::test();
+
+  if (!Pass) {
+printf("FAILED!\n");
+return 1;
+  }
+
+  printf("PASSED!\n");
+  return 0;
+}
Index: External/HIP/CMakeLists.txt
===
--- External/HIP/CMakeLists.txt
+++ External/HIP/CMakeLists.txt
@@ -5,8 +5,12 @@
 # Create targets for HIP tests that are part of the test suite.
 macro(create_local_hip_tests VariantSuffix)
   set(VariantOffload "hip")
+  # Set per-source compilation/link options
+  set_source_files_properties(with_fopenmp.hip PROPERTIES
+COMPILE_FLAGS -fopenmp)
   # Add HIP tests to be added to hip-tests-simple
   list(APPEND HIP_LOCAL_TESTS empty)
+  list(APPEND HIP_LOCAL_TESTS with_fopenmp)
   list(APPEND HIP_LOCAL_TESTS saxpy)
   foreach(_hip_test IN LISTS HIP_LOCAL_TESTS)
 create_one_local_test(${_hip_test} ${_hip_test}.hip


Index: External/HIP/with-fopenmp.reference_output
===
--- /dev/null
+++ External/HIP/with-fopenmp.reference_output
@@ -0,0 +1,2 @@
+PASSED!
+exit 0
Index: External/HIP/with-fopenmp.hip
===
--- /dev/null
+++ External/HIP/with-fopenmp.hip
@@ -0,0 +1,33 @@
+#include 
+#include 
+
+// Test use of std::isnan in device and host code.
+
+namespace TestIsNan {
+__device__ bool DevPass = false;
+
+__global__ void kernel() {
+  double X = 1.0;
+  DevPass = !std::isnan(X);
+}
+
+bool test() {
+  double X = 1.0;
+  kernel<<<1, 1>>>();
+  bool Pass;
+  hipMemcpyFromSymbol(, DevPass, sizeof(DevPass));
+  return Pass & !std::isnan(X);
+}
+}
+
+int main() {
+  bool Pass = TestIsNan::test();
+
+  if (!Pass) {
+printf("FAILED!\n");
+return 1;
+  }
+
+  printf("PASSED!\n");
+  return 0;
+}
Index: External/HIP/CMakeLists.txt
===
--- External/HIP/CMakeLists.txt
+++ External/HIP/CMakeLists.txt
@@ -5,8 +5,12 @@
 # Create targets for HIP tests that are part of the test suite.
 macro(create_local_hip_tests VariantSuffix)
   set(VariantOffload "hip")
+  # Set per-source compilation/link options
+  set_source_files_properties(with_fopenmp.hip PROPERTIES
+COMPILE_FLAGS -fopenmp)
   # Add HIP tests to be added to hip-tests-simple
   list(APPEND HIP_LOCAL_TESTS empty)
+  list(APPEND HIP_LOCAL_TESTS with_fopenmp)
   list(APPEND HIP_LOCAL_TESTS saxpy)
   foreach(_hip_test IN LISTS HIP_LOCAL_TESTS)
 create_one_local_test(${_hip_test} ${_hip_test}.hip
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99350: [OPENMP]Fix PR49649: The introduction of $ref globals is not always valid.

2021-07-21 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 360558.
ABataev added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99350

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/declare_target_codegen.cpp


Index: clang/test/OpenMP/declare_target_codegen.cpp
===
--- clang/test/OpenMP/declare_target_codegen.cpp
+++ clang/test/OpenMP/declare_target_codegen.cpp
@@ -43,10 +43,10 @@
 // CHECK-DAG: @c = external global i32,
 // CHECK-DAG: @globals ={{ hidden | }}global %struct.S zeroinitializer,
 // CHECK-DAG: [[STAT:@.+stat]] = internal global %struct.S zeroinitializer,
-// CHECK-DAG: [[STAT_REF:@.+]] = internal constant %struct.S* [[STAT]]
+// CHECK-DAG: [[STAT_REF:@.+]] = internal constant i8* bitcast (%struct.S* 
[[STAT]] to i8*)
 // CHECK-DAG: @out_decl_target ={{ hidden | }}global i32 0,
 // CHECK-DAG: @llvm.used = appending global [2 x i8*] [i8* bitcast (void ()* 
@__omp_offloading__{{.+}}_globals_l[[@LINE+84]]_ctor to i8*), i8* bitcast (void 
()* @__omp_offloading__{{.+}}_stat_l[[@LINE+85]]_ctor to i8*)],
-// CHECK-DAG: @llvm.compiler.used = appending global [1 x i8*] [i8* bitcast 
(%struct.S** [[STAT_REF]] to i8*)],
+// CHECK-DAG: @llvm.compiler.used = appending global [1 x i8*] [i8* bitcast 
(i8** [[STAT_REF]] to i8*)],
 
 // CHECK-DAG: define {{.*}}i32 @{{.*}}{{foo|bar|baz2|baz3|FA|f_method}}{{.*}}()
 // CHECK-DAG: define {{.*}}void 
@{{.*}}TemplateClass{{.*}}(%class.TemplateClass* {{[^,]*}} %{{.*}})
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -10630,11 +10630,13 @@
   std::string RefName = getName({VarName, "ref"});
   if (!CGM.GetGlobalValue(RefName)) {
 llvm::Constant *AddrRef =
-getOrCreateInternalVariable(Addr->getType(), RefName);
+getOrCreateInternalVariable(CGM.VoidPtrTy, RefName);
 auto *GVAddrRef = cast(AddrRef);
 GVAddrRef->setConstant(/*Val=*/true);
 GVAddrRef->setLinkage(llvm::GlobalValue::InternalLinkage);
-GVAddrRef->setInitializer(Addr);
+GVAddrRef->setInitializer(
+llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(
+Addr, CGM.VoidPtrTy));
 CGM.addCompilerUsedGlobal(GVAddrRef);
   }
 }


Index: clang/test/OpenMP/declare_target_codegen.cpp
===
--- clang/test/OpenMP/declare_target_codegen.cpp
+++ clang/test/OpenMP/declare_target_codegen.cpp
@@ -43,10 +43,10 @@
 // CHECK-DAG: @c = external global i32,
 // CHECK-DAG: @globals ={{ hidden | }}global %struct.S zeroinitializer,
 // CHECK-DAG: [[STAT:@.+stat]] = internal global %struct.S zeroinitializer,
-// CHECK-DAG: [[STAT_REF:@.+]] = internal constant %struct.S* [[STAT]]
+// CHECK-DAG: [[STAT_REF:@.+]] = internal constant i8* bitcast (%struct.S* [[STAT]] to i8*)
 // CHECK-DAG: @out_decl_target ={{ hidden | }}global i32 0,
 // CHECK-DAG: @llvm.used = appending global [2 x i8*] [i8* bitcast (void ()* @__omp_offloading__{{.+}}_globals_l[[@LINE+84]]_ctor to i8*), i8* bitcast (void ()* @__omp_offloading__{{.+}}_stat_l[[@LINE+85]]_ctor to i8*)],
-// CHECK-DAG: @llvm.compiler.used = appending global [1 x i8*] [i8* bitcast (%struct.S** [[STAT_REF]] to i8*)],
+// CHECK-DAG: @llvm.compiler.used = appending global [1 x i8*] [i8* bitcast (i8** [[STAT_REF]] to i8*)],
 
 // CHECK-DAG: define {{.*}}i32 @{{.*}}{{foo|bar|baz2|baz3|FA|f_method}}{{.*}}()
 // CHECK-DAG: define {{.*}}void @{{.*}}TemplateClass{{.*}}(%class.TemplateClass* {{[^,]*}} %{{.*}})
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -10630,11 +10630,13 @@
   std::string RefName = getName({VarName, "ref"});
   if (!CGM.GetGlobalValue(RefName)) {
 llvm::Constant *AddrRef =
-getOrCreateInternalVariable(Addr->getType(), RefName);
+getOrCreateInternalVariable(CGM.VoidPtrTy, RefName);
 auto *GVAddrRef = cast(AddrRef);
 GVAddrRef->setConstant(/*Val=*/true);
 GVAddrRef->setLinkage(llvm::GlobalValue::InternalLinkage);
-GVAddrRef->setInitializer(Addr);
+GVAddrRef->setInitializer(
+llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(
+Addr, CGM.VoidPtrTy));
 CGM.addCompilerUsedGlobal(GVAddrRef);
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99436: [OPENMP]Fix PR49366: crash on VLAs in task untied regions.

2021-07-21 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 360553.
ABataev added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99436

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/OpenMP/task_messages.cpp
  clang/test/OpenMP/taskloop_loop_messages.cpp

Index: clang/test/OpenMP/taskloop_loop_messages.cpp
===
--- clang/test/OpenMP/taskloop_loop_messages.cpp
+++ clang/test/OpenMP/taskloop_loop_messages.cpp
@@ -691,7 +691,7 @@
 
 void test_loop_eh() {
   const int N = 100;
-  float a[N], b[N], c[N];
+  float a[N], b[N], c[N]; // expected-note {{declared here}}
 #pragma omp parallel
 #pragma omp taskloop
   for (int i = 0; i < 10; i++) {
@@ -729,6 +729,13 @@
   void g() { throw 0; }
 };
   }
+// expected-error@+5 {{variable length arrays are not supported in OpenMP tasking regions with 'untied' clause}}
+// expected-note@+4 {{read of non-constexpr variable 'c' is not allowed in a constant expression}}
+#pragma omp taskloop untied
+  {
+  for (int i = 0; i < 10; ++i)
+int array[(int)c[0]];
+  }
 }
 
 void test_loop_firstprivate_lastprivate() {
Index: clang/test/OpenMP/task_messages.cpp
===
--- clang/test/OpenMP/task_messages.cpp
+++ clang/test/OpenMP/task_messages.cpp
@@ -173,7 +173,7 @@
   int  = a;
   S sa;
   S  = sa;
-  int r;
+  int r; // expected-note {{declared here}}
 #pragma omp task { // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
   foo();
 #pragma omp task( // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
@@ -330,6 +330,12 @@
 // expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'mergeable' clause}}
 #pragma omp task mergeable mergeable
   ++r;
+// expected-error@+4 {{variable length arrays are not supported in OpenMP tasking regions with 'untied' clause}}
+// expected-note@+3 {{read of non-const variable 'r' is not allowed in a constant expression}}
+#pragma omp task untied
+  {
+int array[r];
+  }
   volatile omp_event_handle_t evt;
   omp_event_handle_t sevt;
   const omp_event_handle_t cevt = evt;
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2443,6 +2443,9 @@
   } else if (isSFINAEContext()) {
 VLADiag = diag::err_vla_in_sfinae;
 VLAIsError = true;
+  } else if (getLangOpts().OpenMP && isInOpenMPTaskUntiedContext()) {
+VLADiag = diag::err_openmp_vla_in_task_untied;
+VLAIsError = true;
   } else {
 VLADiag = diag::ext_vla;
 VLAIsError = false;
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -174,6 +174,7 @@
 bool HasMutipleLoops = false;
 const Decl *PossiblyLoopCounter = nullptr;
 bool NowaitRegion = false;
+bool UntiedRegion = false;
 bool CancelRegion = false;
 bool LoopStart = false;
 bool BodyComplete = false;
@@ -841,6 +842,15 @@
   return Parent->NowaitRegion;
 return false;
   }
+  /// Marks current region as untied (it has a 'untied' clause).
+  void setUntiedRegion(bool IsUntied = true) {
+getTopOfStack().UntiedRegion = IsUntied;
+  }
+  /// Return true if current region is untied.
+  bool isUntiedRegion() const {
+const SharingMapTy *Top = getTopOfStackOrNull();
+return Top ? Top->UntiedRegion : false;
+  }
   /// Marks parent region as cancel region.
   void setParentCancelRegion(bool Cancel = true) {
 if (SharingMapTy *Parent = getSecondOnStackOrNull())
@@ -2154,6 +2164,11 @@
   return DSAStack->getNestingLevel();
 }
 
+bool Sema::isInOpenMPTaskUntiedContext() const {
+  return isOpenMPTaskingDirective(DSAStack->getCurrentDirective()) &&
+ DSAStack->isUntiedRegion();
+}
+
 bool Sema::isInOpenMPTargetExecutionDirective() const {
   return (isOpenMPTargetExecutionDirective(DSAStack->getCurrentDirective()) &&
   !DSAStack->isClauseParsingMode()) ||
@@ -15046,6 +15061,7 @@
 
 OMPClause *Sema::ActOnOpenMPUntiedClause(SourceLocation StartLoc,
  SourceLocation EndLoc) {
+  DSAStack->setUntiedRegion();
   return new (Context) OMPUntiedClause(StartLoc, EndLoc);
 }
 
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -10542,6 +10542,10 @@
   void finalizeOpenMPDelayedAnalysis(const FunctionDecl *Caller,
  const FunctionDecl *Callee,
  SourceLocation Loc);
+
+  /// Return true if 

[PATCH] D106070: [HIP] Remove workaround in __clang_hip_runtime_wrapper.h

2021-07-21 Thread Yaxun Liu 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 rGdb5f100fe4ca: [HIP] Remove workaround in 
__clang_hip_runtime_wrapper.h (authored by yaxunl).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106070

Files:
  clang/lib/Headers/__clang_hip_runtime_wrapper.h


Index: clang/lib/Headers/__clang_hip_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_hip_runtime_wrapper.h
+++ clang/lib/Headers/__clang_hip_runtime_wrapper.h
@@ -101,7 +101,6 @@
 #include <__clang_hip_libdevice_declares.h>
 #include <__clang_hip_math.h>
 
-#if !_OPENMP || __HIP_ENABLE_CUDA_WRAPPER_FOR_OPENMP__
 #if defined(__HIPCC_RTC__)
 #include <__clang_hip_cmath.h>
 #else
@@ -112,7 +111,6 @@
 #include 
 #include 
 #endif // __HIPCC_RTC__
-#endif // !_OPENMP || __HIP_ENABLE_CUDA_WRAPPER_FOR_OPENMP__
 
 #define __CLANG_HIP_RUNTIME_WRAPPER_INCLUDED__ 1
 #if defined(__HIPCC_RTC__)


Index: clang/lib/Headers/__clang_hip_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_hip_runtime_wrapper.h
+++ clang/lib/Headers/__clang_hip_runtime_wrapper.h
@@ -101,7 +101,6 @@
 #include <__clang_hip_libdevice_declares.h>
 #include <__clang_hip_math.h>
 
-#if !_OPENMP || __HIP_ENABLE_CUDA_WRAPPER_FOR_OPENMP__
 #if defined(__HIPCC_RTC__)
 #include <__clang_hip_cmath.h>
 #else
@@ -112,7 +111,6 @@
 #include 
 #include 
 #endif // __HIPCC_RTC__
-#endif // !_OPENMP || __HIP_ENABLE_CUDA_WRAPPER_FOR_OPENMP__
 
 #define __CLANG_HIP_RUNTIME_WRAPPER_INCLUDED__ 1
 #if defined(__HIPCC_RTC__)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] db5f100 - [HIP] Remove workaround in __clang_hip_runtime_wrapper.h

2021-07-21 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2021-07-21T15:16:28-04:00
New Revision: db5f100fe4ca252d7f392659e7da5dba10331ae7

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

LOG: [HIP] Remove workaround in __clang_hip_runtime_wrapper.h

Remove the workaround for -fopenmp in __clang_hip_runtime_wrapper.h
since it causes device functions in HIP wrapper headers disabled when
compiling HIP program with -fopenmp.

Reviewed by: Aaron Enye Shi, Jon Chesterfield

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

Added: 


Modified: 
clang/lib/Headers/__clang_hip_runtime_wrapper.h

Removed: 




diff  --git a/clang/lib/Headers/__clang_hip_runtime_wrapper.h 
b/clang/lib/Headers/__clang_hip_runtime_wrapper.h
index 6aefbeaec566f..59d5cfef2df83 100644
--- a/clang/lib/Headers/__clang_hip_runtime_wrapper.h
+++ b/clang/lib/Headers/__clang_hip_runtime_wrapper.h
@@ -101,7 +101,6 @@ typedef __SIZE_TYPE__ size_t;
 #include <__clang_hip_libdevice_declares.h>
 #include <__clang_hip_math.h>
 
-#if !_OPENMP || __HIP_ENABLE_CUDA_WRAPPER_FOR_OPENMP__
 #if defined(__HIPCC_RTC__)
 #include <__clang_hip_cmath.h>
 #else
@@ -112,7 +111,6 @@ typedef __SIZE_TYPE__ size_t;
 #include 
 #include 
 #endif // __HIPCC_RTC__
-#endif // !_OPENMP || __HIP_ENABLE_CUDA_WRAPPER_FOR_OPENMP__
 
 #define __CLANG_HIP_RUNTIME_WRAPPER_INCLUDED__ 1
 #if defined(__HIPCC_RTC__)



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


[PATCH] D71734: [Modules] Handle tag types and complain about bad merges in C/Objective-C mode

2021-07-21 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added inline comments.



Comment at: clang/lib/Serialization/ASTReaderDecl.cpp:818
+// performance.
+RecordDecl *Canon = static_cast(RD->getCanonicalDecl());
+if (RD == Canon || Canon->getODRHash() == RD->getODRHash())

During investigation of a different issue noticed there is no error for the 
following test case

```lang=c++
#if defined(FIRST)
typedef struct FW FW;
struct FW {
  int x;
};
#elif defined(SECOND)
struct FW {
  float a;
};
#else
struct FW fw;
#endif
```

And that is because `Canon` is a forward declaration from the typedef and we 
don't compare non-definition with definition.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71734

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


[PATCH] D105257: [clang][darwin] add support for remapping macOS availability to Mac Catalyst availability

2021-07-21 Thread Alex Lorenz 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 rGeb26ba9da8ae: [clang][darwin] add support for remapping 
macOS availability to Mac Catalyst… (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D105257?vs=358511=360539#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105257

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Basic/DarwinSDKInfo.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Driver/Inputs/MacOSX10.14.sdk/SDKSettings.json
  clang/test/Driver/Inputs/WatchOS6.0.sdk/SDKSettings.json
  clang/test/Driver/Inputs/iPhoneOS13.0.sdk/SDKSettings.json
  clang/test/Sema/Inputs/MacOSX11.0.sdk/SDKSettings.json
  clang/test/Sema/attr-availability-iosmac-infer-from-macos-no-sdk-settings.c
  clang/test/Sema/attr-availability-iosmac-infer-from-macos.c
  clang/test/Sema/attr-availability-maccatalyst.c

Index: clang/test/Sema/attr-availability-maccatalyst.c
===
--- clang/test/Sema/attr-availability-maccatalyst.c
+++ clang/test/Sema/attr-availability-maccatalyst.c
@@ -12,8 +12,8 @@
 void f0(int) __attribute__((availability(maccatalyst,introduced=2.0,deprecated=9.1))); // expected-note {{'f0' has been explicitly marked deprecated here}}
 void f1(int) __attribute__((availability(maccatalyst,introduced=2.1)));
 void f2(int) __attribute__((availability(macCatalyst,introduced=2.0,deprecated=9.0))); // expected-note {{'f2' has been explicitly marked deprecated here}}
-void f3(int) __attribute__((availability(macosx,introduced=10.1),  availability(maccatalyst,introduced=3.0, obsoleted=9.0))); // expected-note {{'f3' has been explicitly marked unavailable here}}
-void f32(int) __attribute__((availability(macosx,introduced=10.1,deprecated=10.3,obsoleted=10.5),  availability(maccatalyst,introduced=3.0, obsoleted=9.0))); // expected-note {{'f32' has been explicitly marked unavailable here}}
+void f3(int) __attribute__((availability(maccatalyst,introduced=3.0, obsoleted=9.0))); // expected-note {{'f3' has been explicitly marked unavailable here}}
+void f32(int) __attribute__((availability(maccatalyst,introduced=3.0, obsoleted=9.0))); // expected-note {{'f32' has been explicitly marked unavailable here}}
 
 
 void f5(int) __attribute__((availability(maccatalyst,introduced=2.0))) __attribute__((availability(maccatalyst,deprecated=9.0))); // expected-note {{'f5' has been explicitly marked deprecated here}}
Index: clang/test/Sema/attr-availability-iosmac-infer-from-macos.c
===
--- /dev/null
+++ clang/test/Sema/attr-availability-iosmac-infer-from-macos.c
@@ -0,0 +1,58 @@
+// RUN: %clang_cc1 "-triple" "x86_64-apple-ios13.1-macabi" -isysroot %S/Inputs/MacOSX11.0.sdk -fsyntax-only -verify %s
+// RUN: %clang_cc1 "-triple" "x86_64-apple-ios14-macabi" -isysroot %S/Inputs/MacOSX11.0.sdk -DIOS14 -fsyntax-only -verify %s
+
+void f0(void) __attribute__((availability(macOS, introduced = 10.11)));
+void f1(void) __attribute__((availability(macOS, introduced = 10.15)));
+void f2(void) __attribute__(( // expected-note {{'f2' has been explicitly marked deprecated here}}
+availability(macOS, introduced = 10.11,
+ deprecated = 10.12)));
+void f3(void)
+__attribute__((availability(macOS, introduced = 10.11, deprecated = 10.14)))
+__attribute__((availability(iOS, introduced = 11.0)));
+
+void f4(void)
+__attribute__((availability(macOS, introduced = 10, deprecated = 10)));
+
+void fAvail() __attribute__((availability(macOS, unavailable)));
+
+void f16() __attribute__((availability(macOS, introduced = 11.0)));
+#ifndef IOS14
+// expected-note@-2 {{here}}
+#endif
+
+void fObs() __attribute__((availability(macOS, introduced = 10.11, obsoleted = 10.15))); // expected-note {{'fObs' has been explicitly marked unavailable here}}
+
+void fAPItoDepr() __attribute__((availability(macOS, introduced = 10.11, deprecated = 10)));
+
+void dontRemapFutureVers() __attribute__((availability(macOS, introduced = 20)));
+
+void usage() {
+  f0();
+  f1();
+  f2(); // expected-warning {{'f2' is deprecated: first deprecated in macCatalyst 13.1}}
+  f3();
+  f4();
+  fAvail();
+  f16();
+#ifndef IOS14
+  // expected-warning@-2 {{'f16' is only available on macCatalyst 14.0 or newer}} expected-note@-2 {{enclose}}
+#endif
+  fObs(); // expected-error {{'fObs' is unavailable: obsoleted in macCatalyst 13.1}}
+  fAPItoDepr();
+  dontRemapFutureVers();
+}
+
+#ifdef IOS14
+
+void f15_4(void) __attribute__((availability(macOS, introduced = 10.15, deprecated = 10.15.4))); // expected-note {{here}}
+void f15_3(void) __attribute__((availability(macOS, introduced = 10.15, deprecated = 10.15.3))); // expected-note {{here}}
+void 

[clang] eb26ba9 - [clang][darwin] add support for remapping macOS availability to Mac Catalyst availability

2021-07-21 Thread Alex Lorenz via cfe-commits

Author: Alex Lorenz
Date: 2021-07-21T11:32:25-07:00
New Revision: eb26ba9da8aeab8ecc1209034912f9f12a945128

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

LOG: [clang][darwin] add support for remapping macOS availability to Mac 
Catalyst availability

This commit adds supports for clang to remap macOS availability attributes that 
have introduced,
deprecated or obsoleted versions to appropriate Mac Catalyst availability 
attributes. This
mapping is done using the version mapping provided in the macOS SDK, in the 
SDKSettings.json file.
The mappings in the SDKSettings json file will also be used in the clang driver 
for the driver
Mac Catalyst patch, and they could also be used in the future for other 
platforms as well.

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

Added: 
clang/test/Sema/Inputs/MacOSX11.0.sdk/SDKSettings.json
clang/test/Sema/attr-availability-iosmac-infer-from-macos-no-sdk-settings.c
clang/test/Sema/attr-availability-iosmac-infer-from-macos.c

Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/lib/Basic/DarwinSDKInfo.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/Driver/Inputs/MacOSX10.14.sdk/SDKSettings.json
clang/test/Driver/Inputs/WatchOS6.0.sdk/SDKSettings.json
clang/test/Driver/Inputs/iPhoneOS13.0.sdk/SDKSettings.json
clang/test/Sema/attr-availability-maccatalyst.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 792313fed2a9f..108f1796415c8 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3549,6 +3549,10 @@ def warn_at_available_unchecked_use : Warning<
   "use if (%select{@available|__builtin_available}0) instead">,
   InGroup>;
 
+def warn_missing_sdksettings_for_availability_checking : Warning<
+  "%0 availability is ignored without a valid 'SDKSettings.json' in the SDK">,
+  InGroup>;
+
 // Thread Safety Attributes
 def warn_thread_attribute_ignored : Warning<
   "ignoring %0 attribute because its argument is invalid">,

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 4ade04992a5f4..c200b9b246811 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -115,6 +115,7 @@ namespace clang {
   class CodeCompletionTUInfo;
   class CodeCompletionResult;
   class CoroutineBodyStmt;
+  class DarwinSDKInfo;
   class Decl;
   class DeclAccessPair;
   class DeclContext;
@@ -1525,6 +1526,8 @@ class Sema final {
   /// assignment.
   llvm::DenseMap RefsMinusAssignments;
 
+  Optional> CachedDarwinSDKInfo;
+
 public:
   Sema(Preprocessor , ASTContext , ASTConsumer ,
TranslationUnitKind TUKind = TU_Complete,
@@ -1553,6 +1556,8 @@ class Sema final {
   ASTConsumer () const { return Consumer; }
   ASTMutationListener *getASTMutationListener() const;
   ExternalSemaSource* getExternalSource() const { return ExternalSource; }
+  DarwinSDKInfo *getDarwinSDKInfoForAvailabilityChecking(SourceLocation Loc,
+ StringRef Platform);
 
   ///Registers an external source. If an external source already exists,
   /// creates a multiplex external source and appends to it.

diff  --git a/clang/lib/Basic/DarwinSDKInfo.cpp 
b/clang/lib/Basic/DarwinSDKInfo.cpp
index 6959b84e5c62a..fe3e8edbcd5cb 100644
--- a/clang/lib/Basic/DarwinSDKInfo.cpp
+++ b/clang/lib/Basic/DarwinSDKInfo.cpp
@@ -115,13 +115,8 @@ clang::parseDarwinSDKInfo(llvm::vfs::FileSystem , 
StringRef SDKRootPath) {
 return Result.takeError();
 
   if (const auto *Obj = Result->getAsObject()) {
-// FIXME: Switch to use parseDarwinSDKSettingsJSON.
-auto VersionString = Obj->getString("Version");
-if (VersionString) {
-  VersionTuple Version;
-  if (!Version.tryParse(*VersionString))
-return DarwinSDKInfo(Version, Version);
-}
+if (auto SDKInfo = DarwinSDKInfo::parseDarwinSDKSettingsJSON(Obj))
+  return std::move(SDKInfo);
   }
   return llvm::make_error("invalid SDKSettings.json",
  llvm::inconvertibleErrorCode());

diff  --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index 704b631f94003..fbbb347f57da3 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -22,12 +22,14 @@
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/PrettyDeclStackTrace.h"
 #include "clang/AST/StmtCXX.h"
+#include "clang/Basic/DarwinSDKInfo.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/PartialDiagnostic.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/Stack.h"
 #include 

[PATCH] D106394: [clang][pp] adds '#pragma include_instead'

2021-07-21 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb added a comment.

In D106394#2893681 , @Quuxplusone 
wrote:

> If IWYU has already developed a de facto standard for this information, I 
> would recommend libc++ just use it (perhaps with no changes needed in clang 
> at all). This would have the benefit of getting libc++ to work with IWYU 
> out-of-the-box, instead of having to go beg IWYU to implement support for a 
> new `#pragma include_instead`.  Is any IWYU developer aware of D106394 
>  yet? You should definitely try to get them 
> involved here.

This suggestion misses the fact that this change issues a warning to users who 
include detail system headers and the fact that Clang can use this to improve 
its diagnostics.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106394

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


[PATCH] D106393: [PowerPC][AIX] Add support for varargs for complex types on AIX

2021-07-21 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:4577-4583
+  // If we have a complex type and the base type is smaller than 8 bytes,
+  // the ABI calls for the real and imaginary parts to be right-adjusted
+  // in separate doublewords. However, Clang expects us to produce a
+  // pointer to a structure with the two parts packed tightly. So generate
+  // loads of the real and imaginary parts relative to the va_list pointer,
+  // and store them to a temporary structure. We do the same as the PPC64ABI
+  // here.

hubert.reinterpretcast wrote:
> The 32-bit tests suggest that the "8 bytes"/"doublewords" in the above are 
> not always so.
Yes, I missed updating that part of the comment previously, thank you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106393

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


[PATCH] D106266: [C++4OpenCL] Add run line standard aliases clc++1.0 and CLC++1.0

2021-07-21 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!


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

https://reviews.llvm.org/D106266

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


[PATCH] D106393: [PowerPC][AIX] Add support for varargs for complex types on AIX

2021-07-21 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA updated this revision to Diff 360535.
ZarkoCA added a comment.

- Fix comment to also describe what happens in 32bit mode


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106393

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/aix32-complex-varargs.c
  clang/test/CodeGen/ppc64-varargs-complex.c
  llvm/test/CodeGen/PowerPC/aix32-complex-vararg.ll
  llvm/test/CodeGen/PowerPC/aix64-complex-vararg.ll

Index: llvm/test/CodeGen/PowerPC/aix64-complex-vararg.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/aix64-complex-vararg.ll
@@ -0,0 +1,510 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mattr=-altivec \
+; RUN:  -mtriple powerpc64-ibm-aix-xcoff < %s | \
+; RUN: FileCheck --check-prefix=64BIT %s
+
+@cdbl = local_unnamed_addr global { double, double } zeroinitializer, align 8
+@cdbl1 = local_unnamed_addr global { double, double } zeroinitializer, align 8
+@cdbl2 = local_unnamed_addr global { double, double } zeroinitializer, align 8
+@cdbl3 = local_unnamed_addr global { double, double } zeroinitializer, align 8
+@cflt = local_unnamed_addr global { float, float } zeroinitializer, align 4
+@cflt1 = local_unnamed_addr global { float, float } zeroinitializer, align 4
+@cflt2 = local_unnamed_addr global { float, float } zeroinitializer, align 4
+@cflt3 = local_unnamed_addr global { float, float } zeroinitializer, align 4
+@cldbl = local_unnamed_addr global { double, double } zeroinitializer, align 8
+@cldbl1 = local_unnamed_addr global { double, double } zeroinitializer, align 8
+@cldbl2 = local_unnamed_addr global { double, double } zeroinitializer, align 8
+@cldbl3 = local_unnamed_addr global { double, double } zeroinitializer, align 8
+
+define { double, double } @foo1(double %x.coerce0, double %x.coerce1, ...) local_unnamed_addr {
+; 64BIT-LABEL: foo1:
+; 64BIT:   # %bb.0: # %entry
+; 64BIT-NEXT:ld 3, L..C0(2) # %const.0
+; 64BIT-NEXT:std 5, 64(1)
+; 64BIT-NEXT:std 6, 72(1)
+; 64BIT-NEXT:lfd 4, 64(1)
+; 64BIT-NEXT:lfd 5, 72(1)
+; 64BIT-NEXT:std 7, 80(1)
+; 64BIT-NEXT:std 8, 88(1)
+; 64BIT-NEXT:lfs 0, 0(3)
+; 64BIT-NEXT:std 9, 96(1)
+; 64BIT-NEXT:addi 3, 1, 64
+; 64BIT-NEXT:std 10, 104(1)
+; 64BIT-NEXT:fadd 3, 1, 0
+; 64BIT-NEXT:fadd 0, 2, 0
+; 64BIT-NEXT:fadd 3, 3, 4
+; 64BIT-NEXT:fadd 0, 0, 5
+; 64BIT-NEXT:lfdu 4, 16(3)
+; 64BIT-NEXT:lfd 5, 88(1)
+; 64BIT-NEXT:fadd 3, 3, 1
+; 64BIT-NEXT:fadd 0, 0, 2
+; 64BIT-NEXT:fadd 3, 3, 4
+; 64BIT-NEXT:fadd 0, 0, 5
+; 64BIT-NEXT:lfd 4, 96(1)
+; 64BIT-NEXT:lfd 5, 104(1)
+; 64BIT-NEXT:fadd 3, 3, 1
+; 64BIT-NEXT:fadd 0, 0, 2
+; 64BIT-NEXT:fadd 3, 3, 4
+; 64BIT-NEXT:fadd 0, 0, 5
+; 64BIT-NEXT:lfd 4, 112(1)
+; 64BIT-NEXT:lfd 5, 120(1)
+; 64BIT-NEXT:fadd 3, 3, 1
+; 64BIT-NEXT:fadd 0, 0, 2
+; 64BIT-NEXT:fadd 3, 3, 4
+; 64BIT-NEXT:fadd 0, 0, 5
+; 64BIT-NEXT:fadd 1, 3, 1
+; 64BIT-NEXT:fadd 0, 0, 2
+; 64BIT-NEXT:lfd 2, 128(1)
+; 64BIT-NEXT:lfd 3, 136(1)
+; 64BIT-NEXT:fadd 1, 1, 2
+; 64BIT-NEXT:fadd 2, 0, 3
+; 64BIT-NEXT:blr
+entry:
+  %arg = alloca i8*, align 8
+  %0 = bitcast i8** %arg to i8*
+  call void @llvm.lifetime.start.p0i8(i64 8, i8* nonnull %0)
+  call void @llvm.va_start(i8* nonnull %0)
+  %add.r = fadd double %x.coerce0, 0.00e+00
+  %add.i = fadd double %x.coerce1, 0.00e+00
+  %argp.cur = load i8*, i8** %arg, align 8
+  %argp.next = getelementptr inbounds i8, i8* %argp.cur, i64 16
+  store i8* %argp.next, i8** %arg, align 8
+  %.realp = bitcast i8* %argp.cur to double*
+  %.real = load double, double* %.realp, align 8
+  %.imagp = getelementptr inbounds i8, i8* %argp.cur, i64 8
+  %1 = bitcast i8* %.imagp to double*
+  %.imag = load double, double* %1, align 8
+  %add.r4 = fadd double %add.r, %.real
+  %add.i5 = fadd double %add.i, %.imag
+  %add.r.1 = fadd double %add.r4, %x.coerce0
+  %add.i.1 = fadd double %add.i5, %x.coerce1
+  %argp.next.1 = getelementptr inbounds i8, i8* %argp.cur, i64 32
+  %.realp.1 = bitcast i8* %argp.next to double*
+  %.real.1 = load double, double* %.realp.1, align 8
+  %.imagp.1 = getelementptr inbounds i8, i8* %argp.cur, i64 24
+  %2 = bitcast i8* %.imagp.1 to double*
+  %.imag.1 = load double, double* %2, align 8
+  %add.r4.1 = fadd double %add.r.1, %.real.1
+  %add.i5.1 = fadd double %add.i.1, %.imag.1
+  %add.r.2 = fadd double %add.r4.1, %x.coerce0
+  %add.i.2 = fadd double %add.i5.1, %x.coerce1
+  %argp.next.2 = getelementptr inbounds i8, i8* %argp.cur, i64 48
+  %.realp.2 = bitcast i8* %argp.next.1 to double*
+  %.real.2 = load double, double* %.realp.2, align 8
+  %.imagp.2 = getelementptr inbounds i8, i8* %argp.cur, i64 40
+  %3 = bitcast i8* %.imagp.2 to double*
+  %.imag.2 = load double, double* %3, align 8
+  

[PATCH] D95159: [ASTReader] Allow controlling separately whether validation should be disabled for a PCH vs a module file

2021-07-21 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a subscriber: aaron.ballman.
mibintc added a comment.

@aaron.ballman suggested I may have made a mistake adding the new option, I'll 
look there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95159

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


[PATCH] D106005: [Docs] Define matrix initialisation in MatrixTypes documentation

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

Updated docs to address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106005

Files:
  clang/docs/MatrixTypes.rst


Index: clang/docs/MatrixTypes.rst
===
--- clang/docs/MatrixTypes.rst
+++ clang/docs/MatrixTypes.rst
@@ -266,6 +266,18 @@
   }
 
 
+Initialization Syntax
+-
+A value of a matrix type M can be initialised using aggregate initialization 
syntax:
+
+.. code-block:: c++
+
+  constexpr M m1 = {};
+  constexpr M m2 = {{a, b, c}, {d, e, f}};
+
+The number of constituent arrays must equal the number rows in the matrix type 
M and the number of elements
+in each constituent array must equal the number of columns in the matrix type.
+
 TODOs
 -
 
@@ -274,9 +286,6 @@
 convenient. The alternative is using template deduction to extract this
 information. Also add spelling for C.
 
-Future Work: Initialization syntax.
-
-
 Decisions for the Implementation in Clang
 =
 


Index: clang/docs/MatrixTypes.rst
===
--- clang/docs/MatrixTypes.rst
+++ clang/docs/MatrixTypes.rst
@@ -266,6 +266,18 @@
   }
 
 
+Initialization Syntax
+-
+A value of a matrix type M can be initialised using aggregate initialization syntax:
+
+.. code-block:: c++
+
+  constexpr M m1 = {};
+  constexpr M m2 = {{a, b, c}, {d, e, f}};
+
+The number of constituent arrays must equal the number rows in the matrix type M and the number of elements
+in each constituent array must equal the number of columns in the matrix type.
+
 TODOs
 -
 
@@ -274,9 +286,6 @@
 convenient. The alternative is using template deduction to extract this
 information. Also add spelling for C.
 
-Future Work: Initialization syntax.
-
-
 Decisions for the Implementation in Clang
 =
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105527: libclang.so: Make SONAME independent from LLVM version

2021-07-21 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/tools/libclang/CMakeLists.txt:82
+
+if (LLVM_EXPORTED_SYMBOL_FILE)
+  add_custom_command(OUTPUT ${LLVM_EXPORTED_SYMBOL_FILE}

MaskRay wrote:
> tstellar wrote:
> > MaskRay wrote:
> > > What does this do?
> > > 
> > > A hard-coded list cannot catch up with the real dynamic symbol list. 
> > > We'll have to parse llvm-readelf --dyn-syms output...
> > Are you saying we should generate the version script using llvm-readelf?
> We may need a test checking that if --version-script is used, there is no 
> `clang_*` symbol which isn't versioned.
> 
> This can be checked by running `llvm-nm -Dj --defined-only` on libclang.so
Oh, you used `local: *`. Then there may need a test that there is no localized 
`clang_*` symbol.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105527

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


[PATCH] D105527: libclang.so: Make SONAME independent from LLVM version

2021-07-21 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/tools/libclang/CMakeLists.txt:82
+
+if (LLVM_EXPORTED_SYMBOL_FILE)
+  add_custom_command(OUTPUT ${LLVM_EXPORTED_SYMBOL_FILE}

tstellar wrote:
> MaskRay wrote:
> > What does this do?
> > 
> > A hard-coded list cannot catch up with the real dynamic symbol list. We'll 
> > have to parse llvm-readelf --dyn-syms output...
> Are you saying we should generate the version script using llvm-readelf?
We may need a test checking that if --version-script is used, there is no 
`clang_*` symbol which isn't versioned.

This can be checked by running `llvm-nm -Dj --defined-only` on libclang.so


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105527

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


[PATCH] D106394: [clang][pp] adds '#pragma include_instead'

2021-07-21 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb updated this revision to Diff 360519.
cjdb added a comment.

- renames files
- makes it possible for `#pragma GCC system_header` to come after includes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106394

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/include/clang/Lex/HeaderSearch.h
  clang/include/clang/Lex/Preprocessor.h
  clang/include/clang/Lex/PreprocessorLexer.h
  clang/lib/Lex/Lexer.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/PPLexerChange.cpp
  clang/lib/Lex/Pragma.cpp
  clang/test/Preprocessor/Inputs/include_instead/bad-syntax.h
  clang/test/Preprocessor/Inputs/include_instead/non-system-header.h
  clang/test/Preprocessor/Inputs/include_instead/private-x.h
  clang/test/Preprocessor/Inputs/include_instead/private1.h
  clang/test/Preprocessor/Inputs/include_instead/private2.h
  clang/test/Preprocessor/Inputs/include_instead/private3.h
  clang/test/Preprocessor/Inputs/include_instead/public-after.h
  clang/test/Preprocessor/Inputs/include_instead/public-before.h
  clang/test/Preprocessor/Inputs/include_instead/public-empty.h
  clang/test/Preprocessor/include_instead.cpp

Index: clang/test/Preprocessor/include_instead.cpp
===
--- /dev/null
+++ clang/test/Preprocessor/include_instead.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -I %S/Inputs %s
+
+#include 
+#include 
+
+#include 
+// expected-warning@-1{{header '' is an implementation detail; #include '' instead}}
+
+#include "include_instead/private2.h"
+// expected-warning@-1{{header '"include_instead/private2.h"' is an implementation detail; #include either '' or '"include_instead/public-after.h"' instead}}
+
+#include 
+// expected-warning@-1{{header '' is an implementation detail; #include one of {'', '', '"include_instead/public-before.h"'} instead}}
+
+#include 
+#include 
Index: clang/test/Preprocessor/Inputs/include_instead/public-empty.h
===
--- /dev/null
+++ clang/test/Preprocessor/Inputs/include_instead/public-empty.h
@@ -0,0 +1 @@
+// This file simply needs to exist.
Index: clang/test/Preprocessor/Inputs/include_instead/public-before.h
===
--- /dev/null
+++ clang/test/Preprocessor/Inputs/include_instead/public-before.h
@@ -0,0 +1,5 @@
+#pragma GCC system_header
+
+#include  // no warning expected
+#include  // no warning expected
+#include  // no warning expected
Index: clang/test/Preprocessor/Inputs/include_instead/public-after.h
===
--- /dev/null
+++ clang/test/Preprocessor/Inputs/include_instead/public-after.h
@@ -0,0 +1,2 @@
+#include 
+#pragma GCC system_header
Index: clang/test/Preprocessor/Inputs/include_instead/private3.h
===
--- /dev/null
+++ clang/test/Preprocessor/Inputs/include_instead/private3.h
@@ -0,0 +1,5 @@
+#pragma GCC system_header
+
+#pragma clang include_instead()
+#pragma clang include_instead()
+#pragma clang include_instead("include_instead/public-before.h")
Index: clang/test/Preprocessor/Inputs/include_instead/private2.h
===
--- /dev/null
+++ clang/test/Preprocessor/Inputs/include_instead/private2.h
@@ -0,0 +1,4 @@
+#pragma GCC system_header
+
+#pragma clang include_instead()
+#pragma clang include_instead("include_instead/public-after.h")
Index: clang/test/Preprocessor/Inputs/include_instead/private1.h
===
--- /dev/null
+++ clang/test/Preprocessor/Inputs/include_instead/private1.h
@@ -0,0 +1,2 @@
+#pragma GCC system_header
+#pragma clang include_instead()
Index: clang/test/Preprocessor/Inputs/include_instead/private-x.h
===
--- /dev/null
+++ clang/test/Preprocessor/Inputs/include_instead/private-x.h
@@ -0,0 +1,4 @@
+#include 
+
+#pragma GCC system_header
+#pragma clang include_instead()
Index: clang/test/Preprocessor/Inputs/include_instead/non-system-header.h
===
--- /dev/null
+++ clang/test/Preprocessor/Inputs/include_instead/non-system-header.h
@@ -0,0 +1,2 @@
+#pragma clang include_instead()
+// expected-warning@-1{{'#pragma include_instead' ignored outside of system headers}}
Index: clang/test/Preprocessor/Inputs/include_instead/bad-syntax.h
===
--- /dev/null
+++ clang/test/Preprocessor/Inputs/include_instead/bad-syntax.h
@@ -0,0 +1,10 @@
+#pragma GCC system_header
+
+#pragma clang include_instead 
+// expected-warning@-1{{'#pragma include_instead' expects '(' as its next token; got '<' instead}}

[PATCH] D104904: [OpenMP][AMDGCN] Initial math headers support

2021-07-21 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

cstdlib test header contains

  // amdgcn already provides definition of fabs
  #ifndef __AMDGCN__
  float fabs(float __x) { return __builtin_fabs(__x); }
  #endif

If I delete or invert the ifndef

> $HOME/llvm-build/llvm/lib/clang/13.0.0/include/__clang_hip_cmath.h:660:9: 
> error: target of using declaration conflicts with declaration already in scope
>  using ::fabs;
>  when included from openmp_wrappers/cmath

If I delete the definition,

> $HOME/llvm-project/clang/test/Headers/Inputs/include/cstdlib:29:31: error: 
> use of undeclared identifier 'fabs'
> when included from openmp_wrappers/__clang_openmp_device_functions.h

Current conclusion is that we cannot work around the presence/absence of fabs 
in the cstdlib test file, we have to do something in the real headers such that 
the test file does the right thing


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104904

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


[PATCH] D105527: libclang.so: Make SONAME independent from LLVM version

2021-07-21 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added inline comments.



Comment at: clang/tools/libclang/CMakeLists.txt:82
+
+if (LLVM_EXPORTED_SYMBOL_FILE)
+  add_custom_command(OUTPUT ${LLVM_EXPORTED_SYMBOL_FILE}

MaskRay wrote:
> What does this do?
> 
> A hard-coded list cannot catch up with the real dynamic symbol list. We'll 
> have to parse llvm-readelf --dyn-syms output...
Are you saying we should generate the version script using llvm-readelf?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105527

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


[PATCH] D105527: libclang.so: Make SONAME independent from LLVM version

2021-07-21 Thread Tom Stellard via Phabricator via cfe-commits
tstellar updated this revision to Diff 360517.
tstellar marked 3 inline comments as done.
tstellar added a comment.

Address some review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105527

Files:
  clang/tools/libclang/CMakeLists.txt
  clang/tools/libclang/libclang.exports
  clang/tools/libclang/libclang.map
  clang/tools/libclang/linker-script-to-export-list.py

Index: clang/tools/libclang/linker-script-to-export-list.py
===
--- /dev/null
+++ clang/tools/libclang/linker-script-to-export-list.py
@@ -0,0 +1,10 @@
+import re
+import os
+
+input_file = open(sys.argv[1])
+output_file = open(sys.argv[2])
+
+for line in input_file:
+m = re.search('clang_[^;]+', line)
+if m:
+output_file.write(m.group(0))
Index: clang/tools/libclang/libclang.map
===
--- /dev/null
+++ clang/tools/libclang/libclang.map
@@ -0,0 +1,414 @@
+/* If you add a symbol to this file, make sure to add it with the correct
+ * version.  For example, if the LLVM main branch is LLVM 14.0.0, add new
+ * symbols with the version LLVM_14.
+ * On platforms where versions scripts are not used, this file will be used to
+ * generate a list of exports for libclang.so
+ */
+
+
+LLVM_13 {
+  global:
+clang_BlockCommandComment_getArgText;
+clang_BlockCommandComment_getCommandName;
+clang_BlockCommandComment_getNumArgs;
+clang_BlockCommandComment_getParagraph;
+clang_CXCursorSet_contains;
+clang_CXCursorSet_insert;
+clang_CXIndex_getGlobalOptions;
+clang_CXIndex_setGlobalOptions;
+clang_CXIndex_setInvocationEmissionPathOption;
+clang_CXRewriter_create;
+clang_CXRewriter_dispose;
+clang_CXRewriter_insertTextBefore;
+clang_CXRewriter_overwriteChangedFiles;
+clang_CXRewriter_removeText;
+clang_CXRewriter_replaceText;
+clang_CXRewriter_writeMainFileToStdOut;
+clang_CXXConstructor_isConvertingConstructor;
+clang_CXXConstructor_isCopyConstructor;
+clang_CXXConstructor_isDefaultConstructor;
+clang_CXXConstructor_isMoveConstructor;
+clang_CXXField_isMutable;
+clang_CXXMethod_isConst;
+clang_CXXMethod_isDefaulted;
+clang_CXXMethod_isPureVirtual;
+clang_CXXMethod_isStatic;
+clang_CXXMethod_isVirtual;
+clang_CXXRecord_isAbstract;
+clang_Comment_getChild;
+clang_Comment_getKind;
+clang_Comment_getNumChildren;
+clang_Comment_isWhitespace;
+clang_CompilationDatabase_dispose;
+clang_CompilationDatabase_fromDirectory;
+clang_CompilationDatabase_getAllCompileCommands;
+clang_CompilationDatabase_getCompileCommands;
+clang_CompileCommand_getArg;
+clang_CompileCommand_getDirectory;
+clang_CompileCommand_getFilename;
+clang_CompileCommand_getMappedSourceContent;
+clang_CompileCommand_getMappedSourcePath;
+clang_CompileCommand_getNumArgs;
+clang_CompileCommands_dispose;
+clang_CompileCommands_getCommand;
+clang_CompileCommands_getSize;
+clang_Cursor_Evaluate;
+clang_Cursor_getArgument;
+clang_Cursor_getBriefCommentText;
+clang_Cursor_getCXXManglings;
+clang_Cursor_getCommentRange;
+clang_Cursor_getMangling;
+clang_Cursor_getModule;
+clang_Cursor_getNumArguments;
+clang_Cursor_getNumTemplateArguments;
+clang_Cursor_getObjCDeclQualifiers;
+clang_Cursor_getObjCManglings;
+clang_Cursor_getObjCPropertyAttributes;
+clang_Cursor_getObjCPropertyGetterName;
+clang_Cursor_getObjCPropertySetterName;
+clang_Cursor_getObjCSelectorIndex;
+clang_Cursor_getOffsetOfField;
+clang_Cursor_getParsedComment;
+clang_Cursor_getRawCommentText;
+clang_Cursor_getReceiverType;
+clang_Cursor_getSpellingNameRange;
+clang_Cursor_getStorageClass;
+clang_Cursor_getTemplateArgumentKind;
+clang_Cursor_getTemplateArgumentType;
+clang_Cursor_getTemplateArgumentUnsignedValue;
+clang_Cursor_getTemplateArgumentValue;
+clang_Cursor_getTranslationUnit;
+clang_Cursor_getVarDeclInitializer;
+clang_Cursor_hasAttrs;
+clang_Cursor_hasVarDeclExternalStorage;
+clang_Cursor_hasVarDeclGlobalStorage;
+clang_Cursor_isAnonymous;
+clang_Cursor_isAnonymousRecordDecl;
+clang_Cursor_isBitField;
+clang_Cursor_isDynamicCall;
+clang_Cursor_isExternalSymbol;
+clang_Cursor_isFunctionInlined;
+clang_Cursor_isInlineNamespace;
+clang_Cursor_isMacroBuiltin;
+clang_Cursor_isMacroFunctionLike;
+clang_Cursor_isNull;
+clang_Cursor_isObjCOptional;
+clang_Cursor_isVariadic;
+clang_EnumDecl_isScoped;
+clang_EvalResult_dispose;
+clang_EvalResult_getAsDouble;
+clang_EvalResult_getAsInt;
+clang_EvalResult_getAsLongLong;
+clang_EvalResult_getAsStr;
+clang_EvalResult_getAsUnsigned;
+clang_EvalResult_getKind;
+clang_EvalResult_isUnsignedInt;
+  

[PATCH] D103938: Diagnose -Wunused-value in constant evaluation context

2021-07-21 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: clang/test/Sema/i-c-e.c:77-78
+  // expected-warning {{expression result unused}}
+int comma3[(1, 2)];   // expected-warning {{variable length array folded to 
constant array as an extension}} \
+  // expected-warning {{expression result unused}}
 

aaron.ballman wrote:
> I think this diagnostic is kind of unfortunate because it increases my 
> confusion -- the expression result is most assuredly *not* unused in these 
> cases because it's used in the definition of the type.
> the expression result is most assuredly *not* unused in these cases because 
> it's used in the definition of the type.
 
Do you mean "1" is used in the definition of the type? The warning is for "1" 
in this case. If I change `1` to any other number, the type of `comma3` should 
not change, I think that means `1` is not used.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103938

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


[PATCH] D103938: Diagnose -Wunused-value in constant evaluation context

2021-07-21 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 360514.
ychen marked an inline comment as done.
ychen added a comment.

- fix comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103938

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/CXX/drs/dr14xx.cpp
  clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp
  clang/test/CodeCompletion/pragma-macro-token-caching.c
  clang/test/PCH/cxx-explicit-specifier.cpp
  clang/test/Parser/cxx-ambig-decl-expr.cpp
  clang/test/Parser/cxx0x-ambig.cpp
  clang/test/Sema/const-eval.c
  clang/test/Sema/exprs.c
  clang/test/Sema/i-c-e.c
  clang/test/Sema/vla-2.c
  clang/test/SemaCXX/attr-annotate.cpp
  clang/test/SemaCXX/builtin-constant-p.cpp
  clang/test/SemaCXX/constant-expression-cxx2a.cpp
  clang/test/SemaCXX/constant-expression.cpp
  clang/test/SemaCXX/expression-traits.cpp
  clang/test/SemaCXX/warn-comma-operator.cpp
  clang/test/SemaCXX/warn-unused-value.cpp

Index: clang/test/SemaCXX/warn-unused-value.cpp
===
--- clang/test/SemaCXX/warn-unused-value.cpp
+++ clang/test/SemaCXX/warn-unused-value.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wunused-value %s
 // RUN: %clang_cc1 -fsyntax-only -verify -Wunused-value -std=c++98 %s
 // RUN: %clang_cc1 -fsyntax-only -verify -Wunused-value -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wunused-value -std=c++17 %s
 
 // PR4806
 namespace test0 {
@@ -138,3 +139,26 @@
   (void)arr3;
   (void)arr4;
 }
+
+#if __cplusplus >= 201103L // C++11 or later
+namespace test5 {
+int v[(5, 6)]; // expected-warning {{expression result unused}}
+void foo() {
+  new double[false ? (1, 2) : 3]
+// FIXME: We shouldn't diagnose the unreachable constant expression
+// here.
+[false ? (1, 2) : 3]; // expected-warning {{expression result unused}}
+}
+} // namespace test5
+#endif
+
+#if __cplusplus >= 201703L // C++11 or later
+namespace test6 {
+auto b() {
+  if constexpr (false)
+return (1,0);
+  else
+return (1.0,0.0); // expected-warning {{expression result unused}}
+}
+} // namespace test6
+#endif
Index: clang/test/SemaCXX/warn-comma-operator.cpp
===
--- clang/test/SemaCXX/warn-comma-operator.cpp
+++ clang/test/SemaCXX/warn-comma-operator.cpp
@@ -242,8 +242,8 @@
 
 template 
 class Foo {
-  typedef bool_seq<(xs::value, true)...> all_true;
-  typedef bool_seq<(xs::value, false)...> all_false;
+  typedef bool_seq<((void)xs::value, true)...> all_true;
+  typedef bool_seq<((void)xs::value, false)...> all_false;
   typedef bool_seq seq;
 };
 
Index: clang/test/SemaCXX/expression-traits.cpp
===
--- clang/test/SemaCXX/expression-traits.cpp
+++ clang/test/SemaCXX/expression-traits.cpp
@@ -583,10 +583,10 @@
 
 // Can't use the ASSERT_ macros without adding parens around
 // the comma expression.
-static_assert(__is_lvalue_expr(x,x), "expected an lvalue");
-static_assert(__is_rvalue_expr(x,1), "expected an rvalue");
-static_assert(__is_lvalue_expr(1,x), "expected an lvalue");
-static_assert(__is_rvalue_expr(1,1), "expected an rvalue");
+static_assert(__is_lvalue_expr((void)x,x), "expected an lvalue");
+static_assert(__is_rvalue_expr((void)x,1), "expected an rvalue");
+static_assert(__is_lvalue_expr((void)1,x), "expected an lvalue");
+static_assert(__is_rvalue_expr((void)1,1), "expected an rvalue");
 }
 
 #if 0
Index: clang/test/SemaCXX/constant-expression.cpp
===
--- clang/test/SemaCXX/constant-expression.cpp
+++ clang/test/SemaCXX/constant-expression.cpp
@@ -88,8 +88,8 @@
 
 void diags(int n) {
   switch (n) {
-case (1/0, 1): // expected-error {{not an integral constant expression}} expected-note {{division by zero}}
-case (int)(1/0, 2.0): // expected-error {{not an integral constant expression}} expected-note {{division by zero}}
+case (1/0, 1): // expected-error {{not an integral constant expression}} expected-note {{division by zero}} expected-warning {{expression result unused}}
+case (int)(1/0, 2.0): // expected-error {{not an integral constant expression}} expected-note {{division by zero}} expected-warning {{expression result unused}}
 case __imag(1/0): // expected-error {{not an integral constant expression}} expected-note {{division by zero}}
 case (int)__imag((double)(1/0)): // expected-error {{not an integral constant expression}} expected-note {{division by zero}}
   ;
Index: clang/test/SemaCXX/constant-expression-cxx2a.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx2a.cpp
+++ 

[PATCH] D101526: [analyzer][StdLibraryFunctionsChecker] Add NoteTags for applied arg constraints

2021-07-21 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:857
+if (BR.isInteresting(ArgSVal))
+  OS << Msg;
+  }));

Szelethus wrote:
> steakhal wrote:
> > Ah, there is a slight issue.
> > You should mark some stuff interesting here, to make this interestingness 
> > propagate back transitively.
> > 
> > Let's say `ArgSVal` is `x + y` which is considered to be out of range 
> > `[42,52]`. We should mark both `x` and `y` interesting because they 
> > themselves could have been constrained by the StdLibChecker previously. So, 
> > they must be interesting as well.
> > 
> > On the same token, IMO `PathSensitiveBugReport::markInteresting(symbol)` 
> > should be //transitive//. So that all `SymbolData` in that symbolic 
> > expression tree are considered interesting. What do you think @NoQ?
> > If we were doing this, @martong  - you could simply acquire the assumption 
> > you constructed for the given `ValueConstraint`, and mark that interesting. 
> > Then all `SymbolData`s on both sides of the logic operator would become 
> > implicitly interesting.
> >On the same token, IMO PathSensitiveBugReport::markInteresting(symbol) 
> >should be transitive. So that all SymbolData in that symbolic expression 
> >tree are considered interesting. What do you think @NoQ?
> 
> Thats how I'd expect this to work. This shouldn't be a burden on the checker 
> developer (certainly not this kind of a checker), but rather be handled by 
> `PathSensitiveBugReport`.
> 
> So I think this is fine as it is.
Interestingness isn't a thing on its own; its meaning is entirely tied to the 
nature of the specific bug report. An interesting pointer in the null 
dereference checker is absolutely not the same thing as an interesting mutex 
pointer in `PthreadLockChecker` or a (de)allocated pointer in `MallocChecker`.

I currently treat interestingness as a "GDM for visitors". It's their own way 
of communicating with themselves and with each other, a state they keep track 
of and update as they visit the bug report (initially populated during 
construction of the bug report). But the meaning of this state is entirely 
specific to the visitors. It is visitors who give interestingness a meaning 
(and the visitors are, naturally, also hand-picked during construction of the 
bug report).

So I think the right question to ask is "what do you want interestingness to 
mean in your checker?" and build your visitors accordingly.

Your visitors should provide enough information for the user to be able to 
understand the bug report. When the report says "$x + $y is in range [42, 52] 
and no values in that range are a valid input to that function", the user asks 
"why do you think $x + $y is in range [42, 52]?" and we'll have to answer that.

For example, in
```lang=c++
if (x + y >= 42 && x + y <= 52)
  foo(x + y);
```
there's no need to track ranges for $x and $y separately; it is sufficient to 
point the user to the constraint over $x + $y obtained from the if-statement. 
On the other hand, in
```lang=c++
if (x >= 44 && x <= 50)
  if (y >= -2 && y <= 2)
foo(x + y);
```
you'll have to explain both $x and $y in order for the user to understand that 
$x + $y is indeed in range [42, 52].

There are also other funny edge cases depending on the nature of the 
arithmetic, such as
```
int z = x * y;
if (x == 0)
  return 1 / z;
```
where in order to explain the division by the zero value $x * $y it is 
sufficient to explain $x which makes $y redundant. And if they both are zero 
then we should probably flip a coin?

So I think this is a non-trivial problem. Even on the examples above (let alone 
other bug types!) it's easy to see that interestingness of $x and $y doesn't 
always follow from the interestingness of $x + $y (but sometimes it indeed 
does). I think the answer lies somewhere in the underneathies of the constraint 
solver: we have to follow its logic in order to find out how the range was 
inferred (which it probably should annotate with more note tags so that we 
didn't have to reverse-engineer it in the visitor?) (@vsavchenko you may find 
this discussion particularly peculiar).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101526

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


[PATCH] D105462: [X86] Add CRC32 feature.

2021-07-21 Thread H.J Lu via Phabricator via cfe-commits
hjl.tools added inline comments.



Comment at: clang/lib/Basic/Targets/X86.cpp:159
+  // Enable CRC32 if SSE4.2 is enabled.
+  // NOTE: In conformance with GCC behavior, CRC32 is still available even if
+  // it's explicitly disabled.

craig.topper wrote:
> hjl.tools wrote:
> > tianqing wrote:
> > > craig.topper wrote:
> > > > This doesn't seem to be true. It causes gcc to crash. 
> > > > https://godbolt.org/z/39rEbsejh
> > > Well I was using GCC 11.1, it compiles.
> > > 
> > > The way I see it, crash means a bug (not surprising since it's trunk), 
> > > and can be interpreted as incompletely defined behavior until it's fixed.
> > > 
> > > Some tests on GCC trunk:
> > > 1. -msse4.2: Pass - sse4.2 enables crc32.
> > > 2. -mcrc32 -mno-sse4.2: Pass - no-sse4.2 doesn't disable crc32.
> > > 3. -msse4.2 -mno-sse4.2: Error - no-sse4.2 disables crc32.
> > > 4. -mno-crc32 -msse4.2: Crash - undefined behavior
> > > 5. -msse4.2 -mno-crc32: Crash - undefined behavior
> > > 
> > > 
> > > It's hard to extract some consistent underlying logic from the GCC 
> > > results.
> > I posted a patch: 
> > https://gcc.gnu.org/pipermail/gcc-patches/2021-July/575741.html
> @hjl.tools does that turn the crash into making -mno-crc32 into making crc32 
> instruction disabled?
Correct.  GCC issues an error now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105462

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


[PATCH] D95159: [ASTReader] Allow controlling separately whether validation should be disabled for a PCH vs a module file

2021-07-21 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

The newly added test case clang/test/Index/preamble-reparse-changed-module.m is 
failing on the patch that I'm trying to commit, https://reviews.llvm.org/D93769

Actually the result of the test is a bit flaky, when I build the Debug version 
on Linux, running ninja check-clang does show the test fail, but when I do an 
identical build and in addition enabling llvm assertions, llvm-lit does not 
show this lit test failing.

I think the problem has something to do with the macro __FLT_EVAL_METHOD__.  
The patch now treats this macro specially, more like __LINE__ a macro that can 
vary depending on where it is seen in the source code.

In my patch, __FLT_EVAL_MACRO__ is not expanded in -E mode, it just appears as 
its name in the preprocessed output.  The reason is, the actual value of the 
macro depends on the floating point settings at a particular source code 
location (depends on #pragma float_control settings).  The pragma are 
determined in Sema, and -E runs before Sema so the actual value isn't available.

This macro is the only reason i can think why this test is failing.

Can you help me understand what to do about this test case/about my patch/ so 
that i can get my patch committed? I don't understand what this test is doing. 
In the debugger it hits a failed assertion, looks like index out-of-range. 
here's a little massaged traceback
__assert_fail
 llvm::SmallVectorTemplateCommon unsigned long, void ::indexing operator
clang::ASTReader::ReadString
clang::ASTReader::ParseLanguageOptions
clang::ASTReader::ReadOptionsBlock
clang::ASTReader::ReadControlBlock
clang::ASTReader::ReadASTCore
clang::ASTReader::ReadAST
clang::CompilerInstance::findOrCompileModuleAndReadAST
clang::CompilerInstance::loadModule
clang::Preprocessor::LexAfterModuleImport

Thanks a lot


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95159

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


[PATCH] D103873: [Clang][RISCV] Implement vsoxseg and vsuxseg.

2021-07-21 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper 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/D103873/new/

https://reviews.llvm.org/D103873

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


[PATCH] D103871: [Clang][RISCV] Implement vsseg.

2021-07-21 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper 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/D103871/new/

https://reviews.llvm.org/D103871

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


[PATCH] D103809: [Clang][RISCV] Implement vloxseg and vluxseg.

2021-07-21 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper 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/D103809/new/

https://reviews.llvm.org/D103809

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


  1   2   >