[PATCH] D99487: [CodeGen] Port basic block sections from ELF to COFF

2021-08-19 Thread TaoPan via Phabricator via cfe-commits
TaoPan added a comment.

Thanks MaskRay for your review comments!




Comment at: llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp:1752
+  else {
+UniqueID = NextUniqueID++;
+COMDATSymName = MBB.getParent()->getName();

MaskRay wrote:
> I think `UniqueID = NextUniqueID++;` is not needed.
I added comment (line 1752) to explain why add this line, this line referred to 
ELF implementation, please refer to 
https://github.com/llvm/llvm-project/blob/cb2a2ba8d64da5be3fac0ea90e406270e8a615bd/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp#L993



Comment at: llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp:1756
+
+  // TODO: construct cold section in the case of section ID of MBB is
+  // MBBSectionID::ColdSectionID

MaskRay wrote:
> Can you fix the TODO in this patch?
It's indeed TODO. MMBSectionID::ColdSectionID will be handled in MFS on Windows 
COFF patch. I plan to re-base my previous MFS on Windows COFF patch (D95209) 
after this patch. I also explained this TODO in Summary.



Comment at: llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp:1786
+  // COFF linker will not properly handle comdats otherwise.
+  if (getContext().getTargetTriple().isWindowsGNUEnvironment()) {
+Name += '$';

MaskRay wrote:
> Is `isOSBinFormatCOFF()` more appropriate? Can windows-gnu use the 
> optimization?
Windows-gnu can use the optimization. In the case of Windows-msvc, 
isOSBinFormatCOFF() is true, but the section name should not include 
COMDATSymName suffix.
This part referred to existing code 
https://github.com/llvm/llvm-project/blob/cb2a2ba8d64da5be3fac0ea90e406270e8a615bd/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp#L1663
Thanks for this Windows-gnu comment! I reviewed Window-gnu related 
implementation and fixed Windows-gnu problem of 
TargetLoweringObjectFileCOFF::getSectionForMachineBasicBlock(). 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99487

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


[PATCH] D105759: [WIP] Implement P2361 Unevaluated string literals

2021-08-19 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 367409.
cor3ntin marked 10 inline comments as done.
cor3ntin added a comment.

Address most of Aaron's comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105759

Files:
  clang-tools-extra/test/clang-tidy/checkers/modernize-unary-static-assert.cpp
  clang/include/clang/AST/Expr.h
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Lex/LiteralSupport.h
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Expr.cpp
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Lex/LiteralSupport.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Lex/Pragma.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaStmtAsm.cpp
  clang/test/CXX/dcl.dcl/dcl.link/p2.cpp
  clang/test/CXX/dcl.dcl/p4-0x.cpp
  clang/test/FixIt/fixit-static-assert.cpp
  clang/test/Parser/asm.c
  clang/test/Parser/asm.cpp
  clang/test/Parser/attr-availability-xcore.c
  clang/test/Parser/attr-availability.c
  clang/test/Sema/asm.c
  clang/test/SemaCXX/static-assert.cpp

Index: clang/test/SemaCXX/static-assert.cpp
===
--- clang/test/SemaCXX/static-assert.cpp
+++ clang/test/SemaCXX/static-assert.cpp
@@ -28,12 +28,12 @@
 S s1; // expected-note {{in instantiation of template class 'S' requested here}}
 S s2;
 
-static_assert(false, L"\x"); // expected-error {{static_assert failed L"\x"}}
-static_assert(false, u"\U000317FF"); // expected-error {{static_assert failed u"\U000317FF"}}
+static_assert(false, L"\x"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}} expected-error {{hex escape sequence out of range}}
+static_assert(false, u"\U000317FF"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
 // FIXME: render this as u8"\u03A9"
-static_assert(false, u8"Ω"); // expected-error {{static_assert failed u8"\316\251"}}
-static_assert(false, L"\u1234"); // expected-error {{static_assert failed L"\x1234"}}
-static_assert(false, L"\x1ff" "0\x123" "fx\xf" "goop"); // expected-error {{static_assert failed L"\x1FF""0\x123""fx\xFgoop"}}
+static_assert(false, u8"Ω"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
+static_assert(false, L"\u1234"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
+static_assert(false, L"\x1ff" "0\x123" "fx\xf" "goop"); // expected-error {{an unevaluated string literal cannot have an encoding prefix}} expected-error 3{{hex escape sequence out of range}}
 
 template struct AlwaysFails {
   // Only give one error here.
Index: clang/test/Sema/asm.c
===
--- clang/test/Sema/asm.c
+++ clang/test/Sema/asm.c
@@ -37,14 +37,17 @@
   asm ("nop" : "=c" (a) : "r" (no_clobber_conflict) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
   asm ("nop" : "=r" (no_clobber_conflict) : "c" (c) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
   asm ("nop" : "=r" (clobber_conflict) : "c" (c) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
-  asm ("nop" : "=a" (a) : "b" (b) : "%rcx", "%rbx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}} 
+  asm("nop"
+  : "=a"(a)
+  : "b"(b)
+  : "%rcx", "%rbx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
 }
 
 // rdar://6094010
 void test3() {
   int x;
-  asm(L"foo" : "=r"(x)); // expected-error {{wide string}}
-  asm("foo" : L"=r"(x)); // expected-error {{wide string}}
+  asm(L"foo" : "=r"(x)); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
+  asm("foo" : L"=r"(x)); // expected-error {{an unevaluated string literal cannot have an encoding prefix}}
 }
 
 // 
Index: clang/test/Parser/attr-availability.c
===
--- clang/test/Parser/attr-availability.c
+++ clang/test/Parser/attr-availability.c
@@ -18,21 +18,24 @@
 
 void f6() __attribute__((availability(macosx,unavailable,introduced=10.5))); // expected-warning{{'unavailable' availability overrides all other availability information}}
 
-void f7() __attribute__((availability(macosx,message=L"wide"))); // expected-error {{expected string literal for optional message in '

[PATCH] D105759: [WIP] Implement P2361 Unevaluated string literals

2021-08-19 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

I addressed most of the comments. I still need to look at the 3 loops thing (I 
guess if the string is very long it could leave the cache? I am not actually 
sure it's an issue but maybe I can improve that), and then remain design 
questions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105759

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


[clang] cc3affd - [clang] [MSVC] Implement __mulh and __umulh builtins for aarch64

2021-08-19 Thread Martin Storsjö via cfe-commits

Author: Martin Storsjö
Date: 2021-08-19T11:29:55+03:00
New Revision: cc3affd8b02091bf475f9dd083802e1b6a232be1

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

LOG: [clang] [MSVC] Implement __mulh and __umulh builtins for aarch64

The code is based on the same __mulh and __umulh intrinsics for
x86.

This should fix PR51128.

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

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsAArch64.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Headers/intrin.h
clang/test/CodeGen/arm64-microsoft-intrinsics.c

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsAArch64.def 
b/clang/include/clang/Basic/BuiltinsAArch64.def
index 1dac5d2371d4..634bcaed20a6 100644
--- a/clang/include/clang/Basic/BuiltinsAArch64.def
+++ b/clang/include/clang/Basic/BuiltinsAArch64.def
@@ -243,6 +243,9 @@ TARGET_HEADER_BUILTIN(_ReadStatusReg,  "LLii",  "nh", 
"intrin.h", ALL_MS_LANGUAG
 TARGET_HEADER_BUILTIN(_WriteStatusReg, "viLLi", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(_AddressOfReturnAddress, "v*", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
 
+TARGET_HEADER_BUILTIN(__mulh,  "SLLiSLLiSLLi", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(__umulh, "ULLiULLiULLi", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
+
 #undef BUILTIN
 #undef LANGBUILTIN
 #undef TARGET_HEADER_BUILTIN

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index e172fc493a25..d74209ae27a4 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -9712,6 +9712,29 @@ Value *CodeGenFunction::EmitAArch64BuiltinExpr(unsigned 
BuiltinID,
 return Builder.CreateCall(F);
   }
 
+  if (BuiltinID == AArch64::BI__mulh || BuiltinID == AArch64::BI__umulh) {
+llvm::Type *ResType = ConvertType(E->getType());
+llvm::Type *Int128Ty = llvm::IntegerType::get(getLLVMContext(), 128);
+
+bool IsSigned = BuiltinID == AArch64::BI__mulh;
+Value *LHS =
+Builder.CreateIntCast(EmitScalarExpr(E->getArg(0)), Int128Ty, 
IsSigned);
+Value *RHS =
+Builder.CreateIntCast(EmitScalarExpr(E->getArg(1)), Int128Ty, 
IsSigned);
+
+Value *MulResult, *HigherBits;
+if (IsSigned) {
+  MulResult = Builder.CreateNSWMul(LHS, RHS);
+  HigherBits = Builder.CreateAShr(MulResult, 64);
+} else {
+  MulResult = Builder.CreateNUWMul(LHS, RHS);
+  HigherBits = Builder.CreateLShr(MulResult, 64);
+}
+HigherBits = Builder.CreateIntCast(HigherBits, ResType, IsSigned);
+
+return HigherBits;
+  }
+
   // Handle MSVC intrinsics before argument evaluation to prevent double
   // evaluation.
   if (Optional MsvcIntId = translateAarch64ToMsvcIntrin(BuiltinID))

diff  --git a/clang/lib/Headers/intrin.h b/clang/lib/Headers/intrin.h
index ff8eb8fca268..34ec79d6acbc 100644
--- a/clang/lib/Headers/intrin.h
+++ b/clang/lib/Headers/intrin.h
@@ -574,6 +574,9 @@ void _WriteStatusReg(int, __int64);
 unsigned short __cdecl _byteswap_ushort(unsigned short val);
 unsigned long __cdecl _byteswap_ulong (unsigned long val);
 unsigned __int64 __cdecl _byteswap_uint64(unsigned __int64 val);
+
+__int64 __mulh(__int64 __a, __int64 __b);
+unsigned __int64 __umulh(unsigned __int64 __a, unsigned __int64 __b);
 #endif
 
 
/**\

diff  --git a/clang/test/CodeGen/arm64-microsoft-intrinsics.c 
b/clang/test/CodeGen/arm64-microsoft-intrinsics.c
index ca8f270bd4f3..36f182433edd 100644
--- a/clang/test/CodeGen/arm64-microsoft-intrinsics.c
+++ b/clang/test/CodeGen/arm64-microsoft-intrinsics.c
@@ -81,6 +81,28 @@ void check_ReadWriteBarrier() {
 // CHECK-MSVC: fence syncscope("singlethread")
 // CHECK-LINUX: error: implicit declaration of function '_ReadWriteBarrier'
 
+long long check_mulh(long long a, long long b) {
+  return __mulh(a, b);
+}
+
+// CHECK-MSVC: %[[ARG1:.*]] = sext i64 {{.*}} to i128
+// CHECK-MSVC: %[[ARG2:.*]] = sext i64 {{.*}} to i128
+// CHECK-MSVC: %[[PROD:.*]] = mul nsw i128 %[[ARG1]], %[[ARG2]]
+// CHECK-MSVC: %[[HIGH:.*]] = ashr i128 %[[PROD]], 64
+// CHECK-MSVC: %[[RES:.*]] = trunc i128 %[[HIGH]] to i64
+// CHECK-LINUX: error: implicit declaration of function '__mulh'
+
+unsigned long long check_umulh(unsigned long long a, unsigned long long b) {
+  return __umulh(a, b);
+}
+
+// CHECK-MSVC: %[[ARG1:.*]] = zext i64 {{.*}} to i128
+// CHECK-MSVC: %[[ARG2:.*]] = zext i64 {{.*}} to i128
+// CHECK-MSVC: %[[PROD:.*]] = mul nuw i128 %[[ARG1]], %[[ARG2]]
+// CHECK-MSVC: %[[HIGH:.*]] = lshr i128 %[[PROD]], 64
+// CHECK-MSVC: %[[RES:.*]] = trunc i128 %[[HIGH]] to i64
+// CHECK-LINUX: error: implicit declaration of function '__umulh'
+
 unsigned __int64 check__getReg() {
   unsigned volatile __int64 reg;
   

[PATCH] D106721: [AArch64] Implemnt MSVC __mulh and __umulh builtins and corresponding IR level intrinsics

2021-08-19 Thread Martin Storsjö 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 rGcc3affd8b020: [clang] [MSVC] Implement __mulh and __umulh 
builtins for aarch64 (authored by mstorsjo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106721

Files:
  clang/include/clang/Basic/BuiltinsAArch64.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/intrin.h
  clang/test/CodeGen/arm64-microsoft-intrinsics.c


Index: clang/test/CodeGen/arm64-microsoft-intrinsics.c
===
--- clang/test/CodeGen/arm64-microsoft-intrinsics.c
+++ clang/test/CodeGen/arm64-microsoft-intrinsics.c
@@ -81,6 +81,28 @@
 // CHECK-MSVC: fence syncscope("singlethread")
 // CHECK-LINUX: error: implicit declaration of function '_ReadWriteBarrier'
 
+long long check_mulh(long long a, long long b) {
+  return __mulh(a, b);
+}
+
+// CHECK-MSVC: %[[ARG1:.*]] = sext i64 {{.*}} to i128
+// CHECK-MSVC: %[[ARG2:.*]] = sext i64 {{.*}} to i128
+// CHECK-MSVC: %[[PROD:.*]] = mul nsw i128 %[[ARG1]], %[[ARG2]]
+// CHECK-MSVC: %[[HIGH:.*]] = ashr i128 %[[PROD]], 64
+// CHECK-MSVC: %[[RES:.*]] = trunc i128 %[[HIGH]] to i64
+// CHECK-LINUX: error: implicit declaration of function '__mulh'
+
+unsigned long long check_umulh(unsigned long long a, unsigned long long b) {
+  return __umulh(a, b);
+}
+
+// CHECK-MSVC: %[[ARG1:.*]] = zext i64 {{.*}} to i128
+// CHECK-MSVC: %[[ARG2:.*]] = zext i64 {{.*}} to i128
+// CHECK-MSVC: %[[PROD:.*]] = mul nuw i128 %[[ARG1]], %[[ARG2]]
+// CHECK-MSVC: %[[HIGH:.*]] = lshr i128 %[[PROD]], 64
+// CHECK-MSVC: %[[RES:.*]] = trunc i128 %[[HIGH]] to i64
+// CHECK-LINUX: error: implicit declaration of function '__umulh'
+
 unsigned __int64 check__getReg() {
   unsigned volatile __int64 reg;
   reg = __getReg(18);
Index: clang/lib/Headers/intrin.h
===
--- clang/lib/Headers/intrin.h
+++ clang/lib/Headers/intrin.h
@@ -574,6 +574,9 @@
 unsigned short __cdecl _byteswap_ushort(unsigned short val);
 unsigned long __cdecl _byteswap_ulong (unsigned long val);
 unsigned __int64 __cdecl _byteswap_uint64(unsigned __int64 val);
+
+__int64 __mulh(__int64 __a, __int64 __b);
+unsigned __int64 __umulh(unsigned __int64 __a, unsigned __int64 __b);
 #endif
 
 
/**\
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -9712,6 +9712,29 @@
 return Builder.CreateCall(F);
   }
 
+  if (BuiltinID == AArch64::BI__mulh || BuiltinID == AArch64::BI__umulh) {
+llvm::Type *ResType = ConvertType(E->getType());
+llvm::Type *Int128Ty = llvm::IntegerType::get(getLLVMContext(), 128);
+
+bool IsSigned = BuiltinID == AArch64::BI__mulh;
+Value *LHS =
+Builder.CreateIntCast(EmitScalarExpr(E->getArg(0)), Int128Ty, 
IsSigned);
+Value *RHS =
+Builder.CreateIntCast(EmitScalarExpr(E->getArg(1)), Int128Ty, 
IsSigned);
+
+Value *MulResult, *HigherBits;
+if (IsSigned) {
+  MulResult = Builder.CreateNSWMul(LHS, RHS);
+  HigherBits = Builder.CreateAShr(MulResult, 64);
+} else {
+  MulResult = Builder.CreateNUWMul(LHS, RHS);
+  HigherBits = Builder.CreateLShr(MulResult, 64);
+}
+HigherBits = Builder.CreateIntCast(HigherBits, ResType, IsSigned);
+
+return HigherBits;
+  }
+
   // Handle MSVC intrinsics before argument evaluation to prevent double
   // evaluation.
   if (Optional MsvcIntId = translateAarch64ToMsvcIntrin(BuiltinID))
Index: clang/include/clang/Basic/BuiltinsAArch64.def
===
--- clang/include/clang/Basic/BuiltinsAArch64.def
+++ clang/include/clang/Basic/BuiltinsAArch64.def
@@ -243,6 +243,9 @@
 TARGET_HEADER_BUILTIN(_WriteStatusReg, "viLLi", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(_AddressOfReturnAddress, "v*", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
 
+TARGET_HEADER_BUILTIN(__mulh,  "SLLiSLLiSLLi", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(__umulh, "ULLiULLiULLi", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
+
 #undef BUILTIN
 #undef LANGBUILTIN
 #undef TARGET_HEADER_BUILTIN


Index: clang/test/CodeGen/arm64-microsoft-intrinsics.c
===
--- clang/test/CodeGen/arm64-microsoft-intrinsics.c
+++ clang/test/CodeGen/arm64-microsoft-intrinsics.c
@@ -81,6 +81,28 @@
 // CHECK-MSVC: fence syncscope("singlethread")
 // CHECK-LINUX: error: implicit declaration of function '_ReadWriteBarrier'
 
+long long check_mulh(long long a, long long b) {
+  return __mulh(a, b);
+}
+
+// CHECK-MSVC: %[[ARG1:.*]] = sext i64 {{.*}} to i128
+// CHECK-MSVC: %[[ARG2:.*]] = sext i64 {

[PATCH] D105267: [X86] AVX512FP16 instructions enabling 4/6

2021-08-19 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei added a comment.

Thanks Yuanke and Craig.




Comment at: llvm/lib/Target/X86/X86InstrAVX512.td:9279
 /// avx512_fp14_s rcp14ss, rcp14sd, rsqrt14ss, rsqrt14sd
 multiclass avx512_fp14_s opc, string OpcodeStr, SDNode OpNode,
+ X86FoldableSchedWrite sched, X86VectorVTInfo _,

LuoYuanke wrote:
> The name is not precise now. We now support non-fp14 node. Also update the 
> comments.
The precision of FP16 happens to 2-14 too, so the name is precise.



Comment at: llvm/lib/Target/X86/X86InstrAVX512.td:13476
+
+multiclass avx512_fp16_p_vl_all opc, string OpcodeStr, SDNode OpNode,
+   X86SchedWriteWidths sched> {

LuoYuanke wrote:
> Why not merge this class to avx512_fp14_p_vl_all? Is it because it doesn't 
> use MXCSR?
Not only the use of MXCSR but also naming. Anyway, I merged them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105267

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


[PATCH] D107539: [OpenCL] opencl-c.h: add __opencl_c_images and __opencl_c_read_write_images

2021-08-19 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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107539

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


[PATCH] D108323: [asan] Added -inline-small-callbacks LLVM flag, which would force inline code for 8 and 16 byte data types when otherwise a callback would have been used.

2021-08-19 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: clang/test/CodeGen/asan-use-callbacks.cpp:15
 
-int deref(int *p) {
+long deref(long *p) {
   return *p;

kcc wrote:
> As we introduce a difference in behavior for small and large accesses, 
> I would extend this test to have 1, 2, 4, and 16-byte accesses. 
changes in llvm/lib should be tested in corresponding llvm/test, not clang/test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108323

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


[PATCH] D107850: [asan] Implemented custom calling convention similar to the one used by HWASan for X86.

2021-08-19 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In D107850#2952641 , @kstoimenov 
wrote:

> I know it seems redundant to pass the constants with every function call, but 
> otherwise the code generation code will have to take dependency on 
> AddressSanitizerCommon.h, which I am not sure is ideal. I spent some time 
> looking into it and > becomes quite messy. For example the tests now need a 
> way to set the values for those variables. I think the main downside of this 
> approach is the bloat in the IR code, but it is cleaner than exposing 
> internal asan details.

Bloat in IR is bigger concert than include of AddressSanitizerCommon.h. And I 
don't see anything messy about that.
Similar AArch64/AArch64AsmPrinter.cpp does not hesitate to #include 
"llvm/Transforms/Instrumentation/HWAddressSanitizer.h"

> One other option I have looked into is to pass this info using the Module. 
> For example using the addModuleFlag function, but again there is a problem of 
> the tests. We could have a quick chat to discuss this if you want.

It will extend the language, we should try to avoid that if possible. So far 
all values directly calculated from target triple.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107850

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


[PATCH] D108359: [clang][NFC] Fix needless double-parenthisation

2021-08-19 Thread Andy Wingo via Phabricator via cfe-commits
wingo created this revision.
wingo requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Strip a layer of parentheses in TreeTransform::RebuildQualifiedType.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108359

Files:
  clang/lib/Sema/TreeTransform.h


Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -4745,8 +4745,8 @@
   SourceLocation Loc = TL.getBeginLoc();
   Qualifiers Quals = TL.getType().getLocalQualifiers();
 
-  if (((T.getAddressSpace() != LangAS::Default &&
-Quals.getAddressSpace() != LangAS::Default)) &&
+  if ((T.getAddressSpace() != LangAS::Default &&
+   Quals.getAddressSpace() != LangAS::Default) &&
   T.getAddressSpace() != Quals.getAddressSpace()) {
 SemaRef.Diag(Loc, diag::err_address_space_mismatch_templ_inst)
 << TL.getType() << T;


Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -4745,8 +4745,8 @@
   SourceLocation Loc = TL.getBeginLoc();
   Qualifiers Quals = TL.getType().getLocalQualifiers();
 
-  if (((T.getAddressSpace() != LangAS::Default &&
-Quals.getAddressSpace() != LangAS::Default)) &&
+  if ((T.getAddressSpace() != LangAS::Default &&
+   Quals.getAddressSpace() != LangAS::Default) &&
   T.getAddressSpace() != Quals.getAddressSpace()) {
 SemaRef.Diag(Loc, diag::err_address_space_mismatch_templ_inst)
 << TL.getType() << T;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108360: [clang][NFC] Remove dead code

2021-08-19 Thread Andy Wingo via Phabricator via cfe-commits
wingo created this revision.
wingo requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Remove code that has no effect in SemaType.cpp:processTypeAttrs.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108360

Files:
  clang/lib/Sema/SemaType.cpp


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -8303,10 +8303,6 @@
   attr.getMacroExpansionLoc());
 }
   }
-
-  if (!state.getSema().getLangOpts().OpenCL ||
-  type.getAddressSpace() != LangAS::Default)
-return;
 }
 
 void Sema::completeExprArrayBound(Expr *E) {


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -8303,10 +8303,6 @@
   attr.getMacroExpansionLoc());
 }
   }
-
-  if (!state.getSema().getLangOpts().OpenCL ||
-  type.getAddressSpace() != LangAS::Default)
-return;
 }
 
 void Sema::completeExprArrayBound(Expr *E) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D54943: [clang-tidy] implement const-transformation for cppcoreguidelines-const-correctness

2021-08-19 Thread Tiago Macarios via cfe-commits
I applied the patch on top of the clang13 RC and It seems not to be
generating any replacements. I haven't had the time to dig and understand
why. Diagnostics seem to be correct.

On Sun, Aug 15, 2021 at 12:16 PM Jonas Toth via Phabricator <
revi...@reviews.llvm.org> wrote:

> JonasToth added a comment.
>
> The check in the latest form can properly transform `llvm/lib` and
> `clang/` and requires 28 manual fixes afterwards (values and references are
> transformed, no other modifications).
>  Some are good and not an issue with the analysis itself, some may or may
> not be an issue with the analysis itself. I think it is more a template
> meta programming thing.
>
> Here is the branch that contains the changes:
> https://github.com/JonasToth/llvm-project/tree/transformation/2021-august-15-revision2
>
> Short Stats:
>
> - llvm/lib transformation: `1724 files changed, 62110 insertions(+), 62110
> deletions`; `26 manual fixes`
> - clang/ transformation: `819 files changed, 24166 insertions(+), 24166
> deletions`; `2 manual fixes`, one fix solves a ternary-operator issue where
> only one branch got `const`, the other one adds default construction
>
> I consider all 27 of them as false positives, but they might be bad
> const-correctness of the library code as well.
> Thats good enough?
>
> @0x8000- @tiagoma If you have time it would be great if you could
> check the transformation on your code bases.
> Everyone else is welcome to try it out too!
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D54943/new/
>
> https://reviews.llvm.org/D54943
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 36d5138 - [NewPM] Make some sanitizer passes parameterized in the PassRegistry

2021-08-19 Thread Bjorn Pettersson via cfe-commits

Author: Bjorn Pettersson
Date: 2021-08-19T12:43:37+02:00
New Revision: 36d51386195e3d606e0d40495f1135ab180bd6ae

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

LOG: [NewPM] Make some sanitizer passes parameterized in the PassRegistry

Refactored implementation of AddressSanitizerPass and
HWAddressSanitizerPass to use pass options similar to passes like
MemorySanitizerPass. This makes sure that there is a single mapping
from class name to pass name (needed by D108298), and options like
-debug-only and -print-after makes a bit more sense when (despite
that it is the unparameterized pass name that should be used in those
options).

A result of the above is that some pass names are removed in favor
of the parameterized versions:
- "khwasan" is now "hwasan"
- "kasan" is now "asan"
- "kmsan" is now "msan"

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

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp
llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
llvm/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Passes/PassRegistry.def
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
llvm/tools/opt/NewPMDriver.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 404d2680fac3..991620766b55 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -1161,7 +1161,7 @@ static void addSanitizers(const Triple &TargetTriple,
 CompileKernel, Recover, ModuleUseAfterScope, UseOdrIndicator,
 DestructorKind));
 MPM.addPass(createModuleToFunctionPassAdaptor(AddressSanitizerPass(
-CompileKernel, Recover, UseAfterScope, UseAfterReturn)));
+{CompileKernel, Recover, UseAfterScope, UseAfterReturn})));
   }
 };
 ASanPass(SanitizerKind::Address, false);
@@ -1171,8 +1171,8 @@ static void addSanitizers(const Triple &TargetTriple,
   if (LangOpts.Sanitize.has(Mask)) {
 bool Recover = CodeGenOpts.SanitizeRecover.has(Mask);
 MPM.addPass(HWAddressSanitizerPass(
-CompileKernel, Recover,
-/*DisableOptimization=*/CodeGenOpts.OptimizationLevel == 0));
+{CompileKernel, Recover,
+ /*DisableOptimization=*/CodeGenOpts.OptimizationLevel == 0}));
   }
 };
 HWASanPass(SanitizerKind::HWAddress, false);

diff  --git a/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h 
b/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
index de0871bc9921..9e8b97c0b94f 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
@@ -89,6 +89,20 @@ class ASanGlobalsMetadataAnalysis
   static AnalysisKey Key;
 };
 
+struct AddressSanitizerOptions {
+  AddressSanitizerOptions()
+  : AddressSanitizerOptions(false, false, false,
+AsanDetectStackUseAfterReturnMode::Runtime){};
+  AddressSanitizerOptions(bool CompileKernel, bool Recover, bool UseAfterScope,
+  AsanDetectStackUseAfterReturnMode UseAfterReturn)
+  : CompileKernel(CompileKernel), Recover(Recover),
+UseAfterScope(UseAfterScope), UseAfterReturn(UseAfterReturn){};
+  bool CompileKernel;
+  bool Recover;
+  bool UseAfterScope;
+  AsanDetectStackUseAfterReturnMode UseAfterReturn;
+};
+
 /// Public interface to the address sanitizer pass for instrumenting code to
 /// check for various memory errors at runtime.
 ///
@@ -98,19 +112,13 @@ class ASanGlobalsMetadataAnalysis
 /// surrounding requested memory to be checked for invalid accesses.
 class AddressSanitizerPass : public PassInfoMixin {
 public:
-  explicit AddressSanitizerPass(
-  bool CompileKernel = false, bool Recover = false,
-  bool UseAfterScope = false,
-  AsanDetectStackUseAfterReturnMode UseAfterReturn =
-  AsanDetectStackUseAfterReturnMode::Runtime);
+  explicit AddressSanitizerPass(AddressSanitizerOptions Options)
+  : Options(Options){};
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
   static bool isRequired() { return true; }
 
 private:
-  bool CompileKernel;
-  bool Recover;
-  bool UseAfterScope;
-  AsanDetectStackUseAfterReturnMode UseAfterReturn;
+  AddressSanitizerOptions Options;
 };
 
 /// Public interface to the address sanitizer module pass for instrumenting 
code

diff  --git a/llvm/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h 
b/llvm/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h
index 7942417d2bfa..07248baaa8b6 100644
--- a/llvm/include/llvm/Transforms/

[PATCH] D105007: [NewPM] Make some sanitizer passes parameterized in the PassRegistry

2021-08-19 Thread Bjorn Pettersson 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 rG36d51386195e: [NewPM] Make some sanitizer passes 
parameterized in the PassRegistry (authored by bjope).

Changed prior to commit:
  https://reviews.llvm.org/D105007?vs=367263&id=367445#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105007

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
  llvm/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
  llvm/tools/opt/NewPMDriver.cpp

Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -339,18 +339,19 @@
   PB.registerPipelineParsingCallback(
   [](StringRef Name, ModulePassManager &MPM,
  ArrayRef) {
+AddressSanitizerOptions Opts;
 if (Name == "asan-pipeline") {
   MPM.addPass(
   RequireAnalysisPass());
   MPM.addPass(
-  createModuleToFunctionPassAdaptor(AddressSanitizerPass()));
+  createModuleToFunctionPassAdaptor(AddressSanitizerPass(Opts)));
   MPM.addPass(ModuleAddressSanitizerPass());
   return true;
 } else if (Name == "asan-function-pipeline") {
   MPM.addPass(
   RequireAnalysisPass());
   MPM.addPass(
-  createModuleToFunctionPassAdaptor(AddressSanitizerPass()));
+  createModuleToFunctionPassAdaptor(AddressSanitizerPass(Opts)));
   return true;
 }
 return false;
Index: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -471,19 +471,14 @@
   DisableOptimization);
 }
 
-HWAddressSanitizerPass::HWAddressSanitizerPass(bool CompileKernel, bool Recover,
-   bool DisableOptimization)
-: CompileKernel(CompileKernel), Recover(Recover),
-  DisableOptimization(DisableOptimization) {}
-
 PreservedAnalyses HWAddressSanitizerPass::run(Module &M,
   ModuleAnalysisManager &MAM) {
   const StackSafetyGlobalInfo *SSI = nullptr;
   auto TargetTriple = llvm::Triple(M.getTargetTriple());
-  if (shouldUseStackSafetyAnalysis(TargetTriple, DisableOptimization))
+  if (shouldUseStackSafetyAnalysis(TargetTriple, Options.DisableOptimization))
 SSI = &MAM.getResult(M);
 
-  HWAddressSanitizer HWASan(M, CompileKernel, Recover, SSI);
+  HWAddressSanitizer HWASan(M, Options.CompileKernel, Options.Recover, SSI);
   bool Modified = false;
   auto &FAM = MAM.getResult(M).getManager();
   for (Function &F : M) {
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1212,20 +1212,14 @@
   return GlobalsMetadata(M);
 }
 
-AddressSanitizerPass::AddressSanitizerPass(
-bool CompileKernel, bool Recover, bool UseAfterScope,
-AsanDetectStackUseAfterReturnMode UseAfterReturn)
-: CompileKernel(CompileKernel), Recover(Recover),
-  UseAfterScope(UseAfterScope), UseAfterReturn(UseAfterReturn) {}
-
 PreservedAnalyses AddressSanitizerPass::run(Function &F,
 AnalysisManager &AM) {
   auto &MAMProxy = AM.getResult(F);
   Module &M = *F.getParent();
   if (auto *R = MAMProxy.getCachedResult(M)) {
 const TargetLibraryInfo *TLI = &AM.getResult(F);
-AddressSanitizer Sanitizer(M, R, CompileKernel, Recover, UseAfterScope,
-   UseAfterReturn);
+AddressSanitizer Sanitizer(M, R, Options.CompileKernel, Options.Recover,
+   Options.UseAfterScope, Options.UseAfterReturn);
 if (Sanitizer.instrumentFunction(F, TLI))
   return PreservedAnalyses::none();
 return PreservedAnalyses::all();
Index: llvm/lib/Passes/PassRegistry.def
===
--- llvm/lib/Passes/PassRegistry.def
+++ llvm/lib/Passes/PassRegistry.def
@@ -60,8 +60,6 @@
 MODULE_PASS("globalopt", GlobalOptPass())
 MODULE_PASS("globalsplit", GlobalSplitPass())
 MODULE_PASS("hotcoldsplit", HotColdSplittingPass())
-MODULE_PASS("hwasan", HWAddressSanitizerPass(false, false))
-MODULE_PASS("khwasan", HWAddressSanitizerPass(true, true))
 MODULE_

[clang] 7bda1a0 - [OpenCL] Fix as_type(vec3) invalid store creation

2021-08-19 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2021-08-19T11:57:09+01:00
New Revision: 7bda1a0711c67fde5f9bac5e1c9bd68163659d0e

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

LOG: [OpenCL] Fix as_type(vec3) invalid store creation

With -fpreserve-vec3-type enabled, a cast was not created when
converting from a vec3 type to a non-vec3 type, even though a
conversion to vec4 was performed.  This resulted in creation of
invalid store instructions.

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

Added: 


Modified: 
clang/lib/CodeGen/CGExprScalar.cpp
clang/test/CodeGenOpenCL/preserve_vec3.cl

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index e47701915f2f..5485b3d363fb 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -4785,11 +4785,8 @@ Value *ScalarExprEmitter::VisitAsTypeExpr(AsTypeExpr *E) 
{
   // vector to get a vec4, then a bitcast if the target type is 
diff erent.
   if (NumElementsSrc == 3 && NumElementsDst != 3) {
 Src = ConvertVec3AndVec4(Builder, CGF, Src, 4);
-
-if (!CGF.CGM.getCodeGenOpts().PreserveVec3Type) {
-  Src = createCastsForTypeOfSameSize(Builder, CGF.CGM.getDataLayout(), Src,
- DstTy);
-}
+Src = createCastsForTypeOfSameSize(Builder, CGF.CGM.getDataLayout(), Src,
+   DstTy);
 
 Src->setName("astype");
 return Src;

diff  --git a/clang/test/CodeGenOpenCL/preserve_vec3.cl 
b/clang/test/CodeGenOpenCL/preserve_vec3.cl
index 9260af6167e9..2237cf1e27e4 100644
--- a/clang/test/CodeGenOpenCL/preserve_vec3.cl
+++ b/clang/test/CodeGenOpenCL/preserve_vec3.cl
@@ -1,5 +1,8 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown 
-fpreserve-vec3-type | FileCheck %s
 
+typedef char char3 __attribute__((ext_vector_type(3)));
+typedef short short3 __attribute__((ext_vector_type(3)));
+typedef double double2 __attribute__((ext_vector_type(2)));
 typedef float float3 __attribute__((ext_vector_type(3)));
 typedef float float4 __attribute__((ext_vector_type(4)));
 
@@ -25,3 +28,28 @@ void kernel float3_to_float4(global float3 *a, global float4 
*b) {
   // CHECK: store <4 x float> %[[ASTYPE]], <4 x float> addrspace(1)* %b, align 
16
   *b = __builtin_astype(*a, float4);
 }
+
+void kernel float3_to_double2(global float3 *a, global double2 *b) {
+  // CHECK-LABEL: spir_kernel void @float3_to_double2
+  // CHECK: %[[LOAD_A:.*]] = load <3 x float>, <3 x float> addrspace(1)* %a, 
align 16
+  // CHECK: %[[ASTYPE:.*]] = shufflevector <3 x float> %[[LOAD_A]], <3 x 
float> poison, <4 x i32> 
+  // CHECK: %[[OUT_BC:.*]] = bitcast <2 x double> addrspace(1)* %b to <4 x 
float> addrspace(1)*
+  // CHECK: store <4 x float> %[[ASTYPE]], <4 x float> addrspace(1)* 
%[[OUT_BC]], align 16
+  *b = __builtin_astype(*a, double2);
+}
+
+void from_char3(char3 a, global int *out) {
+  // CHECK-LABEL: void @from_char3
+  // CHECK: %[[ASTYPE:.*]] = shufflevector <3 x i8> %a, <3 x i8> poison, <4 x 
i32> 
+  // CHECK: %[[OUT_BC:.*]] = bitcast i32 addrspace(1)* %out to <4 x i8> 
addrspace(1)*
+  // CHECK: store <4 x i8> %[[ASTYPE]], <4 x i8> addrspace(1)* %[[OUT_BC]]
+  *out = __builtin_astype(a, int);
+}
+
+void from_short3(short3 a, global long *out) {
+  // CHECK-LABEL: void @from_short3
+  // CHECK: %[[ASTYPE:.*]] = shufflevector <3 x i16> %a, <3 x i16> poison, <4 
x i32> 
+  // CHECK: %[[OUT_BC:.*]] = bitcast i64 addrspace(1)* %out to <4 x i16> 
addrspace(1)*
+  // CHECK: store <4 x i16> %[[ASTYPE]], <4 x i16> addrspace(1)* %[[OUT_BC]]
+  *out = __builtin_astype(a, long);
+}



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


[PATCH] D107963: [OpenCL] Fix as_type(vec3) invalid store creation

2021-08-19 Thread Sven van Haastregt via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7bda1a0711c6: [OpenCL] Fix as_type(vec3) invalid store 
creation (authored by svenvh).

Changed prior to commit:
  https://reviews.llvm.org/D107963?vs=365993&id=367448#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107963

Files:
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/test/CodeGenOpenCL/preserve_vec3.cl


Index: clang/test/CodeGenOpenCL/preserve_vec3.cl
===
--- clang/test/CodeGenOpenCL/preserve_vec3.cl
+++ clang/test/CodeGenOpenCL/preserve_vec3.cl
@@ -1,5 +1,8 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown 
-fpreserve-vec3-type | FileCheck %s
 
+typedef char char3 __attribute__((ext_vector_type(3)));
+typedef short short3 __attribute__((ext_vector_type(3)));
+typedef double double2 __attribute__((ext_vector_type(2)));
 typedef float float3 __attribute__((ext_vector_type(3)));
 typedef float float4 __attribute__((ext_vector_type(4)));
 
@@ -25,3 +28,28 @@
   // CHECK: store <4 x float> %[[ASTYPE]], <4 x float> addrspace(1)* %b, align 
16
   *b = __builtin_astype(*a, float4);
 }
+
+void kernel float3_to_double2(global float3 *a, global double2 *b) {
+  // CHECK-LABEL: spir_kernel void @float3_to_double2
+  // CHECK: %[[LOAD_A:.*]] = load <3 x float>, <3 x float> addrspace(1)* %a, 
align 16
+  // CHECK: %[[ASTYPE:.*]] = shufflevector <3 x float> %[[LOAD_A]], <3 x 
float> poison, <4 x i32> 
+  // CHECK: %[[OUT_BC:.*]] = bitcast <2 x double> addrspace(1)* %b to <4 x 
float> addrspace(1)*
+  // CHECK: store <4 x float> %[[ASTYPE]], <4 x float> addrspace(1)* 
%[[OUT_BC]], align 16
+  *b = __builtin_astype(*a, double2);
+}
+
+void from_char3(char3 a, global int *out) {
+  // CHECK-LABEL: void @from_char3
+  // CHECK: %[[ASTYPE:.*]] = shufflevector <3 x i8> %a, <3 x i8> poison, <4 x 
i32> 
+  // CHECK: %[[OUT_BC:.*]] = bitcast i32 addrspace(1)* %out to <4 x i8> 
addrspace(1)*
+  // CHECK: store <4 x i8> %[[ASTYPE]], <4 x i8> addrspace(1)* %[[OUT_BC]]
+  *out = __builtin_astype(a, int);
+}
+
+void from_short3(short3 a, global long *out) {
+  // CHECK-LABEL: void @from_short3
+  // CHECK: %[[ASTYPE:.*]] = shufflevector <3 x i16> %a, <3 x i16> poison, <4 
x i32> 
+  // CHECK: %[[OUT_BC:.*]] = bitcast i64 addrspace(1)* %out to <4 x i16> 
addrspace(1)*
+  // CHECK: store <4 x i16> %[[ASTYPE]], <4 x i16> addrspace(1)* %[[OUT_BC]]
+  *out = __builtin_astype(a, long);
+}
Index: clang/lib/CodeGen/CGExprScalar.cpp
===
--- clang/lib/CodeGen/CGExprScalar.cpp
+++ clang/lib/CodeGen/CGExprScalar.cpp
@@ -4785,11 +4785,8 @@
   // vector to get a vec4, then a bitcast if the target type is different.
   if (NumElementsSrc == 3 && NumElementsDst != 3) {
 Src = ConvertVec3AndVec4(Builder, CGF, Src, 4);
-
-if (!CGF.CGM.getCodeGenOpts().PreserveVec3Type) {
-  Src = createCastsForTypeOfSameSize(Builder, CGF.CGM.getDataLayout(), Src,
- DstTy);
-}
+Src = createCastsForTypeOfSameSize(Builder, CGF.CGM.getDataLayout(), Src,
+   DstTy);
 
 Src->setName("astype");
 return Src;


Index: clang/test/CodeGenOpenCL/preserve_vec3.cl
===
--- clang/test/CodeGenOpenCL/preserve_vec3.cl
+++ clang/test/CodeGenOpenCL/preserve_vec3.cl
@@ -1,5 +1,8 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown -fpreserve-vec3-type | FileCheck %s
 
+typedef char char3 __attribute__((ext_vector_type(3)));
+typedef short short3 __attribute__((ext_vector_type(3)));
+typedef double double2 __attribute__((ext_vector_type(2)));
 typedef float float3 __attribute__((ext_vector_type(3)));
 typedef float float4 __attribute__((ext_vector_type(4)));
 
@@ -25,3 +28,28 @@
   // CHECK: store <4 x float> %[[ASTYPE]], <4 x float> addrspace(1)* %b, align 16
   *b = __builtin_astype(*a, float4);
 }
+
+void kernel float3_to_double2(global float3 *a, global double2 *b) {
+  // CHECK-LABEL: spir_kernel void @float3_to_double2
+  // CHECK: %[[LOAD_A:.*]] = load <3 x float>, <3 x float> addrspace(1)* %a, align 16
+  // CHECK: %[[ASTYPE:.*]] = shufflevector <3 x float> %[[LOAD_A]], <3 x float> poison, <4 x i32> 
+  // CHECK: %[[OUT_BC:.*]] = bitcast <2 x double> addrspace(1)* %b to <4 x float> addrspace(1)*
+  // CHECK: store <4 x float> %[[ASTYPE]], <4 x float> addrspace(1)* %[[OUT_BC]], align 16
+  *b = __builtin_astype(*a, double2);
+}
+
+void from_char3(char3 a, global int *out) {
+  // CHECK-LABEL: void @from_char3
+  // CHECK: %[[ASTYPE:.*]] = shufflevector <3 x i8> %a, <3 x i8> poison, <4 x i32> 
+  // CHECK: %[[OUT_BC:.*]] = bitcast i32 addrspace(1)* %out to <4 x i8> addrspace(1)*
+  // CHECK: store <4 x i8> %[[ASTYPE]], <4 x i8> addrspace(1)* %[[OUT_BC]]
+  *out = __bui

[PATCH] D108339: [openmp][nfc] Replace OMPGridValues array with struct

2021-08-19 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

Given this patch, I can then template the amdgpu one on wavesize to get 
something that is a compile time constant in the devicertl and easily used from 
clang/host plugin. Expecting to have a few refactors following on from this to 
make the gfx9/gfx10 abstraction dry.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108339

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


[PATCH] D108339: [openmp][nfc] Replace OMPGridValues array with struct

2021-08-19 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield updated this revision to Diff 367451.
JonChesterfield added a comment.

- revert to unsigned, file doesn't currently require stdint


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108339

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/NVPTX.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeAMDGCN.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
  llvm/include/llvm/Frontend/OpenMP/OMPGridValues.h
  openmp/libomptarget/plugins/amdgpu/src/rtl.cpp

Index: openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
===
--- openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
+++ openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
@@ -501,14 +501,11 @@
   static const unsigned HardTeamLimit =
   (1 << 16) - 1; // 64K needed to fit in uint16
   static const int DefaultNumTeams = 128;
-  static const int Max_Teams =
-  llvm::omp::AMDGPUGpuGridValues[llvm::omp::GVIDX::GV_Max_Teams];
-  static const int Warp_Size =
-  llvm::omp::AMDGPUGpuGridValues[llvm::omp::GVIDX::GV_Warp_Size];
-  static const int Max_WG_Size =
-  llvm::omp::AMDGPUGpuGridValues[llvm::omp::GVIDX::GV_Max_WG_Size];
+  static const int Max_Teams = llvm::omp::AMDGPUGridValues.GV_Max_Teams;
+  static const int Warp_Size = llvm::omp::AMDGPUGridValues.GV_Warp_Size;
+  static const int Max_WG_Size = llvm::omp::AMDGPUGridValues.GV_Max_WG_Size;
   static const int Default_WG_Size =
-  llvm::omp::AMDGPUGpuGridValues[llvm::omp::GVIDX::GV_Default_WG_Size];
+  llvm::omp::AMDGPUGridValues.GV_Default_WG_Size;
 
   using MemcpyFunc = hsa_status_t (*)(hsa_signal_t, void *, const void *,
   size_t size, hsa_agent_t);
@@ -1058,9 +1055,8 @@
 DeviceInfo.WarpSize[device_id] = wavefront_size;
   } else {
 DP("Default wavefront size: %d\n",
-   llvm::omp::AMDGPUGpuGridValues[llvm::omp::GVIDX::GV_Warp_Size]);
-DeviceInfo.WarpSize[device_id] =
-llvm::omp::AMDGPUGpuGridValues[llvm::omp::GVIDX::GV_Warp_Size];
+   llvm::omp::AMDGPUGridValues.GV_Warp_Size);
+DeviceInfo.WarpSize[device_id] = llvm::omp::AMDGPUGridValues.GV_Warp_Size;
   }
 
   // Adjust teams to the env variables
Index: llvm/include/llvm/Frontend/OpenMP/OMPGridValues.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPGridValues.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPGridValues.h
@@ -29,68 +29,69 @@
 ///
 /// Example usage in clang:
 ///   const unsigned slot_size =
-///   ctx.GetTargetInfo().getGridValue(llvm::omp::GVIDX::GV_Warp_Size);
+///   ctx.GetTargetInfo().getGridValue().GV_Warp_Size;
 ///
 /// Example usage in libomptarget/deviceRTLs:
 ///   #include "llvm/Frontend/OpenMP/OMPGridValues.h"
 ///   #ifdef __AMDGPU__
-/// #define GRIDVAL AMDGPUGpuGridValues
+/// #define GRIDVAL AMDGPUGridValues
 ///   #else
-/// #define GRIDVAL NVPTXGpuGridValues
+/// #define GRIDVAL NVPTXGridValues
 ///   #endif
 ///   ... Then use this reference for GV_Warp_Size in the deviceRTL source.
-///   llvm::omp::GRIDVAL[llvm::omp::GVIDX::GV_Warp_Size]
+///   llvm::omp::GRIDVAL().GV_Warp_Size
 ///
 /// Example usage in libomptarget hsa plugin:
 ///   #include "llvm/Frontend/OpenMP/OMPGridValues.h"
-///   #define GRIDVAL AMDGPUGpuGridValues
+///   #define GRIDVAL AMDGPUGridValues
 ///   ... Then use this reference to access GV_Warp_Size in the hsa plugin.
-///   llvm::omp::GRIDVAL[llvm::omp::GVIDX::GV_Warp_Size]
+///   llvm::omp::GRIDVAL().GV_Warp_Size
 ///
 /// Example usage in libomptarget cuda plugin:
 ///#include "llvm/Frontend/OpenMP/OMPGridValues.h"
-///#define GRIDVAL NVPTXGpuGridValues
+///#define GRIDVAL NVPTXGridValues
 ///   ... Then use this reference to access GV_Warp_Size in the cuda plugin.
-///llvm::omp::GRIDVAL[llvm::omp::GVIDX::GV_Warp_Size]
+///llvm::omp::GRIDVAL().GV_Warp_Size
 ///
-enum GVIDX {
+
+struct GV {
   /// The maximum number of workers in a kernel.
   /// (THREAD_ABSOLUTE_LIMIT) - (GV_Warp_Size), might be issue for blockDim.z
-  GV_Threads,
+  const unsigned GV_Threads;
   /// The size reserved for data in a shared memory slot.
-  GV_Slot_Size,
+  const unsigned GV_Slot_Size;
   /// The default value of maximum number of threads in a worker warp.
-  GV_Warp_Size,
+  const unsigned GV_Warp_Size;
   /// Alternate warp size for some AMDGCN architectures. Same as GV_Warp_Size
   /// for NVPTX.
-  GV_Warp_Size_32,
+  const unsigned GV_Warp_Size_32;
   /// The number of bits required to represent the max number of threads in warp
-  GV_Warp_Size_Log2,
+  const unsigned GV_Warp_Size_Log2;
   /// GV_Warp_Size * GV_Slot_Size,
-  GV_Warp_Slot_Size,
+  const unsigned GV_Warp_Slot_Size;
   /// the maximum number of teams.
-  GV_Max_Teams,
+  const unsigned GV_Max_Teams;
   /// Global Memory Alignm

[PATCH] D108320: Add semantic token modifier for non-const reference parameter

2021-08-19 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Agree this is nice, well done! A few more notes for consideration...




Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:314
 //   (these tend to be vague, like Type or Unknown)
+// - Resolved tokens (i.e. without the "dependent-name" modifier) with kind
+//   "Unknown" are less reliable than resolved tokens with other kinds

nridge wrote:
> We should consider the case where a dependent name is passed by non-const 
> reference, for example:
> 
> ```
> void increment_counter(int&);
> 
> template 
> void bar() {
>increment_counter(T::static_counter);
> }
> ```
> 
> This case does not work yet with the current patch (the dependent name is a 
> `DependentScopeDeclRefExpr` rather than a `DeclRefExpr`), but we'll want to 
> make it work in the future.
> 
> With the conflict resolution logic in this patch, the `Unknown` token kind 
> from `highlightPassedByNonConstReference()` will be chosen over the dependent 
> token kind.
> 
> As it happens, the dependent token kind for expressions is also `Unknown` so 
> it doesn't matter, but perhaps we shouldn't be relying on this. Perhaps the 
> following would make more sense:
> 
> 1. a token with `Unknown` as the kind has the lowest priority
> 2. then a token with the `DependentName` modifier (next lowest)
> 3. then everything else?
The conflict-resolution idea is subtle (and IME hard to debug). I'm wary of 
overloading it by deliberately introducing "conflicts" that should actually be 
merged. Did you consider the idea of tracking extra modifiers separately and 
merging them in at the end?

---

BTW: we're stretching the meaning of `Unknown` here. There are two subtly 
different concepts:
 - clangd happens not to have determined the kind of this token, e.g. because 
we missed a case (uses in this patch)
 - clangd has determined that per C++ rules the kind of token is ambiguous 
(uses prior to this patch)
Call me weird, but I have "Unknown" highlighted in bright orange in my editor, 
because I want to know about the second case :-)



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:514
+  bool VisitCallExpr(CallExpr *E) {
+// Highlighting parameters passed by non-const reference does not really
+// make sence for these

CXXOperatorCallExpr seems to make sense to me for the most part:
 - functor calls are CXXOperatorCallExpr
 - if `x + y` mutates y, I want to know that

There are some exceptions though:
  - the functor object itself is more like the function callee, and to be 
consistent we shouldn't highlight it
  - highlighting `x` in `x += y` is weird
  - `a << b` is a weird ambiguous case ("stream" vs "shift" want different 
behavior)

I think these can be handled by choosing a minimum argument index to highlight 
based on the operator type.

I think it makes sense to leave operators out of scope for this patch, but IMO 
should be a "FIXME" rather than a "let's never do this" :-)



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:528
+
+  void highlightPassedByNonConstReference(
+  const FunctionDecl *FD,

nit: this function name is a bit hard to parse, "highlight" is a transitive 
verb but the rest of the name isn't its object.

Maybe `highlightMutableReferenceArguments`?



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:538
+for (size_t I = 0; I < FD->getNumParams(); ++I) {
+  if (const auto *Param = FD->getParamDecl(I)) {
+auto T = Param->getType();

I feel like you'd be better off using the FunctionProtoType and iterating over 
argument types, rather than the argument declarations on a particular 
declaration of the function.

e.g. this code is legal in C:
```
int x(); // i suspect this is the canonical decl
int x(int); // but this one provides the type
```
We don't have references in C of course!, but maybe similar issues lurking...



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:542
+// Is this parameter passed by non-const reference?
+if (T->isLValueReferenceType() && !isConst(T)) {
+  if (auto *Arg = GetArgExprAtIndex(I)) {

nridge wrote:
> I think there are some edge cases where `isConst()` doesn't do what we want.
> 
> For example, I think for a parameter of type `const int*&`, it will return 
> `true` (and thus we will **not** highlight the corresponding argument), even 
> thus this is actually a non-const reference.
> 
> So, we may want to use a dedicated function that specifically handles 
> reference-related logic only.
> 
> (This probably also makes a good test case.)
Yeah this is the core of this modifier, worth being precise and explicit here. 
I think we want to match only reference types where the inner type is not 
top-level const.

I think we should also conservatively forbid the inner type from being 
*dependent*. Consider the followi

[PATCH] D105177: [clangd] Implemented indexing of standard library

2021-08-19 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

> I removed Refs, Relations and Graph as per your comment. However I have to 
> admit, I don't know what they are and how they are used.
> What's a good place to look at so that I learn what they do?

Sorry about missing this.
The best place is the `SymbolIndex` interface - Symbols corresponds to the 
`fuzzyFind`/`lookup` methods, refs and relations each have their own methods. 
You can somewhat guess from the methods/data structures what these are used 
for, but clangd can answer your question! e.g. find-references on `refs()` will 
show you it is used in the find-references implementation :-) As well as rename 
and others.

Include graph is a bit of a special case, it's basically just used for 
partitioning, incrementally updating, and loading the background index IIRC.




Comment at: clang-tools-extra/clangd/index/StdLib.cpp:72
+  Inputs.TFS = &TFS;
+  // TODO: can we get a real compile command from somewhere?
+  Inputs.CompileCommand.Directory = virtualRoot().str();

nridge wrote:
> sammccall wrote:
> > I'm not sure what this means, I don't think there's anything better to do 
> > here.
> One could imagine picking a source file from the project's CDB, and using its 
> flags to parse the standard library.
> 
> That could be relevant for macros that affect the way standard library 
> headers are parsed (like `_GLIBCXX_DEBUG` perhaps?)
Oh, that makes sense. I'd still probably not do this, given:
 - for projects with a CDB, we'll probably bg-index most of the stdlib in that 
configuration soon anyway.
 - until we see evidence otherwise, my guess is differences are pretty minor. 
(Honestly if it were easy to just ship a prebuilt index for code completion, I 
would be tempted.)
 - it adds some constraints on design/layering/sequencing etc
 - it makes questions of how many configurations to build/when to reuse vs 
invalidate more complicated


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105177

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


[PATCH] D108111: [CodeComplete] Only complete attributes that match the current LangOpts

2021-08-19 Thread Sam McCall 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 rGa1ebae08f4b2: [CodeComplete] Only complete attributes that 
match the current LangOpts (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108111

Files:
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/attr.cpp


Index: clang/test/CodeCompletion/attr.cpp
===
--- clang/test/CodeCompletion/attr.cpp
+++ clang/test/CodeCompletion/attr.cpp
@@ -7,11 +7,14 @@
 // STD-NOT: COMPLETION: __used__
 // STD: COMPLETION: _Clang::__convergent__
 // STD: COMPLETION: carries_dependency
+// STD-NOT: COMPLETION: clang::called_once
 // STD: COMPLETION: clang::convergent
 // STD-NOT: COMPLETION: convergent
 // STD-NOT: COMPLETION: gnu::__used__
 // STD: COMPLETION: gnu::used
 // STD-NOT: COMPLETION: used
+// RUN: %clang_cc1 -code-completion-at=%s:1:9 -xobjective-c++ %s | FileCheck 
--check-prefix=STD-OBJC %s
+// STD-OBJC: COMPLETION: clang::called_once
 // RUN: %clang_cc1 -code-completion-at=%s:1:14 %s | FileCheck 
--check-prefix=STD-NS %s
 // STD-NS-NOT: COMPLETION: __used__
 // STD-NS-NOT: COMPLETION: carries_dependency
@@ -20,12 +23,12 @@
 // STD-NS-NOT: COMPLETION: gnu::used
 // STD-NS: COMPLETION: used
 int b [[__gnu__::used]];
-// RUN: %clang_cc1 -code-completion-at=%s:22:18 %s | FileCheck 
--check-prefix=STD-NSU %s
+// RUN: %clang_cc1 -code-completion-at=%s:25:18 %s | FileCheck 
--check-prefix=STD-NSU %s
 // STD-NSU: COMPLETION: __used__
 // STD-NSU-NOT: COMPLETION: used
 
 int c [[using gnu: used]];
-// RUN: %clang_cc1 -code-completion-at=%s:27:15 %s | FileCheck 
--check-prefix=STD-USING %s
+// RUN: %clang_cc1 -code-completion-at=%s:30:15 %s | FileCheck 
--check-prefix=STD-USING %s
 // STD-USING: COMPLETION: __gnu__
 // STD-USING: COMPLETION: _Clang
 // STD-USING-NOT: COMPLETION: carries_dependency
@@ -33,10 +36,10 @@
 // STD-USING-NOT: COMPLETION: clang::
 // STD-USING-NOT: COMPLETION: gnu::
 // STD-USING: COMPLETION: gnu
-// RUN: %clang_cc1 -code-completion-at=%s:27:20 %s | FileCheck 
--check-prefix=STD-NS %s
+// RUN: %clang_cc1 -code-completion-at=%s:30:20 %s | FileCheck 
--check-prefix=STD-NS %s
 
 int d __attribute__((used));
-// RUN: %clang_cc1 -code-completion-at=%s:38:22 %s | FileCheck 
--check-prefix=GNU %s
+// RUN: %clang_cc1 -code-completion-at=%s:41:22 %s | FileCheck 
--check-prefix=GNU %s
 // GNU: COMPLETION: __carries_dependency__
 // GNU: COMPLETION: __convergent__
 // GNU-NOT: COMPLETION: __gnu__::__used__
@@ -51,12 +54,12 @@
 #pragma clang attribute push (__attribute__((internal_linkage)), 
apply_to=variable)
 int e;
 #pragma clang attribute pop
-// RUN: %clang_cc1 -code-completion-at=%s:51:46 %s | FileCheck 
--check-prefix=PRAGMA %s
+// RUN: %clang_cc1 -code-completion-at=%s:54:46 %s | FileCheck 
--check-prefix=PRAGMA %s
 // PRAGMA: internal_linkage
 
 #ifdef MS_EXT
 int __declspec(thread) f;
-// RUN: %clang_cc1 -fms-extensions -DMS_EXT -code-completion-at=%s:58:16 %s | 
FileCheck --check-prefix=DS %s
+// RUN: %clang_cc1 -fms-extensions -DMS_EXT -code-completion-at=%s:61:16 %s | 
FileCheck --check-prefix=DS %s
 // DS-NOT: COMPLETION: __convergent__
 // DS-NOT: COMPLETION: __used__
 // DS-NOT: COMPLETION: clang::convergent
@@ -66,7 +69,7 @@
 // DS: COMPLETION: uuid
 
 [uuid("123e4567-e89b-12d3-a456-426614174000")] struct g;
-// RUN: %clang_cc1 -fms-extensions -DMS_EXT -code-completion-at=%s:68:2 %s | 
FileCheck --check-prefix=MS %s
+// RUN: %clang_cc1 -fms-extensions -DMS_EXT -code-completion-at=%s:71:2 %s | 
FileCheck --check-prefix=MS %s
 // MS-NOT: COMPLETION: __uuid__
 // MS-NOT: COMPLETION: clang::convergent
 // MS-NOT: COMPLETION: convergent
@@ -80,9 +83,9 @@
   {}
 }
 // FIXME: support for omp attributes would be nice.
-// RUN: %clang_cc1 -fopenmp -code-completion-at=%s:79:5 %s | FileCheck 
--check-prefix=OMP-NS --allow-empty %s
+// RUN: %clang_cc1 -fopenmp -code-completion-at=%s:82:5 %s | FileCheck 
--check-prefix=OMP-NS --allow-empty %s
 // OMP-NS-NOT: omp
-// RUN: %clang_cc1 -fopenmp -code-completion-at=%s:79:10 %s | FileCheck 
--check-prefix=OMP-ATTR --allow-empty %s
+// RUN: %clang_cc1 -fopenmp -code-completion-at=%s:82:10 %s | FileCheck 
--check-prefix=OMP-ATTR --allow-empty %s
 // OMP-ATTR-NOT: sequence
-// RUN: %clang_cc1 -fopenmp -code-completion-at=%s:79:19 %s | FileCheck 
--check-prefix=OMP-NESTED --allow-empty %s
+// RUN: %clang_cc1 -fopenmp -code-completion-at=%s:82:19 %s | FileCheck 
--check-prefix=OMP-NESTED --allow-empty %s
 // OMP-NESTED-NOT: directive
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -4389,7 +4389,8 @@
   auto AddCompletions = [&](const Pa

[clang] a1ebae0 - [CodeComplete] Only complete attributes that match the current LangOpts

2021-08-19 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-08-19T13:35:07+02:00
New Revision: a1ebae08f4b243419738c3b3f0455160a880f861

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

LOG: [CodeComplete] Only complete attributes that match the current LangOpts

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

Added: 


Modified: 
clang/lib/Sema/SemaCodeComplete.cpp
clang/test/CodeCompletion/attr.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaCodeComplete.cpp 
b/clang/lib/Sema/SemaCodeComplete.cpp
index e8e8fb209cc9..445ab4885cfa 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -4389,7 +4389,8 @@ void 
Sema::CodeCompleteAttribute(AttributeCommonInfo::Syntax Syntax,
   auto AddCompletions = [&](const ParsedAttrInfo &A) {
 if (A.IsTargetSpecific && !A.existsInTarget(Context.getTargetInfo()))
   return;
-// FIXME: filter by langopts (diagLangOpts method requires a ParsedAttr)
+if (!A.acceptsLangOpts(getLangOpts()))
+  return;
 for (const auto &S : A.Spellings) {
   if (S.Syntax != Syntax)
 continue;

diff  --git a/clang/test/CodeCompletion/attr.cpp 
b/clang/test/CodeCompletion/attr.cpp
index 61807cf4984c..782e5a1d75ec 100644
--- a/clang/test/CodeCompletion/attr.cpp
+++ b/clang/test/CodeCompletion/attr.cpp
@@ -7,11 +7,14 @@ int a [[gnu::used]];
 // STD-NOT: COMPLETION: __used__
 // STD: COMPLETION: _Clang::__convergent__
 // STD: COMPLETION: carries_dependency
+// STD-NOT: COMPLETION: clang::called_once
 // STD: COMPLETION: clang::convergent
 // STD-NOT: COMPLETION: convergent
 // STD-NOT: COMPLETION: gnu::__used__
 // STD: COMPLETION: gnu::used
 // STD-NOT: COMPLETION: used
+// RUN: %clang_cc1 -code-completion-at=%s:1:9 -xobjective-c++ %s | FileCheck 
--check-prefix=STD-OBJC %s
+// STD-OBJC: COMPLETION: clang::called_once
 // RUN: %clang_cc1 -code-completion-at=%s:1:14 %s | FileCheck 
--check-prefix=STD-NS %s
 // STD-NS-NOT: COMPLETION: __used__
 // STD-NS-NOT: COMPLETION: carries_dependency
@@ -20,12 +23,12 @@ int a [[gnu::used]];
 // STD-NS-NOT: COMPLETION: gnu::used
 // STD-NS: COMPLETION: used
 int b [[__gnu__::used]];
-// RUN: %clang_cc1 -code-completion-at=%s:22:18 %s | FileCheck 
--check-prefix=STD-NSU %s
+// RUN: %clang_cc1 -code-completion-at=%s:25:18 %s | FileCheck 
--check-prefix=STD-NSU %s
 // STD-NSU: COMPLETION: __used__
 // STD-NSU-NOT: COMPLETION: used
 
 int c [[using gnu: used]];
-// RUN: %clang_cc1 -code-completion-at=%s:27:15 %s | FileCheck 
--check-prefix=STD-USING %s
+// RUN: %clang_cc1 -code-completion-at=%s:30:15 %s | FileCheck 
--check-prefix=STD-USING %s
 // STD-USING: COMPLETION: __gnu__
 // STD-USING: COMPLETION: _Clang
 // STD-USING-NOT: COMPLETION: carries_dependency
@@ -33,10 +36,10 @@ int c [[using gnu: used]];
 // STD-USING-NOT: COMPLETION: clang::
 // STD-USING-NOT: COMPLETION: gnu::
 // STD-USING: COMPLETION: gnu
-// RUN: %clang_cc1 -code-completion-at=%s:27:20 %s | FileCheck 
--check-prefix=STD-NS %s
+// RUN: %clang_cc1 -code-completion-at=%s:30:20 %s | FileCheck 
--check-prefix=STD-NS %s
 
 int d __attribute__((used));
-// RUN: %clang_cc1 -code-completion-at=%s:38:22 %s | FileCheck 
--check-prefix=GNU %s
+// RUN: %clang_cc1 -code-completion-at=%s:41:22 %s | FileCheck 
--check-prefix=GNU %s
 // GNU: COMPLETION: __carries_dependency__
 // GNU: COMPLETION: __convergent__
 // GNU-NOT: COMPLETION: __gnu__::__used__
@@ -51,12 +54,12 @@ int d __attribute__((used));
 #pragma clang attribute push (__attribute__((internal_linkage)), 
apply_to=variable)
 int e;
 #pragma clang attribute pop
-// RUN: %clang_cc1 -code-completion-at=%s:51:46 %s | FileCheck 
--check-prefix=PRAGMA %s
+// RUN: %clang_cc1 -code-completion-at=%s:54:46 %s | FileCheck 
--check-prefix=PRAGMA %s
 // PRAGMA: internal_linkage
 
 #ifdef MS_EXT
 int __declspec(thread) f;
-// RUN: %clang_cc1 -fms-extensions -DMS_EXT -code-completion-at=%s:58:16 %s | 
FileCheck --check-prefix=DS %s
+// RUN: %clang_cc1 -fms-extensions -DMS_EXT -code-completion-at=%s:61:16 %s | 
FileCheck --check-prefix=DS %s
 // DS-NOT: COMPLETION: __convergent__
 // DS-NOT: COMPLETION: __used__
 // DS-NOT: COMPLETION: clang::convergent
@@ -66,7 +69,7 @@ int __declspec(thread) f;
 // DS: COMPLETION: uuid
 
 [uuid("123e4567-e89b-12d3-a456-426614174000")] struct g;
-// RUN: %clang_cc1 -fms-extensions -DMS_EXT -code-completion-at=%s:68:2 %s | 
FileCheck --check-prefix=MS %s
+// RUN: %clang_cc1 -fms-extensions -DMS_EXT -code-completion-at=%s:71:2 %s | 
FileCheck --check-prefix=MS %s
 // MS-NOT: COMPLETION: __uuid__
 // MS-NOT: COMPLETION: clang::convergent
 // MS-NOT: COMPLETION: convergent
@@ -80,9 +83,9 @@ void foo() {
   {}
 }
 // FIXME: support for omp attributes would be nice.
-// RUN: %clang_cc1 -fopenmp

[PATCH] D107553: [C++4OpenCL] Initialize temporaries in the private address space

2021-08-19 Thread Ole Strohm via Phabricator via cfe-commits
olestrohm updated this revision to Diff 367455.
olestrohm added a comment.

I made the check into an assert as suggested.


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

https://reviews.llvm.org/D107553

Files:
  clang/include/clang/Sema/Initialization.h
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaOpenCLCXX/addrspace-constructors.clcpp
  clang/test/SemaOpenCLCXX/temporaries.clcpp


Index: clang/test/SemaOpenCLCXX/temporaries.clcpp
===
--- /dev/null
+++ clang/test/SemaOpenCLCXX/temporaries.clcpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 %s -pedantic -ast-dump | FileCheck %s
+
+struct X {
+  X() __private = default;
+};
+
+// CHECK: VarDecl {{.*}} gx
+// CHECK: CXXTemporaryObjectExpr {{.*}} '__private X'
+__global X gx = X();
+
+void k() {
+  // CHECK: VarDecl {{.*}} x1
+  // CHECK: CXXTemporaryObjectExpr {{.*}} '__private X'
+  X x1 = X();
+
+  // CHECK: VarDecl {{.*}} x2
+  // CHECK: CXXConstructExpr {{.*}} 'const __private X'
+  const X x2;
+}
Index: clang/test/SemaOpenCLCXX/addrspace-constructors.clcpp
===
--- clang/test/SemaOpenCLCXX/addrspace-constructors.clcpp
+++ clang/test/SemaOpenCLCXX/addrspace-constructors.clcpp
@@ -32,6 +32,8 @@
   __local X lx;
   __private X x;
 
+  __private X tx = X();
+
   __private Y py;
   __constant Y cy1; // expected-error{{variable in constant address space must 
be initialized}}
   __constant Y cy2(1); // expected-error{{no matching constructor for 
initialization of '__constant Y'}}
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -1454,7 +1454,8 @@
  "List initialization must have initializer list as expression.");
   SourceRange FullRange = SourceRange(TyBeginLoc, RParenOrBraceLoc);
 
-  InitializedEntity Entity = InitializedEntity::InitializeTemporary(TInfo);
+  InitializedEntity Entity =
+  InitializedEntity::InitializeTemporary(Context, TInfo);
   InitializationKind Kind =
   Exprs.size()
   ? ListInitialization
@@ -5293,7 +5294,8 @@
 S, Sema::ExpressionEvaluationContext::Unevaluated);
 Sema::SFINAETrap SFINAE(S, /*AccessCheckingSFINAE=*/true);
 Sema::ContextRAII TUContext(S, S.Context.getTranslationUnitDecl());
-InitializedEntity To(InitializedEntity::InitializeTemporary(Args[0]));
+InitializedEntity To(
+InitializedEntity::InitializeTemporary(S.Context, Args[0]));
 InitializationKind InitKind(InitializationKind::CreateDirect(KWLoc, KWLoc,
  RParenLoc));
 InitializationSequence Init(S, To, InitKind, ArgExprs);
Index: clang/include/clang/Sema/Initialization.h
===
--- clang/include/clang/Sema/Initialization.h
+++ clang/include/clang/Sema/Initialization.h
@@ -335,8 +335,15 @@
   }
 
   /// Create the initialization entity for a temporary.
-  static InitializedEntity InitializeTemporary(TypeSourceInfo *TypeInfo) {
-return InitializeTemporary(TypeInfo, TypeInfo->getType());
+  static InitializedEntity InitializeTemporary(ASTContext &Context,
+   TypeSourceInfo *TypeInfo) {
+QualType Type = TypeInfo->getType();
+if (Context.getLangOpts().OpenCLCPlusPlus) {
+  assert(!Type.hasAddressSpace() && "Temporary already has address 
space!");
+  Type = Context.getAddrSpaceQualType(Type, LangAS::opencl_private);
+}
+
+return InitializeTemporary(TypeInfo, Type);
   }
 
   /// Create the initialization entity for a temporary.


Index: clang/test/SemaOpenCLCXX/temporaries.clcpp
===
--- /dev/null
+++ clang/test/SemaOpenCLCXX/temporaries.clcpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 %s -pedantic -ast-dump | FileCheck %s
+
+struct X {
+  X() __private = default;
+};
+
+// CHECK: VarDecl {{.*}} gx
+// CHECK: CXXTemporaryObjectExpr {{.*}} '__private X'
+__global X gx = X();
+
+void k() {
+  // CHECK: VarDecl {{.*}} x1
+  // CHECK: CXXTemporaryObjectExpr {{.*}} '__private X'
+  X x1 = X();
+
+  // CHECK: VarDecl {{.*}} x2
+  // CHECK: CXXConstructExpr {{.*}} 'const __private X'
+  const X x2;
+}
Index: clang/test/SemaOpenCLCXX/addrspace-constructors.clcpp
===
--- clang/test/SemaOpenCLCXX/addrspace-constructors.clcpp
+++ clang/test/SemaOpenCLCXX/addrspace-constructors.clcpp
@@ -32,6 +32,8 @@
   __local X lx;
   __private X x;
 
+  __private X tx = X();
+
   __private Y py;
   __constant Y cy1; // expected-error{{variable in constant address space must be initialized}}
   __constant Y cy2(1); // expected-error{{no matching constructor for initialization of '__constant Y'}}
Index: clang/lib/Sema/SemaExprCXX.cpp
=

[PATCH] D108301: [MSP430][Clang] Update hard-coded MCU data

2021-08-19 Thread Jozef Lawrynowicz via Phabricator via cfe-commits
jozefl updated this revision to Diff 367458.
jozefl added a comment.

Fixed clang-tidy warnings.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108301

Files:
  clang/include/clang/Basic/MSP430Target.def
  clang/lib/Driver/ToolChains/MSP430.cpp
  clang/test/Driver/msp430-hwmult.c
  clang/test/Driver/msp430-mmcu.c
  clang/test/Driver/msp430-toolchain.c

Index: clang/test/Driver/msp430-toolchain.c
===
--- clang/test/Driver/msp430-toolchain.c
+++ clang/test/Driver/msp430-toolchain.c
@@ -253,6 +253,10 @@
 // RUN:   | FileCheck -check-prefix=HWMult-32BIT %s
 // HWMult-32BIT: "--start-group" "-lmul_32"
 
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-F5 %s
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 -mhwmult=auto --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-F5 %s
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=f5series --sysroot="" 2>&1 \
 // RUN:   | FileCheck -check-prefix=HWMult-F5 %s
 // HWMult-F5: "--start-group" "-lmul_f5"
@@ -261,4 +265,10 @@
 // RUN:   | FileCheck -check-prefix=HWMult-NONE %s
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=none -mmcu=msp430f4783 --sysroot="" 2>&1 \
 // RUN:   | FileCheck -check-prefix=HWMult-NONE %s
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=auto -mmcu=msp430 --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-NONE %s
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=auto -mmcu=msp430x --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-NONE %s
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430xv2 --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-NONE %s
 // HWMult-NONE: "--start-group" "-lmul_none"
Index: clang/test/Driver/msp430-mmcu.c
===
--- clang/test/Driver/msp430-mmcu.c
+++ clang/test/Driver/msp430-mmcu.c
@@ -1,15 +1,62 @@
+// This file tests that various different values passed to -mmcu= select the
+// correct target features and linker scripts, and create MCU-specific defines.
+
+// Test the lexicographic ordering of MCUs in MSP430Target.def.
+//
+// The MCU "msp430f110" should appear before "msp430f1101" when the data has
+// been sorted lexicographically. Some sorts will put "msp430f110" *after*
+// "msp430f1101", so when this happens, Clang will not be able to find this MCU.
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f110 2>&1 \
+// RUN:   | FileCheck %s
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f1101 2>&1 \
+// RUN:   | FileCheck %s
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f1101a 2>&1 \
+// RUN:   | FileCheck %s
+
+// CHECK-NOT: error: the clang compiler does not support
+
+// Test the symbol definitions, linker scripts and hardware multiply features
+// selected for different MCUs.
+
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430c111 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-C111 %s
 
 // MSP430-C111: clang{{.*}} "-cc1" {{.*}} "-D__MSP430C111__"
+// MSP430-C111-NOT: "-target-feature" "+hwmult16"
+// MSP430-C111-NOT: "-target-feature" "+hwmult32"
+// MSP430-C111-NOT: "-target-feature" "+hwmultf5"
 // MSP430-C111: msp430-elf-ld{{.*}} "-Tmsp430c111.ld"
 
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430i2020 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-I2020 %s
 
 // MSP430-I2020: clang{{.*}} "-cc1" {{.*}} "-D__MSP430i2020__"
+// MSP430-I2020: "-target-feature" "+hwmult16"
 // MSP430-I2020: msp430-elf-ld{{.*}} "-Tmsp430i2020.ld"
 
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f47126 2>&1 \
+// RUN:   | FileCheck -check-prefix=MSP430-F47126 %s
+
+// MSP430-F47126: clang{{.*}} "-cc1" {{.*}} "-D__MSP430F47126__"
+// MSP430-F47126: "-target-feature" "+hwmult32"
+// MSP430-F47126: msp430-elf-ld{{.*}} "-Tmsp430f47126.ld"
+
+// RAN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 2>&1 \
+// RAN:   | FileCheck -check-prefix=MSP430-FR5969 %s
+
+// MSP430-FR5969: clang{{.*}} "-cc1" {{.*}} "-D__MSP430FR5969__"
+// MSP430-FR5969: "-target-feature" "+hwmultf5"
+// MSP430-FR5969: msp430-elf-ld{{.*}} "-Tmsp430fr5969.ld"
+
+// Test for the error message emitted when an invalid MCU is selected.
+//
+// Note that if this test is ever modified because the expected error message is
+// changed, the check prefixes at the top of this file, used to validate the
+// ordering of the hard-coded MCU data, also need to be updated.
+//
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=not-a-mcu 2>&1 \
 // RUN:   | FileCheck -check-prefix

[PATCH] D108366: [clang][deps] Deduce resource directory from the compiler path

2021-08-19 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith, arphaman, kousikk.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

After [[libclang][deps] Accept only driver invocations, don't modify 
them](https://github.com/apple/llvm-project/pull/3168) landed downstream, the 
libclang dependency scanner stopped deducing the resource directory based on 
the compiler executable path (in `Driver::Driver` called by 
`createInvocationFromCommandLine` called by `getFileDependencies`) and started 
using the current executable path (injected in `ClangTool::run`). However, the 
current executable is potentially a build system located outside the compiler 
toolchain that loaded the libclang shared library.

This patch adds an option to `ClangTool` to disable the deduction of the 
resource directory. This means the dependency scanner (both `clang-scan-deps` 
and libclang) now base the deduction on the compiler executable provided as 
part of the compilation command-line (in `Driver::Driver` called by 
`ToolInvocation::run` called by `ClangTool::run`).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108366

Files:
  clang/include/clang/Tooling/Tooling.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
  clang/lib/Tooling/Tooling.cpp
  clang/test/ClangScanDeps/Inputs/resource_directory/cdb_tu.json
  clang/test/ClangScanDeps/Inputs/resource_directory/mod.h
  clang/test/ClangScanDeps/Inputs/resource_directory/module.modulemap
  clang/test/ClangScanDeps/Inputs/resource_directory/tu.c
  clang/test/ClangScanDeps/resource_directory.c

Index: clang/test/ClangScanDeps/resource_directory.c
===
--- /dev/null
+++ clang/test/ClangScanDeps/resource_directory.c
@@ -0,0 +1,8 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: cp %S/Inputs/resource_directory/* %t
+// RUN: sed -e "s|CLANG|/our/custom/bin/clang|g" -e "s|DIR|%/t|g" %S/Inputs/resource_directory/cdb_tu.json > %t/cdb.json
+
+// RUN: clang-scan-deps -compilation-database %t/cdb.json --format experimental-full | FileCheck %s
+
+// CHECK:  "-resource-dir"
+// CHECK-NEXT: "/our/custom/{{.*}}"
Index: clang/test/ClangScanDeps/Inputs/resource_directory/tu.c
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/resource_directory/tu.c
@@ -0,0 +1,3 @@
+// tu.c
+
+#include "mod.h"
Index: clang/test/ClangScanDeps/Inputs/resource_directory/module.modulemap
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/resource_directory/module.modulemap
@@ -0,0 +1 @@
+module mod { header "mod.h" }
Index: clang/test/ClangScanDeps/Inputs/resource_directory/mod.h
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/resource_directory/mod.h
@@ -0,0 +1 @@
+// mod.h
Index: clang/test/ClangScanDeps/Inputs/resource_directory/cdb_tu.json
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/resource_directory/cdb_tu.json
@@ -0,0 +1,7 @@
+[
+  {
+"directory": "DIR",
+"command": "CLANG -fmodules -gmodules -fimplicit-module-maps -fmodules-cache-path=DIR/cache -c DIR/tu.c -o DIR/tu.o",
+"file": "DIR/tu.c"
+  }
+]
Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -553,15 +553,17 @@
 CommandLine = ArgsAdjuster(CommandLine, CompileCommand.Filename);
   assert(!CommandLine.empty());
 
-  // Add the resource dir based on the binary of this tool. argv[0] in the
-  // compilation database may refer to a different compiler and we want to
-  // pick up the very same standard library that compiler is using. The
-  // builtin headers in the resource dir need to match the exact clang
-  // version the tool is using.
-  // FIXME: On linux, GetMainExecutable is independent of the value of the
-  // first argument, thus allowing ClangTool and runToolOnCode to just
-  // pass in made-up names here. Make sure this works on other platforms.
-  injectResourceDir(CommandLine, "clang_tool", &StaticSymbol);
+  if (InjectResourceDir) {
+// Add the resource dir based on the binary of this tool. argv[0] in the
+// compilation database may refer to a different compiler and we want to
+// pick up the very same standard library that compiler is using. The
+// builtin headers in the resource dir need to match the exact clang
+// version the tool is using.
+// FIXME: On linux, GetMainExecutable is independent of the value of the
+// first argument, thus allowing ClangTool and runToolOnCode to just
+// pass in made-up names here. Make sure thi

[clang] cab7c52 - [CodeCompletion] Provide placeholders for known attribute arguments

2021-08-19 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-08-19T14:03:41+02:00
New Revision: cab7c52acdf508f73186dfe49b8cb012bb9129b2

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

LOG: [CodeCompletion] Provide placeholders for known attribute arguments

Completion now looks more like function/member completion:

  used
  alias(Aliasee)
  abi_tag(Tags...)

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

Added: 


Modified: 
clang/include/clang/Sema/ParsedAttr.h
clang/lib/Sema/SemaCodeComplete.cpp
clang/test/CodeCompletion/attr.cpp
clang/utils/TableGen/ClangAttrEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/ParsedAttr.h 
b/clang/include/clang/Sema/ParsedAttr.h
index 408032cec7e8..64a078866ca5 100644
--- a/clang/include/clang/Sema/ParsedAttr.h
+++ b/clang/include/clang/Sema/ParsedAttr.h
@@ -67,6 +67,8 @@ struct ParsedAttrInfo {
 const char *NormalizedFullName;
   };
   ArrayRef Spellings;
+  // The names of the known arguments of this attribute.
+  ArrayRef ArgNames;
 
   ParsedAttrInfo(AttributeCommonInfo::Kind AttrKind =
  AttributeCommonInfo::NoSemaHandlerAttribute)

diff  --git a/clang/lib/Sema/SemaCodeComplete.cpp 
b/clang/lib/Sema/SemaCodeComplete.cpp
index 445ab4885cfa..8c551a798b32 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -4423,33 +4423,59 @@ void 
Sema::CodeCompleteAttribute(AttributeCommonInfo::Syntax Syntax,
 Scope = "";
   }
 
+  auto Add = [&](llvm::StringRef Scope, llvm::StringRef Name,
+ bool Underscores) {
+CodeCompletionBuilder Builder(Results.getAllocator(),
+  Results.getCodeCompletionTUInfo());
+llvm::SmallString<32> Text;
+if (!Scope.empty()) {
+  Text.append(Scope);
+  Text.append("::");
+}
+if (Underscores)
+  Text.append("__");
+Text.append(Name);
+if (Underscores)
+  Text.append("__");
+Builder.AddTypedTextChunk(Results.getAllocator().CopyString(Text));
+
+if (!A.ArgNames.empty()) {
+  Builder.AddChunk(CodeCompletionString::CK_LeftParen, "(");
+  bool First = true;
+  for (const char *Arg : A.ArgNames) {
+if (!First)
+  Builder.AddChunk(CodeCompletionString::CK_Comma, ", ");
+First = false;
+Builder.AddPlaceholderChunk(Arg);
+  }
+  Builder.AddChunk(CodeCompletionString::CK_RightParen, ")");
+}
+
+Results.AddResult(Builder.TakeString());
+  };
+
   // Generate the non-underscore-guarded result.
   // Note this is (a suffix of) the NormalizedFullName, no need to copy.
   // If an underscore-guarded scope was specified, only the
   // underscore-guarded attribute name is relevant.
   if (!InScopeUnderscore)
-Results.AddResult(Scope.empty() ? Name.data() : S.NormalizedFullName);
+Add(Scope, Name, /*Underscores=*/false);
 
   // Generate the underscore-guarded version, for syntaxes that support it.
   // We skip this if the scope was already spelled and not guarded, or
   // we must spell it and can't guard it.
   if (!(InScope && !InScopeUnderscore) && SyntaxSupportsGuards) {
 llvm::SmallString<32> Guarded;
-if (!Scope.empty()) {
+if (Scope.empty()) {
+  Add(Scope, Name, /*Underscores=*/true);
+} else {
   const char *GuardedScope = underscoreAttrScope(Scope);
   if (!GuardedScope)
 continue;
-  Guarded.append(GuardedScope);
-  Guarded.append("::");
+  Add(GuardedScope, Name, /*Underscores=*/true);
 }
-Guarded.append("__");
-Guarded.append(Name);
-Guarded.append("__");
-Results.AddResult(
-CodeCompletionResult(Results.getAllocator().CopyString(Guarded)));
   }
 
-  // FIXME: include the list of arg names (not currently exposed).
   // It may be nice to include the Kind so we can look up the docs later.
 }
   };

diff  --git a/clang/test/CodeCompletion/attr.cpp 
b/clang/test/CodeCompletion/attr.cpp
index 782e5a1d75ec..c3f76e7f0d99 100644
--- a/clang/test/CodeCompletion/attr.cpp
+++ b/clang/test/CodeCompletion/attr.cpp
@@ -1,81 +1,83 @@
 int a [[gnu::used]];
 // RUN: %clang_cc1 -code-completion-at=%s:1:9 %s | FileCheck 
--check-prefix=STD %s
-// STD: COMPLETION: __carries_dependency__
-// STD-NOT: COMPLETION: __convergent__
-// STD: COMPLETION: __gnu__::__used__
-// STD-NOT: COMPLETION: __gnu__::used
-// STD-NOT: COMPLETION: __used__
-// STD: COMPLETION: _Clang::__convergent__
-// STD: COMPLETION: carries_dependency
-// STD-NOT: COMPLETION: clang::called_once
-// STD:

[PATCH] D108109: [CodeCompletion] Provide placeholders for known attribute arguments

2021-08-19 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcab7c52acdf5: [CodeCompletion] Provide placeholders for 
known attribute arguments (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D108109?vs=366572&id=367462#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108109

Files:
  clang/include/clang/Sema/ParsedAttr.h
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/attr.cpp
  clang/utils/TableGen/ClangAttrEmitter.cpp

Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -3959,6 +3959,27 @@
   }
   OS << "};\n";
 }
+
+std::vector ArgNames;
+for (const auto &Arg : Attr.getValueAsListOfDefs("Args")) {
+  bool UnusedUnset;
+  if (Arg->getValueAsBitOrUnset("Fake", UnusedUnset))
+continue;
+  ArgNames.push_back(Arg->getValueAsString("Name").str());
+  for (const auto &Class : Arg->getSuperClasses()) {
+if (Class.first->getName().startswith("Variadic")) {
+  ArgNames.back().append("...");
+  break;
+}
+  }
+}
+if (!ArgNames.empty()) {
+  OS << "static constexpr const char *" << I->first << "ArgNames[] = {\n";
+  for (const auto &N : ArgNames)
+OS << '"' << N << "\",";
+  OS << "};\n";
+}
+
 OS << "struct ParsedAttrInfo" << I->first
<< " final : public ParsedAttrInfo {\n";
 OS << "  ParsedAttrInfo" << I->first << "() {\n";
@@ -3980,6 +4001,8 @@
 OS << PragmaAttributeSupport.isAttributedSupported(*I->second) << ";\n";
 if (!Spellings.empty())
   OS << "Spellings = " << I->first << "Spellings;\n";
+if (!ArgNames.empty())
+  OS << "ArgNames = " << I->first << "ArgNames;\n";
 OS << "  }\n";
 GenerateAppertainsTo(Attr, OS);
 GenerateMutualExclusionsChecks(Attr, Records, OS, MergeDeclOS, MergeStmtOS);
Index: clang/test/CodeCompletion/attr.cpp
===
--- clang/test/CodeCompletion/attr.cpp
+++ clang/test/CodeCompletion/attr.cpp
@@ -1,81 +1,83 @@
 int a [[gnu::used]];
 // RUN: %clang_cc1 -code-completion-at=%s:1:9 %s | FileCheck --check-prefix=STD %s
-// STD: COMPLETION: __carries_dependency__
-// STD-NOT: COMPLETION: __convergent__
-// STD: COMPLETION: __gnu__::__used__
-// STD-NOT: COMPLETION: __gnu__::used
-// STD-NOT: COMPLETION: __used__
-// STD: COMPLETION: _Clang::__convergent__
-// STD: COMPLETION: carries_dependency
-// STD-NOT: COMPLETION: clang::called_once
-// STD: COMPLETION: clang::convergent
-// STD-NOT: COMPLETION: convergent
-// STD-NOT: COMPLETION: gnu::__used__
-// STD: COMPLETION: gnu::used
-// STD-NOT: COMPLETION: used
+// STD: COMPLETION: Pattern : __carries_dependency__
+// STD-NOT: COMPLETION: Pattern : __convergent__
+// STD: COMPLETION: Pattern : __gnu__::__used__
+// STD-NOT: COMPLETION: Pattern : __gnu__::used
+// STD-NOT: COMPLETION: Pattern : __used__
+// STD: COMPLETION: Pattern : _Clang::__convergent__
+// STD: COMPLETION: Pattern : carries_dependency
+// STD-NOT: COMPLETION: Pattern : clang::called_once
+// STD: COMPLETION: Pattern : clang::convergent
+// STD-NOT: COMPLETION: Pattern : convergent
+// STD-NOT: COMPLETION: Pattern : gnu::__used__
+// STD: COMPLETION: Pattern : gnu::abi_tag(<#Tags...#>)
+// STD: COMPLETION: Pattern : gnu::alias(<#Aliasee#>)
+// STD: COMPLETION: Pattern : gnu::used
+// STD-NOT: COMPLETION: Pattern : used
 // RUN: %clang_cc1 -code-completion-at=%s:1:9 -xobjective-c++ %s | FileCheck --check-prefix=STD-OBJC %s
-// STD-OBJC: COMPLETION: clang::called_once
+// STD-OBJC: COMPLETION: Pattern : clang::called_once
 // RUN: %clang_cc1 -code-completion-at=%s:1:14 %s | FileCheck --check-prefix=STD-NS %s
-// STD-NS-NOT: COMPLETION: __used__
-// STD-NS-NOT: COMPLETION: carries_dependency
-// STD-NS-NOT: COMPLETION: clang::convergent
-// STD-NS-NOT: COMPLETION: convergent
-// STD-NS-NOT: COMPLETION: gnu::used
-// STD-NS: COMPLETION: used
+// STD-NS-NOT: COMPLETION: Pattern : __used__
+// STD-NS-NOT: COMPLETION: Pattern : carries_dependency
+// STD-NS-NOT: COMPLETION: Pattern : clang::convergent
+// STD-NS-NOT: COMPLETION: Pattern : convergent
+// STD-NS-NOT: COMPLETION: Pattern : gnu::used
+// STD-NS: COMPLETION: Pattern : used
 int b [[__gnu__::used]];
-// RUN: %clang_cc1 -code-completion-at=%s:25:18 %s | FileCheck --check-prefix=STD-NSU %s
-// STD-NSU: COMPLETION: __used__
-// STD-NSU-NOT: COMPLETION: used
+// RUN: %clang_cc1 -code-completion-at=%s:27:18 %s | FileCheck --check-prefix=STD-NSU %s
+// STD-NSU: COMPLETION: Pattern : __used__
+// STD-NSU-NOT: COMPLETION: Pattern : used
 
 int c [[using gnu: used]];
-// RUN: %clang_cc1 -code-completion-at=

[PATCH] D106870: [OpenMP] Multi architecture compilation support

2021-08-19 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

I think this patch needs to split up into a large number of much smaller pieces.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106870

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


[PATCH] D108359: [clang][NFC] Fix needless double-parenthisation

2021-08-19 Thread Andy Wingo via Phabricator via cfe-commits
wingo added a reviewer: rsmith.
wingo added a comment.

Hi Richard, I am new to clang, having mostly worked on the WebAssembly target 
in llvm proper -- I have a stack of patches, of which a couple later ones touch 
Sema/.  See https://lists.llvm.org/pipermail/cfe-dev/2021-July/068559.html for 
broader context.  However I had a couple small NFC cleanups I found when 
reading code, like this one; would it be OK if I sent them your way?  Cheers, 
Andy.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108359

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


[PATCH] D108366: [clang][deps] Deduce resource directory from the compiler path

2021-08-19 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

Tagging @kousikk, since this is related to D69122 
 that introduced `ResourceDirectoryCache` to 
`clang-scan-deps`. When the compilation command doesn't have a `-resource-dir` 
argument, `ResourceDirectoryCache` invokes the specified compiler with 
`-print-resource-dir` and injects the result into the command-line as 
`-resource-dir`.

This happens way before the dependency scanner worker is invoked, meaning the 
logic this patch tweaks won't usually kick in. The test passes only because the 
invocation of `/our/custom/bin/clang -print-resource-dir` made by 
`ResourceDirectoryCache` silently fails (the binary doesn't exist), allowing 
the worker to deduce the resource directory using regular driver logic.

I think both `clang-scan-deps` and the downstream libclang API clearly head 
towards only supporting compilers built the same way (same version, 
architecture, etc.). The modular dependency scanner already returns 
command-lines of cc1 arguments that are not stable across Clang versions.

I wanted to see if we can reach consensus on removing `ResourceDirectoryCache` 
entirely. It makes the resource directory deduction much more lightweight and 
is in line with the direction we're already going regarding compiler 
compatibility. It also allows `clang-scan-deps` and libclang API to have the 
same behavior, which is a desirable property IMO. If users really want the 
behavior of `ResourceDirectoryCache`, they can keep using prior versions 
`clang-scan-deps`.

What do you all think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108366

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


[PATCH] D108215: [clang][deps] NFC: Move `ResourceDirectoryCache`

2021-08-19 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 abandoned this revision.
jansvoboda11 added a comment.

Fair points. Abandoning in favor of D108366 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108215

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


[PATCH] D108367: [NFC] computeSPIRKernelABIInfo(): use SPIRABInfo

2021-08-19 Thread Henry Linjamäki via Phabricator via cfe-commits
linjamaki created this revision.
linjamaki requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Make computeSPIRKernelABIInfo() to use SPIRABIInfo instead of
DefaultABIInfo.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108367

Files:
  clang/lib/CodeGen/TargetInfo.cpp


Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -10214,7 +10214,7 @@
 namespace clang {
 namespace CodeGen {
 void computeSPIRKernelABIInfo(CodeGenModule &CGM, CGFunctionInfo &FI) {
-  DefaultABIInfo SPIRABI(CGM.getTypes());
+  SPIRABIInfo SPIRABI(CGM.getTypes());
   SPIRABI.computeInfo(FI);
 }
 }


Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -10214,7 +10214,7 @@
 namespace clang {
 namespace CodeGen {
 void computeSPIRKernelABIInfo(CodeGenModule &CGM, CGFunctionInfo &FI) {
-  DefaultABIInfo SPIRABI(CGM.getTypes());
+  SPIRABIInfo SPIRABI(CGM.getTypes());
   SPIRABI.computeInfo(FI);
 }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108360: [clang][NFC] Remove dead code

2021-08-19 Thread Andy Wingo via Phabricator via cfe-commits
wingo added a reviewer: rjmccall.
wingo added a comment.

Hi John, I am new to clang, having mostly worked on the WebAssembly target in 
llvm proper.  I have a stack of patches related to address space treatment in 
codegen -- most of them NFC refactors to later allow the WebAssembly target to 
alloca in different address spaces. See 
https://lists.llvm.org/pipermail/cfe-dev/2021-July/068559.html for broader 
context. Would it be OK if I sent them your way? Cheers, Andy.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108360

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


[clang] 77579b9 - [openmp][nfc] Replace OMPGridValues array with struct

2021-08-19 Thread Jon Chesterfield via cfe-commits

Author: Jon Chesterfield
Date: 2021-08-19T13:25:42+01:00
New Revision: 77579b99e9ce1638ca696fa7c3872ae8668d997d

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

LOG: [openmp][nfc] Replace OMPGridValues array with struct

[nfc] Replaces enum indices into an array with a struct. Named the
fields to match the enum, leaves memory layout and initialization unchanged.

Motivation is to later safely remove dead fields and replace redundant ones
with (compile time) computation. It should also be possible to factor some
common fields into a base and introduce a gfx10 amdgpu instance with less
duplication than the arrays of integers require.

Reviewed By: ronlieb

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

Added: 


Modified: 
clang/include/clang/Basic/TargetInfo.h
clang/lib/Basic/Targets/AMDGPU.cpp
clang/lib/Basic/Targets/NVPTX.cpp
clang/lib/CodeGen/CGOpenMPRuntimeAMDGCN.cpp
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
llvm/include/llvm/Frontend/OpenMP/OMPGridValues.h
openmp/libomptarget/plugins/amdgpu/src/rtl.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 21289b0dfd04..ab855948b447 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -210,8 +210,8 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   unsigned char RegParmMax, SSERegParmMax;
   TargetCXXABI TheCXXABI;
   const LangASMap *AddrSpaceMap;
-  const unsigned *GridValues =
-  nullptr; // Array of target-specific GPU grid values that must be
+  const llvm::omp::GV *GridValues =
+  nullptr; // target-specific GPU grid values that must be
// consistent between host RTL (plugin), device RTL, and clang.
 
   mutable StringRef PlatformName;
@@ -1410,10 +1410,10 @@ class TargetInfo : public virtual 
TransferrableTargetInfo,
 return LangAS::Default;
   }
 
-  /// Return a target-specific GPU grid value based on the GVIDX enum \p gv
-  unsigned getGridValue(llvm::omp::GVIDX gv) const {
+  /// Return a target-specific GPU grid values
+  const llvm::omp::GV &getGridValue() const {
 assert(GridValues != nullptr && "GridValues not initialized");
-return GridValues[gv];
+return *GridValues;
   }
 
   /// Retrieve the name of the platform as it is used in the

diff  --git a/clang/lib/Basic/Targets/AMDGPU.cpp 
b/clang/lib/Basic/Targets/AMDGPU.cpp
index fac786dbcf9e..cebb19e7ccab 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -335,7 +335,7 @@ AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple 
&Triple,
   llvm::AMDGPU::getArchAttrR600(GPUKind)) {
   resetDataLayout(isAMDGCN(getTriple()) ? DataLayoutStringAMDGCN
 : DataLayoutStringR600);
-  GridValues = llvm::omp::AMDGPUGpuGridValues;
+  GridValues = &llvm::omp::AMDGPUGridValues;
 
   setAddressSpaceMap(Triple.getOS() == llvm::Triple::Mesa3D ||
  !isAMDGCN(Triple));

diff  --git a/clang/lib/Basic/Targets/NVPTX.cpp 
b/clang/lib/Basic/Targets/NVPTX.cpp
index 56f8a179db3c..d1a34e4a81c5 100644
--- a/clang/lib/Basic/Targets/NVPTX.cpp
+++ b/clang/lib/Basic/Targets/NVPTX.cpp
@@ -65,7 +65,7 @@ NVPTXTargetInfo::NVPTXTargetInfo(const llvm::Triple &Triple,
   TLSSupported = false;
   VLASupported = false;
   AddrSpaceMap = &NVPTXAddrSpaceMap;
-  GridValues = llvm::omp::NVPTXGpuGridValues;
+  GridValues = &llvm::omp::NVPTXGridValues;
   UseAddrSpaceMapMangling = true;
 
   // Define available target features

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntimeAMDGCN.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntimeAMDGCN.cpp
index 33d4ab838af1..cac5faaa8d0f 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeAMDGCN.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeAMDGCN.cpp
@@ -20,6 +20,7 @@
 #include "clang/AST/StmtVisitor.h"
 #include "clang/Basic/Cuda.h"
 #include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/Frontend/OpenMP/OMPGridValues.h"
 #include "llvm/IR/IntrinsicsAMDGPU.h"
 
 using namespace clang;
@@ -35,7 +36,7 @@ CGOpenMPRuntimeAMDGCN::CGOpenMPRuntimeAMDGCN(CodeGenModule 
&CGM)
 llvm::Value *CGOpenMPRuntimeAMDGCN::getGPUWarpSize(CodeGenFunction &CGF) {
   CGBuilderTy &Bld = CGF.Builder;
   // return constant compile-time target-specific warp size
-  unsigned WarpSize = CGF.getTarget().getGridValue(llvm::omp::GV_Warp_Size);
+  unsigned WarpSize = CGF.getTarget().getGridValue().GV_Warp_Size;
   return Bld.getInt32(WarpSize);
 }
 

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
index 63fecedc6fb7..b13d55994ef6 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp

[PATCH] D108339: [openmp][nfc] Replace OMPGridValues array with struct

2021-08-19 Thread Jon Chesterfield 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 rG77579b99e9ce: [openmp][nfc] Replace OMPGridValues array with 
struct (authored by JonChesterfield).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108339

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/NVPTX.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeAMDGCN.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
  llvm/include/llvm/Frontend/OpenMP/OMPGridValues.h
  openmp/libomptarget/plugins/amdgpu/src/rtl.cpp

Index: openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
===
--- openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
+++ openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
@@ -501,14 +501,11 @@
   static const unsigned HardTeamLimit =
   (1 << 16) - 1; // 64K needed to fit in uint16
   static const int DefaultNumTeams = 128;
-  static const int Max_Teams =
-  llvm::omp::AMDGPUGpuGridValues[llvm::omp::GVIDX::GV_Max_Teams];
-  static const int Warp_Size =
-  llvm::omp::AMDGPUGpuGridValues[llvm::omp::GVIDX::GV_Warp_Size];
-  static const int Max_WG_Size =
-  llvm::omp::AMDGPUGpuGridValues[llvm::omp::GVIDX::GV_Max_WG_Size];
+  static const int Max_Teams = llvm::omp::AMDGPUGridValues.GV_Max_Teams;
+  static const int Warp_Size = llvm::omp::AMDGPUGridValues.GV_Warp_Size;
+  static const int Max_WG_Size = llvm::omp::AMDGPUGridValues.GV_Max_WG_Size;
   static const int Default_WG_Size =
-  llvm::omp::AMDGPUGpuGridValues[llvm::omp::GVIDX::GV_Default_WG_Size];
+  llvm::omp::AMDGPUGridValues.GV_Default_WG_Size;
 
   using MemcpyFunc = hsa_status_t (*)(hsa_signal_t, void *, const void *,
   size_t size, hsa_agent_t);
@@ -1058,9 +1055,8 @@
 DeviceInfo.WarpSize[device_id] = wavefront_size;
   } else {
 DP("Default wavefront size: %d\n",
-   llvm::omp::AMDGPUGpuGridValues[llvm::omp::GVIDX::GV_Warp_Size]);
-DeviceInfo.WarpSize[device_id] =
-llvm::omp::AMDGPUGpuGridValues[llvm::omp::GVIDX::GV_Warp_Size];
+   llvm::omp::AMDGPUGridValues.GV_Warp_Size);
+DeviceInfo.WarpSize[device_id] = llvm::omp::AMDGPUGridValues.GV_Warp_Size;
   }
 
   // Adjust teams to the env variables
Index: llvm/include/llvm/Frontend/OpenMP/OMPGridValues.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPGridValues.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPGridValues.h
@@ -29,68 +29,69 @@
 ///
 /// Example usage in clang:
 ///   const unsigned slot_size =
-///   ctx.GetTargetInfo().getGridValue(llvm::omp::GVIDX::GV_Warp_Size);
+///   ctx.GetTargetInfo().getGridValue().GV_Warp_Size;
 ///
 /// Example usage in libomptarget/deviceRTLs:
 ///   #include "llvm/Frontend/OpenMP/OMPGridValues.h"
 ///   #ifdef __AMDGPU__
-/// #define GRIDVAL AMDGPUGpuGridValues
+/// #define GRIDVAL AMDGPUGridValues
 ///   #else
-/// #define GRIDVAL NVPTXGpuGridValues
+/// #define GRIDVAL NVPTXGridValues
 ///   #endif
 ///   ... Then use this reference for GV_Warp_Size in the deviceRTL source.
-///   llvm::omp::GRIDVAL[llvm::omp::GVIDX::GV_Warp_Size]
+///   llvm::omp::GRIDVAL().GV_Warp_Size
 ///
 /// Example usage in libomptarget hsa plugin:
 ///   #include "llvm/Frontend/OpenMP/OMPGridValues.h"
-///   #define GRIDVAL AMDGPUGpuGridValues
+///   #define GRIDVAL AMDGPUGridValues
 ///   ... Then use this reference to access GV_Warp_Size in the hsa plugin.
-///   llvm::omp::GRIDVAL[llvm::omp::GVIDX::GV_Warp_Size]
+///   llvm::omp::GRIDVAL().GV_Warp_Size
 ///
 /// Example usage in libomptarget cuda plugin:
 ///#include "llvm/Frontend/OpenMP/OMPGridValues.h"
-///#define GRIDVAL NVPTXGpuGridValues
+///#define GRIDVAL NVPTXGridValues
 ///   ... Then use this reference to access GV_Warp_Size in the cuda plugin.
-///llvm::omp::GRIDVAL[llvm::omp::GVIDX::GV_Warp_Size]
+///llvm::omp::GRIDVAL().GV_Warp_Size
 ///
-enum GVIDX {
+
+struct GV {
   /// The maximum number of workers in a kernel.
   /// (THREAD_ABSOLUTE_LIMIT) - (GV_Warp_Size), might be issue for blockDim.z
-  GV_Threads,
+  const unsigned GV_Threads;
   /// The size reserved for data in a shared memory slot.
-  GV_Slot_Size,
+  const unsigned GV_Slot_Size;
   /// The default value of maximum number of threads in a worker warp.
-  GV_Warp_Size,
+  const unsigned GV_Warp_Size;
   /// Alternate warp size for some AMDGCN architectures. Same as GV_Warp_Size
   /// for NVPTX.
-  GV_Warp_Size_32,
+  const unsigned GV_Warp_Size_32;
   /// The number of bits required to represent the max number of threads in warp
-  GV_Warp_Size_Log2,
+  const unsigned GV_Warp_Size_Log2;
   /// GV_Warp_Size * GV_Slot_Size,
-  GV_Warp_Slot_Size,
+  const unsigned GV_Warp_Slot_Size;
   /// the m

[PATCH] D106888: [RISC-V] Implement jump tables for CFI-icall

2021-08-19 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

Is it possible to write a test case for this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106888

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


[PATCH] D108029: [clang][Codegen] Introduce the disable_sanitizer_instrumentation attribute

2021-08-19 Thread Alexander Potapenko via Phabricator via cfe-commits
glider added inline comments.



Comment at: llvm/include/llvm/Bitcode/LLVMBitCodes.h:674
   ATTR_KIND_ELEMENTTYPE = 77,
+  ATTR_DISABLE_SANITIZER_INSTRUMENTATION = 78,
 };

Missing "_KIND_"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108029

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


[PATCH] D105168: [RISCV] Unify the arch string parsing logic to RISCVISAInfo.

2021-08-19 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

I'm getting a build error (building with clang 12.0.1):

  FAILED: lib/Support/CMakeFiles/LLVMSupport.dir/RISCVISAInfo.cpp.o 
  /usr/bin/clang++ -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/asb/llvm-project/build/default/lib/Support 
-I/home/asb/llvm-project/llvm/lib/Support 
-I/home/asb/llvm-project/build/default/include 
-I/home/asb/llvm-project/llvm/include -fPIC -fvisibility-inlines-hidden 
-Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers 
-pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wstring-conversion -Wmisleading-indentation 
-fdiagnostics-color -Werror=global-constructors -g -fPIC -gsplit-dwarf 
-std=c++14  -fno-exceptions -fno-rtti -MD -MT 
lib/Support/CMakeFiles/LLVMSupport.dir/RISCVISAInfo.cpp.o -MF 
lib/Support/CMakeFiles/LLVMSupport.dir/RISCVISAInfo.cpp.o.d -o 
lib/Support/CMakeFiles/LLVMSupport.dir/RISCVISAInfo.cpp.o -c 
/home/asb/llvm-project/llvm/lib/Support/RISCVISAInfo.cpp
  /home/asb/llvm-project/llvm/lib/Support/RISCVISAInfo.cpp:399:10: warning: 
moving a local object in a return statement prevents copy elision 
[-Wpessimizing-move]
return std::move(ISAInfo);
   ^
  /home/asb/llvm-project/llvm/lib/Support/RISCVISAInfo.cpp:399:10: note: remove 
std::move call here
return std::move(ISAInfo);
   ^~   ~
  /home/asb/llvm-project/llvm/lib/Support/RISCVISAInfo.cpp:478:12: error: call 
to deleted constructor of 'llvm::Error'
  return E;
 ^
  /home/asb/llvm-project/llvm/include/llvm/Support/Error.h:186:3: note: 'Error' 
has been explicitly marked deleted here
Error(const Error &Other) = delete;
^
  /home/asb/llvm-project/llvm/include/llvm/Support/Error.h:493:18: note: 
passing argument to parameter 'Err' here
Expected(Error Err)
   ^
  /home/asb/llvm-project/llvm/lib/Support/RISCVISAInfo.cpp:520:14: error: call 
to deleted constructor of 'llvm::Error'
return E;
   ^
  /home/asb/llvm-project/llvm/include/llvm/Support/Error.h:186:3: note: 'Error' 
has been explicitly marked deleted here
Error(const Error &Other) = delete;
^
  /home/asb/llvm-project/llvm/include/llvm/Support/Error.h:493:18: note: 
passing argument to parameter 'Err' here
Expected(Error Err)
   ^
  /home/asb/llvm-project/llvm/lib/Support/RISCVISAInfo.cpp:642:14: error: call 
to deleted constructor of 'llvm::Error'
return E;
   ^
  /home/asb/llvm-project/llvm/include/llvm/Support/Error.h:186:3: note: 'Error' 
has been explicitly marked deleted here
Error(const Error &Other) = delete;
^
  /home/asb/llvm-project/llvm/include/llvm/Support/Error.h:493:18: note: 
passing argument to parameter 'Err' here
Expected(Error Err)
   ^
  1 warning and 3 errors generated.
  [3/3711] Building CXX object 
tools/llvm-config/CMakeFiles/llvm-config.dir/llvm-config.cpp.o
  ninja: build stopped: subcommand failed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105168

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


[PATCH] D80392: [mips][mc][clang] Use pc-relative relocations in .eh_frame

2021-08-19 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan updated this revision to Diff 367472.
atanasyan retitled this revision from "[WIP][mips] Use pc-relative relocations 
in .eh_frame" to "[mips][mc][clang] Use pc-relative relocations in .eh_frame".
atanasyan edited the summary of this revision.
atanasyan edited reviewers, added: emaste, grosbach; removed: sdardis, 
dsanders, espindola.
atanasyan added a project: clang.
atanasyan added a comment.
Herald added subscribers: cfe-commits, dang, sdardis.

For compatibility with tools unsupported 64-bit pc-relative relocations the 
patch introduces new command line options in Clang: `mmips-pc64-rel` and 
`mno-mips-pc64-rel`. These options passed to LLVM by Clang driver as 
`-mmips-pc64-rel={true|false}`. I could not find any better way to pass the 
option into `MC` layer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80392

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/mips-features.c
  lld/test/ELF/mips-eh_frame-pic.s
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/MC/MCObjectFileInfo.cpp
  llvm/test/CodeGen/Mips/ehframe-indirect.ll
  llvm/test/DebugInfo/Mips/eh_frame.ll
  llvm/test/MC/Mips/eh-frame.s

Index: llvm/test/MC/Mips/eh-frame.s
===
--- llvm/test/MC/Mips/eh-frame.s
+++ llvm/test/MC/Mips/eh-frame.s
@@ -33,14 +33,18 @@
 // RUN: llvm-readobj -r %t.o | FileCheck --check-prefixes=RELOCS,PIC64 %s
 // RUN: llvm-dwarfdump -eh-frame %t.o | FileCheck --check-prefixes=DWARF64,DWARF64_PIC %s
 
-/// However using the large code model forces R_MIPS_64 since there is no R_MIPS_PC64 relocation:
 // RUN: llvm-mc -filetype=obj %s -o %t.o -triple mips64-unknown-linux-gnu --position-independent --large-code-model
-// RUN: llvm-readobj -r %t.o | FileCheck --check-prefixes=RELOCS,ABS64 %s
-// RUN: llvm-dwarfdump -eh-frame %t.o | FileCheck --check-prefixes=DWARF64,DWARF64_ABS %s
+// RUN: llvm-readobj -r %t.o | FileCheck --check-prefixes=RELOCS,PIC64 %s
+// RUN: llvm-dwarfdump -eh-frame %t.o | FileCheck --check-prefixes=DWARF64,DWARF64_PIC %s
 
 // RUN: llvm-mc -filetype=obj %s -o %t.o -triple mips64el-unknown-linux-gnu --position-independent  --large-code-model
-// RUN: llvm-readobj -r %t.o | FileCheck --check-prefixes=RELOCS,ABS64 %s
-// RUN: llvm-dwarfdump -eh-frame %t.o | FileCheck --check-prefixes=DWARF64,DWARF64_ABS %s
+// RUN: llvm-readobj -r %t.o | FileCheck --check-prefixes=RELOCS,PIC64 %s
+// RUN: llvm-dwarfdump -eh-frame %t.o | FileCheck --check-prefixes=DWARF64,DWARF64_PIC %s
+
+// RUN: llvm-mc -filetype=obj %s -o %t.o -triple mips64-unknown-linux-gnu \
+// RUN: --position-independent --large-code-model -mmips-pc64-rel=false
+// RUN: llvm-readobj -r %t.o | FileCheck --check-prefixes=RELOCS,OLD64 %s
+// RUN: llvm-dwarfdump -eh-frame %t.o | FileCheck --check-prefixes=DWARF64,DWARF64_OLD %s
 
 func:
 	.cfi_startproc
@@ -51,7 +55,8 @@
 // ABS32-NEXT:  R_MIPS_32
 // ABS64-NEXT:  R_MIPS_64/R_MIPS_NONE/R_MIPS_NONE
 // PIC32-NEXT:  R_MIPS_PC32
-// PIC64-NEXT:  R_MIPS_PC32/R_MIPS_NONE/R_MIPS_NONE
+// PIC64-NEXT:  R_MIPS_PC32/R_MIPS_64/R_MIPS_NONE
+// OLD64-NEXT:  R_MIPS_64/R_MIPS_NONE/R_MIPS_NONE
 // RELOCS-NEXT:   }
 
 // DWARF32:  0010  CIE
@@ -87,14 +92,17 @@
 // DWARF64-NEXT: Return address column: 31
 // DWARF64_ABS-NEXT: Augmentation data: 0C
 //  ^^ fde pointer encoding: DW_EH_PE_sdata8
-// DWARF64_PIC:  Augmentation data: 1B
-//  ^^ fde pointer encoding: DW_EH_PE_pcrel | DW_EH_PE_sdata4
+// DWARF64_PIC:  Augmentation data: 1C
+//  ^^ fde pointer encoding: DW_EH_PE_pcrel | DW_EH_PE_sdata8
+// DWARF64_OLD:  Augmentation data: 0C
+//  ^^ fde pointer encoding: DW_EH_PE_sdata8
 // DWARF64-EMPTY:
 // DWARF64-NEXT: DW_CFA_def_cfa_register: SP_64
 // DWARF64_PIC-NEXT: DW_CFA_nop:
 //
 // DWARF64_ABS:  0014 0018 0018 FDE cie= pc=...
-// DWARF64_PIC:  0014 0010 0018 FDE cie= pc=...
+// DWARF64_PIC:  0014 0018 0018 FDE cie= pc=001c...001c
+// DWARF64_OLD:  0014 0018 0018 FDE cie= pc=...
 // DWARF64-NEXT: Format:   DWARF32
 // DWARF64-NEXT: DW_CFA_nop:
 // DWARF64-NEXT: DW_CFA_nop:
Index: llvm/test/DebugInfo/Mips/eh_frame.ll
===
--- llvm/test/DebugInfo/Mips/eh_frame.ll
+++ llvm/test/DebugInfo/Mips/eh_frame.ll
@@ -17,9 +17,9 @@
 ; STATIC-DAG: R_MIPS_32  .gcc_except_table
 
 ; PIC-LABEL: Relocation section '.rel.eh_frame'
-; PIC-DAG: R_MIPS_32    DW.ref.__gxx_personality_v0
+; PIC-DAG: R_MIPS_PC32  DW.ref.__gxx_personality_v0
+; PIC-DA

[PATCH] D108370: [clang-tidy] Fix wrong FixIt about union in cppcoreguidelines-pro-type-member-init

2021-08-19 Thread gehry via Phabricator via cfe-commits
Sockke created this revision.
Sockke added reviewers: aaron.ballman, bkramer, alexfh, malcolm.parsons, MTC, 
steven.zhang.
Herald added subscribers: shchenz, kbarton, xazax.hun, nemanjai.
Sockke requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

I can only initialize one member variable of the same level in the union. The 
case of anonymous records with multiple levels of nesting like the following 
also needs to meet this rule. The original logic is to horizontally obtain all 
the member variables in a record that need to be initialized and then filter to 
the variables that need to be fixed. Obviously, it is impossible to correctly 
initialize the desired variables according to the nesting relationship.

See Example 3 in class.union 

  union U {
U() {}
int x;  // int x{};
union {
  int k;  // int k{};  <==  wrong fix
};
union {
  int z;  // int z{};  <== wrong fix
  int y;
};
  };


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108370

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-member-init.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-member-init.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-member-init.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-member-init.cpp
@@ -516,3 +516,34 @@
 
 PositiveDefaultConstructorOutOfDecl::PositiveDefaultConstructorOutOfDecl() = 
default;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: constructor does not initialize 
these fields: F
+
+union U1 {
+  U1() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: union constructor should 
initialize one of these fields: X, K, Z, Y
+  int X;
+  // CHECK-FIXES: int X{};
+  union {
+int K;
+  };
+  union {
+int Z;
+int Y;
+  };
+};
+
+union U2 {
+  U2() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: union constructor should 
initialize one of these fields: B, C, A
+  struct {
+int B;
+// CHECK-FIXES: int B{};
+union {
+  struct {
+PositiveMultipleConstructors Value;
+  };
+  int C;
+  // CHECK-FIXES: int C{};
+};
+  };
+  int A;
+};
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -44,6 +44,23 @@
   }
 }
 
+template 
+void forEachFieldWithFilter(const RecordDecl &Record, const T &Fields,
+bool &AnyMemberHasInitPerUnion, Func &&Fn) {
+  for (const FieldDecl *F : Fields) {
+if (F->isAnonymousStructOrUnion()) {
+  if (const CXXRecordDecl *R = F->getType()->getAsCXXRecordDecl()) {
+AnyMemberHasInitPerUnion = false;
+forEachFieldWithFilter(*R, R->fields(), AnyMemberHasInitPerUnion, Fn);
+  }
+} else {
+  Fn(F);
+}
+if (Record.isUnion() && AnyMemberHasInitPerUnion)
+  break;
+  }
+}
+
 void removeFieldsInitializedInBody(
 const Stmt &Stmt, ASTContext &Context,
 SmallPtrSetImpl &FieldDecls) {
@@ -461,8 +478,9 @@
   // Collect all fields but only suggest a fix for the first member of unions,
   // as initializing more than one union member is an error.
   SmallPtrSet FieldsToFix;
-  SmallPtrSet UnionsSeen;
-  forEachField(ClassDecl, OrderedFields, [&](const FieldDecl *F) {
+  bool AnyMemberHasInitPerUnion = false;
+  forEachFieldWithFilter(ClassDecl, ClassDecl.fields(),
+ AnyMemberHasInitPerUnion, [&](const FieldDecl *F) {
 if (!FieldsToInit.count(F))
   return;
 // Don't suggest fixes for enums because we don't know a good default.
@@ -471,8 +489,8 @@
 if (F->getType()->isEnumeralType() ||
 (!getLangOpts().CPlusPlus20 && F->isBitField()))
   return;
-if (!F->getParent()->isUnion() || UnionsSeen.insert(F->getParent()).second)
-  FieldsToFix.insert(F);
+FieldsToFix.insert(F);
+AnyMemberHasInitPerUnion = true;
   });
   if (FieldsToFix.empty())
 return;


Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-member-init.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-member-init.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-member-init.cpp
@@ -516,3 +516,34 @@
 
 PositiveDefaultConstructorOutOfDecl::PositiveDefaultConstructorOutOfDecl() = default;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: constructor does not initialize these fields: F
+
+union U1 {
+  U1() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]

[PATCH] D106870: [OpenMP] Multi architecture compilation support

2021-08-19 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added reviewers: ronlieb, pdhaliwal.
JonChesterfield added a comment.

Spent some time reading through this. I think the idea is to create a host 
binary that contains code objects for multiple variants of amdgpu - e.g. one 
that runs on gfx906 and another on gfx908, or one that runs on gfx906-xnack+ 
and another on gfx906-xnack-.

That's close to the long running feature request to compile a program to a 
binary that can run on totally different architectures, e.g. nvptx + amdgpu + 
vgpu + remote. Probably in the first instance making one binary that can run on 
whatever and then extending it to run on a system that has multiple targets 
available. I've got a nvptx / amdgpu box here that would be well suited to 
testing that. Tagging Ron and Pushpinder who may be interested in such.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106870

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


[PATCH] D107450: [clang-tidy] Fix wrong FIxIt in performance-move-const-arg

2021-08-19 Thread gehry via Phabricator via cfe-commits
Sockke updated this revision to Diff 367474.
Sockke marked 2 inline comments as done.
Sockke added a comment.
Herald added a subscriber: jfb.

Thanks for your reply @Quuxplusone. I have updated!


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

https://reviews.llvm.org/D107450

Files:
  clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp
  clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.h
  clang-tools-extra/test/clang-tidy/checkers/performance-move-const-arg.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/performance-move-const-arg.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance-move-const-arg.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance-move-const-arg.cpp
@@ -246,3 +246,27 @@
   };
   f(MoveSemantics());
 }
+
+void showInt(int &&) {}
+void testInt() {
+  int a = 10;
+  showInt(std::move(a));
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: std::move of the variable 'a' of the trivially-copyable type 'int' has no effect; consider changing showInt's parameter from 'int &&' to 'const int &'
+}
+template 
+void forwardToShowInt(T &&t) {
+  showInt(static_cast(t));
+}
+void testTemplate() {
+  int a = 10;
+  forwardToShowInt(std::move(a));
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: std::move of the variable 'a' of the trivially-copyable type 'int' has no effect
+}
+
+struct Tmp {};
+void showTmp(Tmp &&) {}
+void testTmp() {
+  Tmp t;
+  showTmp(std::move(t));
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: std::move of the variable 't' of the trivially-copyable type 'Tmp' has no effect; consider changing showTmp's parameter from 'Tmp &&' to 'const Tmp &'
+}
Index: clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.h
===
--- clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.h
+++ clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.h
@@ -10,6 +10,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MOVECONSTANTARGUMENTCHECK_H
 
 #include "../ClangTidyCheck.h"
+#include "llvm/ADT/DenseSet.h"
 
 namespace clang {
 namespace tidy {
@@ -36,6 +37,7 @@
 
 private:
   const bool CheckTriviallyCopyableMove;
+  llvm::DenseSet HasCheckedMoveSet;
 };
 
 } // namespace performance
Index: clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp
===
--- clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp
+++ clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp
@@ -50,7 +50,9 @@
   Finder->addMatcher(
   invocation(forEachArgumentWithParam(
  MoveCallMatcher,
- parmVarDecl(hasType(references(isConstQualified())
+ parmVarDecl(anyOf(hasType(references(isConstQualified())),
+   hasType(rValueReferenceType(
+ .bind("invocation-parm")))
   .bind("receiving-expr"),
   this);
 }
@@ -58,6 +60,15 @@
 void MoveConstArgCheck::check(const MatchFinder::MatchResult &Result) {
   const auto *CallMove = Result.Nodes.getNodeAs("call-move");
   const auto *ReceivingExpr = Result.Nodes.getNodeAs("receiving-expr");
+  const auto *InvocationParm =
+  Result.Nodes.getNodeAs("invocation-parm");
+
+  if (!ReceivingExpr && HasCheckedMoveSet.contains(CallMove))
+return;
+
+  if (ReceivingExpr)
+HasCheckedMoveSet.insert(CallMove);
+
   const Expr *Arg = CallMove->getArg(0);
   SourceManager &SM = Result.Context->getSourceManager();
 
@@ -90,20 +101,57 @@
   return;
 
 bool IsVariable = isa(Arg);
+bool IsRValueReferenceArg = false;
+bool IsTemplateInstantiation = false;
+StringRef FuncName;
+QualType ParmType;
+std::string ExpectParmTypeName;
 const auto *Var =
 IsVariable ? dyn_cast(Arg)->getDecl() : nullptr;
+
+if (ReceivingExpr &&
+InvocationParm->getOriginalType()->isRValueReferenceType() &&
+!ReceivingExpr->getType()->isRecordType() && Arg->isLValue()) {
+  IsRValueReferenceArg = true;
+  const auto *ReceivingCallExpr = dyn_cast(ReceivingExpr);
+  if (!ReceivingCallExpr)
+return;
+  IsTemplateInstantiation =
+  ReceivingCallExpr->getDirectCallee()->isTemplateInstantiation();
+  FuncName = ReceivingCallExpr->getDirectCallee()->getName();
+  ParmType = InvocationParm->getOriginalType();
+  if (Arg->getType()->isRecordType()) {
+if (const CXXRecordDecl *R = Arg->getType()->getAsCXXRecordDecl())
+  ExpectParmTypeName = R->getNameAsString();
+  } else
+ExpectParmTypeName =
+Arg->getType().getAtomicUnqualifiedType().getAsString();
+}
+
 auto Diag = diag(FileMoveRange.getBegin(),
  "std::move of the %select{|const }0"
- "%select{expression|variable %4}1 "
- "%select{|o

[PATCH] D108366: [clang][deps] Deduce resource directory from the compiler path

2021-08-19 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 367478.
jansvoboda11 added a comment.

Account for Windows backslashes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108366

Files:
  clang/include/clang/Tooling/Tooling.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
  clang/lib/Tooling/Tooling.cpp
  clang/test/ClangScanDeps/Inputs/resource_directory/cdb_tu.json
  clang/test/ClangScanDeps/Inputs/resource_directory/mod.h
  clang/test/ClangScanDeps/Inputs/resource_directory/module.modulemap
  clang/test/ClangScanDeps/Inputs/resource_directory/tu.c
  clang/test/ClangScanDeps/resource_directory.c

Index: clang/test/ClangScanDeps/resource_directory.c
===
--- /dev/null
+++ clang/test/ClangScanDeps/resource_directory.c
@@ -0,0 +1,9 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: cp %S/Inputs/resource_directory/* %t
+// RUN: sed -e "s|CLANG|/our/custom/bin/clang|g" -e "s|DIR|%/t|g" %S/Inputs/resource_directory/cdb_tu.json > %t/cdb.json
+
+// RUN: clang-scan-deps -compilation-database %t/cdb.json --format experimental-full > result.json
+// RUN: cat result.json | sed 's:\?:/:g' | FileCheck %s
+
+// CHECK:  "-resource-dir"
+// CHECK-NEXT: "/our/custom/{{.*}}"
Index: clang/test/ClangScanDeps/Inputs/resource_directory/tu.c
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/resource_directory/tu.c
@@ -0,0 +1,3 @@
+// tu.c
+
+#include "mod.h"
Index: clang/test/ClangScanDeps/Inputs/resource_directory/module.modulemap
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/resource_directory/module.modulemap
@@ -0,0 +1 @@
+module mod { header "mod.h" }
Index: clang/test/ClangScanDeps/Inputs/resource_directory/mod.h
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/resource_directory/mod.h
@@ -0,0 +1 @@
+// mod.h
Index: clang/test/ClangScanDeps/Inputs/resource_directory/cdb_tu.json
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/resource_directory/cdb_tu.json
@@ -0,0 +1,7 @@
+[
+  {
+"directory": "DIR",
+"command": "CLANG -fmodules -gmodules -fimplicit-module-maps -fmodules-cache-path=DIR/cache -c DIR/tu.c -o DIR/tu.o",
+"file": "DIR/tu.c"
+  }
+]
Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -553,15 +553,17 @@
 CommandLine = ArgsAdjuster(CommandLine, CompileCommand.Filename);
   assert(!CommandLine.empty());
 
-  // Add the resource dir based on the binary of this tool. argv[0] in the
-  // compilation database may refer to a different compiler and we want to
-  // pick up the very same standard library that compiler is using. The
-  // builtin headers in the resource dir need to match the exact clang
-  // version the tool is using.
-  // FIXME: On linux, GetMainExecutable is independent of the value of the
-  // first argument, thus allowing ClangTool and runToolOnCode to just
-  // pass in made-up names here. Make sure this works on other platforms.
-  injectResourceDir(CommandLine, "clang_tool", &StaticSymbol);
+  if (InjectResourceDir) {
+// Add the resource dir based on the binary of this tool. argv[0] in the
+// compilation database may refer to a different compiler and we want to
+// pick up the very same standard library that compiler is using. The
+// builtin headers in the resource dir need to match the exact clang
+// version the tool is using.
+// FIXME: On linux, GetMainExecutable is independent of the value of the
+// first argument, thus allowing ClangTool and runToolOnCode to just
+// pass in made-up names here. Make sure this works on other platforms.
+injectResourceDir(CommandLine, "clang_tool", &StaticSymbol);
+  }
 
   // FIXME: We need a callback mechanism for the tool writer to output a
   // customized message for each file.
@@ -625,6 +627,10 @@
   this->RestoreCWD = RestoreCWD;
 }
 
+void ClangTool::setInjectResourceDir(bool InjectResourceDir) {
+  this->InjectResourceDir = InjectResourceDir;
+}
+
 void ClangTool::setPrintErrorMessage(bool PrintErrorMessage) {
   this->PrintErrorMessage = PrintErrorMessage;
 }
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -316,6 +316,10 @@
 tooling::ClangTool Tool(CDB, Input, PCHContainerOps, RealFS, Files);
 Tool.clearAr

[PATCH] D108029: [clang][Codegen] Introduce the disable_sanitizer_instrumentation attribute

2021-08-19 Thread Alexander Potapenko via Phabricator via cfe-commits
glider updated this revision to Diff 367480.
glider added a comment.

Updated BitcodeReader.cpp and several tests per Marco's suggestion
Renamed ATTR_DISABLE_SANITIZER_INSTRUMENTATION to 
ATTR_KIND_DISABLE_SANITIZER_INSTRUMENTATION


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108029

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGen/attr-disable-sanitizer-instrumentation.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  llvm/docs/BitCodeFormat.rst
  llvm/include/llvm/AsmParser/LLToken.h
  llvm/include/llvm/Bitcode/LLVMBitCodes.h
  llvm/include/llvm/IR/Attributes.td
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/Transforms/Utils/CodeExtractor.cpp
  llvm/test/Bitcode/attributes.ll
  llvm/test/Bitcode/compatibility.ll

Index: llvm/test/Bitcode/compatibility.ll
===
--- llvm/test/Bitcode/compatibility.ll
+++ llvm/test/Bitcode/compatibility.ll
@@ -1510,7 +1510,7 @@
   ; CHECK: select <2 x i1> , <2 x i8> , <2 x i8> 
 
   call void @f.nobuiltin() builtin
-  ; CHECK: call void @f.nobuiltin() #45
+  ; CHECK: call void @f.nobuiltin() #46
 
   call fastcc noalias i32* @f.noalias() noinline
   ; CHECK: call fastcc noalias i32* @f.noalias() #12
@@ -1907,6 +1907,9 @@
 declare void @f.nosanitize_coverage() nosanitize_coverage
 ; CHECK: declare void @f.nosanitize_coverage() #44
 
+declare void @f.disable_sanitizer_instrumentation() disable_sanitizer_instrumentation
+; CHECK: declare void @f.disable_sanitizer_instrumentation() #45
+
 ; immarg attribute
 declare void @llvm.test.immarg.intrinsic(i32 immarg)
 ; CHECK: declare void @llvm.test.immarg.intrinsic(i32 immarg)
@@ -1965,7 +1968,8 @@
 ; CHECK: attributes #42 = { speculatable }
 ; CHECK: attributes #43 = { strictfp }
 ; CHECK: attributes #44 = { nosanitize_coverage }
-; CHECK: attributes #45 = { builtin }
+; CHECK: attributes #45 = { disable_sanitizer_instrumentation }
+; CHECK: attributes #46 = { builtin }
 
 ;; Metadata
 
Index: llvm/test/Bitcode/attributes.ll
===
--- llvm/test/Bitcode/attributes.ll
+++ llvm/test/Bitcode/attributes.ll
@@ -472,6 +472,12 @@
   ret void
 }
 
+; CHECK: define void @f80() #50
+define void @f80() disable_sanitizer_instrumentation
+{
+ret void;
+}
+
 ; CHECK: attributes #0 = { noreturn }
 ; CHECK: attributes #1 = { nounwind }
 ; CHECK: attributes #2 = { readnone }
@@ -522,4 +528,5 @@
 ; CHECK: attributes #47 = { vscale_range(1,0) }
 ; CHECK: attributes #48 = { nosanitize_coverage }
 ; CHECK: attributes #49 = { noprofile }
+; CHECK: attributes #50 = { disable_sanitizer_instrumentation }
 ; CHECK: attributes #[[NOBUILTIN]] = { nobuiltin }
Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp
===
--- llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -943,6 +943,7 @@
   // Those attributes should be safe to propagate to the extracted function.
   case Attribute::AlwaysInline:
   case Attribute::Cold:
+  case Attribute::DisableSanitizerInstrumentation:
   case Attribute::Hot:
   case Attribute::NoRecurse:
   case Attribute::InlineHint:
Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -627,6 +627,8 @@
 return bitc::ATTR_KIND_IN_ALLOCA;
   case Attribute::Cold:
 return bitc::ATTR_KIND_COLD;
+  case Attribute::DisableSanitizerInstrumentation:
+return bitc::ATTR_KIND_DISABLE_SANITIZER_INSTRUMENTATION;
   case Attribute::Hot:
 return bitc::ATTR_KIND_HOT;
   case Attribute::ElementType:
Index: llvm/lib/Bitcode/Reader/BitcodeReader.cpp
===
--- llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -1388,6 +1388,8 @@
 return Attribute::Cold;
   case bitc::ATTR_KIND_CONVERGENT:
 return Attribute::Convergent;
+  case bitc::ATTR_KIND_DISABLE_SANITIZER_INSTRUMENTATION:
+return Attribute::DisableSanitizerInstrumentation;
   case bitc::ATTR_KIND_ELEMENTTYPE:
 return Attribute::ElementType;
   case bitc::ATTR_KIND_INACCESSIBLEMEM_ONLY:
Index: llvm/lib/AsmParser/LLLexer.cpp
===
--- llvm/lib/AsmParser/LLLexer.cpp
+++ llvm/lib/AsmParser/LLLexer.cpp
@@ -643,6 +643,7 @@
   KEYWORD(convergent);
   KEYWORD(dereferenceable);
   KEYWORD(dereferenceable_or_null);
+  KEYWORD(disable_sanitizer_instrumentation);
   KEYWORD(elementtype);

[PATCH] D108029: [clang][Codegen] Introduce the disable_sanitizer_instrumentation attribute

2021-08-19 Thread Marco Elver via Phabricator via cfe-commits
melver added inline comments.



Comment at: llvm/lib/AsmParser/LLLexer.cpp:646
   KEYWORD(dereferenceable_or_null);
+  KEYWORD(disable_sanitizer_instrumentation);
   KEYWORD(elementtype);

Do the tests pass?

There should also be the code that actually turns the token into the attribute 
in llvm/lib/AsmParser/LLParser.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108029

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


[PATCH] D108029: [clang][Codegen] Introduce the disable_sanitizer_instrumentation attribute

2021-08-19 Thread Marco Elver via Phabricator via cfe-commits
melver added a comment.

llvm/docs/LangRef.rst also needs a corresponding change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108029

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


[PATCH] D108370: [clang-tidy] Fix wrong FixIt about union in cppcoreguidelines-pro-type-member-init

2021-08-19 Thread liushuai wang via Phabricator via cfe-commits
MTC added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp:49
+void forEachFieldWithFilter(const RecordDecl &Record, const T &Fields,
+bool &AnyMemberHasInitPerUnion, Func &&Fn) {
+  for (const FieldDecl *F : Fields) {

Can it be modified to the following form? Or further abstract `filter` into a 
parameter to make this function more general.


```
template 
void forEachFieldWithFilter(const RecordDecl &Record, const T &Fields,
bool &AnyMemberHasInitPerUnion, Func &&Fn) {
  forEachField(Record, Fields, Fn);
  if (Record.isUnion() && AnyMemberHasInitPerUnion)
break;
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108370

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


[PATCH] D106888: [RISC-V] Implement jump tables for CFI-icall

2021-08-19 Thread Luís Marques via Phabricator via cfe-commits
luismarques added a comment.

In D106888#2954425 , @asb wrote:

> Is it possible to write a test case for this?

Good question. I had checked that the AArch64 implementation had included a 
test, but I think that was only for new target-specific stuff, which doesn't 
apply here. So I was assuming the answer was no, but it would be good to get 
confirmation. I was also confused by the comment about "the build failure", 
since this applied cleanly and built OK for me when I looked at it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106888

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


[PATCH] D108265: .clang-tidy: Push variable related readability-identifier-naming options down to projects

2021-08-19 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

> the original discussion that spawned the (not-yet-accepted, as it says in its 
> opening sentence) linked proposal around variable naming.

+1 with David again: if the proposal gets accepted, then this patch makes sense 
to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108265

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


[PATCH] D108029: [clang][Codegen] Introduce the disable_sanitizer_instrumentation attribute

2021-08-19 Thread Alexander Potapenko via Phabricator via cfe-commits
glider added a comment.

In D108029#2954566 , @melver wrote:

> llvm/docs/LangRef.rst also needs a corresponding change.

Right, will do. I thought LangRef was missing the sanitizer bits as well, and 
was planning to add them together, but apparently I was just looking for the 
wrong attributes.




Comment at: llvm/lib/AsmParser/LLLexer.cpp:646
   KEYWORD(dereferenceable_or_null);
+  KEYWORD(disable_sanitizer_instrumentation);
   KEYWORD(elementtype);

melver wrote:
> Do the tests pass?
> 
> There should also be the code that actually turns the token into the 
> attribute in llvm/lib/AsmParser/LLParser.cpp
check-llvm and check-clang pass for me, check-all seems to choke on some 
unrelated bugs.

LLParser is using Tablegen now, no need to change it: 
https://github.com/llvm/llvm-project/blob/main/llvm/lib/AsmParser/LLParser.cpp#L1247


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108029

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


[PATCH] D108029: [clang][Codegen] Introduce the disable_sanitizer_instrumentation attribute

2021-08-19 Thread Marco Elver via Phabricator via cfe-commits
melver accepted this revision.
melver added a comment.

LGTM
with the LangRef change.

Thanks!




Comment at: llvm/lib/AsmParser/LLLexer.cpp:646
   KEYWORD(dereferenceable_or_null);
+  KEYWORD(disable_sanitizer_instrumentation);
   KEYWORD(elementtype);

glider wrote:
> melver wrote:
> > Do the tests pass?
> > 
> > There should also be the code that actually turns the token into the 
> > attribute in llvm/lib/AsmParser/LLParser.cpp
> check-llvm and check-clang pass for me, check-all seems to choke on some 
> unrelated bugs.
> 
> LLParser is using Tablegen now, no need to change it: 
> https://github.com/llvm/llvm-project/blob/main/llvm/lib/AsmParser/LLParser.cpp#L1247
Ah, nice, I missed that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108029

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


[PATCH] D54943: [clang-tidy] implement const-transformation for cppcoreguidelines-const-correctness

2021-08-19 Thread Tiago Macarios via Phabricator via cfe-commits
tiagoma added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.cpp:168
+*Variable, *Result.Context, DeclSpec::TQ_const,
+QualifierTarget::Value, QualifierPolicy::Right)) {
+  Diag << *Fix;

The core guidelines suggests the use of west const. Could this be made the 
default?
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rl-const



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/ConstCorrectnessCheck.h:31
+WarnPointersAsValues(Options.get("WarnPointersAsValues", 0)),
+TransformValues(Options.get("TransformValues", 1)),
+TransformReferences(Options.get("TransformReferences", 1)),

JonasToth wrote:
> Deactivating the transformations by default, as they are not ready for 
> production yet.
Ok. This got me off-guard. I would rather have this on.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D54943

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


[PATCH] D108151: [NFC][clang] Use X86 Features declaration from X86TargetParser

2021-08-19 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/Basic/Targets/X86.cpp:1061
 static unsigned getFeaturePriority(llvm::X86::ProcessorFeatures Feat) {
-  enum class FeatPriority {
-#define FEATURE(FEAT) FEAT,
-#include "clang/Basic/X86Target.def"
+  // Check that priorites are set properly in the .def file.
+#define X86_FEATURE_COMPAT(ENUM, STR, PRIORITY) PRIORITY,

priorites -> priorities



Comment at: clang/lib/Basic/Targets/X86.cpp:1067
   };
+  (void)Priorities;
+  for (unsigned Priority = 0;

Maybe just wrap this all in #ifndef NDEBUG?



Comment at: clang/lib/Basic/Targets/X86.cpp:1069
+  for (unsigned Priority = 0;
+   Priority < sizeof(Priorities) / sizeof(unsigned) - 1; ++Priority) {
+assert(llvm::is_contained(Priorities, Priority) &&

array_lengthof(Priorities) - 1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108151

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


[clang] caa282a - Fix unknown parameter Wdocumentation warning. NFC.

2021-08-19 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2021-08-19T15:40:09+01:00
New Revision: caa282a4490332034809bd0baf3e7a2ed1b080ae

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

LOG: Fix unknown parameter Wdocumentation warning. NFC.

Added: 


Modified: 
clang/lib/Sema/SemaStmt.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index f4f7e353a2c1..dc93e9e1c51c 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -3316,7 +3316,7 @@ Sema::ActOnBreakStmt(SourceLocation BreakLoc, Scope 
*CurScope) {
 /// being thrown, or being co_returned from a coroutine. This expression
 /// might be modified by the implementation.
 ///
-/// \param ForceCXX2b Overrides detection of current language mode
+/// \param Mode Overrides detection of current language mode
 /// and uses the rules for C++2b.
 ///
 /// \returns An aggregate which contains the Candidate and isMoveEligible



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


[clang] fd37ead - Fix unknown parameter Wdocumentation warning. NFC.

2021-08-19 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2021-08-19T15:40:10+01:00
New Revision: fd37ead38659dec3e63b1b560d43e81249f3e3ce

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

LOG: Fix unknown parameter Wdocumentation warning. NFC.

Added: 


Modified: 
clang/lib/Frontend/PrintPreprocessedOutput.cpp

Removed: 




diff  --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp 
b/clang/lib/Frontend/PrintPreprocessedOutput.cpp
index 1a820ad985a4..5c5fc751179d 100644
--- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp
+++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp
@@ -182,7 +182,7 @@ class PrintPPOutputPPCallbacks : public PPCallbacks {
   /// implicitly when at the beginning of the file.
   ///
   /// @param Tok Token where to move to.
-  /// @param RequiresStartOfLine Whether the next line depends on being in the
+  /// @param RequireStartOfLine  Whether the next line depends on being in the
   ///first column, such as a directive.
   ///
   /// @return Whether column adjustments are necessary.



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


[clang] ae69164 - Fix unknown parameter Wdocumentation warning. NFC.

2021-08-19 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2021-08-19T15:40:10+01:00
New Revision: ae691648b47091313a5c2f964800d53e60b635ea

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

LOG: Fix unknown parameter Wdocumentation warning. NFC.

Added: 


Modified: 
clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp 
b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
index 2c54bffabc43..ecd9b649c4f4 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -1175,7 +1175,7 @@ class StoreSiteFinder final : public 
TrackingBugReporterVisitor {
 public:
   /// \param V We're searching for the store where \c R received this value.
   /// \param R The region we're tracking.
-  /// \param TKind May limit the amount of notes added to the bug report.
+  /// \param Options Tracking behavior options.
   /// \param OriginSFC Only adds notes when the last store happened in a
   ///
diff erent stackframe to this one. Disregarded if the tracking kind
   ///is thorough.



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


[PATCH] D108151: [NFC][clang] Use X86 Features declaration from X86TargetParser

2021-08-19 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/Basic/Targets/X86.cpp:1071
+assert(llvm::is_contained(Priorities, Priority) &&
+   "Priorites don't form consequtive range!");
+  }

If all you care about is whether they are a consecutive range, why not just use 
`std::is_sorted`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108151

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


[PATCH] D108151: [NFC][clang] Use X86 Features declaration from X86TargetParser

2021-08-19 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/Basic/Targets/X86.cpp:1071
+assert(llvm::is_contained(Priorities, Priority) &&
+   "Priorites don't form consequtive range!");
+  }

erichkeane wrote:
> If all you care about is whether they are a consecutive range, why not just 
> use `std::is_sorted`?
The Priorities array isn't sorted. It's just whatever order the 
X86_FEATURE_COMPAT lists them.

The values need to be unique and in a contiguous range.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108151

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


[PATCH] D108377: [asan] Implemented custom calling convention similar used by HWASan for X86.

2021-08-19 Thread Kirill Stoimenov via Phabricator via cfe-commits
kstoimenov created this revision.
kstoimenov added a reviewer: vitalybuka.
Herald added a subscriber: hiraditya.
kstoimenov requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

The address sanitizer part of the code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108377

Files:
  clang/test/CodeGen/asan-use-callbacks.cpp
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -348,6 +348,10 @@
 static cl::opt ClOpt("asan-opt", cl::desc("Optimize instrumentation"),
cl::Hidden, cl::init(true));
 
+static cl::opt ClOptimizeCallbacks("asan-optimize-callbacks",
+ cl::desc("Optimize callbacks"),
+ cl::Hidden, cl::init(false));
+
 static cl::opt ClOptSameTemp(
 "asan-opt-same-temp", cl::desc("Instrument the same temp just once"),
 cl::Hidden, cl::init(true));
@@ -559,6 +563,17 @@
   return Mapping;
 }
 
+void getAddressSanitizerParams(Module &M, uint64_t *ShadowBase,
+   int *MappingScale, bool *OrShadowOffset) {
+  Triple TargetTriple = Triple(M.getTargetTriple());
+  auto Mapping =
+  getShadowMapping(TargetTriple, M.getDataLayout().getPointerSizeInBits(),
+   ClEnableKasan.getNumOccurrences() > 0);
+  *ShadowBase = Mapping.Offset;
+  *MappingScale = Mapping.Scale;
+  *OrShadowOffset = Mapping.OrShadowOffset;
+}
+
 static uint64_t getRedzoneSizeForScale(int MappingScale) {
   // Redzone used for stack and globals is at least 32 bytes.
   // For scales 6 and 7, the redzone has to be 64 and 128 bytes respectively.
@@ -623,6 +638,7 @@
 C = &(M.getContext());
 LongSize = M.getDataLayout().getPointerSizeInBits();
 IntptrTy = Type::getIntNTy(*C, LongSize);
+Int8PtrTy = Type::getInt8PtrTy(*C);
 TargetTriple = Triple(M.getTargetTriple());
 
 Mapping = getShadowMapping(TargetTriple, LongSize, this->CompileKernel);
@@ -673,6 +689,7 @@
  Value *SizeArgument, uint32_t Exp);
   void instrumentMemIntrinsic(MemIntrinsic *MI);
   Value *memToShadow(Value *Shadow, IRBuilder<> &IRB);
+  void encodeMemToShadowInfo(int64_t *AccessInfo);
   bool suppressInstrumentationSiteForDebug(int &Instrumented);
   bool instrumentFunction(Function &F, const TargetLibraryInfo *TLI);
   bool maybeInsertAsanInitAtFunctionEntry(Function &F);
@@ -713,6 +730,7 @@
   bool UseAfterScope;
   AsanDetectStackUseAfterReturnMode UseAfterReturn;
   Type *IntptrTy;
+  Type *Int8PtrTy;
   ShadowMapping Mapping;
   FunctionCallee AsanHandleNoReturnFunc;
   FunctionCallee AsanPtrCmpFunction, AsanPtrSubFunction;
@@ -1742,12 +1760,21 @@
   size_t AccessSizeIndex = TypeSizeToSizeIndex(TypeSize);
 
   if (UseCalls) {
-if (Exp == 0)
-  IRB.CreateCall(AsanMemoryAccessCallback[IsWrite][0][AccessSizeIndex],
- AddrLong);
-else
-  IRB.CreateCall(AsanMemoryAccessCallback[IsWrite][1][AccessSizeIndex],
- {AddrLong, ConstantInt::get(IRB.getInt32Ty(), Exp)});
+if (ClOptimizeCallbacks) {
+  Value *Ptr8 = IRB.CreatePointerCast(Addr, Int8PtrTy);
+  Module *M = IRB.GetInsertBlock()->getParent()->getParent();
+  IRB.CreateCall(
+  Intrinsic::getDeclaration(M, Intrinsic::asan_check_memaccess),
+  {Ptr8, ConstantInt::get(IRB.getInt8Ty(), IsWrite),
+   ConstantInt::get(IRB.getInt8Ty(), AccessSizeIndex)});
+} else {
+  if (Exp == 0)
+IRB.CreateCall(AsanMemoryAccessCallback[IsWrite][0][AccessSizeIndex],
+   AddrLong);
+  else
+IRB.CreateCall(AsanMemoryAccessCallback[IsWrite][1][AccessSizeIndex],
+   {AddrLong, ConstantInt::get(IRB.getInt32Ty(), Exp)});
+}
 return;
   }
 
Index: llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h
===
--- llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h
+++ llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h
@@ -87,6 +87,8 @@
   return true;
 }
 
+void getASanShadowMapping(int *Scale, uint64_t *Offset, bool *OrShadowOffset);
+
 } // namespace llvm
 
 #endif
Index: llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
===
--- llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
+++ llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
@@ -147,6 +147,10 @@
 bool UseOdrIn

[PATCH] D105268: [X86] AVX512FP16 instructions enabling 5/6

2021-08-19 Thread LuoYuanke via Phabricator via cfe-commits
LuoYuanke added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsX86.def:2010
+TARGET_BUILTIN(__builtin_ia32_vfmaddph, "V8xV8xV8xV8x", "ncV:128:", 
"avx512fp16,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vfmaddph256, "V16xV16xV16xV16x", "ncV:256:", 
"avx512fp16,avx512vl")
+

Can we arrange the vfmaddph variant together?  Move it to line 1997?
Why there is no mask version for 128 and 256?



Comment at: clang/include/clang/Basic/BuiltinsX86.def:2014
+
+TARGET_BUILTIN(__builtin_ia32_vfmaddsh3_mask, "V8xV8xV8xV8xUcIi", "ncV:128:", 
"avx512fp16")
+TARGET_BUILTIN(__builtin_ia32_vfmaddsh3_maskz, "V8xV8xV8xV8xUcIi", "ncV:128:", 
"avx512fp16")

What does "3" stand for?



Comment at: clang/lib/Headers/avx512vlfp16intrin.h:1385
+  __m128h __C) 
{
+  return (__m128h)__builtin_ia32_selectph_128(
+  (__mmask8)__U,

Sorry, I'm confused sometimes we use mask builtin, sometimes we use select 
builtin. Any guideline on it?



Comment at: llvm/include/llvm/IR/IntrinsicsX86.td:5709
+
+  def int_x86_avx512fp16_vfmadd_ph_512
+  : Intrinsic<[ llvm_v32f16_ty ],

I notice there is no builtin bound to this intrinsic. What is it used for?



Comment at: llvm/include/llvm/IR/IntrinsicsX86.td:5727
+  [ IntrNoMem, ImmArg> ]>;
+  def int_x86_avx512fp16_vfmadd_f16
+  : Intrinsic<[ llvm_half_ty ],

ph?



Comment at: llvm/lib/Target/X86/X86InstrFMA3Info.cpp:148
+
+#define FP16_FMA3GROUP_PACKED_AVX512(Name, Suf, Attrs) 
\
+  FMA3GROUP_PACKED_AVX512_WIDTHS(Name, PH, Suf, Attrs)

Can we integrate it to FMA3GROUP_PACKED_AVX512() with PH extended?



Comment at: llvm/lib/Target/X86/X86InstrFMA3Info.cpp:151
+
+#define FP16_FMA3GROUP_PACKED_AVX512_ROUND(Name, Suf, Attrs)   
\
+  FMA3GROUP_MASKED(Name, PHZ##Suf, Attrs)

Ditto.



Comment at: llvm/lib/Target/X86/X86InstrFMA3Info.cpp:154
+
+#define FP16_FMA3GROUP_SCALAR_AVX512_ROUND(Name, Suf, Attrs)   
\
+  FMA3GROUP(Name, SHZ##Suf, Attrs) 
\

Ditto.



Comment at: llvm/lib/Target/X86/X86InstrFMA3Info.cpp:158
+
+static const X86InstrFMA3Group FP16BroadcastGroups[] = {
+  FP16_FMA3GROUP_PACKED_AVX512(VFMADD, mb, 0)

Ditto.



Comment at: llvm/lib/Target/X86/X86InstrFMA3Info.cpp:167
+
+static const X86InstrFMA3Group FP16RoundGroups[] = {
+  FP16_FMA3GROUP_PACKED_AVX512_ROUND(VFMADD, rb, 0)

Ditto.



Comment at: llvm/lib/Target/X86/X86InstrFMA3Info.cpp:208
  (BaseOpcode >= 0xB6 && BaseOpcode <= 0xBF));
+  bool IsFMA3H = (TSFlags & X86II::EncodingMask) == X86II::EVEX &&
+ (TSFlags & X86II::OpMapMask) == X86II::T_MAP6 &&

Looks some redundant logic. Only X86II::EVEX and X86II::T_MAP6 is special for 
FP16?



Comment at: llvm/lib/Target/X86/X86InstrFMA3Info.cpp:235
+else
+  Table = makeArrayRef(FP16Groups);
+  }

Seems we only need FP16Groups be separate table.



Comment at: llvm/test/CodeGen/X86/avx512fp16-fma-commute.ll:9
+
+define half @fma_123_f16(half %x, half %y, half %z) {
+; CHECK-LABEL: fma_123_f16:

The name 123 is not the same with the generated instruction (213sh). Is it 
expected?



Comment at: llvm/test/CodeGen/X86/vec-strict-128-fp16.ll:105
 
+define <8 x half> @f13(<8 x half> %a, <8 x half> %b, <8 x half> %c) #0 {
+; CHECK-LABEL: f13:

Is it necessary to test 132, 231 version?



Comment at: llvm/test/CodeGen/X86/vec-strict-256-fp16.ll:105
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vfmadd213ph %ymm2, %ymm1, %ymm0
+; CHECK-NEXT:ret{{[l|q]}}

Ditto.



Comment at: llvm/test/CodeGen/X86/vec-strict-512-fp16.ll:104
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vfmadd213ph %zmm2, %zmm1, %zmm0
+; CHECK-NEXT:ret{{[l|q]}}

Ditto.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105268

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


[PATCH] D108377: [asan] Implemented custom calling convention similar used by HWASan for X86.

2021-08-19 Thread Kirill Stoimenov via Phabricator via cfe-commits
kstoimenov updated this revision to Diff 367500.
kstoimenov added a comment.

Pulled constants like shadow base, etc out of the intrinsic.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108377

Files:
  clang/test/CodeGen/asan-use-callbacks.cpp
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -348,6 +348,10 @@
 static cl::opt ClOpt("asan-opt", cl::desc("Optimize instrumentation"),
cl::Hidden, cl::init(true));
 
+static cl::opt ClOptimizeCallbacks("asan-optimize-callbacks",
+ cl::desc("Optimize callbacks"),
+ cl::Hidden, cl::init(false));
+
 static cl::opt ClOptSameTemp(
 "asan-opt-same-temp", cl::desc("Instrument the same temp just once"),
 cl::Hidden, cl::init(true));
@@ -559,6 +563,17 @@
   return Mapping;
 }
 
+void getAddressSanitizerParams(Module &M, uint64_t *ShadowBase,
+   int *MappingScale, bool *OrShadowOffset) {
+  Triple TargetTriple = Triple(M.getTargetTriple());
+  auto Mapping =
+  getShadowMapping(TargetTriple, M.getDataLayout().getPointerSizeInBits(),
+   ClEnableKasan.getNumOccurrences() > 0);
+  *ShadowBase = Mapping.Offset;
+  *MappingScale = Mapping.Scale;
+  *OrShadowOffset = Mapping.OrShadowOffset;
+}
+
 static uint64_t getRedzoneSizeForScale(int MappingScale) {
   // Redzone used for stack and globals is at least 32 bytes.
   // For scales 6 and 7, the redzone has to be 64 and 128 bytes respectively.
@@ -623,6 +638,7 @@
 C = &(M.getContext());
 LongSize = M.getDataLayout().getPointerSizeInBits();
 IntptrTy = Type::getIntNTy(*C, LongSize);
+Int8PtrTy = Type::getInt8PtrTy(*C);
 TargetTriple = Triple(M.getTargetTriple());
 
 Mapping = getShadowMapping(TargetTriple, LongSize, this->CompileKernel);
@@ -673,6 +689,7 @@
  Value *SizeArgument, uint32_t Exp);
   void instrumentMemIntrinsic(MemIntrinsic *MI);
   Value *memToShadow(Value *Shadow, IRBuilder<> &IRB);
+  void encodeMemToShadowInfo(int64_t *AccessInfo);
   bool suppressInstrumentationSiteForDebug(int &Instrumented);
   bool instrumentFunction(Function &F, const TargetLibraryInfo *TLI);
   bool maybeInsertAsanInitAtFunctionEntry(Function &F);
@@ -713,6 +730,7 @@
   bool UseAfterScope;
   AsanDetectStackUseAfterReturnMode UseAfterReturn;
   Type *IntptrTy;
+  Type *Int8PtrTy;
   ShadowMapping Mapping;
   FunctionCallee AsanHandleNoReturnFunc;
   FunctionCallee AsanPtrCmpFunction, AsanPtrSubFunction;
@@ -1742,12 +1760,21 @@
   size_t AccessSizeIndex = TypeSizeToSizeIndex(TypeSize);
 
   if (UseCalls) {
-if (Exp == 0)
-  IRB.CreateCall(AsanMemoryAccessCallback[IsWrite][0][AccessSizeIndex],
- AddrLong);
-else
-  IRB.CreateCall(AsanMemoryAccessCallback[IsWrite][1][AccessSizeIndex],
- {AddrLong, ConstantInt::get(IRB.getInt32Ty(), Exp)});
+if (ClOptimizeCallbacks) {
+  Value *Ptr8 = IRB.CreatePointerCast(Addr, Int8PtrTy);
+  Module *M = IRB.GetInsertBlock()->getParent()->getParent();
+  IRB.CreateCall(
+  Intrinsic::getDeclaration(M, Intrinsic::asan_check_memaccess),
+  {Ptr8, ConstantInt::get(IRB.getInt8Ty(), IsWrite),
+   ConstantInt::get(IRB.getInt8Ty(), AccessSizeIndex)});
+} else {
+  if (Exp == 0)
+IRB.CreateCall(AsanMemoryAccessCallback[IsWrite][0][AccessSizeIndex],
+   AddrLong);
+  else
+IRB.CreateCall(AsanMemoryAccessCallback[IsWrite][1][AccessSizeIndex],
+   {AddrLong, ConstantInt::get(IRB.getInt32Ty(), Exp)});
+}
 return;
   }
 
Index: llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h
===
--- llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h
+++ llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h
@@ -87,6 +87,8 @@
   return true;
 }
 
+void getASanShadowMapping(int *Scale, uint64_t *Offset, bool *OrShadowOffset);
+
 } // namespace llvm
 
 #endif
Index: llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
===
--- llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
+++ llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
@@ -147,6 +147,10 @@
 bool UseOdrIndicator = true,
 AsanDtorKind DestructorKind = AsanDtorKind::Global);
 
+// Get

[PATCH] D107850: [asan] Implemented custom calling convention similar to the one used by HWASan for X86.

2021-08-19 Thread Kirill Stoimenov via Phabricator via cfe-commits
kstoimenov updated this revision to Diff 367501.
kstoimenov added a comment.

Pulled constants like shadow base, etc out of the intrinsic.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107850

Files:
  clang/test/CodeGen/asan-use-callbacks.cpp
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -348,6 +348,10 @@
 static cl::opt ClOpt("asan-opt", cl::desc("Optimize instrumentation"),
cl::Hidden, cl::init(true));
 
+static cl::opt ClOptimizeCallbacks("asan-optimize-callbacks",
+ cl::desc("Optimize callbacks"),
+ cl::Hidden, cl::init(false));
+
 static cl::opt ClOptSameTemp(
 "asan-opt-same-temp", cl::desc("Instrument the same temp just once"),
 cl::Hidden, cl::init(true));
@@ -559,6 +563,17 @@
   return Mapping;
 }
 
+void getAddressSanitizerParams(Module &M, uint64_t *ShadowBase,
+   int *MappingScale, bool *OrShadowOffset) {
+  Triple TargetTriple = Triple(M.getTargetTriple());
+  auto Mapping =
+  getShadowMapping(TargetTriple, M.getDataLayout().getPointerSizeInBits(),
+   ClEnableKasan.getNumOccurrences() > 0);
+  *ShadowBase = Mapping.Offset;
+  *MappingScale = Mapping.Scale;
+  *OrShadowOffset = Mapping.OrShadowOffset;
+}
+
 static uint64_t getRedzoneSizeForScale(int MappingScale) {
   // Redzone used for stack and globals is at least 32 bytes.
   // For scales 6 and 7, the redzone has to be 64 and 128 bytes respectively.
@@ -623,6 +638,7 @@
 C = &(M.getContext());
 LongSize = M.getDataLayout().getPointerSizeInBits();
 IntptrTy = Type::getIntNTy(*C, LongSize);
+Int8PtrTy = Type::getInt8PtrTy(*C);
 TargetTriple = Triple(M.getTargetTriple());
 
 Mapping = getShadowMapping(TargetTriple, LongSize, this->CompileKernel);
@@ -673,6 +689,7 @@
  Value *SizeArgument, uint32_t Exp);
   void instrumentMemIntrinsic(MemIntrinsic *MI);
   Value *memToShadow(Value *Shadow, IRBuilder<> &IRB);
+  void encodeMemToShadowInfo(int64_t *AccessInfo);
   bool suppressInstrumentationSiteForDebug(int &Instrumented);
   bool instrumentFunction(Function &F, const TargetLibraryInfo *TLI);
   bool maybeInsertAsanInitAtFunctionEntry(Function &F);
@@ -713,6 +730,7 @@
   bool UseAfterScope;
   AsanDetectStackUseAfterReturnMode UseAfterReturn;
   Type *IntptrTy;
+  Type *Int8PtrTy;
   ShadowMapping Mapping;
   FunctionCallee AsanHandleNoReturnFunc;
   FunctionCallee AsanPtrCmpFunction, AsanPtrSubFunction;
@@ -1742,12 +1760,21 @@
   size_t AccessSizeIndex = TypeSizeToSizeIndex(TypeSize);
 
   if (UseCalls) {
-if (Exp == 0)
-  IRB.CreateCall(AsanMemoryAccessCallback[IsWrite][0][AccessSizeIndex],
- AddrLong);
-else
-  IRB.CreateCall(AsanMemoryAccessCallback[IsWrite][1][AccessSizeIndex],
- {AddrLong, ConstantInt::get(IRB.getInt32Ty(), Exp)});
+if (ClOptimizeCallbacks) {
+  Value *Ptr8 = IRB.CreatePointerCast(Addr, Int8PtrTy);
+  Module *M = IRB.GetInsertBlock()->getParent()->getParent();
+  IRB.CreateCall(
+  Intrinsic::getDeclaration(M, Intrinsic::asan_check_memaccess),
+  {Ptr8, ConstantInt::get(IRB.getInt8Ty(), IsWrite),
+   ConstantInt::get(IRB.getInt8Ty(), AccessSizeIndex)});
+} else {
+  if (Exp == 0)
+IRB.CreateCall(AsanMemoryAccessCallback[IsWrite][0][AccessSizeIndex],
+   AddrLong);
+  else
+IRB.CreateCall(AsanMemoryAccessCallback[IsWrite][1][AccessSizeIndex],
+   {AddrLong, ConstantInt::get(IRB.getInt32Ty(), Exp)});
+}
 return;
   }
 
Index: llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h
===
--- llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h
+++ llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h
@@ -87,6 +87,8 @@
   return true;
 }
 
+void getASanShadowMapping(int *Scale, uint64_t *Offset, bool *OrShadowOffset);
+
 } // namespace llvm
 
 #endif
Index: llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
===
--- llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
+++ llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
@@ -147,6 +147,10 @@
 bool UseOdrIndicator = true,
 AsanDtorKind DestructorKind = AsanDtorKind::Global);
 
+// Get

[PATCH] D107477: [Clang][AST][NFC] Resolve FIXME: Make CXXRecordDecl *Record const.

2021-08-19 Thread Alf via Phabricator via cfe-commits
gAlfonso-bit added a comment.

gentle ping


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

https://reviews.llvm.org/D107477

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


[PATCH] D107477: [Clang][AST][NFC] Resolve FIXME: Make CXXRecordDecl *Record const.

2021-08-19 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

In D107477#2954764 , @gAlfonso-bit 
wrote:

> gentle ping

Sorry I forgot about this - I'll deal with this but you really need to request 
commit access


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

https://reviews.llvm.org/D107477

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


[PATCH] D107477: [Clang][AST][NFC] Resolve FIXME: Make CXXRecordDecl *Record const.

2021-08-19 Thread Alf via Phabricator via cfe-commits
gAlfonso-bit added a comment.

How do I request it?


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

https://reviews.llvm.org/D107477

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


[PATCH] D106888: [RISC-V] Implement jump tables for CFI-icall

2021-08-19 Thread Wende Tan via Phabricator via cfe-commits
twd2 added a comment.

In D106888#2954571 , @luismarques 
wrote:

> In D106888#2954425 , @asb wrote:
>
>> Is it possible to write a test case for this?
>
> Good question. I had checked that the AArch64 implementation had included a 
> test, but I think that was only for new target-specific stuff, which doesn't 
> apply here. So I was assuming the answer was no, but it would be good to get 
> confirmation. I was also confused by the comment about "the build failure", 
> since this applied cleanly and built OK for me when I looked at it.

Hi, you can check here: 
https://buildkite.com/llvm-project/premerge-checks/builds/49755#814fd222-2e5a-4400-824d-d1a1f1293c01
The clang-tidy failed due to the invalid case style for variable 
'kRISCVJumpTableEntrySize'.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106888

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


[PATCH] D108151: [NFC][clang] Use X86 Features declaration from X86TargetParser

2021-08-19 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/Basic/Targets/X86.cpp:1071
+assert(llvm::is_contained(Priorities, Priority) &&
+   "Priorites don't form consequtive range!");
+  }

craig.topper wrote:
> erichkeane wrote:
> > If all you care about is whether they are a consecutive range, why not just 
> > use `std::is_sorted`?
> The Priorities array isn't sorted. It's just whatever order the 
> X86_FEATURE_COMPAT lists them.
> 
> The values need to be unique and in a contiguous range.
Then I'd suggest something like: `llvm::sort`, then `assert *(end - 1) - *begin 
== std::distance(begin, end) && llvm::adjacent_find` or something.

I definitely didn't get that point out of this odd for-loop and is_contained.  
There is perhaps at trick with std::min and std::max too.  Though, it looks 
like this is perhaps trying to prove that the range is 0 to the the array size, 
right?  In that case, perhaps there is something easier.

Also a nit, it is `consecutive` in that case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108151

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


[PATCH] D107850: [asan] Implemented custom calling convention similar to the one used by HWASan for X86.

2021-08-19 Thread Kirill Stoimenov via Phabricator via cfe-commits
kstoimenov updated this revision to Diff 367505.
kstoimenov added a comment.

Pulled constants like shadow base, etc out of the intrinsic.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107850

Files:
  clang/test/CodeGen/asan-use-callbacks.cpp
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -348,6 +348,10 @@
 static cl::opt ClOpt("asan-opt", cl::desc("Optimize instrumentation"),
cl::Hidden, cl::init(true));
 
+static cl::opt ClOptimizeCallbacks("asan-optimize-callbacks",
+ cl::desc("Optimize callbacks"),
+ cl::Hidden, cl::init(false));
+
 static cl::opt ClOptSameTemp(
 "asan-opt-same-temp", cl::desc("Instrument the same temp just once"),
 cl::Hidden, cl::init(true));
@@ -559,6 +563,17 @@
   return Mapping;
 }
 
+void getAddressSanitizerParams(Module &M, uint64_t *ShadowBase,
+   int *MappingScale, bool *OrShadowOffset) {
+  Triple TargetTriple = Triple(M.getTargetTriple());
+  auto Mapping =
+  getShadowMapping(TargetTriple, M.getDataLayout().getPointerSizeInBits(),
+   ClEnableKasan.getNumOccurrences() > 0);
+  *ShadowBase = Mapping.Offset;
+  *MappingScale = Mapping.Scale;
+  *OrShadowOffset = Mapping.OrShadowOffset;
+}
+
 static uint64_t getRedzoneSizeForScale(int MappingScale) {
   // Redzone used for stack and globals is at least 32 bytes.
   // For scales 6 and 7, the redzone has to be 64 and 128 bytes respectively.
@@ -623,6 +638,7 @@
 C = &(M.getContext());
 LongSize = M.getDataLayout().getPointerSizeInBits();
 IntptrTy = Type::getIntNTy(*C, LongSize);
+Int8PtrTy = Type::getInt8PtrTy(*C);
 TargetTriple = Triple(M.getTargetTriple());
 
 Mapping = getShadowMapping(TargetTriple, LongSize, this->CompileKernel);
@@ -673,6 +689,7 @@
  Value *SizeArgument, uint32_t Exp);
   void instrumentMemIntrinsic(MemIntrinsic *MI);
   Value *memToShadow(Value *Shadow, IRBuilder<> &IRB);
+  void encodeMemToShadowInfo(int64_t *AccessInfo);
   bool suppressInstrumentationSiteForDebug(int &Instrumented);
   bool instrumentFunction(Function &F, const TargetLibraryInfo *TLI);
   bool maybeInsertAsanInitAtFunctionEntry(Function &F);
@@ -713,6 +730,7 @@
   bool UseAfterScope;
   AsanDetectStackUseAfterReturnMode UseAfterReturn;
   Type *IntptrTy;
+  Type *Int8PtrTy;
   ShadowMapping Mapping;
   FunctionCallee AsanHandleNoReturnFunc;
   FunctionCallee AsanPtrCmpFunction, AsanPtrSubFunction;
@@ -1742,12 +1760,21 @@
   size_t AccessSizeIndex = TypeSizeToSizeIndex(TypeSize);
 
   if (UseCalls) {
-if (Exp == 0)
-  IRB.CreateCall(AsanMemoryAccessCallback[IsWrite][0][AccessSizeIndex],
- AddrLong);
-else
-  IRB.CreateCall(AsanMemoryAccessCallback[IsWrite][1][AccessSizeIndex],
- {AddrLong, ConstantInt::get(IRB.getInt32Ty(), Exp)});
+if (ClOptimizeCallbacks) {
+  Value *Ptr8 = IRB.CreatePointerCast(Addr, Int8PtrTy);
+  Module *M = IRB.GetInsertBlock()->getParent()->getParent();
+  IRB.CreateCall(
+  Intrinsic::getDeclaration(M, Intrinsic::asan_check_memaccess),
+  {Ptr8, ConstantInt::get(IRB.getInt8Ty(), IsWrite),
+   ConstantInt::get(IRB.getInt8Ty(), AccessSizeIndex)});
+} else {
+  if (Exp == 0)
+IRB.CreateCall(AsanMemoryAccessCallback[IsWrite][0][AccessSizeIndex],
+   AddrLong);
+  else
+IRB.CreateCall(AsanMemoryAccessCallback[IsWrite][1][AccessSizeIndex],
+   {AddrLong, ConstantInt::get(IRB.getInt32Ty(), Exp)});
+}
 return;
   }
 
Index: llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h
===
--- llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h
+++ llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h
@@ -87,6 +87,8 @@
   return true;
 }
 
+void getASanShadowMapping(int *Scale, uint64_t *Offset, bool *OrShadowOffset);
+
 } // namespace llvm
 
 #endif
Index: llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
===
--- llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
+++ llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
@@ -147,6 +147,10 @@
 bool UseOdrIndicator = true,
 AsanDtorKind DestructorKind = AsanDtorKind::Global);
 
+// Get

[PATCH] D108151: [NFC][clang] Use X86 Features declaration from X86TargetParser

2021-08-19 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/Basic/Targets/X86.cpp:1071
+assert(llvm::is_contained(Priorities, Priority) &&
+   "Priorites don't form consequtive range!");
+  }

erichkeane wrote:
> craig.topper wrote:
> > erichkeane wrote:
> > > If all you care about is whether they are a consecutive range, why not 
> > > just use `std::is_sorted`?
> > The Priorities array isn't sorted. It's just whatever order the 
> > X86_FEATURE_COMPAT lists them.
> > 
> > The values need to be unique and in a contiguous range.
> Then I'd suggest something like: `llvm::sort`, then `assert *(end - 1) - 
> *begin == std::distance(begin, end) && llvm::adjacent_find` or something.
> 
> I definitely didn't get that point out of this odd for-loop and is_contained. 
>  There is perhaps at trick with std::min and std::max too.  Though, it looks 
> like this is perhaps trying to prove that the range is 0 to the the array 
> size, right?  In that case, perhaps there is something easier.
> 
> Also a nit, it is `consecutive` in that case.
Actually...

std::array HelperList;
std::iota(HelperList.begin(), HelperList.end());
std::is_permutation(HelperList.begin(), HelperList.end(),  
std::begin(Priorities), std::end(Priorities));


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108151

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


[PATCH] D108379: [OpenCL] Fix version reporting of C++ for OpenCL 2021

2021-08-19 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Topotuna added a reviewer: Anastasia.
Herald added subscribers: ldrumm, dexonsmith, yaxunl.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

C++ for OpenCL version 2021 and later are expected to consist of a
major version number only. Therefore, a different constructor for
`VersionTuple` needs to be called when reporting language version.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108379

Files:
  clang/lib/Basic/LangOptions.cpp


Index: clang/lib/Basic/LangOptions.cpp
===
--- clang/lib/Basic/LangOptions.cpp
+++ clang/lib/Basic/LangOptions.cpp
@@ -47,6 +47,8 @@
 
 VersionTuple LangOptions::getOpenCLVersionTuple() const {
   const int Ver = OpenCLCPlusPlus ? OpenCLCPlusPlusVersion : OpenCLVersion;
+  if (OpenCLCPlusPlus && Ver != 100)
+return VersionTuple(Ver / 100);
   return VersionTuple(Ver / 100, (Ver % 100) / 10);
 }
 


Index: clang/lib/Basic/LangOptions.cpp
===
--- clang/lib/Basic/LangOptions.cpp
+++ clang/lib/Basic/LangOptions.cpp
@@ -47,6 +47,8 @@
 
 VersionTuple LangOptions::getOpenCLVersionTuple() const {
   const int Ver = OpenCLCPlusPlus ? OpenCLCPlusPlusVersion : OpenCLVersion;
+  if (OpenCLCPlusPlus && Ver != 100)
+return VersionTuple(Ver / 100);
   return VersionTuple(Ver / 100, (Ver % 100) / 10);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107850: [asan] Implemented custom calling convention similar to the one used by HWASan for X86.

2021-08-19 Thread Kirill Stoimenov via Phabricator via cfe-commits
kstoimenov updated this revision to Diff 367507.
kstoimenov added a comment.

Fixed after rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107850

Files:
  llvm/include/llvm/IR/Intrinsics.td
  llvm/lib/Target/X86/X86AsmPrinter.cpp
  llvm/lib/Target/X86/X86AsmPrinter.h
  llvm/lib/Target/X86/X86InstrCompiler.td
  llvm/lib/Target/X86/X86MCInstLower.cpp
  llvm/lib/Target/X86/X86RegisterInfo.td
  llvm/test/CodeGen/X86/asan-check-memaccess-add.ll
  llvm/test/CodeGen/X86/asan-check-memaccess-or.ll

Index: llvm/test/CodeGen/X86/asan-check-memaccess-or.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/asan-check-memaccess-or.ll
@@ -0,0 +1,234 @@
+; RUN: llc < %s | FileCheck %s
+
+target triple = "x86_64-unknown-linux-gnu"
+
+define void @load1(i8* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load1_rn[[RN1:.*]]
+; CHECK:  callq   __asan_check_store1_rn[[RN1]]
+; CHECK-NEXT: retq
+  call void @llvm.asan.check.memaccess(i8* %x, i64 2147450880, i32 0,
+   i32 0, i32 3, i32 1)
+  call void @llvm.asan.check.memaccess(i8* %x, i64 2147450880, i32 1,
+   i32 0, i32 3, i32 1)
+  ret void
+}
+
+define void @load2(i16* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load2_rn[[RN2:.*]]
+; CHECK:  callq   __asan_check_store2_rn[[RN2]]
+; CHECK-NEXT: retq
+  %1 = ptrtoint i16* %x to i64
+  %2 = bitcast i16* %x to i8*
+  call void @llvm.asan.check.memaccess(i8* %2, i64 2147450880, i32 0,
+   i32 1, i32 3, i32 1)
+  call void @llvm.asan.check.memaccess(i8* %2, i64 2147450880, i32 1,
+   i32 1, i32 3, i32 1)
+  ret void
+}
+
+define void @load4(i32* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load4_rn[[RN4:.*]]
+; CHECK:  callq   __asan_check_store4_rn[[RN4]]
+; CHECK-NEXT: retq
+  %1 = ptrtoint i32* %x to i64
+  %2 = bitcast i32* %x to i8*
+  call void @llvm.asan.check.memaccess(i8* %2, i64 2147450880, i32 0,
+   i32 2, i32 3, i32 1)
+  call void @llvm.asan.check.memaccess(i8* %2, i64 2147450880, i32 1,
+   i32 2, i32 3, i32 1)
+  ret void
+}
+define void @load8(i64* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load8_rn[[RN8:.*]]
+; CHECK:  callq   __asan_check_store8_rn[[RN8]]
+; CHECK-NEXT: retq
+  %1 = ptrtoint i64* %x to i64
+  %2 = bitcast i64* %x to i8*
+  call void @llvm.asan.check.memaccess(i8* %2, i64 2147450880, i32 0,
+   i32 3, i32 3, i32 1)
+  call void @llvm.asan.check.memaccess(i8* %2, i64 2147450880, i32 1,
+   i32 3, i32 3, i32 1)
+  ret void
+}
+
+define void @load16(i128* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load16_rn[[RN16:.*]]
+; CHECK:  callq   __asan_check_store16_rn[[RN16]]
+; CHECK-NEXT: retq
+  %1 = ptrtoint i128* %x to i64
+  %2 = bitcast i128* %x to i8*
+  call void @llvm.asan.check.memaccess(i8* %2, i64 2147450880, i32 0,
+   i32 4, i32 3, i32 1)
+  call void @llvm.asan.check.memaccess(i8* %2, i64 2147450880, i32 1,
+   i32 4, i32 3, i32 1)
+  ret void
+}
+
+; CHECK:  __asan_check_load1_rn[[RN1]]:
+; CHECK-NEXT: movq[[REG:.*]], %r8
+; CHECK-NEXT: shrq$3, %r8
+; CHECK-NEXT: orq $2147450880, %r8{{.*}}
+; CHECK-NEXT: movb(%r8), %r8b
+; CHECK-NEXT: testb   %r8b, %r8b
+; CHECK-NEXT: jne [[EXTRA:.*]]
+; CHECK-NEXT: [[RET:.*]]:
+; CHECK-NEXT: retq
+; CHECK-NEXT: [[EXTRA]]:
+; CHECK-NEXT: pushq   %rcx
+; CHECK-NEXT: movq[[REG]], %rcx
+; CHECK-NEXT: andl$7, %ecx
+; CHECK-NEXT: cmpl%r8d, %ecx
+; CHECK-NEXT: popq%rcx
+; CHECK-NEXT: jl  [[RET]]
+; CHECK-NEXT: movq[[REG:.*]], %rdi
+; CHECK-NEXT: jmp __asan_report_load1
+
+; CHECK:  __asan_check_load2_rn[[RN2]]:
+; CHECK-NEXT: movq[[REG:.*]], %r8
+; CHECK-NEXT: shrq$3, %r8
+; CHECK-NEXT: orq $2147450880, %r8{{.*}}
+; CHECK-NEXT: movb(%r8), %r8b
+; CHECK-NEXT: testb   %r8b, %r8b
+; CHECK-NEXT: jne [[EXTRA:.*]]
+; CHECK-NEXT: [[RET:.*]]:
+; CHECK-NEXT: retq
+; CHECK-NEXT: [[EXTRA]]:
+; CHECK-NEXT: pushq   %rcx
+; CHECK-NEXT: movq[[REG]], %rcx
+; CHECK-NEXT: andl$7, %ecx
+; CHECK-NEXT: addl$1, %ecx
+; CHECK-NEXT: cmpl%r8d, %ecx
+; CHECK-NEXT: popq%rcx
+; CHECK-NEXT: jl  [[RET]]
+; CHECK-NEXT: movq[[REG:.*]]

[PATCH] D105268: [X86] AVX512FP16 instructions enabling 5/6

2021-08-19 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsX86.def:2014
+
+TARGET_BUILTIN(__builtin_ia32_vfmaddsh3_mask, "V8xV8xV8xV8xUcIi", "ncV:128:", 
"avx512fp16")
+TARGET_BUILTIN(__builtin_ia32_vfmaddsh3_maskz, "V8xV8xV8xV8xUcIi", "ncV:128:", 
"avx512fp16")

LuoYuanke wrote:
> What does "3" stand for?
The 3 is there because AMD's 4 operand fma used vfmaddss/vfmaddsd. So Intel's 3 
operand used vfmaddss3/vfmaddsd3. That naming is being carried forward here.



Comment at: clang/lib/Headers/avx512vlfp16intrin.h:1385
+  __m128h __C) 
{
+  return (__m128h)__builtin_ia32_selectph_128(
+  (__mmask8)__U,

LuoYuanke wrote:
> Sorry, I'm confused sometimes we use mask builtin, sometimes we use select 
> builtin. Any guideline on it?
Ideally FP should never use select because it doesn't convey that exceptions 
should be masked for strictfp. But the mistake was already made for 
add/sub/mul/div/fma/etc years ago before strictfp support existed in llvm. fp16 
is intentionally following float/double for consistency.



Comment at: llvm/include/llvm/IR/IntrinsicsX86.td:5709
+
+  def int_x86_avx512fp16_vfmadd_ph_512
+  : Intrinsic<[ llvm_v32f16_ty ],

LuoYuanke wrote:
> I notice there is no builtin bound to this intrinsic. What is it used for?
It is manually selected in CGBuiltin.cpp



Comment at: llvm/include/llvm/IR/IntrinsicsX86.td:5727
+  [ IntrNoMem, ImmArg> ]>;
+  def int_x86_avx512fp16_vfmadd_f16
+  : Intrinsic<[ llvm_half_ty ],

LuoYuanke wrote:
> ph?
It's scalar so it shouldn't be ph. This matches int_x86_avx512_vfmadd_f32 and 
int_x86_avx512_vfmadd_f64. They don't use ss/sd because the ss/sd names are 
usually used for intrinsics that 128-bit operands and only modify the lower 
element. int_x86_avx512_vfmadd_f32 and int_x86_avx512_vfmadd_f64 have 
float/double inputs and produce float/double results.



Comment at: llvm/test/CodeGen/X86/avx512fp16-fma-commute.ll:9
+
+define half @fma_123_f16(half %x, half %y, half %z) {
+; CHECK-LABEL: fma_123_f16:

LuoYuanke wrote:
> The name 123 is not the same with the generated instruction (213sh). Is it 
> expected?
123 represents how the 3 arguments to the fucntion are mapped to the 3 
intrinsic arguments that it calls. There are 6 possible permutations which are 
all tested here, but only 3 instruction mnemonics.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105268

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


[PATCH] D106888: [RISC-V] Implement jump tables for CFI-icall

2021-08-19 Thread Luís Marques via Phabricator via cfe-commits
luismarques added a comment.

In D106888#2954788 , @twd2 wrote:

> Hi, you can check here: 
> https://buildkite.com/llvm-project/premerge-checks/builds/49755#814fd222-2e5a-4400-824d-d1a1f1293c01
> The clang-tidy failed due to the invalid case style for variable 
> 'kRISCVJumpTableEntrySize'.

We can ignore the lint check failure. The new constant follows the same style 
as the existing ones.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106888

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


[PATCH] D107850: [asan] Implemented custom calling convention similar to the one used by HWASan for X86.

2021-08-19 Thread Kirill Stoimenov via Phabricator via cfe-commits
kstoimenov marked 7 inline comments as done.
kstoimenov added a comment.

Added getAddressSanitizerParams to pull the constants out. Let me know if this 
is what you had in mind. Also struggled a little bit with git and rebase, but I 
think I have figured it out now.




Comment at: llvm/lib/Target/X86/X86MCInstLower.cpp:1340-1341
+  MCSymbol *&Sym = AsanMemaccessSymbols[{
+  Reg, ShadowBase, IsWrite, AccessSizeIndex, MI.getOperand(4).getImm(),
+  MI.getOperand(5).getImm()}];
+  if (!Sym) {

vitalybuka wrote:
> vitalybuka wrote:
> > Why shadow is an argument? Both runtime and instrumented code know the 
> > shadow.
> could you please unpack these to into local variables for consistency?
Removed the variables as we have discussed. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107850

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


[PATCH] D108379: [OpenCL] Fix version reporting of C++ for OpenCL 2021

2021-08-19 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!

I imagine you will be adding some tests that will check the correctness of 
diagnostic wording in the subsequent commits?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108379

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


[PATCH] D108380: [openmp][nfc] Refactor GridValues

2021-08-19 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield created this revision.
JonChesterfield added reviewers: jdoerfert, dpalermo, gregrodgers, ronlieb, 
tianshilei1992, grokos, atmnpatel.
Herald added subscribers: kerbowa, guansong, yaxunl, nhaehnle, jvesely, 
jholewinski.
JonChesterfield requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, sstefan1.
Herald added projects: clang, LLVM.

Remove  redundant fields and replace pointer with virtual function

Of fourteen fields, three are dead and four can be computed from the
remainder. This leaves a couple of currently dead fields in place as
they are expected to be used from the deviceRTL shortly.

This change leaves the new methods in the same location in the struct
as the previous values and includes static asserts that the values are
unchanged. This is for ease of verifying the review, methods will be
grouped together and the static asserts dropped post commit.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108380

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/AMDGPU.h
  clang/lib/Basic/Targets/NVPTX.cpp
  clang/lib/Basic/Targets/NVPTX.h
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPGridValues.h

Index: llvm/include/llvm/Frontend/OpenMP/OMPGridValues.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPGridValues.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPGridValues.h
@@ -62,19 +62,21 @@
   const unsigned GV_Slot_Size;
   /// The default value of maximum number of threads in a worker warp.
   const unsigned GV_Warp_Size;
-  /// Alternate warp size for some AMDGCN architectures. Same as GV_Warp_Size
-  /// for NVPTX.
-  const unsigned GV_Warp_Size_32;
+
   /// The number of bits required to represent the max number of threads in warp
-  const unsigned GV_Warp_Size_Log2;
-  /// GV_Warp_Size * GV_Slot_Size,
-  const unsigned GV_Warp_Slot_Size;
+  constexpr unsigned warpSizeLog2() const { return log2(GV_Warp_Size); }
+
+  constexpr unsigned warpSlotSize() const {
+return GV_Warp_Size * GV_Slot_Size;
+  }
+
+  constexpr unsigned warpSizeLog2Mask() const {
+return ~0u >> (32u - warpSizeLog2());
+  }
+
   /// the maximum number of teams.
   const unsigned GV_Max_Teams;
-  /// Global Memory Alignment
-  const unsigned GV_Mem_Align;
-  /// (~0u >> (GV_Warp_Size - GV_Warp_Size_Log2))
-  const unsigned GV_Warp_Size_Log2_Mask;
+
   // An alternative to the heavy data sharing infrastructure that uses global
   // memory is one that uses device __shared__ memory.  The amount of such space
   // (in bytes) reserved by the OpenMP runtime is noted here.
@@ -83,49 +85,55 @@
   const unsigned GV_Max_WG_Size;
   // The default maximum team size for a working group
   const unsigned GV_Default_WG_Size;
-  // This is GV_Max_WG_Size / GV_WarpSize. 32 for NVPTX and 16 for AMDGCN.
-  const unsigned GV_Max_Warp_Number;
-  /// The slot size that should be reserved for a working warp.
-  /// (~0u >> (GV_Warp_Size - GV_Warp_Size_Log2))
-  const unsigned GV_Warp_Size_Log2_MaskL;
+
+  constexpr unsigned maxWarpNumber() const {
+return GV_Max_WG_Size / GV_Warp_Size;
+  }
+
+private:
+  static constexpr unsigned log2(unsigned I) {
+// assumes I is nonzero power of 2
+// reimplemented here for use from freestanding devicertl
+unsigned R = 0;
+while (I >>= 1) {
+  R++;
+}
+return R;
+  }
 };
 
 /// For AMDGPU GPUs
 static constexpr GV AMDGPUGridValues = {
-448,   // GV_Threads
-256,   // GV_Slot_Size
-64,// GV_Warp_Size
-32,// GV_Warp_Size_32
-6, // GV_Warp_Size_Log2
-64 * 256,  // GV_Warp_Slot_Size
-128,   // GV_Max_Teams
-256,   // GV_Mem_Align
-63,// GV_Warp_Size_Log2_Mask
-896,   // GV_SimpleBufferSize
-1024,  // GV_Max_WG_Size,
-256,   // GV_Defaut_WG_Size
-1024 / 64, // GV_Max_WG_Size / GV_WarpSize
-63 // GV_Warp_Size_Log2_MaskL
+448,  // GV_Threads
+256,  // GV_Slot_Size
+64,   // GV_Warp_Size
+128,  // GV_Max_Teams
+896,  // GV_SimpleBufferSize
+1024, // GV_Max_WG_Size,
+256,  // GV_Default_WG_Size
 };
 
+static_assert(6 == AMDGPUGridValues.warpSizeLog2(), "");
+static_assert(64 * 256 == AMDGPUGridValues.warpSlotSize(), "");
+static_assert(63 == AMDGPUGridValues.warpSizeLog2Mask(), "");
+static_assert(1024 / 64 == AMDGPUGridValues.maxWarpNumber(), "");
+
 /// For Nvidia GPUs
 static constexpr GV NVPTXGridValues = {
-992,   // GV_Threads
-256,   // GV_Slot_Size
-32,// GV_Warp_Size
-32,// GV_Warp_Size_32
-5, // GV_Warp_Size_Log2
-32 * 256,  // GV_Warp_Slot_Size
-1024,  // GV_Max_Teams
-256,   // GV_Mem_Align
-(~0u >> (32 - 5)), // GV_Warp_Size_Log2_Mask
-896,   // GV_Si

[clang] b0bf0b2 - [Clang][AST][NFC] Resolve FIXME: Make CXXRecordDecl *Record const.

2021-08-19 Thread Simon Pilgrim via cfe-commits

Author: Alfsonso Gregory
Date: 2021-08-19T16:36:32+01:00
New Revision: b0bf0b2e79e848ae502d7efc00a0bac37a96aedb

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

LOG: [Clang][AST][NFC] Resolve FIXME: Make CXXRecordDecl *Record const.

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

Added: 


Modified: 
clang/include/clang/AST/ComparisonCategories.h

Removed: 




diff  --git a/clang/include/clang/AST/ComparisonCategories.h 
b/clang/include/clang/AST/ComparisonCategories.h
index b41e934142ee4..fb648b322b61c 100644
--- a/clang/include/clang/AST/ComparisonCategories.h
+++ b/clang/include/clang/AST/ComparisonCategories.h
@@ -115,8 +115,7 @@ class ComparisonCategoryInfo {
 public:
   /// The declaration for the comparison category type from the
   /// standard library.
-  // FIXME: Make this const
-  CXXRecordDecl *Record = nullptr;
+  const CXXRecordDecl *Record = nullptr;
 
   /// The Kind of the comparison category type
   ComparisonCategoryType Kind;



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


[PATCH] D107477: [Clang][AST][NFC] Resolve FIXME: Make CXXRecordDecl *Record const.

2021-08-19 Thread Simon Pilgrim via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb0bf0b2e79e8: [Clang][AST][NFC] Resolve FIXME: Make 
CXXRecordDecl *Record const. (authored by gAlfonso-bit, committed by RKSimon).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107477

Files:
  clang/include/clang/AST/ComparisonCategories.h


Index: clang/include/clang/AST/ComparisonCategories.h
===
--- clang/include/clang/AST/ComparisonCategories.h
+++ clang/include/clang/AST/ComparisonCategories.h
@@ -115,8 +115,7 @@
 public:
   /// The declaration for the comparison category type from the
   /// standard library.
-  // FIXME: Make this const
-  CXXRecordDecl *Record = nullptr;
+  const CXXRecordDecl *Record = nullptr;
 
   /// The Kind of the comparison category type
   ComparisonCategoryType Kind;


Index: clang/include/clang/AST/ComparisonCategories.h
===
--- clang/include/clang/AST/ComparisonCategories.h
+++ clang/include/clang/AST/ComparisonCategories.h
@@ -115,8 +115,7 @@
 public:
   /// The declaration for the comparison category type from the
   /// standard library.
-  // FIXME: Make this const
-  CXXRecordDecl *Record = nullptr;
+  const CXXRecordDecl *Record = nullptr;
 
   /// The Kind of the comparison category type
   ComparisonCategoryType Kind;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108247: [CUDA] Improve CUDA version detection and diagnostics.

2021-08-19 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added inline comments.



Comment at: clang/lib/Driver/ToolChains/Cuda.cpp:209-211
+  Version = FS.exists(LibDevicePath + "/libdevice.10.bc")
+? Version = CudaVersion::NEW
+: Version = CudaVersion::CUDA_70;

The compiler is now warning here because of the assignment to `VERSION` in the 
ternary operator


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108247

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


[PATCH] D108380: [openmp][nfc] Refactor GridValues

2021-08-19 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield updated this revision to Diff 367513.
JonChesterfield added a comment.

- reorder field


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108380

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/AMDGPU.h
  clang/lib/Basic/Targets/NVPTX.cpp
  clang/lib/Basic/Targets/NVPTX.h
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPGridValues.h

Index: llvm/include/llvm/Frontend/OpenMP/OMPGridValues.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPGridValues.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPGridValues.h
@@ -62,19 +62,21 @@
   const unsigned GV_Slot_Size;
   /// The default value of maximum number of threads in a worker warp.
   const unsigned GV_Warp_Size;
-  /// Alternate warp size for some AMDGCN architectures. Same as GV_Warp_Size
-  /// for NVPTX.
-  const unsigned GV_Warp_Size_32;
+
   /// The number of bits required to represent the max number of threads in warp
-  const unsigned GV_Warp_Size_Log2;
-  /// GV_Warp_Size * GV_Slot_Size,
-  const unsigned GV_Warp_Slot_Size;
+  constexpr unsigned warpSizeLog2() const { return log2(GV_Warp_Size); }
+
+  constexpr unsigned warpSlotSize() const {
+return GV_Warp_Size * GV_Slot_Size;
+  }
+
   /// the maximum number of teams.
   const unsigned GV_Max_Teams;
-  /// Global Memory Alignment
-  const unsigned GV_Mem_Align;
-  /// (~0u >> (GV_Warp_Size - GV_Warp_Size_Log2))
-  const unsigned GV_Warp_Size_Log2_Mask;
+
+  constexpr unsigned warpSizeLog2Mask() const {
+return ~0u >> (32u - warpSizeLog2());
+  }
+
   // An alternative to the heavy data sharing infrastructure that uses global
   // memory is one that uses device __shared__ memory.  The amount of such space
   // (in bytes) reserved by the OpenMP runtime is noted here.
@@ -83,49 +85,55 @@
   const unsigned GV_Max_WG_Size;
   // The default maximum team size for a working group
   const unsigned GV_Default_WG_Size;
-  // This is GV_Max_WG_Size / GV_WarpSize. 32 for NVPTX and 16 for AMDGCN.
-  const unsigned GV_Max_Warp_Number;
-  /// The slot size that should be reserved for a working warp.
-  /// (~0u >> (GV_Warp_Size - GV_Warp_Size_Log2))
-  const unsigned GV_Warp_Size_Log2_MaskL;
+
+  constexpr unsigned maxWarpNumber() const {
+return GV_Max_WG_Size / GV_Warp_Size;
+  }
+
+private:
+  static constexpr unsigned log2(unsigned I) {
+// assumes I is nonzero power of 2
+// reimplemented here for use from freestanding devicertl
+unsigned R = 0;
+while (I >>= 1) {
+  R++;
+}
+return R;
+  }
 };
 
 /// For AMDGPU GPUs
 static constexpr GV AMDGPUGridValues = {
-448,   // GV_Threads
-256,   // GV_Slot_Size
-64,// GV_Warp_Size
-32,// GV_Warp_Size_32
-6, // GV_Warp_Size_Log2
-64 * 256,  // GV_Warp_Slot_Size
-128,   // GV_Max_Teams
-256,   // GV_Mem_Align
-63,// GV_Warp_Size_Log2_Mask
-896,   // GV_SimpleBufferSize
-1024,  // GV_Max_WG_Size,
-256,   // GV_Defaut_WG_Size
-1024 / 64, // GV_Max_WG_Size / GV_WarpSize
-63 // GV_Warp_Size_Log2_MaskL
+448,  // GV_Threads
+256,  // GV_Slot_Size
+64,   // GV_Warp_Size
+128,  // GV_Max_Teams
+896,  // GV_SimpleBufferSize
+1024, // GV_Max_WG_Size,
+256,  // GV_Default_WG_Size
 };
 
+static_assert(6 == AMDGPUGridValues.warpSizeLog2(), "");
+static_assert(64 * 256 == AMDGPUGridValues.warpSlotSize(), "");
+static_assert(63 == AMDGPUGridValues.warpSizeLog2Mask(), "");
+static_assert(1024 / 64 == AMDGPUGridValues.maxWarpNumber(), "");
+
 /// For Nvidia GPUs
 static constexpr GV NVPTXGridValues = {
-992,   // GV_Threads
-256,   // GV_Slot_Size
-32,// GV_Warp_Size
-32,// GV_Warp_Size_32
-5, // GV_Warp_Size_Log2
-32 * 256,  // GV_Warp_Slot_Size
-1024,  // GV_Max_Teams
-256,   // GV_Mem_Align
-(~0u >> (32 - 5)), // GV_Warp_Size_Log2_Mask
-896,   // GV_SimpleBufferSize
-1024,  // GV_Max_WG_Size
-128,   // GV_Defaut_WG_Size
-1024 / 32, // GV_Max_WG_Size / GV_WarpSize
-31 // GV_Warp_Size_Log2_MaskL
+992,  // GV_Threads
+256,  // GV_Slot_Size
+32,   // GV_Warp_Size
+1024, // GV_Max_Teams
+896,  // GV_SimpleBufferSize
+1024, // GV_Max_WG_Size
+128,  // GV_Default_WG_Size
 };
 
+static_assert(5 == NVPTXGridValues.warpSizeLog2(), "");
+static_assert(32 * 256 == NVPTXGridValues.warpSlotSize(), "");
+static_assert((~0u >> (32 - 5)) == NVPTXGridValues.warpSizeLog2Mask(), "");
+static_assert(1024 / 32 == NVPTXGridValues.maxWarpNumber(), "");
+
 } // namespace omp
 } // namespace llvm
 
Index: clang/lib/CodeGen/C

[PATCH] D107477: [Clang][AST][NFC] Resolve FIXME: Make CXXRecordDecl *Record const.

2021-08-19 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

In D107477#2954787 , @gAlfonso-bit 
wrote:

> How do I request it?

https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107477

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


[PATCH] D108379: [OpenCL] Fix version reporting of C++ for OpenCL 2021

2021-08-19 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna added a comment.

In D108379#2954826 , @Anastasia wrote:

> LGTM! Thanks!
>
> I imagine you will be adding some tests that will check the correctness of 
> diagnostic wording in the subsequent commits?

Yes, I will add tests for diagnostics reporting once C++ for OpenCL 2021 
achieves similar functionality as OpenCL 3.0.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108379

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


[PATCH] D105177: [clangd] Implemented indexing of standard library

2021-08-19 Thread Christian Kühnel via Phabricator via cfe-commits
kuhnel updated this revision to Diff 367523.
kuhnel marked 18 inline comments as done.
kuhnel added a comment.

addressed review comments, has use-after-free problem


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105177

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/FS.cpp
  clang-tools-extra/clangd/FS.h
  clang-tools-extra/clangd/index/StdLib.cpp
  clang-tools-extra/clangd/index/StdLib.h
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/StdLibIndexTests.cpp

Index: clang-tools-extra/clangd/unittests/StdLibIndexTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/StdLibIndexTests.cpp
@@ -0,0 +1,60 @@
+//===-- StdLibIndexTests.cpp *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "FuzzyMatch.h"
+#include "TestFS.h"
+#include "TestIndex.h"
+#include "index/StdLib.h"
+#include "support/Logger.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace testing;
+
+namespace clang {
+namespace clangd {
+
+/// check that the generated header sources contains some usual standard library
+/// headers
+TEST(StdLibIndexTests, generateUmbrellaHeader) {
+  MockFS FS;
+  auto UmbrellaHeader = generateUmbrellaHeaders(StandardLibrarVariant::CXX14);
+
+  EXPECT_THAT(UmbrellaHeader, HasSubstr("#include "));
+  EXPECT_THAT(UmbrellaHeader, HasSubstr("#include "));
+  EXPECT_THAT(UmbrellaHeader, HasSubstr("#include "));
+}
+
+/// build the index and check if it contains the right symbols
+TEST(StdLibIndexTests, buildIndex) {
+  MockFS FS;
+  // TODO: maybe find a way to use a local libcxx for testing if that is
+  //   available on the machine
+  std::string HeaderMock = R"CPP(
+int myfunc(int a);
+bool otherfunc(int a, int b);
+  )CPP";
+  auto Index =
+  indexUmbrellaHeaders(HeaderMock, FS, StandardLibrarVariant::CXX14);
+  ASSERT_TRUE(Index != nullptr);
+
+  FuzzyFindRequest Req;
+  Req.AnyScope = true;
+  EXPECT_THAT(match(*Index, Req),
+  UnorderedElementsAre(llvm::StringRef("myfunc"),
+   llvm::StringRef("otherfunc")));
+}
+
+// TODO: add tests for indexStandardLibrary()
+// TODO: test with different library versions
+
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/unittests/CMakeLists.txt
===
--- clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -79,6 +79,7 @@
   SemanticSelectionTests.cpp
   SerializationTests.cpp
   SourceCodeTests.cpp
+  StdLibIndexTests.cpp
   SymbolCollectorTests.cpp
   SymbolInfoTests.cpp
   SyncAPI.cpp
Index: clang-tools-extra/clangd/index/StdLib.h
===
--- /dev/null
+++ clang-tools-extra/clangd/index/StdLib.h
@@ -0,0 +1,55 @@
+//===--- StdLib.h *- C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+// Clangd indexer for the C++ standard library.
+//
+// The index only contains symbols that are part of the translation unit. So
+// if your translation unit does not yet #include , you do not get
+// auto completion for std::string. However we expect that many users would
+// like to use the the standard library anyway, so we could index that by
+// default an offer e.g. code completion without requiring #includes.
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_STDLIB_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_STDLIB_H
+
+#include "FS.h"
+#include "index/Index.h"
+#include "index/MemIndex.h"
+#include "support/ThreadsafeFS.h"
+#include "clang/AST/Expr.h"
+#include "llvm/ADT/StringRef.h"
+#include 
+
+namespace clang {
+namespace clangd {
+
+// Enumeration of supported Standard Library versions.
+// FIXME: support muiltiple languages (e.g. C and C++) and versions (e.g. 11,
+// 14, 17) of the standard library.
+// FIXME: add heuristic to detect this version somehow (magically).
+enum class StandardLibrarVariant { CXX14 = 0 };
+
+/// Generate a index of the standard library index

[PATCH] D107878: [SampleFDO] Flow Sensitive Sample FDO (FSAFDO) profile loader

2021-08-19 Thread Sam Elliott via Phabricator via cfe-commits
lenary added inline comments.



Comment at: llvm/test/CodeGen/X86/fsafdo_test2.ll:3
+; RUN: llvm-profdata merge --sample -profile-isfs -o %t.afdo 
%S/Inputs/fsloader.afdo
+; RUN: llc -enable-fs-discriminator -fs-profile-file=%t.afdo 
-show-fs-branchprob -disable-ra-fsprofile-loader=false 
-disable-layout-fsprofile-loader=false < %s 2>&1 | FileCheck %s 
--check-prefix=LOADER
+;

I think this `REQUIRES: asserts` if you're checking the debug output?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107878

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


[PATCH] D107878: [SampleFDO] Flow Sensitive Sample FDO (FSAFDO) profile loader

2021-08-19 Thread Wenlei He via Phabricator via cfe-commits
wenlei added inline comments.



Comment at: llvm/test/CodeGen/X86/fsafdo_test2.ll:3
+; RUN: llvm-profdata merge --sample -profile-isfs -o %t.afdo 
%S/Inputs/fsloader.afdo
+; RUN: llc -enable-fs-discriminator -fs-profile-file=%t.afdo 
-show-fs-branchprob -disable-ra-fsprofile-loader=false 
-disable-layout-fsprofile-loader=false < %s 2>&1 | FileCheck %s 
--check-prefix=LOADER
+;

lenary wrote:
> I think this `REQUIRES: asserts` if you're checking the debug output?
Should be fixed in D108364


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107878

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


[PATCH] D107878: [SampleFDO] Flow Sensitive Sample FDO (FSAFDO) profile loader

2021-08-19 Thread Hongtao Yu via Phabricator via cfe-commits
hoy added inline comments.



Comment at: llvm/test/CodeGen/X86/fsafdo_test2.ll:3
+; RUN: llvm-profdata merge --sample -profile-isfs -o %t.afdo 
%S/Inputs/fsloader.afdo
+; RUN: llc -enable-fs-discriminator -fs-profile-file=%t.afdo 
-show-fs-branchprob -disable-ra-fsprofile-loader=false 
-disable-layout-fsprofile-loader=false < %s 2>&1 | FileCheck %s 
--check-prefix=LOADER
+;

lenary wrote:
> I think this `REQUIRES: asserts` if you're checking the debug output?
That's right. It was just fixed by https://reviews.llvm.org/D108364.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107878

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


[PATCH] D105177: [clangd] Implemented indexing of standard library

2021-08-19 Thread Christian Kühnel via Phabricator via cfe-commits
kuhnel added inline comments.



Comment at: clang-tools-extra/clangd/index/StdLib.cpp:72
+  Inputs.TFS = &TFS;
+  // TODO: can we get a real compile command from somewhere?
+  Inputs.CompileCommand.Directory = virtualRoot().str();

nridge wrote:
> sammccall wrote:
> > I'm not sure what this means, I don't think there's anything better to do 
> > here.
> One could imagine picking a source file from the project's CDB, and using its 
> flags to parse the standard library.
> 
> That could be relevant for macros that affect the way standard library 
> headers are parsed (like `_GLIBCXX_DEBUG` perhaps?)
Yes, my question was: can we get the real compile command form the file in 
which we're querying the standard library index and then extract the (relevant) 
compiler argument from that.

That might also help in guessing the current language variant.



Comment at: clang-tools-extra/clangd/unittests/StdLibIndexTests.cpp:51
+  Req.AnyScope = true;
+  EXPECT_THAT(match(*Index, Req),
+  UnorderedElementsAre(llvm::StringRef("myfunc"),

@sammccall I seem to be running into a use-after-free problem here. Debugging 
the whole thing shows that `Index` is pointing to an invalid address. So the 
problem is somewhere between returning the `unique_ptr` from 
`indexUmbrellaHeaders(...)` and assigning it to the `Index` variable.

Can you please take a look and give me a hint how to fix this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105177

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


[PATCH] D107878: [SampleFDO] Flow Sensitive Sample FDO (FSAFDO) profile loader

2021-08-19 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added inline comments.



Comment at: llvm/include/llvm/CodeGen/MIRSampleProfile.h:59
+MIRSampleLoader(
+std::make_unique(FileName, RemappingFileName)) {
+LowBit = getFSPassBitBegin(P);

You're instantiating a forward-declared type. This breaks the modules build: 
https://green.lab.llvm.org/green/job/lldb-cmake/34450/console



Comment at: llvm/lib/CodeGen/MIRSampleProfile.cpp:289
+
+bool MIRProfileLoaderPass::runOnMachineFunction(MachineFunction &MF) {
+  if (!MIRSampleLoader->isValid())

Why is this outside the `llvm` namespace? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107878

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


[PATCH] D106870: [OpenMP] Multi architecture compilation support

2021-08-19 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

Can you document the device binary embedding scheme for multiple GPU's in clang 
documentation? This will help tool developers to develop tools to extract 
device binaries from executables or shared libraries. Also this may help 
interoperability with other offloading language modes in case multiple 
offloading are desired to be supported in one executable or shared library in 
the future.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106870

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


[PATCH] D106409: [PowerPC] Truncate results for out of range values for vec_cts,vec_ctf

2021-08-19 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA updated this revision to Diff 367525.
ZarkoCA retitled this revision from "[PowerPC] Add diagnostic for out of range 
values for vec_cts,vec_ctf" to "[PowerPC] Truncate results for out of range 
values for vec_cts,vec_ctf".
ZarkoCA edited the summary of this revision.
ZarkoCA added a comment.

Switch direction of patch as per reviewer comments.  We now truncate the 
results and there is no diagnostic.
Edited title and summary to reflect this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106409

Files:
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-xlcompat.c
  clang/test/CodeGen/ppc-emmintrin.c

Index: clang/test/CodeGen/ppc-emmintrin.c
===
--- clang/test/CodeGen/ppc-emmintrin.c
+++ clang/test/CodeGen/ppc-emmintrin.c
@@ -905,7 +905,7 @@
 // CHECK-NEXT: store <2 x i64> [[REG583]], <2 x i64>* [[REG584:[0-9a-zA-Z_%.]+]], align 16
 // CHECK-NEXT: [[REG585:[0-9a-zA-Z_%.]+]] = load <2 x i64>, <2 x i64>* [[REG584]], align 16
 // CHECK-NEXT: [[REG586:[0-9a-zA-Z_%.]+]] = sitofp <2 x i64> [[REG585]] to <2 x double>
-// CHECK-NEXT: [[REG587:[0-9a-zA-Z_%.]+]] = fmul <2 x double> [[REG586]], 
+// CHECK-NEXT: [[REG587:[0-9a-zA-Z_%.]+]] = fmul <2 x double> [[REG586]], zeroinitializer 
 // CHECK-NEXT: ret <2 x double> [[REG587]]
 
 // CHECK: define available_externally <4 x float> @_mm_cvtepi32_ps(<2 x i64> [[REG588:[0-9a-zA-Z_%.]+]])
@@ -974,7 +974,7 @@
 // CHECK-NEXT: store <2 x i64> [[REG640]], <2 x i64>* [[REG641:[0-9a-zA-Z_%.]+]], align 16
 // CHECK-NEXT: [[REG642:[0-9a-zA-Z_%.]+]] = load <2 x i64>, <2 x i64>* [[REG641]], align 16
 // CHECK-NEXT: [[REG643:[0-9a-zA-Z_%.]+]] = sitofp <2 x i64> [[REG642]] to <2 x double>
-// CHECK-NEXT: [[REG644:[0-9a-zA-Z_%.]+]] = fmul <2 x double> [[REG643]], 
+// CHECK-NEXT: [[REG644:[0-9a-zA-Z_%.]+]] = fmul <2 x double> [[REG643]], zeroinitializer 
 // CHECK-NEXT: store <2 x double> [[REG644]], <2 x double>* [[REG645:[0-9a-zA-Z_%.]+]], align 16
 // CHECK-NEXT: [[REG646:[0-9a-zA-Z_%.]+]] = load <2 x double>, <2 x double>* [[REG645]], align 16
 // CHECK-NEXT: ret <2 x double> [[REG646]]
Index: clang/test/CodeGen/builtins-ppc-xlcompat.c
===
--- clang/test/CodeGen/builtins-ppc-xlcompat.c
+++ clang/test/CodeGen/builtins-ppc-xlcompat.c
@@ -22,20 +22,20 @@
   res_vf = vec_ctf(vsll, 4);
 // CHECK: [[TMP0:%.*]] = load <2 x i64>, <2 x i64>* @vsll, align 16
 // CHECK-NEXT:[[TMP1:%.*]] = call <4 x float> @llvm.ppc.vsx.xvcvsxdsp(<2 x i64> [[TMP0]])
-// CHECK-NEXT:fmul <4 x float> [[TMP1]], 
+// CHECK-NEXT:fmul <4 x float> [[TMP1]], zeroinitializer 
 
   res_vf = vec_ctf(vull, 4);
 // CHECK: [[TMP2:%.*]] = load <2 x i64>, <2 x i64>* @vull, align 16
 // CHECK-NEXT:[[TMP3:%.*]] = call <4 x float> @llvm.ppc.vsx.xvcvuxdsp(<2 x i64> [[TMP2]])
-// CHECK-NEXT:fmul <4 x float> [[TMP3]], 
+// CHECK-NEXT:fmul <4 x float> [[TMP3]], zeroinitializer 
 
   res_vsi = vec_cts(vd, 4);
 // CHECK: [[TMP4:%.*]] = load <2 x double>, <2 x double>* @vd, align 16
-// CHECK-NEXT:fmul <2 x double> [[TMP4]], 
+// CHECK-NEXT:fmul <2 x double> [[TMP4]], zeroinitializer 
 // CHECK: call <4 x i32> @llvm.ppc.vsx.xvcvdpsxws(<2 x double>
 
   res_vui = vec_ctu(vd, 4);
 // CHECK: [[TMP8:%.*]] = load <2 x double>, <2 x double>* @vd, align 16
-// CHECK-NEXT:fmul <2 x double> [[TMP8]], 
+// CHECK-NEXT:fmul <2 x double> [[TMP8]], zeroinitializer 
 // CHECK: call <4 x i32> @llvm.ppc.vsx.xvcvdpuxws(<2 x double>
 }
Index: clang/lib/Headers/altivec.h
===
--- clang/lib/Headers/altivec.h
+++ clang/lib/Headers/altivec.h
@@ -3167,42 +3167,45 @@
 // the XL-compatible signatures are used for those functions.
 #ifdef __XL_COMPAT_ALTIVEC__
 #define vec_ctf(__a, __b)  \
-  _Generic((__a), vector int   \
-   : (vector float)__builtin_altivec_vcfsx((vector int)(__a), (__b)),  \
- vector unsigned int   \
-   : (vector float)__builtin_altivec_vcfux((vector unsigned int)(__a), \
-   (__b)), \
- vector unsigned long long \
-   : (__builtin_vsx_xvcvuxdsp((vector unsigned long long)(__a)) *  \
-  (vector float)(vector unsigned)((0x7f - (__b)) << 23)),  \
- vector signed long long   \
-   : (__builtin_vsx_xvcvsxdsp((vector signed long long)(__a)) *\
-  (vector float)(vector unsigned)((0x7f - (__b)) << 23)))
+  _Generic(   

[PATCH] D107290: [PoC][RISCV] Add support for the vscale_range attribute

2021-08-19 Thread Fraser Cormack via Phabricator via cfe-commits
frasercrmck added a comment.

This may be as far as we can take this patch without exposing RVV vectors bit 
control to the user/driver and having to worry about the concerns that spring 
from that: linking objects compiled with different RVV vector bits options, 
LTO, etc.

I believe that with the current state of the patch, the default, hard-coded 
`vscale_range` with values mandated by the spec, combined with the existing 
backend options for overrides, mean we're not losing any functionality.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107290

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


[clang] ca6d581 - [clang] Do not warn unused -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang

2021-08-19 Thread Yi Kong via cfe-commits

Author: Yi Kong
Date: 2021-08-20T00:37:01+08:00
New Revision: ca6d5813d17598cd180995fb3bdfca00f364475f

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

LOG: [clang] Do not warn unused 
-enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang

Android enables zero initialisation globally by default, but also allows
subprojects to override with different option. Clang complains the above
flag being unused in this case.

Instead of adding a 75 char long -no-* flag, don't warn unused argument
for this flag.

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index fd9ecd7394a01..a91dacb0ec348 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2561,7 +2561,7 @@ def ftrivial_auto_var_init : Joined<["-"], 
"ftrivial-auto-var-init=">, Group,
   MarshallingInfoEnum, "Uninitialized">;
 def enable_trivial_var_init_zero : Flag<["-"], 
"enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang">,
-  Flags<[CC1Option, CoreOption]>,
+  Flags<[CC1Option, CoreOption, NoArgumentUnused]>,
   HelpText<"Trivial automatic variable initialization to zero is only here for 
benchmarks, it'll eventually be removed, and I'm OK with that because I'm only 
using it to benchmark">;
 def ftrivial_auto_var_init_stop_after : Joined<["-"], 
"ftrivial-auto-var-init-stop-after=">, Group,
   Flags<[CC1Option, CoreOption]>, HelpText<"Stop initializing trivial 
automatic stack variables after the specified number of instances">,



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


[PATCH] D108278: [clang] Do not warn unused -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang

2021-08-19 Thread Yi Kong via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGca6d5813d175: [clang] Do not warn unused 
-enable-trivial-auto-var-init-zero-knowing-it-will… (authored by kongyi).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108278

Files:
  clang/include/clang/Driver/Options.td


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2561,7 +2561,7 @@
   NormalizedValues<["Uninitialized", "Zero", "Pattern"]>,
   MarshallingInfoEnum, "Uninitialized">;
 def enable_trivial_var_init_zero : Flag<["-"], 
"enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang">,
-  Flags<[CC1Option, CoreOption]>,
+  Flags<[CC1Option, CoreOption, NoArgumentUnused]>,
   HelpText<"Trivial automatic variable initialization to zero is only here for 
benchmarks, it'll eventually be removed, and I'm OK with that because I'm only 
using it to benchmark">;
 def ftrivial_auto_var_init_stop_after : Joined<["-"], 
"ftrivial-auto-var-init-stop-after=">, Group,
   Flags<[CC1Option, CoreOption]>, HelpText<"Stop initializing trivial 
automatic stack variables after the specified number of instances">,


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2561,7 +2561,7 @@
   NormalizedValues<["Uninitialized", "Zero", "Pattern"]>,
   MarshallingInfoEnum, "Uninitialized">;
 def enable_trivial_var_init_zero : Flag<["-"], "enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang">,
-  Flags<[CC1Option, CoreOption]>,
+  Flags<[CC1Option, CoreOption, NoArgumentUnused]>,
   HelpText<"Trivial automatic variable initialization to zero is only here for benchmarks, it'll eventually be removed, and I'm OK with that because I'm only using it to benchmark">;
 def ftrivial_auto_var_init_stop_after : Joined<["-"], "ftrivial-auto-var-init-stop-after=">, Group,
   Flags<[CC1Option, CoreOption]>, HelpText<"Stop initializing trivial automatic stack variables after the specified number of instances">,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108003: [Clang] Extend -Wbool-operation to warn about bitwise and of bools with side effects

2021-08-19 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

In D108003#2944178 , @aeubanks wrote:

> I ran this over Chrome and ran into a use case that looks legitimate. It 
> seems like the pattern in LLVM where we want to run a bunch of 
> transformations and get if any of them changed anything.
>
> https://source.chromium.org/chromium/chromium/src/+/main:third_party/webrtc/api/audio/echo_canceller3_config.cc;drc=cbdbb8c1666fd08a094422905e73391706a05b03;l=111

The remaining places where this fired looked like places where `&&` would be 
better than `&`, except for one where the code was treating bools as one bit 
integers and doing various bitwise operations on them
https://source.chromium.org/chromium/chromium/src/+/main:third_party/distributed_point_functions/src/dpf/distributed_point_function.cc;drc=87b84b3834343e141ec94e3321f4d1c7be8a7a9d;l=230


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

https://reviews.llvm.org/D108003

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


[PATCH] D107647: [PowerPC] MMA - Remove deprecated built-ins and add new built-ins

2021-08-19 Thread Ahsan Saghir via Phabricator via cfe-commits
saghir updated this revision to Diff 367530.
saghir added a comment.

Change the implementation to add new builtins and keep the depracated builtins.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107647

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-ppc-pair-mma.c
  clang/test/Sema/ppc-pair-mma-types.c
  clang/test/SemaCXX/ppc-pair-mma-types.cpp
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/mma-intrinsics.ll
  llvm/test/CodeGen/PowerPC/paired-vector-intrinsics.ll

Index: llvm/test/CodeGen/PowerPC/paired-vector-intrinsics.ll
===
--- llvm/test/CodeGen/PowerPC/paired-vector-intrinsics.ll
+++ llvm/test/CodeGen/PowerPC/paired-vector-intrinsics.ll
@@ -51,6 +51,42 @@
   ret void
 }
 
+; build_pair
+declare <256 x i1> @llvm.ppc.vsx.build.pair(<16 x i8>, <16 x i8>)
+define void @build_pair(<256 x i1>* %ptr, <16 x i8> %vc) {
+; CHECK-LABEL: build_pair:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vmr v3, v2
+; CHECK-NEXT:stxv v2, 16(r3)
+; CHECK-NEXT:stxv v3, 0(r3)
+; CHECK-NEXT:blr
+;
+; CHECK-NOMMA-LABEL: build_pair:
+; CHECK-NOMMA:   # %bb.0: # %entry
+; CHECK-NOMMA-NEXT:vmr v3, v2
+; CHECK-NOMMA-NEXT:stxv v2, 16(r3)
+; CHECK-NOMMA-NEXT:stxv v3, 0(r3)
+; CHECK-NOMMA-NEXT:blr
+;
+; CHECK-BE-LABEL: build_pair:
+; CHECK-BE:   # %bb.0: # %entry
+; CHECK-BE-NEXT:vmr v3, v2
+; CHECK-BE-NEXT:stxv v2, 16(r3)
+; CHECK-BE-NEXT:stxv v2, 0(r3)
+; CHECK-BE-NEXT:blr
+;
+; CHECK-BE-NOMMA-LABEL: build_pair:
+; CHECK-BE-NOMMA:   # %bb.0: # %entry
+; CHECK-BE-NOMMA-NEXT:vmr v3, v2
+; CHECK-BE-NOMMA-NEXT:stxv v2, 16(r3)
+; CHECK-BE-NOMMA-NEXT:stxv v2, 0(r3)
+; CHECK-BE-NOMMA-NEXT:blr
+entry:
+  %0 = tail call <256 x i1> @llvm.ppc.vsx.build.pair(<16 x i8> %vc, <16 x i8> %vc)
+  store <256 x i1> %0, <256 x i1>* %ptr, align 32
+  ret void
+}
+
 ; disassemble_pair
 declare { <16 x i8>, <16 x i8> } @llvm.ppc.vsx.disassemble.pair(<256 x i1>)
 define void @disass_pair(<256 x i1>* %ptr1, <16 x i8>* %ptr2, <16 x i8>* %ptr3) {
Index: llvm/test/CodeGen/PowerPC/mma-intrinsics.ll
===
--- llvm/test/CodeGen/PowerPC/mma-intrinsics.ll
+++ llvm/test/CodeGen/PowerPC/mma-intrinsics.ll
@@ -40,6 +40,40 @@
   ret void
 }
 
+; build_acc
+declare <512 x i1> @llvm.ppc.mma.build.acc(<16 x i8>, <16 x i8>, <16 x i8>, <16 x i8>)
+define void @build_acc(<512 x i1>* %ptr, <16 x i8> %vc) {
+; CHECK-LABEL: build_acc:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vmr v3, v2
+; CHECK-NEXT:xxlor vs0, v2, v2
+; CHECK-NEXT:xxlor vs1, v3, v3
+; CHECK-NEXT:xxlor vs2, v2, v2
+; CHECK-NEXT:xxlor vs3, v3, v3
+; CHECK-NEXT:stxv vs0, 48(r3)
+; CHECK-NEXT:stxv vs1, 32(r3)
+; CHECK-NEXT:stxv vs2, 16(r3)
+; CHECK-NEXT:stxv vs3, 0(r3)
+; CHECK-NEXT:blr
+;
+; CHECK-BE-LABEL: build_acc:
+; CHECK-BE:   # %bb.0: # %entry
+; CHECK-BE-NEXT:vmr v3, v2
+; CHECK-BE-NEXT:xxlor vs0, v2, v2
+; CHECK-BE-NEXT:xxlor vs1, v3, v3
+; CHECK-BE-NEXT:xxlor vs2, v2, v2
+; CHECK-BE-NEXT:xxlor vs3, v3, v3
+; CHECK-BE-NEXT:stxv vs1, 16(r3)
+; CHECK-BE-NEXT:stxv vs0, 0(r3)
+; CHECK-BE-NEXT:stxv vs3, 48(r3)
+; CHECK-BE-NEXT:stxv vs2, 32(r3)
+; CHECK-BE-NEXT:blr
+entry:
+  %0 = tail call <512 x i1> @llvm.ppc.mma.build.acc(<16 x i8> %vc, <16 x i8> %vc, <16 x i8> %vc, <16 x i8> %vc)
+  store <512 x i1> %0, <512 x i1>* %ptr, align 64
+  ret void
+}
+
 ; xxmtacc
 declare <512 x i1> @llvm.ppc.mma.xxmtacc(<512 x i1>)
 define void @int_xxmtacc(<512 x i1>* %ptr, <16 x i8> %vc) {
@@ -185,18 +219,18 @@
 ; CHECK-LABEL: testBranch:
 ; CHECK:   # %bb.0: # %entry
 ; CHECK-NEXT:cmplwi r7, 0
-; CHECK-NEXT:beq cr0, .LBB5_2
+; CHECK-NEXT:beq cr0, .LBB6_2
 ; CHECK-NEXT:  # %bb.1: # %if.then
 ; CHECK-NEXT:xxsetaccz acc0
-; CHECK-NEXT:b .LBB5_3
-; CHECK-NEXT:  .LBB5_2: # %if.else
+; CHECK-NEXT:b .LBB6_3
+; CHECK-NEXT:  .LBB6_2: # %if.else
 ; CHECK-NEXT:lxv vs1, 32(r3)
 ; CHECK-NEXT:lxv vs0, 48(r3)
 ; CHECK-NEXT:lxv vs3, 0(r3)
 ; CHECK-NEXT:lxv vs2, 16(r3)
 ; CHECK-NEXT:xxmtacc acc0
 ; CHECK-NEXT:xvi4ger8pp acc0, v2, v2
-; CHECK-NEXT:  .LBB5_3: # %if.end
+; CHECK-NEXT:  .LBB6_3: # %if.end
 ; CHECK-NEXT:xxmfacc acc0
 ; CHECK-NEXT:stxv vs0, 48(r3)
 ; CHECK-NEXT:stxv vs1, 32(r3)
@@ -207,18 +241,18 @@
 ; CHECK-BE-LABEL: testBranch:
 ; CHECK-BE:   # %bb.0: # %entry
 ; CHECK-BE-NEXT:cmplwi r7, 0
-; CHECK-BE-NEXT:beq cr0, .LBB5_2
+; CHECK-BE-NEXT:beq cr0, .LBB6_2
 ; CHECK-BE-NEXT:  # %bb.1: # %if.then
 ; CHECK-BE-NEXT:xxsetaccz acc0
-; CHECK-BE-NEXT:b .LBB5_3
-; CHECK-BE-NEXT:  .LBB5_2: # %if.else
+; CHECK-BE-NEXT:b .LBB6_3
+; CHECK-BE-

[PATCH] D108247: [CUDA] Improve CUDA version detection and diagnostics.

2021-08-19 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/lib/Driver/ToolChains/Cuda.cpp:209-211
+  Version = FS.exists(LibDevicePath + "/libdevice.10.bc")
+? Version = CudaVersion::NEW
+: Version = CudaVersion::CUDA_70;

Hahnfeld wrote:
> The compiler is now warning here because of the assignment to `VERSION` in 
> the ternary operator
I'll fix it shortly. I also need to figure out why my build does not produce 
the warning. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108247

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


[PATCH] D107690: [Modules] Do not remove failed modules after the control block phase

2021-08-19 Thread Yaron Keren via Phabricator via cfe-commits
yaron.keren added inline comments.



Comment at: clang/lib/Serialization/ASTReader.cpp:4268
 // Read the AST block.
 if (ASTReadResult Result = ReadASTBlock(F, ClientLoadCapabilities))
+  return Failure;

Result is unused now.



Comment at: clang/lib/Serialization/ASTReader.cpp:4279
 while (!SkipCursorToBlock(F.Stream, EXTENSION_BLOCK_ID)) {
   if (ASTReadResult Result = ReadExtensionBlock(F))
+return Failure;

Same here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107690

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


[PATCH] D108247: [CUDA] Improve CUDA version detection and diagnostics.

2021-08-19 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 367532.
tra added a comment.

Fixed an error spotted by reviewer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108247

Files:
  clang/include/clang/Basic/Cuda.h
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Basic/Cuda.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Driver/ToolChains/Cuda.h
  clang/test/Driver/Inputs/CUDA-new/usr/local/cuda/bin/.keep
  clang/test/Driver/Inputs/CUDA-new/usr/local/cuda/include/.keep
  clang/test/Driver/Inputs/CUDA-new/usr/local/cuda/include/cuda.h
  clang/test/Driver/Inputs/CUDA-new/usr/local/cuda/lib/.keep
  clang/test/Driver/Inputs/CUDA-new/usr/local/cuda/lib64/.keep
  
clang/test/Driver/Inputs/CUDA-new/usr/local/cuda/nvvm/libdevice/libdevice.10.bc
  clang/test/Driver/Inputs/CUDA-unknown/usr/local/cuda/version.txt
  clang/test/Driver/Inputs/CUDA_80/usr/local/cuda/include/cuda.h
  clang/test/Driver/Inputs/CUDA_80/usr/local/cuda/version.txt
  clang/test/Driver/Inputs/CUDA_90/usr/local/cuda/include/cuda.h
  clang/test/Driver/cuda-version-check.cu

Index: clang/test/Driver/cuda-version-check.cu
===
--- clang/test/Driver/cuda-version-check.cu
+++ clang/test/Driver/cuda-version-check.cu
@@ -8,15 +8,12 @@
 // RUN:FileCheck %s --check-prefix=OK
 // RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda 2>&1 %s | \
 // RUN:FileCheck %s --check-prefix=OK
-// Test version guess when no version.txt or cuda.h are found
+// Test version guess when cuda.h has not been found
 // RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-path=%S/Inputs/CUDA-unknown/usr/local/cuda 2>&1 %s | \
 // RUN:FileCheck %s --check-prefix=UNKNOWN_VERSION
-// Unknown version with version.txt present
-// RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda 2>&1 %s | \
-// RUN:FileCheck %s --check-prefix=UNKNOWN_VERSION_V
-// Unknown version with no version.txt but with version info present in cuda.h
-// RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-path=%S/Inputs/CUDA_111/usr/local/cuda 2>&1 %s | \
-// RUN:FileCheck %s --check-prefix=UNKNOWN_VERSION_H
+// Unknown version info present in cuda.h
+// RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-path=%S/Inputs/CUDA-new/usr/local/cuda 2>&1 %s | \
+// RUN:FileCheck %s --check-prefix=UNKNOWN_VERSION
 // Make sure that we don't warn about CUDA version during C++ compilation.
 // RUN: %clang --target=x86_64-linux -v -### -x c++ --cuda-gpu-arch=sm_60 \
 // RUN:--cuda-path=%S/Inputs/CUDA-unknown/usr/local/cuda 2>&1 %s | \
@@ -66,13 +63,14 @@
 // OK_SM35-NOT: error: GPU arch sm_35
 
 // We should only get one error per architecture.
+// ERR_SM20: error: GPU arch sm_20 {{.*}}
+// ERR_SM20-NOT: error: GPU arch sm_20
+
 // ERR_SM60: error: GPU arch sm_60 {{.*}}
 // ERR_SM60-NOT: error: GPU arch sm_60
 
 // ERR_SM61: error: GPU arch sm_61 {{.*}}
 // ERR_SM61-NOT: error: GPU arch sm_61
 
-// UNKNOWN_VERSION_V: unknown CUDA version: version.txt:{{.*}}; assuming the latest supported version
-// UNKNOWN_VERSION_H: unknown CUDA version: cuda.h: CUDA_VERSION={{.*}}; assuming the latest supported version
-// UNKNOWN_VERSION: unknown CUDA version: no version found in version.txt or cuda.h; assuming the latest supported version
+// UNKNOWN_VERSION: CUDA version is newer than the latest{{.*}} supported version
 // UNKNOWN_VERSION_CXX-NOT: unknown CUDA version
Index: clang/test/Driver/Inputs/CUDA_90/usr/local/cuda/include/cuda.h
===
--- /dev/null
+++ clang/test/Driver/Inputs/CUDA_90/usr/local/cuda/include/cuda.h
@@ -0,0 +1,7 @@
+//
+// Placeholder file for testing CUDA version detection
+//
+
+#define CUDA_VERSION 9000
+
+//
Index: clang/test/Driver/Inputs/CUDA_80/usr/local/cuda/version.txt
===
--- clang/test/Driver/Inputs/CUDA_80/usr/local/cuda/version.txt
+++ /dev/null
@@ -1 +0,0 @@
-CUDA Version 8.0.42
Index: clang/test/Driver/Inputs/CUDA_80/usr/local/cuda/include/cuda.h
===
--- /dev/null
+++ clang/test/Driver/Inputs/CUDA_80/usr/local/cuda/include/cuda.h
@@ -0,0 +1,7 @@
+//
+// Placeholder file for testing CUDA version detection
+//
+
+#define CUDA_VERSION 8000
+
+//
Index: clang/test/Driver/Inputs/CUDA-unknown/usr/local/cuda/version.txt
===
--- clang/test/Driver/Inputs/CUDA-unknown/usr/local/cuda/version.txt
+++ /dev/null
@@ -1 +0,0 @@
-CUDA Version 999.999.999
Index: clang/test/Driver/Inputs/CUDA-new/usr/local/cuda/include/cuda.h
===
--- /dev/null
+++ cla

[PATCH] D108387: [WebAssembly] Restore builtins and intrinsics for pmin/pmax

2021-08-19 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.

Partially reverts 85157c007903 
, which 
had removed these builtins and intrinsics
in favor of normal codegen patterns. It turns out that it is possible for the
patterns to be split over multiple basic blocks, however, which means that DAG
ISel is not able to select them to the pmin/pmax instructions. To make sure the
SIMD intrinsics generate the correct instructions in these cases, reintroduce
the clang builtins and corresponding LLVM intrinsics, but also keep the normal
pattern matching as well.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108387

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/wasm_simd128.h
  clang/test/CodeGen/builtins-wasm.c
  clang/test/Headers/wasm.c
  llvm/include/llvm/IR/IntrinsicsWebAssembly.td
  llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
  llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll

Index: llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
===
--- llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
+++ llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
@@ -540,6 +540,26 @@
   ret <4 x float> %a
 }
 
+; CHECK-LABEL: pmin_v4f32:
+; CHECK-NEXT: .functype pmin_v4f32 (v128, v128) -> (v128){{$}}
+; CHECK-NEXT: f32x4.pmin $push[[R:[0-9]+]]=, $0, $1{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+declare <4 x float> @llvm.wasm.pmin.v4f32(<4 x float>, <4 x float>)
+define <4 x float> @pmin_v4f32(<4 x float> %a, <4 x float> %b) {
+  %v = call <4 x float> @llvm.wasm.pmin.v4f32(<4 x float> %a, <4 x float> %b)
+  ret <4 x float> %v
+}
+
+; CHECK-LABEL: pmax_v4f32:
+; CHECK-NEXT: .functype pmax_v4f32 (v128, v128) -> (v128){{$}}
+; CHECK-NEXT: f32x4.pmax $push[[R:[0-9]+]]=, $0, $1{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+declare <4 x float> @llvm.wasm.pmax.v4f32(<4 x float>, <4 x float>)
+define <4 x float> @pmax_v4f32(<4 x float> %a, <4 x float> %b) {
+  %v = call <4 x float> @llvm.wasm.pmax.v4f32(<4 x float> %a, <4 x float> %b)
+  ret <4 x float> %v
+}
+
 ; CHECK-LABEL: ceil_v4f32:
 ; CHECK-NEXT: .functype ceil_v4f32 (v128) -> (v128){{$}}
 ; CHECK-NEXT: f32x4.ceil $push[[R:[0-9]+]]=, $0{{$}}
@@ -595,6 +615,26 @@
   ret <2 x double> %a
 }
 
+; CHECK-LABEL: pmin_v2f64:
+; CHECK-NEXT: .functype pmin_v2f64 (v128, v128) -> (v128){{$}}
+; CHECK-NEXT: f64x2.pmin $push[[R:[0-9]+]]=, $0, $1{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+declare <2 x double> @llvm.wasm.pmin.v2f64(<2 x double>, <2 x double>)
+define <2 x double> @pmin_v2f64(<2 x double> %a, <2 x double> %b) {
+  %v = call <2 x double> @llvm.wasm.pmin.v2f64(<2 x double> %a, <2 x double> %b)
+  ret <2 x double> %v
+}
+
+; CHECK-LABEL: pmax_v2f64:
+; CHECK-NEXT: .functype pmax_v2f64 (v128, v128) -> (v128){{$}}
+; CHECK-NEXT: f64x2.pmax $push[[R:[0-9]+]]=, $0, $1{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+declare <2 x double> @llvm.wasm.pmax.v2f64(<2 x double>, <2 x double>)
+define <2 x double> @pmax_v2f64(<2 x double> %a, <2 x double> %b) {
+  %v = call <2 x double> @llvm.wasm.pmax.v2f64(<2 x double> %a, <2 x double> %b)
+  ret <2 x double> %v
+}
+
 ; CHECK-LABEL: ceil_v2f64:
 ; CHECK-NEXT: .functype ceil_v2f64 (v128) -> (v128){{$}}
 ; CHECK-NEXT: f64x2.ceil $push[[R:[0-9]+]]=, $0{{$}}
Index: llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
===
--- llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
+++ llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
@@ -1165,6 +1165,16 @@
   (pmax $lhs, $rhs)>;
 }
 
+// And match the pmin/pmax LLVM intrinsics as well
+def : Pat<(v4f32 (int_wasm_pmin (v4f32 V128:$lhs), (v4f32 V128:$rhs))),
+  (PMIN_F32x4 V128:$lhs, V128:$rhs)>;
+def : Pat<(v4f32 (int_wasm_pmax (v4f32 V128:$lhs), (v4f32 V128:$rhs))),
+  (PMAX_F32x4 V128:$lhs, V128:$rhs)>;
+def : Pat<(v2f64 (int_wasm_pmin (v2f64 V128:$lhs), (v2f64 V128:$rhs))),
+  (PMIN_F64x2 V128:$lhs, V128:$rhs)>;
+def : Pat<(v2f64 (int_wasm_pmax (v2f64 V128:$lhs), (v2f64 V128:$rhs))),
+  (PMAX_F64x2 V128:$lhs, V128:$rhs)>;
+
 //===--===//
 // Conversions
 //===--===//
Index: llvm/include/llvm/IR/IntrinsicsWebAssembly.td
===
--- llvm/include/llvm/IR/IntrinsicsWebAssembly.td
+++ llvm/include/llvm/IR/IntrinsicsWebAssembly.td
@@ -164,6 +164,15 @@
 [llvm_v8i16_ty, llvm_v8i16_ty],
 [IntrNoMem, IntrSpeculatable]>;
 
+def int_wasm_pmin :
+

[PATCH] D108003: [Clang] Extend -Wbool-operation to warn about bitwise and of bools with side effects

2021-08-19 Thread Ryan Beltran via Phabricator via cfe-commits
rpbeltran added a comment.

This patch seems like a great contribution! Really glad to see this being 
added. I did have a question though on why this only appears to catch "&" vs 
"&&" instead of doing the same for "|" vs "||". It seems like both operators 
have roughly the same potential for confusion. Could we add support for bitwise 
vs logical or in this?


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

https://reviews.llvm.org/D108003

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


  1   2   3   >