[PATCH] D105876: OMPIRBuilder for Interop directive

2021-07-22 Thread Sri Hari Krishna Narayanan via Phabricator via cfe-commits
sriharikrishna updated this revision to Diff 361079.
sriharikrishna added a comment.

OMPIRBuilder for Interop directive. Squashed commit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105876

Files:
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/OpenMP/interop_irbuilder.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -2173,6 +2173,96 @@
   return Builder.CreateCall(Fn, Args, Name);
 }
 
+CallInst *OpenMPIRBuilder::createOMPInteropInit(const LocationDescription ,
+Value *InteropVar,
+omp::OMPInteropType InteropType,
+Value *Device,
+Value *NumDependences,
+Value *DependenceAddress,
+bool HaveNowaitClause) {
+  IRBuilder<>::InsertPointGuard IPG(Builder);
+  Builder.restoreIP(Loc.IP);
+
+  Constant *SrcLocStr = getOrCreateSrcLocStr(Loc);
+  Value *Ident = getOrCreateIdent(SrcLocStr);
+  Value *ThreadId = getOrCreateThreadID(Ident);
+  if (Device == NULL)
+Device = ConstantInt::get(M.getContext(), APInt(32, -1, true));
+  Constant *InteropTypeVal =
+  ConstantInt::get(Int64, (int)InteropType);
+  if (NumDependences == nullptr) {
+NumDependences = ConstantInt::get(Int32, 0);
+PointerType *PointerTypeVar = Type::getInt8PtrTy(M.getContext());
+DependenceAddress = ConstantPointerNull::get(PointerTypeVar);
+  }
+  Value *HaveNowaitClauseVal =
+  ConstantInt::get(M.getContext(), APInt(32, HaveNowaitClause, true));
+  Value *Args[] = {
+  Ident,  ThreadId,   InteropVar,InteropTypeVal,
+  Device, NumDependences, DependenceAddress, HaveNowaitClauseVal};
+
+  Function *Fn = getOrCreateRuntimeFunctionPtr(OMPRTL___kmpc_interop_init);
+
+  return Builder.CreateCall(Fn, Args);
+}
+
+CallInst *OpenMPIRBuilder::createOMPInteropDestroy(
+const LocationDescription , Value *InteropVar, Value *Device,
+Value *NumDependences, Value *DependenceAddress,
+bool HaveNowaitClause) {
+  IRBuilder<>::InsertPointGuard IPG(Builder);
+  Builder.restoreIP(Loc.IP);
+
+  Constant *SrcLocStr = getOrCreateSrcLocStr(Loc);
+  Value *Ident = getOrCreateIdent(SrcLocStr);
+  Value *ThreadId = getOrCreateThreadID(Ident);
+  if (Device == NULL)
+Device = ConstantInt::get(M.getContext(), APInt(32, -1, true));
+  if (NumDependences == nullptr) {
+NumDependences = ConstantInt::get(Int32, 0);
+PointerType *PointerTypeVar = Type::getInt8PtrTy(M.getContext());
+DependenceAddress = ConstantPointerNull::get(PointerTypeVar);
+  }
+  Value *HaveNowaitClauseVal =
+  ConstantInt::get(M.getContext(), APInt(32, HaveNowaitClause, true));
+  Value *Args[] = {
+  Ident,  ThreadId,  InteropVar, Device,
+  NumDependences, DependenceAddress, HaveNowaitClauseVal};
+
+  Function *Fn = getOrCreateRuntimeFunctionPtr(OMPRTL___kmpc_interop_destroy);
+
+  return Builder.CreateCall(Fn, Args);
+}
+
+CallInst *OpenMPIRBuilder::createOMPInteropUse(const LocationDescription ,
+   Value *InteropVar,
+   Value *Device,
+   Value *NumDependences,
+   Value *DependenceAddress,
+   bool HaveNowaitClause) {
+  IRBuilder<>::InsertPointGuard IPG(Builder);
+  Builder.restoreIP(Loc.IP);
+  Constant *SrcLocStr = getOrCreateSrcLocStr(Loc);
+  Value *Ident = getOrCreateIdent(SrcLocStr);
+  Value *ThreadId = getOrCreateThreadID(Ident);
+  if (Device == NULL)
+Device = ConstantInt::get(M.getContext(), APInt(32, -1, true));
+  if (NumDependences == nullptr) {
+NumDependences = ConstantInt::get(Int32, 0);
+PointerType *PointerTypeVar = Type::getInt8PtrTy(M.getContext());
+DependenceAddress = ConstantPointerNull::get(PointerTypeVar);
+  }
+  Value *HaveNowaitClauseVal =
+  ConstantInt::get(M.getContext(), APInt(32, HaveNowaitClause, true));
+  Value *Args[] = {
+  Ident,  ThreadId,  InteropVar, Device,
+  NumDependences, DependenceAddress, HaveNowaitClauseVal};
+
+  Function *Fn = getOrCreateRuntimeFunctionPtr(OMPRTL___kmpc_interop_use);
+
+  return Builder.CreateCall(Fn, Args);
+}
+
 CallInst 

[PATCH] D106577: [clang] Define __STDC_ISO_10646__

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

In D106577#2897588 , @aaron.ballman 
wrote:

> In D106577#2897522 , @jyknight 
> wrote:
>
>> I'm not sure we should be populating this.
>>
>> The _value_ is determined by what libc supports, so it probably needs to be 
>> left up to libc to define it.
>
> Why is the value determined by what libc supports? The definition from the 
> standard is:
>
>   If this symbol is defined, then every character in the Unicode required 
> set, when stored in an
>   object of type wchar_t, has the same value as the short identifier of that 
> character.
>
> That doesn't seem to imply anything about the library, just the size of 
> `wchar_t`.

Every character in the Unicode required set encoded in what way? To say that 
such a character is stored in an object of type `wchar_t` means that 
interpreting the `wchar_t` yields that stored character. Methods to determining 
the interpretation of the stored `wchar_t` value include locale-sensitive 
functions such as `wcstombs` (and thus is tied to libc).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106577

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


[PATCH] D105690: [RISCV] Rename assembler mnemonic of unordered floating-point reductions for v1.0-rc change

2021-07-22 Thread Jianjian Guan via Phabricator via cfe-commits
jacquesguan added inline comments.



Comment at: llvm/test/MC/RISCV/rvv/aliases.s:86
+# NO-ALIAS: vfwredusum.vs v8, v4, v20, v0.t  # encoding: [0x57,0x14,0x4a,0xc4]
+vfwredusum.vs v8, v4, v20, v0.t

craig.topper wrote:
> jacquesguan wrote:
> > kito-cheng wrote:
> > > I guess you want to verify `vfredsum.vs`  and `vfwredsum.vs` here?
> > Yes, but because the `Emit` of the InstAlias is set to 0, the printing 
> > priority of alias is lower than instruction, It just print the mnemonic of 
> > the instruction.
> Don't you want to use the alias `vfredsum.vs` as input and verify you get the 
> non-alias `vfredusum.vs` back?
Yes, you are right, I do not notice using wrong input, thank you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105690

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


[PATCH] D105690: [RISCV] Rename assembler mnemonic of unordered floating-point reductions for v1.0-rc change

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



Comment at: llvm/test/MC/RISCV/rvv/aliases.s:86
+# NO-ALIAS: vfwredusum.vs v8, v4, v20, v0.t  # encoding: [0x57,0x14,0x4a,0xc4]
+vfwredusum.vs v8, v4, v20, v0.t

jacquesguan wrote:
> kito-cheng wrote:
> > I guess you want to verify `vfredsum.vs`  and `vfwredsum.vs` here?
> Yes, but because the `Emit` of the InstAlias is set to 0, the printing 
> priority of alias is lower than instruction, It just print the mnemonic of 
> the instruction.
Don't you want to use the alias `vfredsum.vs` as input and verify you get the 
non-alias `vfredusum.vs` back?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105690

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


[PATCH] D105690: [RISCV] Rename assembler mnemonic of unordered floating-point reductions for v1.0-rc change

2021-07-22 Thread Jianjian Guan via Phabricator via cfe-commits
jacquesguan added inline comments.



Comment at: llvm/test/MC/RISCV/rvv/aliases.s:86
+# NO-ALIAS: vfwredusum.vs v8, v4, v20, v0.t  # encoding: [0x57,0x14,0x4a,0xc4]
+vfwredusum.vs v8, v4, v20, v0.t

kito-cheng wrote:
> I guess you want to verify `vfredsum.vs`  and `vfwredsum.vs` here?
Yes, but because the `Emit` of the InstAlias is set to 0, the printing priority 
of alias is lower than instruction, It just print the mnemonic of the 
instruction.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105690

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


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

2021-07-22 Thread Kai Luo 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 rGe4ed93cb25ac: [PowerPC] Implement XL compatible behavior of 
__compare_and_swap (authored by lkail).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106344

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

Index: llvm/test/CodeGen/PowerPC/opt-builtins-ppc-xlcompat-cas.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/opt-builtins-ppc-xlcompat-cas.ll
@@ -0,0 +1,70 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -enable-new-pm=1 -S -passes='default' %s -o - | FileCheck %s
+define void @test_builtin_ppc_compare_and_swaplp(i64 %a, i64 %b, i64 %c) {
+; CHECK-LABEL: @test_builtin_ppc_compare_and_swaplp(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[A_ADDR:%.*]] = alloca i64, align 8
+; CHECK-NEXT:store i64 [[A:%.*]], i64* [[A_ADDR]], align 8
+; CHECK-NEXT:[[TMP0:%.*]] = cmpxchg weak volatile i64* [[A_ADDR]], i64 [[B:%.*]], i64 [[C:%.*]] monotonic monotonic, align 8
+; CHECK-NEXT:ret void
+;
+entry:
+  %a.addr = alloca i64, align 8
+  %b.addr = alloca i64, align 8
+  %c.addr = alloca i64, align 8
+  store i64 %a, i64* %a.addr, align 8
+  store i64 %b, i64* %b.addr, align 8
+  store i64 %c, i64* %c.addr, align 8
+  %0 = load i64, i64* %c.addr, align 8
+  %1 = load i64, i64* %b.addr, align 8
+  %2 = cmpxchg weak volatile i64* %a.addr, i64 %1, i64 %0 monotonic monotonic, align 8
+  %3 = extractvalue { i64, i1 } %2, 0
+  %4 = extractvalue { i64, i1 } %2, 1
+  store i64 %3, i64* %b.addr, align 8
+  ret void
+}
+
+define dso_local void @test_builtin_ppc_compare_and_swaplp_loop(i64* %a) {
+; CHECK-LABEL: @test_builtin_ppc_compare_and_swaplp_loop(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[CALL:%.*]] = tail call i64 bitcast (i64 (...)* @bar to i64 ()*)()
+; CHECK-NEXT:br label [[DO_BODY:%.*]]
+; CHECK:   do.body:
+; CHECK-NEXT:[[X_0:%.*]] = phi i64 [ [[CALL]], [[ENTRY:%.*]] ], [ [[TMP1:%.*]], [[DO_BODY]] ]
+; CHECK-NEXT:[[ADD:%.*]] = add nsw i64 [[X_0]], 1
+; CHECK-NEXT:[[TMP0:%.*]] = cmpxchg weak volatile i64* [[A:%.*]], i64 [[X_0]], i64 [[ADD]] monotonic monotonic, align 8
+; CHECK-NEXT:[[TMP1]] = extractvalue { i64, i1 } [[TMP0]], 0
+; CHECK-NEXT:[[TMP2:%.*]] = extractvalue { i64, i1 } [[TMP0]], 1
+; CHECK-NEXT:br i1 [[TMP2]], label [[DO_BODY]], label [[DO_END:%.*]]
+; CHECK:   do.end:
+; CHECK-NEXT:ret void
+;
+entry:
+  %a.addr = alloca i64*, align 8
+  %x = alloca i64, align 8
+  store i64* %a, i64** %a.addr, align 8
+  %call = call i64 bitcast (i64 (...)* @bar to i64 ()*)()
+  store i64 %call, i64* %x, align 8
+  br label %do.body
+
+do.body:  ; preds = %do.cond, %entry
+  br label %do.cond
+
+do.cond:  ; preds = %do.body
+  %0 = load i64*, i64** %a.addr, align 8
+  %1 = load i64, i64* %x, align 8
+  %add = add nsw i64 %1, 1
+  %2 = load i64*, i64** %a.addr, align 8
+  %3 = load i64, i64* %x, align 8
+  %4 = cmpxchg weak volatile i64* %2, i64 %3, i64 %add monotonic monotonic, align 8
+  %5 = extractvalue { i64, i1 } %4, 0
+  %6 = extractvalue { i64, i1 } %4, 1
+  store i64 %5, i64* %x, align 8
+  %tobool = icmp ne i1 %6, false
+  br i1 %tobool, label %do.body, label %do.end
+
+do.end:   ; preds = %do.cond
+  ret void
+}
+
+declare i64 @bar(...)
Index: clang/test/CodeGen/builtins-ppc-xlcompat-cas.c
===
--- clang/test/CodeGen/builtins-ppc-xlcompat-cas.c
+++ clang/test/CodeGen/builtins-ppc-xlcompat-cas.c
@@ -19,6 +19,7 @@
 // CHECK-NEXT:[[TMP2:%.*]] = cmpxchg weak volatile i32* [[A_ADDR]], i32 [[TMP1]], i32 [[TMP0]] monotonic monotonic, align 4
 // CHECK-NEXT:[[TMP3:%.*]] = extractvalue { i32, i1 } [[TMP2]], 0
 // CHECK-NEXT:[[TMP4:%.*]] = extractvalue { i32, i1 } [[TMP2]], 1
+// CHECK-NEXT:store i32 [[TMP3]], i32* [[B_ADDR]], align 4
 // CHECK-NEXT:ret void
 //
 void test_builtin_ppc_compare_and_swap(int a, int b, int c) {
@@ -39,6 +40,7 @@
 // CHECK-NEXT:[[TMP2:%.*]] = cmpxchg weak volatile i64* [[A_ADDR]], i64 [[TMP1]], i64 [[TMP0]] monotonic monotonic, align 8
 // CHECK-NEXT:[[TMP3:%.*]] = extractvalue { i64, i1 } [[TMP2]], 0
 // CHECK-NEXT:[[TMP4:%.*]] = extractvalue { i64, i1 } [[TMP2]], 1
+// CHECK-NEXT:store i64 [[TMP3]], i64* [[B_ADDR]], align 8
 // CHECK-NEXT:ret void
 //
 void test_builtin_ppc_compare_and_swaplp(long a, long b, long c) {
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ 

[clang] e4ed93c - [PowerPC] Implement XL compatible behavior of __compare_and_swap

2021-07-22 Thread Kai Luo via cfe-commits

Author: Kai Luo
Date: 2021-07-23T01:16:02Z
New Revision: e4ed93cb25acc624a1d32e77d2c63c8c25fddbae

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

LOG: [PowerPC] Implement XL compatible behavior of __compare_and_swap

According to 
https://www.ibm.com/docs/en/xl-c-and-cpp-aix/16.1?topic=functions-compare-swap-compare-swaplp
XL's `__compare_and_swap` has a weird behavior that

> In either case, the contents of the memory location specified by addr are 
> copied into the memory location specified by old_val_addr.

(unlike c11 `atomic_compare_exchange` specified in 
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf)

This patch let clang's implementation follow this behavior.

Reviewed By: jsji

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

Added: 
llvm/test/CodeGen/PowerPC/opt-builtins-ppc-xlcompat-cas.ll

Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/builtins-ppc-xlcompat-cas.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index a4d0d87f2cbc..a3a0c3e88359 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -15662,6 +15662,15 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned 
BuiltinID,
 auto Pair = EmitAtomicCompareExchange(
 LV, RValue::get(OldVal), RValue::get(Ops[2]), E->getExprLoc(),
 llvm::AtomicOrdering::Monotonic, llvm::AtomicOrdering::Monotonic, 
true);
+// Unlike c11's atomic_compare_exchange, accroding to
+// 
https://www.ibm.com/docs/en/xl-c-and-cpp-aix/16.1?topic=functions-compare-swap-compare-swaplp
+// > In either case, the contents of the memory location specified by addr
+// > are copied into the memory location specified by old_val_addr.
+// But it hasn't specified storing to OldValAddr is atomic or not and
+// which order to use. Now following XL's codegen, treat it as a normal
+// store.
+Value *LoadedVal = Pair.first.getScalarVal();
+Builder.CreateStore(LoadedVal, OldValAddr);
 return Pair.second;
   }
   case PPC::BI__builtin_ppc_fetch_and_add:

diff  --git a/clang/test/CodeGen/builtins-ppc-xlcompat-cas.c 
b/clang/test/CodeGen/builtins-ppc-xlcompat-cas.c
index ea4b349d9a52..cd66eb09d36f 100644
--- a/clang/test/CodeGen/builtins-ppc-xlcompat-cas.c
+++ b/clang/test/CodeGen/builtins-ppc-xlcompat-cas.c
@@ -19,6 +19,7 @@
 // CHECK-NEXT:[[TMP2:%.*]] = cmpxchg weak volatile i32* [[A_ADDR]], i32 
[[TMP1]], i32 [[TMP0]] monotonic monotonic, align 4
 // CHECK-NEXT:[[TMP3:%.*]] = extractvalue { i32, i1 } [[TMP2]], 0
 // CHECK-NEXT:[[TMP4:%.*]] = extractvalue { i32, i1 } [[TMP2]], 1
+// CHECK-NEXT:store i32 [[TMP3]], i32* [[B_ADDR]], align 4
 // CHECK-NEXT:ret void
 //
 void test_builtin_ppc_compare_and_swap(int a, int b, int c) {
@@ -39,6 +40,7 @@ void test_builtin_ppc_compare_and_swap(int a, int b, int c) {
 // CHECK-NEXT:[[TMP2:%.*]] = cmpxchg weak volatile i64* [[A_ADDR]], i64 
[[TMP1]], i64 [[TMP0]] monotonic monotonic, align 8
 // CHECK-NEXT:[[TMP3:%.*]] = extractvalue { i64, i1 } [[TMP2]], 0
 // CHECK-NEXT:[[TMP4:%.*]] = extractvalue { i64, i1 } [[TMP2]], 1
+// CHECK-NEXT:store i64 [[TMP3]], i64* [[B_ADDR]], align 8
 // CHECK-NEXT:ret void
 //
 void test_builtin_ppc_compare_and_swaplp(long a, long b, long c) {

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

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

2021-07-22 Thread Ben Barham via Phabricator via cfe-commits
bnbarham added a comment.

In D95159#2897941 , @mibintc wrote:

> Can you suggest how to find the problem?  Thanks a lot.

@mibintc the test is reusing the module cache directory and that's causing some 
issues between runs, sorry about that. You could add a `rm -rf %t` or `rm -rf 
%t/mcp` to this test to fix that. Looks like the same issue was run into in 
https://reviews.llvm.org/D96816#2572589. I'd prefer 
`clang/test/Index/preamble-reparse-changed-module.m` add the `rm` and another 
test added for the `LLVM_APPEND_VC_REV=NO` if we want that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95159

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


[PATCH] D106620: [Clang][LLVM] generate btf_tag annotations for func parameters

2021-07-22 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song created this revision.
yonghong-song added reviewers: dblaikie, probinson, aprantl, aaron.ballman.
yonghong-song added a project: debug-info.
Herald added subscribers: dexonsmith, ormris, hiraditya.
yonghong-song requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Generate btf_tag annotations for function parameters.
A field "annotations" is introduced to DILocalVariable, and 
annotations are represented as an DINodeArray, similar to
DIComposite elements. The following example illustrates how 
annotations are encoded in IR:

  distinct !DILocalVariable(name: "info",, arg: 1, ..., annotations: !10)
  !10 = !{!11, !12}
  !11 = !{!"btf_tag", !"a"}
  !12 = !{!"btf_tag", !"b"}


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106620

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/attr-btf_tag-parameter.c
  llvm/include/llvm/IR/DIBuilder.h
  llvm/include/llvm/IR/DebugInfoMetadata.h
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/Bitcode/Reader/MetadataLoader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/DIBuilder.cpp
  llvm/lib/IR/DebugInfoMetadata.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/test/Bitcode/attr-btf_tag-parameter.ll

Index: llvm/test/Bitcode/attr-btf_tag-parameter.ll
===
--- /dev/null
+++ llvm/test/Bitcode/attr-btf_tag-parameter.ll
@@ -0,0 +1,46 @@
+; REQUIRES: x86-registered-target
+; RUN: llvm-as < %s | llvm-dis | FileCheck %s
+
+; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone uwtable willreturn
+define dso_local i32 @f(i32 %a) local_unnamed_addr #0 !dbg !8 {
+entry:
+  call void @llvm.dbg.value(metadata i32 %a, metadata !13, metadata !DIExpression()), !dbg !17
+  ret i32 0, !dbg !18
+}
+
+; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
+declare void @llvm.dbg.value(metadata, metadata, metadata) #1
+
+attributes #0 = { mustprogress nofree norecurse nosync nounwind readnone uwtable willreturn "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
+attributes #1 = { nofree nosync nounwind readnone speculatable willreturn }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5, !6}
+!llvm.ident = !{!7}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0 (https://github.com/llvm/llvm-project.git c9e3139e00bcef23b236a02890b909a130d1b3d9)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
+!1 = !DIFile(filename: "func.c", directory: "/home/yhs/work/tests/llvm/btf_tag")
+!2 = !{}
+!3 = !{i32 7, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 4}
+!6 = !{i32 7, !"uwtable", i32 1}
+!7 = !{!"clang version 13.0.0 (https://github.com/llvm/llvm-project.git c9e3139e00bcef23b236a02890b909a130d1b3d9)"}
+!8 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 1, type: !9, scopeLine: 1, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !12)
+!9 = !DISubroutineType(types: !10)
+!10 = !{!11, !11}
+!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!12 = !{!13}
+!13 = !DILocalVariable(name: "a", arg: 1, scope: !8, file: !1, line: 1, type: !11, annotations: !14)
+!14 = !{!15, !16}
+!15 = !{!"btf_tag", !"a"}
+!16 = !{!"btf_tag", !"b"}
+
+; CHECK:!DILocalVariable(name: "a", arg: 1,
+; CHECK-SAME:   annotations: ![[ANNOT:[0-9]+]]
+; CHECK:![[ANNOT]] = !{![[TAG1:[0-9]+]], ![[TAG2:[0-9]+]]}
+; CHECK:![[TAG1]] = !{!"btf_tag", !"a"}
+; CHECK:![[TAG2]] = !{!"btf_tag", !"b"}
+
+!17 = !DILocation(line: 0, scope: !8)
+!18 = !DILocation(line: 1, column: 76, scope: !8)
Index: llvm/lib/IR/LLVMContextImpl.h
===
--- llvm/lib/IR/LLVMContextImpl.h
+++ llvm/lib/IR/LLVMContextImpl.h
@@ -1042,22 +1042,25 @@
   unsigned Arg;
   unsigned Flags;
   uint32_t AlignInBits;
+  Metadata *Annotations;
 
   MDNodeKeyImpl(Metadata *Scope, MDString *Name, Metadata *File, unsigned Line,
 Metadata *Type, unsigned Arg, unsigned Flags,
-uint32_t AlignInBits)
+uint32_t AlignInBits, Metadata *Annotations)
   : Scope(Scope), Name(Name), File(File), Line(Line), Type(Type), Arg(Arg),
-Flags(Flags), AlignInBits(AlignInBits) {}
+Flags(Flags), AlignInBits(AlignInBits), Annotations(Annotations) {}
   MDNodeKeyImpl(const DILocalVariable *N)
   : Scope(N->getRawScope()), Name(N->getRawName()), File(N->getRawFile()),
 Line(N->getLine()), Type(N->getRawType()), Arg(N->getArg()),
-

[PATCH] D106619: [Clang][LLVM] generate btf_tag annotations for DIGlobalVariable

2021-07-22 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song created this revision.
yonghong-song added reviewers: dblaikie, probinson, aprantl, aaron.ballman.
yonghong-song added a project: debug-info.
Herald added subscribers: dexonsmith, ormris, hiraditya.
yonghong-song requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Generate btf_tag annotations for DIGlobalVariable.
A field "annotations" is introduced to DIGlobalVariable, and 
annotations are represented as an DINodeArray, similar to
DIComposite elements. The following example illustrates how 
annotations are encoded in IR:

  distinct !DIGlobalVariable(..., annotations: !10)
  !10 = !{!11, !12}
  !11 = !{!"btf_tag", !"a"}
  !12 = !{!"btf_tag", !"b"}


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106619

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/attr-btf_tag-diglobalvariable.c
  llvm/include/llvm/IR/DIBuilder.h
  llvm/include/llvm/IR/DebugInfoMetadata.h
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/Bitcode/Reader/MetadataLoader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/DIBuilder.cpp
  llvm/lib/IR/DebugInfoMetadata.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/test/Bitcode/attr-btf_tag-diglobalvariable.ll

Index: llvm/test/Bitcode/attr-btf_tag-diglobalvariable.ll
===
--- /dev/null
+++ llvm/test/Bitcode/attr-btf_tag-diglobalvariable.ll
@@ -0,0 +1,37 @@
+; REQUIRES: x86-registered-target
+; RUN: llvm-as < %s | llvm-dis | FileCheck %s
+
+%struct.t1 = type { i32 }
+
+@g1 = dso_local global %struct.t1 zeroinitializer, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!2}
+!llvm.module.flags = !{!13, !14, !15, !16, !17}
+!llvm.ident = !{!18}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = distinct !DIGlobalVariable(name: "g1", scope: !2, file: !3, line: 7, type: !6, isLocal: false, isDefinition: true, annotations: !10)
+!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 13.0.0 (https://github.com/llvm/llvm-project.git 47af5574a87dc298b5c6c36ff6a969c8c77c8499)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, splitDebugInlining: false, nameTableKind: None)
+!3 = !DIFile(filename: "t.c", directory: "/home/yhs/work/tests/llvm/btf_tag")
+!4 = !{}
+!5 = !{!0}
+!6 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t1", file: !3, line: 4, size: 32, elements: !7)
+!7 = !{!8}
+!8 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !6, file: !3, line: 5, baseType: !9, size: 32)
+!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!10 = !{!11, !12}
+!11 = !{!"btf_tag", !"tag1"}
+!12 = !{!"btf_tag", !"tag2"}
+
+; CHECK:distinct !DIGlobalVariable(name: "g1"
+; CHECK-SAME:   annotations: ![[ANNOT:[0-9]+]]
+; CHECK:![[ANNOT]] = !{![[TAG1:[0-9]+]], ![[TAG2:[0-9]+]]}
+; CHECK:![[TAG1]] = !{!"btf_tag", !"tag1"}
+; CHECK:![[TAG2]] = !{!"btf_tag", !"tag2"}
+
+!13 = !{i32 7, !"Dwarf Version", i32 4}
+!14 = !{i32 2, !"Debug Info Version", i32 3}
+!15 = !{i32 1, !"wchar_size", i32 4}
+!16 = !{i32 7, !"uwtable", i32 1}
+!17 = !{i32 7, !"frame-pointer", i32 2}
+!18 = !{!"clang version 13.0.0 (https://github.com/llvm/llvm-project.git 47af5574a87dc298b5c6c36ff6a969c8c77c8499)"}
Index: llvm/lib/IR/LLVMContextImpl.h
===
--- llvm/lib/IR/LLVMContextImpl.h
+++ llvm/lib/IR/LLVMContextImpl.h
@@ -984,17 +984,19 @@
   Metadata *StaticDataMemberDeclaration;
   Metadata *TemplateParams;
   uint32_t AlignInBits;
+  Metadata *Annotations;
 
   MDNodeKeyImpl(Metadata *Scope, MDString *Name, MDString *LinkageName,
 Metadata *File, unsigned Line, Metadata *Type,
 bool IsLocalToUnit, bool IsDefinition,
 Metadata *StaticDataMemberDeclaration, Metadata *TemplateParams,
-uint32_t AlignInBits)
+uint32_t AlignInBits, Metadata *Annotations)
   : Scope(Scope), Name(Name), LinkageName(LinkageName), File(File),
 Line(Line), Type(Type), IsLocalToUnit(IsLocalToUnit),
 IsDefinition(IsDefinition),
 StaticDataMemberDeclaration(StaticDataMemberDeclaration),
-TemplateParams(TemplateParams), AlignInBits(AlignInBits) {}
+TemplateParams(TemplateParams), AlignInBits(AlignInBits),
+Annotations(Annotations) {}
   MDNodeKeyImpl(const DIGlobalVariable *N)
   : Scope(N->getRawScope()), Name(N->getRawName()),
 LinkageName(N->getRawLinkageName()), File(N->getRawFile()),
@@ -1002,7 +1004,7 @@
 IsLocalToUnit(N->isLocalToUnit()), IsDefinition(N->isDefinition()),
 StaticDataMemberDeclaration(N->getRawStaticDataMemberDeclaration()),
 TemplateParams(N->getRawTemplateParams()),
-AlignInBits(N->getAlignInBits()) {}
+AlignInBits(N->getAlignInBits()), 

[PATCH] D106618: [Clang][LLVM] generate btf_tag annotations for DISubprogram types

2021-07-22 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song created this revision.
yonghong-song added reviewers: dblaikie, probinson, aprantl, aaron.ballman.
yonghong-song added a project: debug-info.
Herald added subscribers: dexonsmith, ormris, hiraditya.
yonghong-song requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Generate btf_tag annotations for DISubprogram types.
A field "annotations" is introduced to DISubprogram, and 
annotations are represented as an DINodeArray, similar to
DIComposite elements. The following example illustrates how 
annotations are encoded in IR:

  distinct !DISubprogram(..., annotations: !10)
  !10 = !{!11, !12}
  !11 = !{!"btf_tag", !"a"}
  !12 = !{!"btf_tag", !"b"}


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106618

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/attr-btf_tag-disubprogram.c
  llvm/include/llvm/IR/DIBuilder.h
  llvm/include/llvm/IR/DebugInfoMetadata.h
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/Bitcode/Reader/MetadataLoader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/DIBuilder.cpp
  llvm/lib/IR/DebugInfoMetadata.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/test/Bitcode/attr-btf_tag-disubprogram.ll

Index: llvm/test/Bitcode/attr-btf_tag-disubprogram.ll
===
--- /dev/null
+++ llvm/test/Bitcode/attr-btf_tag-disubprogram.ll
@@ -0,0 +1,46 @@
+; REQUIRES: x86-registered-target
+; RUN: llvm-as < %s | llvm-dis | FileCheck %s
+
+; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone uwtable willreturn
+define dso_local i32 @f(i32 %a) local_unnamed_addr #0 !dbg !8 {
+entry:
+  call void @llvm.dbg.value(metadata i32 %a, metadata !13, metadata !DIExpression()), !dbg !17
+  ret i32 0, !dbg !18
+}
+
+; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
+declare void @llvm.dbg.value(metadata, metadata, metadata) #1
+
+attributes #0 = { mustprogress nofree norecurse nosync nounwind readnone uwtable willreturn "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
+attributes #1 = { nofree nosync nounwind readnone speculatable willreturn }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5, !6}
+!llvm.ident = !{!7}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0 (https://github.com/llvm/llvm-project.git a6dd9d402a04d53403664bbb47771f2573c7ade0)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
+!1 = !DIFile(filename: "func.c", directory: "/home/yhs/work/tests/llvm/btf_tag")
+!2 = !{}
+!3 = !{i32 7, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 4}
+!6 = !{i32 7, !"uwtable", i32 1}
+!7 = !{!"clang version 13.0.0 (https://github.com/llvm/llvm-project.git a6dd9d402a04d53403664bbb47771f2573c7ade0)"}
+!8 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 1, type: !9, scopeLine: 1, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !12, annotations: !14)
+!9 = !DISubroutineType(types: !10)
+!10 = !{!11, !11}
+!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!12 = !{!13}
+!13 = !DILocalVariable(name: "a", arg: 1, scope: !8, file: !1, line: 1, type: !11)
+!14 = !{!15, !16}
+!15 = !{!"btf_tag", !"a"}
+!16 = !{!"btf_tag", !"b"}
+
+; CHECK:distinct !DISubprogram(name: "f"
+; CHECK-SAME:   annotations: ![[ANNOT:[0-9]+]]
+; CHECK:![[ANNOT]] = !{![[TAG1:[0-9]+]], ![[TAG2:[0-9]+]]}
+; CHECK:![[TAG1]] = !{!"btf_tag", !"a"}
+; CHECK:![[TAG2]] = !{!"btf_tag", !"b"}
+
+!17 = !DILocation(line: 0, scope: !8)
+!18 = !DILocation(line: 1, column: 77, scope: !8)
Index: llvm/lib/IR/LLVMContextImpl.h
===
--- llvm/lib/IR/LLVMContextImpl.h
+++ llvm/lib/IR/LLVMContextImpl.h
@@ -697,6 +697,7 @@
   Metadata *Declaration;
   Metadata *RetainedNodes;
   Metadata *ThrownTypes;
+  Metadata *Annotations;
 
   MDNodeKeyImpl(Metadata *Scope, MDString *Name, MDString *LinkageName,
 Metadata *File, unsigned Line, Metadata *Type,
@@ -704,13 +705,14 @@
 unsigned VirtualIndex, int ThisAdjustment, unsigned Flags,
 unsigned SPFlags, Metadata *Unit, Metadata *TemplateParams,
 Metadata *Declaration, Metadata *RetainedNodes,
-Metadata *ThrownTypes)
+Metadata *ThrownTypes, Metadata *Annotations)
   : Scope(Scope), Name(Name), LinkageName(LinkageName), File(File),
 Line(Line), Type(Type), ScopeLine(ScopeLine),
 ContainingType(ContainingType), 

[PATCH] D106616: [Clang][LLVM] generate btf_tag annotations for DIDerived types

2021-07-22 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song created this revision.
yonghong-song added reviewers: dblaikie, probinson, aprantl, aaron.ballman.
yonghong-song added a project: debug-info.
Herald added subscribers: dexonsmith, ormris, hiraditya.
yonghong-song requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Generate btf_tag annotations for DIDrived types. More specifically,
clang frontend generates the btf_tag annotations for record
fields. The annotations are represented as an DINodeArray
in DebugInfo. The following example illustrate how 
annotations are encoded in IR:

  distinct !DIDerivedType(tag: DW_TAG_member, ..., annotations: !10)
  !10 = !{!11, !12}
  !11 = !{!"btf_tag", !"a"}
  !12 = !{!"btf_tag", !"b"}


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106616

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/attr-btf_tag-field.c
  llvm/include/llvm/IR/DebugInfoMetadata.h
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/Bitcode/Reader/MetadataLoader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/DebugInfoMetadata.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/test/Bitcode/attr-btf_tag-field.ll

Index: llvm/test/Bitcode/attr-btf_tag-field.ll
===
--- /dev/null
+++ llvm/test/Bitcode/attr-btf_tag-field.ll
@@ -0,0 +1,36 @@
+; REQUIRES: x86-registered-target
+; RUN: llvm-as < %s | llvm-dis | FileCheck %s
+
+%struct.t = type { i32 }
+
+@g = dso_local local_unnamed_addr global %struct.t zeroinitializer, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!2}
+!llvm.module.flags = !{!13, !14, !15, !16}
+!llvm.ident = !{!17}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = distinct !DIGlobalVariable(name: "g", scope: !2, file: !3, line: 2, type: !6, isLocal: false, isDefinition: true)
+!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 13.0.0 (https://github.com/llvm/llvm-project.git 1b8d548385089fd516c11cd69d20c4ad33cae328)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, splitDebugInlining: false, nameTableKind: None)
+!3 = !DIFile(filename: "struct.c", directory: "/home/yhs/work/tests/llvm/btf_tag")
+!4 = !{}
+!5 = !{!0}
+!6 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t", file: !3, line: 1, size: 32, elements: !7)
+!7 = !{!8}
+!8 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !6, file: !3, line: 1, baseType: !9, size: 32, annotations: !10)
+!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!10 = !{!11, !12}
+!11 = !{!"btf_tag", !"a"}
+!12 = !{!"btf_tag", !"b"}
+
+; CHECK:!DIDerivedType(tag: DW_TAG_member, name: "a"
+; CHECK-SAME:   annotations: ![[ANNOT:[0-9]+]]
+; CHECK:![[ANNOT]] = !{![[TAG1:[0-9]+]], ![[TAG2:[0-9]+]]}
+; CHECK:![[TAG1]] = !{!"btf_tag", !"a"}
+; CHECK:![[TAG2]] = !{!"btf_tag", !"b"}
+
+!13 = !{i32 7, !"Dwarf Version", i32 4}
+!14 = !{i32 2, !"Debug Info Version", i32 3}
+!15 = !{i32 1, !"wchar_size", i32 4}
+!16 = !{i32 7, !"uwtable", i32 1}
+!17 = !{!"clang version 13.0.0 (https://github.com/llvm/llvm-project.git 1b8d548385089fd516c11cd69d20c4ad33cae328)"}
Index: llvm/lib/IR/LLVMContextImpl.h
===
--- llvm/lib/IR/LLVMContextImpl.h
+++ llvm/lib/IR/LLVMContextImpl.h
@@ -471,23 +471,24 @@
   Optional DWARFAddressSpace;
   unsigned Flags;
   Metadata *ExtraData;
+  Metadata *Annotations;
 
   MDNodeKeyImpl(unsigned Tag, MDString *Name, Metadata *File, unsigned Line,
 Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
 uint32_t AlignInBits, uint64_t OffsetInBits,
 Optional DWARFAddressSpace, unsigned Flags,
-Metadata *ExtraData)
+Metadata *ExtraData, Metadata *Annotations)
   : Tag(Tag), Name(Name), File(File), Line(Line), Scope(Scope),
 BaseType(BaseType), SizeInBits(SizeInBits), OffsetInBits(OffsetInBits),
 AlignInBits(AlignInBits), DWARFAddressSpace(DWARFAddressSpace),
-Flags(Flags), ExtraData(ExtraData) {}
+Flags(Flags), ExtraData(ExtraData), Annotations(Annotations) {}
   MDNodeKeyImpl(const DIDerivedType *N)
   : Tag(N->getTag()), Name(N->getRawName()), File(N->getRawFile()),
 Line(N->getLine()), Scope(N->getRawScope()),
 BaseType(N->getRawBaseType()), SizeInBits(N->getSizeInBits()),
 OffsetInBits(N->getOffsetInBits()), AlignInBits(N->getAlignInBits()),
 DWARFAddressSpace(N->getDWARFAddressSpace()), Flags(N->getFlags()),
-ExtraData(N->getRawExtraData()) {}
+ExtraData(N->getRawExtraData()), Annotations(N->getRawAnnotations()) {}
 
   bool isKeyOf(const DIDerivedType *RHS) const {
 return Tag == RHS->getTag() && Name == RHS->getRawName() &&
@@ -498,7 +499,8 @@
OffsetInBits == RHS->getOffsetInBits() &&

[PATCH] D106615: [Clang][LLVM] generate btf_tag annotations for DIComposite types

2021-07-22 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song created this revision.
yonghong-song added reviewers: dblaikie, probinson, aprantl, aaron.ballman, ast.
yonghong-song added a project: debug-info.
Herald added subscribers: dexonsmith, ormris, hiraditya.
yonghong-song requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Generate btf_tag annotations for DIComposite types.
A field "annotations" is introduced to DIComposite, and the 
annotations are represented as an DINodeArray, similar to
DIComposite elements. The following example illustrates
how annotations are encoded in IR:

  distinct !DICompositeType(..., annotations: !10)
  !10 = !{!11, !12}
  !11 = !{!"btf_tag", !"a"}
  !12 = !{!"btf_tag", !"b"}

Each btf_tag annotation is represented as a 2D array of
meta strings. Each record may have more than one 
btf_tag annotations, as in the above example.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106615

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/test/CodeGen/attr-btf_tag-dicomposite.c
  llvm/include/llvm/IR/DebugInfoMetadata.h
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/Bitcode/Reader/MetadataLoader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/DebugInfoMetadata.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/test/Bitcode/attr-btf_tag-dicomposite.ll

Index: llvm/test/Bitcode/attr-btf_tag-dicomposite.ll
===
--- /dev/null
+++ llvm/test/Bitcode/attr-btf_tag-dicomposite.ll
@@ -0,0 +1,36 @@
+; REQUIRES: x86-registered-target
+; RUN: llvm-as < %s | llvm-dis | FileCheck %s
+
+%struct.t = type { i32 }
+
+@g = dso_local global %struct.t zeroinitializer, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!2}
+!llvm.module.flags = !{!13, !14, !15, !16, !17}
+!llvm.ident = !{!18}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = distinct !DIGlobalVariable(name: "g", scope: !2, file: !3, line: 2, type: !6, isLocal: false, isDefinition: true)
+!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 13.0.0 (https://github.com/llvm/llvm-project.git a20bed0ba269a4f9b67e58093c50af9ef0730fd1)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, splitDebugInlining: false, nameTableKind: None)
+!3 = !DIFile(filename: "struct.c", directory: "/home/yhs/work/tests/llvm/btf_tag")
+!4 = !{}
+!5 = !{!0}
+!6 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t", file: !3, line: 1, size: 32, elements: !7, annotations: !10)
+!7 = !{!8}
+!8 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !6, file: !3, line: 1, baseType: !9, size: 32)
+!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!10 = !{!11, !12}
+!11 = !{!"btf_tag", !"a"}
+!12 = !{!"btf_tag", !"b"}
+
+; CHECK:distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t"
+; CHECK-SAME:   annotations: ![[ANNOT:[0-9]+]]
+; CHECK:![[ANNOT]] = !{![[TAG1:[0-9]+]], ![[TAG2:[0-9]+]]}
+; CHECK:![[TAG1]] = !{!"btf_tag", !"a"}
+; CHECK:![[TAG2]] = !{!"btf_tag", !"b"}
+!13 = !{i32 7, !"Dwarf Version", i32 4}
+!14 = !{i32 2, !"Debug Info Version", i32 3}
+!15 = !{i32 1, !"wchar_size", i32 4}
+!16 = !{i32 7, !"uwtable", i32 1}
+!17 = !{i32 7, !"frame-pointer", i32 2}
+!18 = !{!"clang version 13.0.0 (https://github.com/llvm/llvm-project.git a20bed0ba269a4f9b67e58093c50af9ef0730fd1)"}
Index: llvm/lib/IR/LLVMContextImpl.h
===
--- llvm/lib/IR/LLVMContextImpl.h
+++ llvm/lib/IR/LLVMContextImpl.h
@@ -569,6 +569,7 @@
   Metadata *Associated;
   Metadata *Allocated;
   Metadata *Rank;
+  Metadata *Annotations;
 
   MDNodeKeyImpl(unsigned Tag, MDString *Name, Metadata *File, unsigned Line,
 Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
@@ -577,14 +578,15 @@
 Metadata *VTableHolder, Metadata *TemplateParams,
 MDString *Identifier, Metadata *Discriminator,
 Metadata *DataLocation, Metadata *Associated,
-Metadata *Allocated, Metadata *Rank)
+Metadata *Allocated, Metadata *Rank, Metadata *Annotations)
   : Tag(Tag), Name(Name), File(File), Line(Line), Scope(Scope),
 BaseType(BaseType), SizeInBits(SizeInBits), OffsetInBits(OffsetInBits),
 AlignInBits(AlignInBits), Flags(Flags), Elements(Elements),
 RuntimeLang(RuntimeLang), VTableHolder(VTableHolder),
 TemplateParams(TemplateParams), Identifier(Identifier),
 Discriminator(Discriminator), DataLocation(DataLocation),
-Associated(Associated), Allocated(Allocated), Rank(Rank) {}
+Associated(Associated), Allocated(Allocated), Rank(Rank),
+Annotations(Annotations) {}
   MDNodeKeyImpl(const DICompositeType *N)
   : Tag(N->getTag()), Name(N->getRawName()), File(N->getRawFile()),
   

[PATCH] D106614: [Clang] add btf_tag attribute

2021-07-22 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song created this revision.
yonghong-song added reviewers: dblaikie, probinson, aprantl, aaron.ballman, ast.
yonghong-song added a project: debug-info.
Herald added a subscriber: jdoerfert.
yonghong-song requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

A new attribute btf_tag is added. The syntax looks like

  __attribute__((btf_tag()))

Users may tag a particular structure/member/function/variable
declaration with an arbitrary string and the intention is
that this string is passed to dwarf so it is available for 
post-compilation analysis. The string will be also passed
to .BTF section if the target is BPF.  For detailed use cases,
please see

  https://lists.llvm.org/pipermail/llvm-dev/2021-June/151009.html


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106614

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/attr-btf_tag.c

Index: clang/test/Sema/attr-btf_tag.c
===
--- /dev/null
+++ clang/test/Sema/attr-btf_tag.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -x c -triple x86_64-pc-linux-gnu -dwarf-version=4 -fsyntax-only -verify %s
+
+#define __tag __attribute__((btf_tag("tag")))
+#define __invalid __attribute__((btf_tag(1)))
+
+struct t1 {
+  int a __tag;
+} __tag;
+
+int g1 __tag;
+int i1 __invalid; // expected-error {{'btf_tag' attribute requires a string}}
+
+int __tag foo(struct t1 __tag *arg) {
+  return arg->a;
+}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -22,6 +22,7 @@
 // CHECK-NEXT: Assumption (SubjectMatchRule_function, SubjectMatchRule_objc_method)
 // CHECK-NEXT: Availability ((SubjectMatchRule_record, SubjectMatchRule_enum, SubjectMatchRule_enum_constant, SubjectMatchRule_field, SubjectMatchRule_function, SubjectMatchRule_namespace, SubjectMatchRule_objc_category, SubjectMatchRule_objc_implementation, SubjectMatchRule_objc_interface, SubjectMatchRule_objc_method, SubjectMatchRule_objc_property, SubjectMatchRule_objc_protocol, SubjectMatchRule_record, SubjectMatchRule_type_alias, SubjectMatchRule_variable))
 // CHECK-NEXT: BPFPreserveAccessIndex (SubjectMatchRule_record)
+// CHECK-NEXT: BTFTag (SubjectMatchRule_variable, SubjectMatchRule_function, SubjectMatchRule_record, SubjectMatchRule_field)
 // CHECK-NEXT: BuiltinAlias (SubjectMatchRule_function)
 // CHECK-NEXT: CFAuditedTransfer (SubjectMatchRule_function)
 // CHECK-NEXT: CFConsumed (SubjectMatchRule_variable_is_parameter)
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -6753,6 +6753,14 @@
   Rec->addAttr(::new (S.Context) BPFPreserveAccessIndexAttr(S.Context, AL));
 }
 
+static void handleBTFTagAttr(Sema , Decl *D, const ParsedAttr ) {
+  StringRef Str;
+  if (!S.checkStringLiteralArgumentAttr(AL, 0, Str))
+return;
+
+  D->addAttr(::new (S.Context) BTFTagAttr(S.Context, AL, Str));
+}
+
 static void handleWebAssemblyExportNameAttr(Sema , Decl *D, const ParsedAttr ) {
   if (!isFunctionOrMethod(D)) {
 S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type)
@@ -7790,6 +7798,9 @@
   case ParsedAttr::AT_BPFPreserveAccessIndex:
 handleBPFPreserveAccessIndexAttr(S, D, AL);
 break;
+  case ParsedAttr::AT_BTFTag:
+handleBTFTagAttr(S, D, AL);
+break;
   case ParsedAttr::AT_WebAssemblyExportName:
 handleWebAssemblyExportNameAttr(S, D, AL);
 break;
Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -2011,6 +2011,16 @@
 struct or union, similar to clang ``__builtin_preserve_access_index()``.
   }];
 }
+def BTFTagDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Clang supports the ``__attribute__((btf_tag("ARGUMENT")))`` attribute for all
+targets. This attribute may be attached to a struct/union, struct/union field,
+function or variables declaration. If -g is specified, the ARGUMENT info will
+be preserved in IR and be emitted to dwarf. For BPF target, the ARGUMENT info
+will be emitted to .BTF ELF section too.
+  }];
+}
 
 def MipsInterruptDocs : Documentation {
   let Category = DocCatFunction;
Index: clang/include/clang/Basic/Attr.td
===
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -1829,6 +1829,14 @@
   let LangOpts = [COnly];
 }
 
+def BTFTag : InheritableAttr {
+  let Spellings = 

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

2021-07-22 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In D105703#2898350 , @vitalybuka 
wrote:

> In D105703#2898343 , @vitalybuka 
> wrote:
>
>> fix crash
>
> weird, my config with -DLLVM_ENABLE_ASSERTIONS=ON does not reproduce, however 
> exact cmake from bot does

-DLLVM_TARGETS_TO_BUILD=X86 was needed as well


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105703

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


[PATCH] D101566: Let -Wweak-template-vtables warn on implicit instantiations

2021-07-22 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert abandoned this revision.
aaronpuchert added a comment.

In D101566#2896911 , @aaron.ballman 
wrote:

> Off-by-default warnings are generally discouraged unless there's a very 
> compelling reason to have them.

There are IMO valuable warnings that can be noisy initially and will probably 
never be on-by-default, like `-Wmissing-prototypes`. There are controversial 
warnings like `-Wshadow` (some people actually like shadowing, others do not). 
There are contradictory warnings like GCC's `-Wswitch-default` and our 
`-Wcovered-switch-default`. Warnings for compatibility with older standards. 
Warnings about certain implicit casts that are way too noisy in many code 
bases, but some might want them. Only having on-by-default warnings is just not 
realistic, there will always be many exceptions. Partly because the language 
moves on, but code needs time to catch up.

But in any event, my goal here wasn't to introduce this warning, just to fix 
it, given that it's there.

>> That was a valid reason, but now there are code bases that work with 
>> -Weverything and disable the warnings they are not interested in.
>
> -Weverything is not a particularly compelling use case IMO. We tell people 
> not to enable it and expect good things to happen over time.

That was in response to off-by-default warnings remaining unused.

> If I'm following along properly, my suggestion would be to commit the 
> uncontentious bit (silencing the diagnostic in the problematic cases) in this 
> review.

Silencing it in problematic cases means never emitting it at all. So you agree 
with @dblaikie that it should be removed.

> If still desired, we can always start a new review to see if there's 
> sentiment for the new warning behavior (under the existing diagnostic name or 
> under a new one), but hopefully the proposed new behavior would be palatable 
> for an on-by-default warning as that's more compelling than tweaks to an 
> off-by-default warning that the original author isn't sure should even exist.

Likely not.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101566

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


[PATCH] D106315: [HIP] Preserve ASAN bitcode library functions

2021-07-22 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

LGTM in general.

One question -- does it have to be a function calling other functions just for 
the sake of preserving them?
Can it be a flat array of pointers to the functions you need to keep around?


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

https://reviews.llvm.org/D106315

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


[PATCH] D106611: [WebAssembly][NFC] Update test expectations labels after db7efcab7dd9

2021-07-22 Thread Thomas Lively via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG481084f669e1: [WebAssembly][NFC] Update test expectations 
labels after db7efcab7dd9 (authored by tlively).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106611

Files:
  clang/test/Headers/wasm.c

Index: clang/test/Headers/wasm.c
===
--- clang/test/Headers/wasm.c
+++ clang/test/Headers/wasm.c
@@ -458,8 +458,8 @@
 // CHECK-LABEL: @test_i8x16_extract_lane(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i32> [[A:%.*]] to <16 x i8>
-// CHECK-NEXT:[[TMP1:%.*]] = extractelement <16 x i8> [[TMP0]], i32 15
-// CHECK-NEXT:ret i8 [[TMP1]]
+// CHECK-NEXT:[[VECEXT_I:%.*]] = extractelement <16 x i8> [[TMP0]], i32 15
+// CHECK-NEXT:ret i8 [[VECEXT_I]]
 //
 int8_t test_i8x16_extract_lane(v128_t a) {
   return wasm_i8x16_extract_lane(a, 15);
@@ -468,8 +468,8 @@
 // CHECK-LABEL: @test_u8x16_extract_lane(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i32> [[A:%.*]] to <16 x i8>
-// CHECK-NEXT:[[TMP1:%.*]] = extractelement <16 x i8> [[TMP0]], i32 15
-// CHECK-NEXT:ret i8 [[TMP1]]
+// CHECK-NEXT:[[VECEXT_I:%.*]] = extractelement <16 x i8> [[TMP0]], i32 15
+// CHECK-NEXT:ret i8 [[VECEXT_I]]
 //
 uint8_t test_u8x16_extract_lane(v128_t a) {
   return wasm_u8x16_extract_lane(a, 15);
@@ -478,9 +478,9 @@
 // CHECK-LABEL: @test_i8x16_replace_lane(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i32> [[A:%.*]] to <16 x i8>
-// CHECK-NEXT:[[TMP1:%.*]] = insertelement <16 x i8> [[TMP0]], i8 [[B:%.*]], i32 15
-// CHECK-NEXT:[[TMP2:%.*]] = bitcast <16 x i8> [[TMP1]] to <4 x i32>
-// CHECK-NEXT:ret <4 x i32> [[TMP2]]
+// CHECK-NEXT:[[VECINS_I:%.*]] = insertelement <16 x i8> [[TMP0]], i8 [[B:%.*]], i32 15
+// CHECK-NEXT:[[TMP1:%.*]] = bitcast <16 x i8> [[VECINS_I]] to <4 x i32>
+// CHECK-NEXT:ret <4 x i32> [[TMP1]]
 //
 v128_t test_i8x16_replace_lane(v128_t a, int8_t b) {
   return wasm_i8x16_replace_lane(a, 15, b);
@@ -500,8 +500,8 @@
 // CHECK-LABEL: @test_i16x8_extract_lane(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i32> [[A:%.*]] to <8 x i16>
-// CHECK-NEXT:[[TMP1:%.*]] = extractelement <8 x i16> [[TMP0]], i32 7
-// CHECK-NEXT:ret i16 [[TMP1]]
+// CHECK-NEXT:[[VECEXT_I:%.*]] = extractelement <8 x i16> [[TMP0]], i32 7
+// CHECK-NEXT:ret i16 [[VECEXT_I]]
 //
 int16_t test_i16x8_extract_lane(v128_t a) {
   return wasm_i16x8_extract_lane(a, 7);
@@ -510,8 +510,8 @@
 // CHECK-LABEL: @test_u16x8_extract_lane(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i32> [[A:%.*]] to <8 x i16>
-// CHECK-NEXT:[[TMP1:%.*]] = extractelement <8 x i16> [[TMP0]], i32 7
-// CHECK-NEXT:ret i16 [[TMP1]]
+// CHECK-NEXT:[[VECEXT_I:%.*]] = extractelement <8 x i16> [[TMP0]], i32 7
+// CHECK-NEXT:ret i16 [[VECEXT_I]]
 //
 uint16_t test_u16x8_extract_lane(v128_t a) {
   return wasm_u16x8_extract_lane(a, 7);
@@ -520,9 +520,9 @@
 // CHECK-LABEL: @test_i16x8_replace_lane(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i32> [[A:%.*]] to <8 x i16>
-// CHECK-NEXT:[[TMP1:%.*]] = insertelement <8 x i16> [[TMP0]], i16 [[B:%.*]], i32 7
-// CHECK-NEXT:[[TMP2:%.*]] = bitcast <8 x i16> [[TMP1]] to <4 x i32>
-// CHECK-NEXT:ret <4 x i32> [[TMP2]]
+// CHECK-NEXT:[[VECINS_I:%.*]] = insertelement <8 x i16> [[TMP0]], i16 [[B:%.*]], i32 7
+// CHECK-NEXT:[[TMP1:%.*]] = bitcast <8 x i16> [[VECINS_I]] to <4 x i32>
+// CHECK-NEXT:ret <4 x i32> [[TMP1]]
 //
 v128_t test_i16x8_replace_lane(v128_t a, int16_t b) {
   return wasm_i16x8_replace_lane(a, 7, b);
@@ -540,8 +540,8 @@
 
 // CHECK-LABEL: @test_i32x4_extract_lane(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = extractelement <4 x i32> [[A:%.*]], i32 3
-// CHECK-NEXT:ret i32 [[TMP0]]
+// CHECK-NEXT:[[VECEXT_I:%.*]] = extractelement <4 x i32> [[A:%.*]], i32 3
+// CHECK-NEXT:ret i32 [[VECEXT_I]]
 //
 int32_t test_i32x4_extract_lane(v128_t a) {
   return wasm_i32x4_extract_lane(a, 3);
@@ -549,8 +549,8 @@
 
 // CHECK-LABEL: @test_i32x4_replace_lane(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = insertelement <4 x i32> [[A:%.*]], i32 [[B:%.*]], i32 3
-// CHECK-NEXT:ret <4 x i32> [[TMP0]]
+// CHECK-NEXT:[[VECINS_I:%.*]] = insertelement <4 x i32> [[A:%.*]], i32 [[B:%.*]], i32 3
+// CHECK-NEXT:ret <4 x i32> [[VECINS_I]]
 //
 v128_t test_i32x4_replace_lane(v128_t a, int32_t b) {
   return wasm_i32x4_replace_lane(a, 3, b);
@@ -570,8 +570,8 @@
 // CHECK-LABEL: @test_i64x2_extract_lane(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i32> [[A:%.*]] to <2 x i64>
-// CHECK-NEXT:[[TMP1:%.*]] = extractelement <2 x i64> [[TMP0]], 

[clang] 481084f - [WebAssembly][NFC] Update test expectations labels after db7efcab7dd9

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

Author: Thomas Lively
Date: 2021-07-22T16:31:12-07:00
New Revision: 481084f669e10beb89b2e1a75bc67e7fb8125941

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

LOG: [WebAssembly][NFC] Update test expectations labels after db7efcab7dd9

Commit db7efcab7dd9 changed the implementations of the wasm_*_extract_lane and
wasm_*_replace_lane intrinsics from using builtin functions to using the
standard vector extensions. This did not change the resulting IR, but it changes
how update_cc_test_checks.py labels values in the IR. This commit simply updates
those labels.

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

Added: 


Modified: 
clang/test/Headers/wasm.c

Removed: 




diff  --git a/clang/test/Headers/wasm.c b/clang/test/Headers/wasm.c
index bcf48a7c37ff..f4e08dda8c4e 100644
--- a/clang/test/Headers/wasm.c
+++ b/clang/test/Headers/wasm.c
@@ -458,8 +458,8 @@ v128_t test_i8x16_splat(int8_t a) {
 // CHECK-LABEL: @test_i8x16_extract_lane(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i32> [[A:%.*]] to <16 x i8>
-// CHECK-NEXT:[[TMP1:%.*]] = extractelement <16 x i8> [[TMP0]], i32 15
-// CHECK-NEXT:ret i8 [[TMP1]]
+// CHECK-NEXT:[[VECEXT_I:%.*]] = extractelement <16 x i8> [[TMP0]], i32 15
+// CHECK-NEXT:ret i8 [[VECEXT_I]]
 //
 int8_t test_i8x16_extract_lane(v128_t a) {
   return wasm_i8x16_extract_lane(a, 15);
@@ -468,8 +468,8 @@ int8_t test_i8x16_extract_lane(v128_t a) {
 // CHECK-LABEL: @test_u8x16_extract_lane(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i32> [[A:%.*]] to <16 x i8>
-// CHECK-NEXT:[[TMP1:%.*]] = extractelement <16 x i8> [[TMP0]], i32 15
-// CHECK-NEXT:ret i8 [[TMP1]]
+// CHECK-NEXT:[[VECEXT_I:%.*]] = extractelement <16 x i8> [[TMP0]], i32 15
+// CHECK-NEXT:ret i8 [[VECEXT_I]]
 //
 uint8_t test_u8x16_extract_lane(v128_t a) {
   return wasm_u8x16_extract_lane(a, 15);
@@ -478,9 +478,9 @@ uint8_t test_u8x16_extract_lane(v128_t a) {
 // CHECK-LABEL: @test_i8x16_replace_lane(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i32> [[A:%.*]] to <16 x i8>
-// CHECK-NEXT:[[TMP1:%.*]] = insertelement <16 x i8> [[TMP0]], i8 
[[B:%.*]], i32 15
-// CHECK-NEXT:[[TMP2:%.*]] = bitcast <16 x i8> [[TMP1]] to <4 x i32>
-// CHECK-NEXT:ret <4 x i32> [[TMP2]]
+// CHECK-NEXT:[[VECINS_I:%.*]] = insertelement <16 x i8> [[TMP0]], i8 
[[B:%.*]], i32 15
+// CHECK-NEXT:[[TMP1:%.*]] = bitcast <16 x i8> [[VECINS_I]] to <4 x i32>
+// CHECK-NEXT:ret <4 x i32> [[TMP1]]
 //
 v128_t test_i8x16_replace_lane(v128_t a, int8_t b) {
   return wasm_i8x16_replace_lane(a, 15, b);
@@ -500,8 +500,8 @@ v128_t test_i16x8_splat(int16_t a) {
 // CHECK-LABEL: @test_i16x8_extract_lane(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i32> [[A:%.*]] to <8 x i16>
-// CHECK-NEXT:[[TMP1:%.*]] = extractelement <8 x i16> [[TMP0]], i32 7
-// CHECK-NEXT:ret i16 [[TMP1]]
+// CHECK-NEXT:[[VECEXT_I:%.*]] = extractelement <8 x i16> [[TMP0]], i32 7
+// CHECK-NEXT:ret i16 [[VECEXT_I]]
 //
 int16_t test_i16x8_extract_lane(v128_t a) {
   return wasm_i16x8_extract_lane(a, 7);
@@ -510,8 +510,8 @@ int16_t test_i16x8_extract_lane(v128_t a) {
 // CHECK-LABEL: @test_u16x8_extract_lane(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i32> [[A:%.*]] to <8 x i16>
-// CHECK-NEXT:[[TMP1:%.*]] = extractelement <8 x i16> [[TMP0]], i32 7
-// CHECK-NEXT:ret i16 [[TMP1]]
+// CHECK-NEXT:[[VECEXT_I:%.*]] = extractelement <8 x i16> [[TMP0]], i32 7
+// CHECK-NEXT:ret i16 [[VECEXT_I]]
 //
 uint16_t test_u16x8_extract_lane(v128_t a) {
   return wasm_u16x8_extract_lane(a, 7);
@@ -520,9 +520,9 @@ uint16_t test_u16x8_extract_lane(v128_t a) {
 // CHECK-LABEL: @test_i16x8_replace_lane(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i32> [[A:%.*]] to <8 x i16>
-// CHECK-NEXT:[[TMP1:%.*]] = insertelement <8 x i16> [[TMP0]], i16 
[[B:%.*]], i32 7
-// CHECK-NEXT:[[TMP2:%.*]] = bitcast <8 x i16> [[TMP1]] to <4 x i32>
-// CHECK-NEXT:ret <4 x i32> [[TMP2]]
+// CHECK-NEXT:[[VECINS_I:%.*]] = insertelement <8 x i16> [[TMP0]], i16 
[[B:%.*]], i32 7
+// CHECK-NEXT:[[TMP1:%.*]] = bitcast <8 x i16> [[VECINS_I]] to <4 x i32>
+// CHECK-NEXT:ret <4 x i32> [[TMP1]]
 //
 v128_t test_i16x8_replace_lane(v128_t a, int16_t b) {
   return wasm_i16x8_replace_lane(a, 7, b);
@@ -540,8 +540,8 @@ v128_t test_i32x4_splat(int32_t a) {
 
 // CHECK-LABEL: @test_i32x4_extract_lane(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = extractelement <4 x i32> [[A:%.*]], i32 3
-// CHECK-NEXT:ret i32 [[TMP0]]
+// CHECK-NEXT:[[VECEXT_I:%.*]] = extractelement <4 x i32> [[A:%.*]], i32 3
+// CHECK-NEXT:ret i32 [[VECEXT_I]]
 //

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

2021-07-22 Thread Vitaly Buka 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 rG96c63492cb95: [hwasan] Use stack safety analysis. (authored 
by fmayer, committed by vitalybuka).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105703

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

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

[clang] 96c6349 - [hwasan] Use stack safety analysis.

2021-07-22 Thread Vitaly Buka via cfe-commits

Author: Florian Mayer
Date: 2021-07-22T16:20:27-07:00
New Revision: 96c63492cb952431fd9732146663fe227f8c52c1

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

LOG: [hwasan] Use stack safety analysis.

This avoids unnecessary instrumentation.

Reviewed By: eugenis, vitalybuka

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

Added: 
clang/test/CodeGen/hwasan-stack-safety-analysis.c
llvm/test/Instrumentation/HWAddressSanitizer/stack-safety-analysis.ll

Modified: 
clang/lib/CodeGen/BackendUtil.cpp
llvm/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h
llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 9aa67ed2a67ba..481f5347d978b 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -314,14 +314,19 @@ static void addHWAddressSanitizerPasses(const 
PassManagerBuilder ,
   static_cast(Builder);
   const CodeGenOptions  = BuilderWrapper.getCGOpts();
   bool Recover = CGOpts.SanitizeRecover.has(SanitizerKind::HWAddress);
-  PM.add(
-  createHWAddressSanitizerLegacyPassPass(/*CompileKernel*/ false, 
Recover));
+  PM.add(createHWAddressSanitizerLegacyPassPass(
+  /*CompileKernel*/ false, Recover,
+  /*DisableOptimization*/ CGOpts.OptimizationLevel == 0));
 }
 
 static void addKernelHWAddressSanitizerPasses(const PassManagerBuilder 
,
-legacy::PassManagerBase ) {
+  legacy::PassManagerBase ) {
+  const PassManagerBuilderWrapper  =
+  static_cast(Builder);
+  const CodeGenOptions  = BuilderWrapper.getCGOpts();
   PM.add(createHWAddressSanitizerLegacyPassPass(
-  /*CompileKernel*/ true, /*Recover*/ true));
+  /*CompileKernel*/ true, /*Recover*/ true,
+  /*DisableOptimization*/ CGOpts.OptimizationLevel == 0));
 }
 
 static void addGeneralOptsForMemorySanitizer(const PassManagerBuilder ,
@@ -1164,7 +1169,9 @@ static void addSanitizers(const Triple ,
 auto HWASanPass = [&](SanitizerMask Mask, bool CompileKernel) {
   if (LangOpts.Sanitize.has(Mask)) {
 bool Recover = CodeGenOpts.SanitizeRecover.has(Mask);
-MPM.addPass(HWAddressSanitizerPass(CompileKernel, Recover));
+MPM.addPass(HWAddressSanitizerPass(
+CompileKernel, Recover,
+/*DisableOptimization=*/CodeGenOpts.OptimizationLevel == 0));
   }
 };
 HWASanPass(SanitizerKind::HWAddress, false);

diff  --git a/clang/test/CodeGen/hwasan-stack-safety-analysis.c 
b/clang/test/CodeGen/hwasan-stack-safety-analysis.c
new file mode 100644
index 0..5c4f34027bacd
--- /dev/null
+++ b/clang/test/CodeGen/hwasan-stack-safety-analysis.c
@@ -0,0 +1,15 @@
+// RUN: %clang -fsanitize=hwaddress -target aarch64-linux-gnu -S -emit-llvm 
-mllvm -hwasan-use-stack-safety=true -mllvm -hwasan-generate-tags-with-calls 
-O2 %s -o - | FileCheck %s --check-prefix=SAFETY
+// RUN: %clang -fsanitize=hwaddress -target aarch64-linux-gnu -S -emit-llvm 
-mllvm -hwasan-use-stack-safety=false -mllvm -hwasan-generate-tags-with-calls 
-O2 %s -o - | FileCheck %s --check-prefix=NOSAFETY
+
+// Default when optimizing, but not with O0.
+// RUN: %clang -fsanitize=hwaddress -target aarch64-linux-gnu -S -emit-llvm 
-mllvm -hwasan-generate-tags-with-calls -O2 %s -o - | FileCheck %s 
--check-prefix=SAFETY
+// RUN: %clang -fsanitize=hwaddress -target aarch64-linux-gnu -S -emit-llvm 
-mllvm -hwasan-generate-tags-with-calls -O0 %s -o - | FileCheck %s 
--check-prefix=NOSAFETY
+
+int main(int argc, char **argv) {
+  char buf[10];
+  volatile char *x = buf;
+  *x = 0;
+  return buf[0];
+  // NOSAFETY: __hwasan_generate_tag
+  // SAFETY-NOT: __hwasan_generate_tag
+}

diff  --git a/llvm/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h 
b/llvm/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h
index 76e02f06435c3..2e4f3338030a4 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h
@@ -25,17 +25,21 @@ namespace llvm {
 class HWAddressSanitizerPass : public PassInfoMixin {
 public:
   explicit HWAddressSanitizerPass(bool CompileKernel = false,
-  bool Recover = false);
+  bool Recover = false,
+  bool DisableOptimization = false);
   PreservedAnalyses run(Module , ModuleAnalysisManager );
   static bool isRequired() { return true; }
 
 private:
   bool CompileKernel;
   bool Recover;
+  bool DisableOptimization;
 };
 
-FunctionPass *createHWAddressSanitizerLegacyPassPass(bool CompileKernel = 
false,
-

[PATCH] D95588: [RISCV] Implement the MC layer support of P extension

2021-07-22 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

Oh, technically none of the clang changes belong in this patch. Those are for 
the Clang driver and preprocessor, not the MC layer which is purely llvm.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95588

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


[PATCH] D95588: [RISCV] Implement the MC layer support of P extension

2021-07-22 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

I can't help but feel the assembly syntax for the register pair instructions 
shouldn't include both registers (perhaps in curly braces). The implicit use of 
the other register when reading the source is rather ugly, and particularly 
hard to remember when the RV64 versions *don't* do that.




Comment at: llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp:442
+
+if (STI.getFeatureBits()[RISCV::FeatureExtZpsfoperand] &&
+!STI.getFeatureBits()[RISCV::Feature64Bit]) {

The table is called RISCV32POnly but you're checking for Zpsfoperand (whatever 
that mouthful of an extension is). Which is it?



Comment at: llvm/lib/Target/RISCV/RISCV.td:186-188
+   [FeatureExtZpsfoperand,
+FeatureExtZpn,
+FeatureExtZprvsfextra]>;

These aren't correct? RV64 doesn't have Zpsfoperand and RV32 doesn't have 
Zprvsfextra.



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoP.td:145
+multiclass RVPALU64 funct7, bits<3> funct3, string opcodestr> {
+  let DecoderNamespace = "RISCV32POnly_", Predicates = [HasStdExtZpsfoperand, 
IsRV32] in
+  def "32" : RVPALU64Pair;

These lines look too long to me



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoP.td:176-177
+}
+
+
+let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in

 



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoP.td:231
+def CLRS8 : RVPUnary<0b1010111, 0b0, 0b000, "clrs8">,
+Sched<[]>;
+def CLRS16: RVPUnary<0b1010111, 0b01000, 0b000, "clrs16">,

Should probably have a TODO: to add scheduling information for these otherwise 
it'll get lost



Comment at: llvm/lib/Target/RISCV/RISCVRegisterInfo.td:216
+// Dummy zero register for pairing with X0.
+def ZERO : RISCVReg<0, "0">;
+

Ew, this is a gross quirk of the register pair instructions. ZERO is not a good 
name for it though, that's the ABI name for x0 so already taken and is pretty 
confusing. I assume LLVM doesn't like it if you create a register pair that is 
(X0, X0)?



Comment at: llvm/lib/Target/RISCV/RISCVRegisterInfo.td:226-228
+def GPRPair : RegisterClass<"RISCV", [untyped], 64, (add GPRPairs)> {
+  let Size = 64;
+}

IMO the register class should be GPR32Pair not GPRPair unless you also make it 
have a sensible interpretation for RV32 (which seems like a waste of time)



Comment at: llvm/lib/Target/RISCV/RISCVRegisterInfo.td:69
 
+def sub_lo : SubRegIndex<32>;
+def sub_hi : SubRegIndex<32, 32>;

Jim wrote:
> Jim wrote:
> > luismarques wrote:
> > > jrtc27 wrote:
> > > > This assumes RV32, and is not clear it applies to register pairs
> > > What's the best way to address this?
> > sub_lo and sub_hi are only used for GPRPair register class to extract a 
> > register from pair registers on RV32.
> Do you mean that sub_lo and sub_hi only used on RV32? Does it need to rename 
> or ..?
Yes, these should have names that make it clear they're for each half of a 
2*32-bit register pair. Otherwise it sounds like they're the 32-bit hi and lo 
halves of the 64-bit registers on RV64.



Comment at: llvm/test/MC/RISCV/rv64zpn-invalid.s:6-24
+# 16-bit shift
+
+# CHECK-ERROR: immediate must be an integer in the range [0, 15]
+srai16 a0, a1, 21
+
+# CHECK-ERROR: immediate must be an integer in the range [0, 15]
+srai16.u a0, a1, 21

This looks mostly the same as rv32zpn-invalid. The common tests should go in 
rv32zpn-invalid and have RV32 and RV64 RUN lines. Any truly RV32-only tests 
belong in something like rv32zpn-only-invalid. Any truly RV64-only tests can 
stay in rv64zpn-invalid.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95588

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


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

2021-07-22 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb updated this revision to Diff 361014.
cjdb marked 12 inline comments as done.
cjdb added a comment.

- applies all of @aaron.ballman's suggested changes
- turns warnings into errors and deletes warning group
- replaces `interleave` with `join`
- properly abandons LF transmuting

The only things that shouldn't be applied are comments with replies (and even 
some of those have been actioned).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106394

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

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

[PATCH] D106612: [WebAssembly] Codegen for pmin and pmax

2021-07-22 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.

Replace the clang builtins and LLVM intrinsics for {f32x4,f64x2}.{pmin,pmax}
with standard codegen patterns. Since wasm_simd128.h uses an integer vector as
the standard single vector type, the IR for the pmin and pmax intrinsic
functions contains bitcasts that would not be there otherwise. Add extra codegen
patterns that can still select the pmin and pmax instructions in the presence of
these bitcasts.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106612

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-arith.ll
  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
@@ -685,26 +685,6 @@
   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{{$}}
@@ -760,26 +740,6 @@
   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/test/CodeGen/WebAssembly/simd-arith.ll
===
--- llvm/test/CodeGen/WebAssembly/simd-arith.ll
+++ llvm/test/CodeGen/WebAssembly/simd-arith.ll
@@ -1409,6 +1409,54 @@
   ret <4 x float> %a
 }
 
+; CHECK-LABEL: pmin_v4f32:
+; NO-SIMD128-NOT: f32x4
+; SIMD128-NEXT: .functype pmin_v4f32 (v128, v128) -> (v128){{$}}
+; SIMD128-NEXT: f32x4.pmin $push[[R:[0-9]+]]=, $0, $1{{$}}
+; SIMD128-NEXT: return $pop[[R]]{{$}}
+define <4 x float> @pmin_v4f32(<4 x float> %x, <4 x float> %y) {
+  %c = fcmp olt <4 x float> %y, %x
+  %a = select <4 x i1> %c, <4 x float> %y, <4 x float> %x
+  ret <4 x float> %a
+}
+
+; CHECK-LABEL: pmin_int_v4f32:
+; NO-SIMD128-NOT: f32x4
+; SIMD128-NEXT: .functype pmin_int_v4f32 (v128, v128) -> (v128){{$}}
+; SIMD128-NEXT: f32x4.pmin $push[[R:[0-9]+]]=, $0, $1{{$}}
+; SIMD128-NEXT: return $pop[[R]]{{$}}
+define <4 x i32> @pmin_int_v4f32(<4 x i32> %x, <4 x i32> %y) {
+  %fx = bitcast <4 x i32> %x to <4 x float>
+  %fy = bitcast <4 x i32> %y to <4 x float>
+  %c = fcmp olt <4 x float> %fy, %fx
+  %a = select <4 x i1> %c, <4 x i32> %y, <4 x i32> %x
+  ret <4 x i32> %a
+}
+
+; CHECK-LABEL: pmax_v4f32:
+; NO-SIMD128-NOT: f32x4
+; SIMD128-NEXT: .functype pmax_v4f32 (v128, v128) -> (v128){{$}}
+; SIMD128-NEXT: f32x4.pmax $push[[R:[0-9]+]]=, $0, $1{{$}}
+; SIMD128-NEXT: return $pop[[R]]{{$}}
+define <4 x float> @pmax_v4f32(<4 x float> %x, <4 x float> %y) {
+  %c = fcmp olt <4 x float> %x, 

[PATCH] D106611: [WebAssembly][NFC] Update test expectations labels after db7efcab7dd9

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

Commit db7efcab7dd9 
 changed 
the implementations of the wasm_*_extract_lane and
wasm_*_replace_lane intrinsics from using builtin functions to using the
standard vector extensions. This did not change the resulting IR, but it changes
how update_cc_test_checks.py labels values in the IR. This commit simply updates
those labels.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106611

Files:
  clang/test/Headers/wasm.c

Index: clang/test/Headers/wasm.c
===
--- clang/test/Headers/wasm.c
+++ clang/test/Headers/wasm.c
@@ -458,8 +458,8 @@
 // CHECK-LABEL: @test_i8x16_extract_lane(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i32> [[A:%.*]] to <16 x i8>
-// CHECK-NEXT:[[TMP1:%.*]] = extractelement <16 x i8> [[TMP0]], i32 15
-// CHECK-NEXT:ret i8 [[TMP1]]
+// CHECK-NEXT:[[VECEXT_I:%.*]] = extractelement <16 x i8> [[TMP0]], i32 15
+// CHECK-NEXT:ret i8 [[VECEXT_I]]
 //
 int8_t test_i8x16_extract_lane(v128_t a) {
   return wasm_i8x16_extract_lane(a, 15);
@@ -468,8 +468,8 @@
 // CHECK-LABEL: @test_u8x16_extract_lane(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i32> [[A:%.*]] to <16 x i8>
-// CHECK-NEXT:[[TMP1:%.*]] = extractelement <16 x i8> [[TMP0]], i32 15
-// CHECK-NEXT:ret i8 [[TMP1]]
+// CHECK-NEXT:[[VECEXT_I:%.*]] = extractelement <16 x i8> [[TMP0]], i32 15
+// CHECK-NEXT:ret i8 [[VECEXT_I]]
 //
 uint8_t test_u8x16_extract_lane(v128_t a) {
   return wasm_u8x16_extract_lane(a, 15);
@@ -478,9 +478,9 @@
 // CHECK-LABEL: @test_i8x16_replace_lane(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i32> [[A:%.*]] to <16 x i8>
-// CHECK-NEXT:[[TMP1:%.*]] = insertelement <16 x i8> [[TMP0]], i8 [[B:%.*]], i32 15
-// CHECK-NEXT:[[TMP2:%.*]] = bitcast <16 x i8> [[TMP1]] to <4 x i32>
-// CHECK-NEXT:ret <4 x i32> [[TMP2]]
+// CHECK-NEXT:[[VECINS_I:%.*]] = insertelement <16 x i8> [[TMP0]], i8 [[B:%.*]], i32 15
+// CHECK-NEXT:[[TMP1:%.*]] = bitcast <16 x i8> [[VECINS_I]] to <4 x i32>
+// CHECK-NEXT:ret <4 x i32> [[TMP1]]
 //
 v128_t test_i8x16_replace_lane(v128_t a, int8_t b) {
   return wasm_i8x16_replace_lane(a, 15, b);
@@ -500,8 +500,8 @@
 // CHECK-LABEL: @test_i16x8_extract_lane(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i32> [[A:%.*]] to <8 x i16>
-// CHECK-NEXT:[[TMP1:%.*]] = extractelement <8 x i16> [[TMP0]], i32 7
-// CHECK-NEXT:ret i16 [[TMP1]]
+// CHECK-NEXT:[[VECEXT_I:%.*]] = extractelement <8 x i16> [[TMP0]], i32 7
+// CHECK-NEXT:ret i16 [[VECEXT_I]]
 //
 int16_t test_i16x8_extract_lane(v128_t a) {
   return wasm_i16x8_extract_lane(a, 7);
@@ -510,8 +510,8 @@
 // CHECK-LABEL: @test_u16x8_extract_lane(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i32> [[A:%.*]] to <8 x i16>
-// CHECK-NEXT:[[TMP1:%.*]] = extractelement <8 x i16> [[TMP0]], i32 7
-// CHECK-NEXT:ret i16 [[TMP1]]
+// CHECK-NEXT:[[VECEXT_I:%.*]] = extractelement <8 x i16> [[TMP0]], i32 7
+// CHECK-NEXT:ret i16 [[VECEXT_I]]
 //
 uint16_t test_u16x8_extract_lane(v128_t a) {
   return wasm_u16x8_extract_lane(a, 7);
@@ -520,9 +520,9 @@
 // CHECK-LABEL: @test_i16x8_replace_lane(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i32> [[A:%.*]] to <8 x i16>
-// CHECK-NEXT:[[TMP1:%.*]] = insertelement <8 x i16> [[TMP0]], i16 [[B:%.*]], i32 7
-// CHECK-NEXT:[[TMP2:%.*]] = bitcast <8 x i16> [[TMP1]] to <4 x i32>
-// CHECK-NEXT:ret <4 x i32> [[TMP2]]
+// CHECK-NEXT:[[VECINS_I:%.*]] = insertelement <8 x i16> [[TMP0]], i16 [[B:%.*]], i32 7
+// CHECK-NEXT:[[TMP1:%.*]] = bitcast <8 x i16> [[VECINS_I]] to <4 x i32>
+// CHECK-NEXT:ret <4 x i32> [[TMP1]]
 //
 v128_t test_i16x8_replace_lane(v128_t a, int16_t b) {
   return wasm_i16x8_replace_lane(a, 7, b);
@@ -540,8 +540,8 @@
 
 // CHECK-LABEL: @test_i32x4_extract_lane(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = extractelement <4 x i32> [[A:%.*]], i32 3
-// CHECK-NEXT:ret i32 [[TMP0]]
+// CHECK-NEXT:[[VECEXT_I:%.*]] = extractelement <4 x i32> [[A:%.*]], i32 3
+// CHECK-NEXT:ret i32 [[VECEXT_I]]
 //
 int32_t test_i32x4_extract_lane(v128_t a) {
   return wasm_i32x4_extract_lane(a, 3);
@@ -549,8 +549,8 @@
 
 // CHECK-LABEL: @test_i32x4_replace_lane(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = insertelement <4 x i32> [[A:%.*]], i32 [[B:%.*]], i32 3
-// CHECK-NEXT:ret <4 x i32> [[TMP0]]
+// CHECK-NEXT:[[VECINS_I:%.*]] = insertelement <4 x i32> [[A:%.*]], i32 [[B:%.*]], i32 3
+// CHECK-NEXT:ret <4 x i32> 

[PATCH] D106583: [clang] SIGSEGV at DeduceTemplateArgumentsByTypeMatch

2021-07-22 Thread Ivan Murashko via Phabricator via cfe-commits
ivanmurashko updated this revision to Diff 361005.
ivanmurashko added a comment.

LIT test was updated


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106583

Files:
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/SemaCXX/pr51171-crash.cpp


Index: clang/test/SemaCXX/pr51171-crash.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/pr51171-crash.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
+
+// Ensure that we don't crash if errors are suppressed by an error limit.
+// RUN: not %clang_cc1 -fsyntax-only -std=c++17 -ferror-limit 1 %s
+
+template 
+struct tv_val {
+};
+
+template 
+auto (const tv_val ) { return val.val(); } // expected-note 
{{possible target for call}}
+
+struct Class {
+  template 
+  struct Entry {
+tv_val val;
+  };
+};
+
+enum Types : int {
+  Class = 1, // expected-note 2 {{struct 'Class' is hidden}}
+};
+
+struct Record {
+  Class *val_;// expected-error {{must use 'struct' tag}}
+  void setClass(Class *); // expected-error {{must use 'struct' tag}}
+};
+
+void Record::setClass(Class *val) { // expected-error {{variable has 
incomplete type 'void'}} \
+   // expected-error {{reference to overloaded 
function}} \
+   // expected-error {{expected ';' after top 
level declarator}}
+  val_ = val;
+}
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -4346,7 +4346,7 @@
 HasDeducedReturnType = true;
   }
 
-  if (!ArgFunctionType.isNull()) {
+  if (!ArgFunctionType.isNull() && !FunctionType.isNull()) {
 unsigned TDF =
 TDF_TopLevelParameterTypeList | TDF_AllowCompatibleFunctionType;
 // Deduce template arguments from the function type.


Index: clang/test/SemaCXX/pr51171-crash.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/pr51171-crash.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
+
+// Ensure that we don't crash if errors are suppressed by an error limit.
+// RUN: not %clang_cc1 -fsyntax-only -std=c++17 -ferror-limit 1 %s
+
+template 
+struct tv_val {
+};
+
+template 
+auto (const tv_val ) { return val.val(); } // expected-note {{possible target for call}}
+
+struct Class {
+  template 
+  struct Entry {
+tv_val val;
+  };
+};
+
+enum Types : int {
+  Class = 1, // expected-note 2 {{struct 'Class' is hidden}}
+};
+
+struct Record {
+  Class *val_;// expected-error {{must use 'struct' tag}}
+  void setClass(Class *); // expected-error {{must use 'struct' tag}}
+};
+
+void Record::setClass(Class *val) { // expected-error {{variable has incomplete type 'void'}} \
+   // expected-error {{reference to overloaded function}} \
+   // expected-error {{expected ';' after top level declarator}}
+  val_ = val;
+}
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -4346,7 +4346,7 @@
 HasDeducedReturnType = true;
   }
 
-  if (!ArgFunctionType.isNull()) {
+  if (!ArgFunctionType.isNull() && !FunctionType.isNull()) {
 unsigned TDF =
 TDF_TopLevelParameterTypeList | TDF_AllowCompatibleFunctionType;
 // Deduce template arguments from the function type.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2021-07-22 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In D105703#2898343 , @vitalybuka 
wrote:

> fix crash

weird, my config with -DLLVM_ENABLE_ASSERTIONS=ON does not reproduce, however 
exact cmake from bot does


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105703

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


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

2021-07-22 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh added a comment.

Some Android developers and legacy code care less about clang-tidy warnings.
Newer developers spend a lot of time to get lint-free new code.
So Android source tree has a lot of clang-tidy flags like
header-filter, checks, and warnings-as-errors to select checks
for different modules. People are even asking for new features like
making header-filter to accept a list of regexp like the checks flag.

If a new change to header-filter or skip-headers lose existing valid warnings,
maybe it will be perfectly acceptable to some but not to people who want to
make code lint-free. To them, these changes are regressions.
A clang-tidy check's owner would not like to lose capability for
some minor performance gain, either.

bugprone-forward-declaration-namespace is just one valid warning found
in a couple of days. Android tree is huge and has disabled many checks,
so we won't know the impact to all checks any time soon. 
If we have a mechanism to keep any special checks from the impact,
like the PPCallback-based checks, it will be much safer to release 
the first phase skip-headers and know that we can fix any bad impact quickly.

I am trying such a mechanism to support "see-all-file" MatchFinder-based checks.
Those checks will be very few, so skip-headers still saves a lot of runtime.
After more tests, I will upload it to D98709 .

Please note that I added a new test skip-headers-2.cpp.
It is extremely simplified, but reflects the need to check a top-level
Decl and ignore warnings in included nested Decls in other files.
If we implement skip-headers based on only top-level Decls,
we won't be able to support such a use case.
In D98709 , we check/skip not only top-level 
Decls.


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

https://reviews.llvm.org/D98710

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


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

2021-07-22 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka updated this revision to Diff 361002.
vitalybuka added a comment.

fix crash


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105703

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

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

[PATCH] D95588: [RISCV] Implement the MC layer support of P extension

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

I think this looks good to me. @luismarques or @jrtc27 any further feedback?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95588

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


[PATCH] D106583: [clang] SIGSEGV at DeduceTemplateArgumentsByTypeMatch

2021-07-22 Thread Ivan Murashko via Phabricator via cfe-commits
ivanmurashko updated this revision to Diff 361001.
ivanmurashko added a comment.

The LIT test was added:

  build] ./bin/llvm-lit -v ../clang/test/SemaCXX/pr51171-crash.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106583

Files:
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/SemaCXX/pr51171-crash.cpp


Index: clang/test/SemaCXX/pr51171-crash.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/pr51171-crash.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
+
+// Ensure that we don't crash if errors are suppressed by an error limit.
+// RUN: not %clang_cc1 -fsyntax-only -std=c++17 -ferror-limit 1 %s
+
+template 
+struct tv_val {
+};
+
+template 
+auto (const tv_val ) { return val.val(); } // expected-note 
{{possible target for call}}
+
+struct Class {
+  template 
+  struct Entry {
+tv_val val;
+  };
+};
+
+enum Types : int {
+  Class = 1, // expected-note {{struct 'Class' is hidden}} \
+   // expected-note {{struct 'Class' is hidden}}
+};
+
+struct Record {
+  Class *val_;// expected-error {{must use 'struct' tag}}
+  void setClass(Class *); // expected-error {{must use 'struct' tag}}
+};
+
+void Record::setClass(Class *val) { // expected-error {{variable has 
incomplete type 'void'}} \
+   // expected-error {{reference to overloaded 
function}} \
+   // expected-error {{expected ';' after top 
level declarator}}
+  val_ = val;
+}
+
+/// expected-fatal {{too many errors emitted, stopping now [-ferror-limit=]}}
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -4346,7 +4346,7 @@
 HasDeducedReturnType = true;
   }
 
-  if (!ArgFunctionType.isNull()) {
+  if (!ArgFunctionType.isNull() && !FunctionType.isNull()) {
 unsigned TDF =
 TDF_TopLevelParameterTypeList | TDF_AllowCompatibleFunctionType;
 // Deduce template arguments from the function type.


Index: clang/test/SemaCXX/pr51171-crash.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/pr51171-crash.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
+
+// Ensure that we don't crash if errors are suppressed by an error limit.
+// RUN: not %clang_cc1 -fsyntax-only -std=c++17 -ferror-limit 1 %s
+
+template 
+struct tv_val {
+};
+
+template 
+auto (const tv_val ) { return val.val(); } // expected-note {{possible target for call}}
+
+struct Class {
+  template 
+  struct Entry {
+tv_val val;
+  };
+};
+
+enum Types : int {
+  Class = 1, // expected-note {{struct 'Class' is hidden}} \
+   // expected-note {{struct 'Class' is hidden}}
+};
+
+struct Record {
+  Class *val_;// expected-error {{must use 'struct' tag}}
+  void setClass(Class *); // expected-error {{must use 'struct' tag}}
+};
+
+void Record::setClass(Class *val) { // expected-error {{variable has incomplete type 'void'}} \
+   // expected-error {{reference to overloaded function}} \
+   // expected-error {{expected ';' after top level declarator}}
+  val_ = val;
+}
+
+/// expected-fatal {{too many errors emitted, stopping now [-ferror-limit=]}}
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -4346,7 +4346,7 @@
 HasDeducedReturnType = true;
   }
 
-  if (!ArgFunctionType.isNull()) {
+  if (!ArgFunctionType.isNull() && !FunctionType.isNull()) {
 unsigned TDF =
 TDF_TopLevelParameterTypeList | TDF_AllowCompatibleFunctionType;
 // Deduce template arguments from the function type.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106585: Fix clang debug info irgen of i128 enums

2021-07-22 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:3117
+llvm::APSInt Value = Enum->getInitVal();
+Value.setIsSigned(IsSigned);
+Enumerators.push_back(DBuilder.createEnumerator(Enum->getName(), Value));

rnk wrote:
> dblaikie wrote:
> > Is the value already signed appropriately?
> > 
> > Removing this line of code (and the `bool IsSigned` variable, so it doesn't 
> > break `-Werror=unused-variable`) doesn't cause any tests to fail, that I 
> > can see.
> I'm afraid it might not be NFC. I took the cautious approach of trying to 
> leave things exactly as they were. Enums in C can have surprisingly different 
> behavior, IIRC.
I'd rather not leave in haunted-graveyard-y code like that.

Could we assert that Value.getIsSigned == IsSigned? Then if there's a case 
where it isn't we'll have a test case/justification for the code?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106585

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


[PATCH] D106582: [DebugInfo] Add -fno-ctor-homing for as counterpart to -fuse-ctor-homing

2021-07-22 Thread Amy Huang 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 rG3e2ad26b08a2: [DebugInfo] Add -fno-ctor-homing for as 
counterpart to -fuse-ctor-homing (authored by akhuang).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106582

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp


Index: clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp
===
--- clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp
+++ clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp
@@ -8,6 +8,9 @@
 // RUN:| FileCheck %s -check-prefix=NO_DEBUG
 // RUN: %clang -cc1 -fuse-ctor-homing -emit-llvm %s -o - \
 // RUN:| FileCheck %s -check-prefix=NO_DEBUG
+//
+// RUN: %clang -cc1 -debug-info-kind=constructor -fno-use-ctor-homing \
+// RUN:-emit-llvm %s -o - | FileCheck %s -check-prefix=FULL_DEBUG
 
 // This tests that the -fuse-ctor-homing is only used if limited debug info 
would have
 // been used otherwise.
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1369,9 +1369,6 @@
   if (DebugInfoVal)
 GenerateArg(Args, OPT_debug_info_kind_EQ, *DebugInfoVal, SA);
 
-  if (Opts.DebugInfo == codegenoptions::DebugInfoConstructor)
-GenerateArg(Args, OPT_fuse_ctor_homing, SA);
-
   for (const auto  : Opts.DebugPrefixMap)
 GenerateArg(Args, OPT_fdebug_prefix_map_EQ,
 Prefix.first + "=" + Prefix.second, SA);
@@ -1627,10 +1624,16 @@
   }
 
   // If -fuse-ctor-homing is set and limited debug info is already on, then use
-  // constructor homing.
-  if (Args.getLastArg(OPT_fuse_ctor_homing))
-if (Opts.getDebugInfo() == codegenoptions::LimitedDebugInfo)
+  // constructor homing, and vice versa for -fno-use-ctor-homing.
+  if (const Arg *A =
+  Args.getLastArg(OPT_fuse_ctor_homing, OPT_fno_use_ctor_homing)) {
+if (A->getOption().matches(OPT_fuse_ctor_homing) &&
+Opts.getDebugInfo() == codegenoptions::LimitedDebugInfo)
   Opts.setDebugInfo(codegenoptions::DebugInfoConstructor);
+if (A->getOption().matches(OPT_fno_use_ctor_homing) &&
+Opts.getDebugInfo() == codegenoptions::DebugInfoConstructor)
+  Opts.setDebugInfo(codegenoptions::LimitedDebugInfo);
+  }
 
   for (const auto  : Args.getAllArgValues(OPT_fdebug_prefix_map_EQ)) {
 auto Split = StringRef(Arg).split('=');
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4836,6 +4836,8 @@
 def fno_math_builtin : Flag<["-"], "fno-math-builtin">,
   HelpText<"Disable implicit builtin knowledge of math functions">,
   MarshallingInfoFlag>;
+def fno_use_ctor_homing: Flag<["-"], "fno-use-ctor-homing">,
+HelpText<"Don't use constructor homing for debug info">;
 def fuse_ctor_homing: Flag<["-"], "fuse-ctor-homing">,
 HelpText<"Use constructor homing if we are using limited debug info 
already">;
 }
Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -2563,7 +2563,8 @@
non-trivial, non-aggregate C++ class in the modules that contain a
definition of one of its constructors. This relies on the additional
assumption that all classes that are not trivially constructible have a
-   non-trivial constructor that is used somewhere.
+   non-trivial constructor that is used somewhere. The negation,
+   -fno-use-ctor-homing, ensures that constructor homing is not used.
 
This flag is not enabled by default, and needs to be used with -cc1 or
-Xclang.


Index: clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp
===
--- clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp
+++ clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp
@@ -8,6 +8,9 @@
 // RUN:| FileCheck %s -check-prefix=NO_DEBUG
 // RUN: %clang -cc1 -fuse-ctor-homing -emit-llvm %s -o - \
 // RUN:| FileCheck %s -check-prefix=NO_DEBUG
+//
+// RUN: %clang -cc1 -debug-info-kind=constructor -fno-use-ctor-homing \
+// RUN:-emit-llvm %s -o - | FileCheck %s -check-prefix=FULL_DEBUG
 
 // This tests that the -fuse-ctor-homing is only used if limited debug info would have
 // been used otherwise.
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ 

[clang] 3e2ad26 - [DebugInfo] Add -fno-ctor-homing for as counterpart to -fuse-ctor-homing

2021-07-22 Thread Amy Huang via cfe-commits

Author: Amy Huang
Date: 2021-07-22T14:52:36-07:00
New Revision: 3e2ad26b08a23e786e64e8e47547d25a1b5a7f28

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

LOG: [DebugInfo] Add -fno-ctor-homing for as counterpart to -fuse-ctor-homing

Add an opt out flag for constructor homing.

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

Added: 


Modified: 
clang/docs/UsersManual.rst
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index f7f76ed3f3e20..20be01a5f40ac 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -2563,7 +2563,8 @@ below. If multiple flags are present, the last one is 
used.
non-trivial, non-aggregate C++ class in the modules that contain a
definition of one of its constructors. This relies on the additional
assumption that all classes that are not trivially constructible have a
-   non-trivial constructor that is used somewhere.
+   non-trivial constructor that is used somewhere. The negation,
+   -fno-use-ctor-homing, ensures that constructor homing is not used.
 
This flag is not enabled by default, and needs to be used with -cc1 or
-Xclang.

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 79955f4fa4f08..1815cd4621e87 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4836,6 +4836,8 @@ def mrelocation_model : Separate<["-"], 
"mrelocation-model">,
 def fno_math_builtin : Flag<["-"], "fno-math-builtin">,
   HelpText<"Disable implicit builtin knowledge of math functions">,
   MarshallingInfoFlag>;
+def fno_use_ctor_homing: Flag<["-"], "fno-use-ctor-homing">,
+HelpText<"Don't use constructor homing for debug info">;
 def fuse_ctor_homing: Flag<["-"], "fuse-ctor-homing">,
 HelpText<"Use constructor homing if we are using limited debug info 
already">;
 }

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 2c696b5394538..a8f25fa7c11c4 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1369,9 +1369,6 @@ void CompilerInvocation::GenerateCodeGenArgs(
   if (DebugInfoVal)
 GenerateArg(Args, OPT_debug_info_kind_EQ, *DebugInfoVal, SA);
 
-  if (Opts.DebugInfo == codegenoptions::DebugInfoConstructor)
-GenerateArg(Args, OPT_fuse_ctor_homing, SA);
-
   for (const auto  : Opts.DebugPrefixMap)
 GenerateArg(Args, OPT_fdebug_prefix_map_EQ,
 Prefix.first + "=" + Prefix.second, SA);
@@ -1627,10 +1624,16 @@ bool 
CompilerInvocation::ParseCodeGenArgs(CodeGenOptions , ArgList ,
   }
 
   // If -fuse-ctor-homing is set and limited debug info is already on, then use
-  // constructor homing.
-  if (Args.getLastArg(OPT_fuse_ctor_homing))
-if (Opts.getDebugInfo() == codegenoptions::LimitedDebugInfo)
+  // constructor homing, and vice versa for -fno-use-ctor-homing.
+  if (const Arg *A =
+  Args.getLastArg(OPT_fuse_ctor_homing, OPT_fno_use_ctor_homing)) {
+if (A->getOption().matches(OPT_fuse_ctor_homing) &&
+Opts.getDebugInfo() == codegenoptions::LimitedDebugInfo)
   Opts.setDebugInfo(codegenoptions::DebugInfoConstructor);
+if (A->getOption().matches(OPT_fno_use_ctor_homing) &&
+Opts.getDebugInfo() == codegenoptions::DebugInfoConstructor)
+  Opts.setDebugInfo(codegenoptions::LimitedDebugInfo);
+  }
 
   for (const auto  : Args.getAllArgValues(OPT_fdebug_prefix_map_EQ)) {
 auto Split = StringRef(Arg).split('=');

diff  --git a/clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp 
b/clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp
index 5443fa9ade237..e0832f48c5e21 100644
--- a/clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp
+++ b/clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp
@@ -8,6 +8,9 @@
 // RUN:| FileCheck %s -check-prefix=NO_DEBUG
 // RUN: %clang -cc1 -fuse-ctor-homing -emit-llvm %s -o - \
 // RUN:| FileCheck %s -check-prefix=NO_DEBUG
+//
+// RUN: %clang -cc1 -debug-info-kind=constructor -fno-use-ctor-homing \
+// RUN:-emit-llvm %s -o - | FileCheck %s -check-prefix=FULL_DEBUG
 
 // This tests that the -fuse-ctor-homing is only used if limited debug info 
would have
 // been used otherwise.



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


[clang] 8322593 - PR51158: Don't emit -Wswitch or -Wcovered-switch-default for empty enums

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

Author: David Blaikie
Date: 2021-07-22T14:51:56-07:00
New Revision: 83225936af317e6bdd7103a8a039c51a29ce9f57

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

LOG: PR51158: Don't emit -Wswitch or -Wcovered-switch-default for empty enums

An empty enum is used to implement C++'s new-ish "byte" type (to make
sure it's a separate type for overloading, etc - compared to a typedef)
- without any enumerators. Some clang warnings don't make sense in this
sort of situation, so let's skip them for empty enums.

It's arguable that possibly some situations of enumerations without
enumerators might want the previous-to-this-patch behavior (if the enum
is autogenerated and in some cases comes up empty, then maybe a default
in an empty switch would still be considered problematic - so that when
you add the first enumeration you do get a -Wswitch warning). But I
think that's niche enough & this std::byte case is mainstream enough
that we should prioritize the latter over the former.

If someone's got a middle ground proposal to account for both of those
situations, I'm open to patches/suggestions/etc.

Added: 


Modified: 
clang/lib/Sema/SemaStmt.cpp
clang/test/SemaCXX/switch.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 2ae27de9b207..64c53df0 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -1461,7 +1461,8 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, 
Stmt *Switch,
 
 // If switch has default case, then ignore it.
 if (!CaseListIsErroneous && !CaseListIsIncomplete && !HasConstantCond &&
-ET && ET->getDecl()->isCompleteDefinition()) {
+ET && ET->getDecl()->isCompleteDefinition() &&
+!empty(ET->getDecl()->enumerators())) {
   const EnumDecl *ED = ET->getDecl();
   EnumValsTy EnumVals;
 

diff  --git a/clang/test/SemaCXX/switch.cpp b/clang/test/SemaCXX/switch.cpp
index 0c60ce02097b..380f4d559ef8 100644
--- a/clang/test/SemaCXX/switch.cpp
+++ b/clang/test/SemaCXX/switch.cpp
@@ -130,3 +130,19 @@ void test(Opaque o, OpaqueClass oc, Defined d) {
 }
 
 }
+
+namespace EmptyEnum {
+
+enum Empty : int {};
+void test(Empty e) {
+  switch (e) {
+  case (Empty)0:
+break;
+  }
+  switch (e) {
+  default:
+break;
+  }
+}
+
+} // namespace EmptyEnum



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


[PATCH] D105904: [clangd] Support `#pragma mark` in the outline

2021-07-22 Thread David Goldman via Phabricator via cfe-commits
dgoldman added a comment.

PTAL, now merge outside of DocumentOutline although the algorithm I've used is 
roughly the same


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105904

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


[PATCH] D105904: [clangd] Support `#pragma mark` in the outline

2021-07-22 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 360980.
dgoldman added a comment.

Misc vector changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105904

Files:
  clang-tools-extra/clangd/CollectMacros.cpp
  clang-tools-extra/clangd/CollectMacros.h
  clang-tools-extra/clangd/FindSymbols.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/ParsedAST.h
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/Preamble.h
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
  clang/include/clang/Lex/PPCallbacks.h

Index: clang/include/clang/Lex/PPCallbacks.h
===
--- clang/include/clang/Lex/PPCallbacks.h
+++ clang/include/clang/Lex/PPCallbacks.h
@@ -492,6 +492,11 @@
 Second->PragmaComment(Loc, Kind, Str);
   }
 
+  void PragmaMark(SourceLocation Loc, StringRef Trivia) override {
+First->PragmaMark(Loc, Trivia);
+Second->PragmaMark(Loc, Trivia);
+  }
+
   void PragmaDetectMismatch(SourceLocation Loc, StringRef Name,
 StringRef Value) override {
 First->PragmaDetectMismatch(Loc, Name, Value);
Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -1027,6 +1027,105 @@
 AllOf(WithName("-pur"), WithKind(SymbolKind::Method));
 }
 
+TEST(DocumentSymbolsTest, PragmaMarkGroups) {
+  TestTU TU;
+  TU.ExtraArgs = {"-xobjective-c++", "-Wno-objc-root-class"};
+  Annotations Main(R"cpp(
+  $DogDef[[@interface Dog
+  @end]]
+
+  $DogImpl[[@implementation Dog
+
+  + (id)sharedDoggo { return 0; }
+
+  #pragma $Overrides[[mark - Overrides
+
+  - (id)init {
+return self;
+  }
+  - (void)bark {}]]
+
+  #pragma $Specifics[[mark - Dog Specifics
+
+  - (int)isAGoodBoy {
+return 1;
+  }]]
+  @]]end  // FIXME: Why doesn't this include the 'end'?
+
+  #pragma $End[[mark - End
+]]
+)cpp");
+  TU.Code = Main.code().str();
+  EXPECT_THAT(
+  getSymbols(TU.build()),
+  ElementsAre(
+  AllOf(WithName("Dog"), SymRange(Main.range("DogDef"))),
+  AllOf(WithName("Dog"), SymRange(Main.range("DogImpl")),
+Children(AllOf(WithName("+sharedDoggo"),
+   WithKind(SymbolKind::Method)),
+ AllOf(WithName("Overrides"),
+   SymRange(Main.range("Overrides")),
+   Children(AllOf(WithName("-init"),
+  WithKind(SymbolKind::Method)),
+AllOf(WithName("-bark"),
+  WithKind(SymbolKind::Method,
+ AllOf(WithName("Dog Specifics"),
+   SymRange(Main.range("Specifics")),
+   Children(AllOf(WithName("-isAGoodBoy"),
+  WithKind(SymbolKind::Method)),
+  AllOf(WithName("End"), SymRange(Main.range("End");
+}
+
+TEST(DocumentSymbolsTest, PragmaMarkGroupsNoNesting) {
+  TestTU TU;
+  TU.ExtraArgs = {"-xobjective-c++", "-Wno-objc-root-class"};
+  Annotations Main(R"cpp(
+  #pragma mark Helpers
+  void helpA(id obj) {}
+
+  #pragma mark -
+  #pragma mark Core
+
+  void coreMethod() {}
+)cpp");
+  TU.Code = Main.code().str();
+  EXPECT_THAT(getSymbols(TU.build()),
+  ElementsAre(AllOf(WithName("Helpers")), AllOf(WithName("helpA")),
+  AllOf(WithName("(unnamed group)")),
+  AllOf(WithName("Core")),
+  AllOf(WithName("coreMethod";
+}
+
+TEST(DocumentSymbolsTest, SymbolsAreSorted) {
+  TestTU TU;
+  TU.ExtraArgs = {"-xobjective-c++", "-Wno-objc-root-class"};
+  Annotations Main(R"cpp(
+  @interface MYObject
+  @end
+
+  void someFunctionAbove() {}
+
+  @implementation MYObject
+  - (id)init { return self; }
+
+  void someHelperFunction() {}
+
+  - (void)retain {}
+  - (void)release {}
+  @end
+)cpp");
+  TU.Code = Main.code().str();
+  EXPECT_THAT(getSymbols(TU.build()),
+  ElementsAre(AllOf(WithName("MYObject")),
+  AllOf(WithName("someFunctionAbove")),
+  // FIXME: This should be nested under MYObject below.
+  AllOf(WithName("someHelperFunction")),
+  AllOf(WithName("MYObject"),
+Children(AllOf(WithName("-init")),
+ 

[PATCH] D104601: [Preprocessor] Implement -fminimize-whitespace.

2021-07-22 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

Because of how large the switch construct would have been, I created a new 
function `types::isDerivedFromC` together with the other functions. These 
commonly have default-cases so compilers would not warn when `Types.def` is 
amended, but `isDerivedFromC` can be found between other functions that would 
need to be updated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104601

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


[PATCH] D106585: Fix clang debug info irgen of i128 enums

2021-07-22 Thread Reid Kleckner via Phabricator via cfe-commits
rnk updated this revision to Diff 360978.
rnk added a comment.

- move


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106585

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-enum-i128.cpp
  llvm/include/llvm/IR/DIBuilder.h
  llvm/lib/IR/DIBuilder.cpp


Index: llvm/lib/IR/DIBuilder.cpp
===
--- llvm/lib/IR/DIBuilder.cpp
+++ llvm/lib/IR/DIBuilder.cpp
@@ -250,6 +250,11 @@
Name);
 }
 
+DIEnumerator *DIBuilder::createEnumerator(StringRef Name, APSInt Value) {
+  assert(!Name.empty() && "Unable to create enumerator without name");
+  return DIEnumerator::get(VMContext, APInt(Value), Value.isUnsigned(), Name);
+}
+
 DIBasicType *DIBuilder::createUnspecifiedType(StringRef Name) {
   assert(!Name.empty() && "Unable to create type without name");
   return DIBasicType::get(VMContext, dwarf::DW_TAG_unspecified_type, Name);
Index: llvm/include/llvm/IR/DIBuilder.h
===
--- llvm/include/llvm/IR/DIBuilder.h
+++ llvm/include/llvm/IR/DIBuilder.h
@@ -181,7 +181,9 @@
  DIFile *File);
 
 /// Create a single enumerator value.
-DIEnumerator *createEnumerator(StringRef Name, int64_t Val, bool 
IsUnsigned = false);
+DIEnumerator *createEnumerator(StringRef Name, APSInt Value);
+DIEnumerator *createEnumerator(StringRef Name, int64_t Val,
+   bool IsUnsigned = false);
 
 /// Create a DWARF unspecified type.
 DIBasicType *createUnspecifiedType(StringRef Name);
Index: clang/test/CodeGenCXX/debug-info-enum-i128.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/debug-info-enum-i128.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -triple x86_64-windows-msvc -gcodeview 
-debug-info-kind=limited -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple x86_64-linux-gnu -debug-info-kind=limited 
-emit-llvm -o - | FileCheck %s
+
+enum class uns : __uint128_t { unsval = __uint128_t(1) << 64 };
+uns t1() { return uns::unsval; }
+
+enum class sig : __int128 { sigval = -(__int128(1) << 64) };
+sig t2() { return sig::sigval; }
+
+
+// CHECK-LABEL: !DICompositeType(tag: DW_TAG_enumeration_type, name: "uns", 
{{.*}})
+// CHECK: !DIEnumerator(name: "unsval", value: 18446744073709551616, 
isUnsigned: true)
+
+// CHECK-LABEL: !DICompositeType(tag: DW_TAG_enumeration_type, name: "sig", 
{{.*}})
+// CHECK: !DIEnumerator(name: "sigval", value: -18446744073709551616)
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3113,10 +3113,10 @@
   ED = ED->getDefinition();
   bool IsSigned = ED->getIntegerType()->isSignedIntegerType();
   for (const auto *Enum : ED->enumerators()) {
-const auto  = Enum->getInitVal();
-auto Value = IsSigned ? InitVal.getSExtValue() : InitVal.getZExtValue();
+llvm::APSInt Value = Enum->getInitVal();
+Value.setIsSigned(IsSigned);
 Enumerators.push_back(
-DBuilder.createEnumerator(Enum->getName(), Value, !IsSigned));
+DBuilder.createEnumerator(Enum->getName(), std::move(Value)));
   }
 
   // Return a CompositeType for the enum itself.


Index: llvm/lib/IR/DIBuilder.cpp
===
--- llvm/lib/IR/DIBuilder.cpp
+++ llvm/lib/IR/DIBuilder.cpp
@@ -250,6 +250,11 @@
Name);
 }
 
+DIEnumerator *DIBuilder::createEnumerator(StringRef Name, APSInt Value) {
+  assert(!Name.empty() && "Unable to create enumerator without name");
+  return DIEnumerator::get(VMContext, APInt(Value), Value.isUnsigned(), Name);
+}
+
 DIBasicType *DIBuilder::createUnspecifiedType(StringRef Name) {
   assert(!Name.empty() && "Unable to create type without name");
   return DIBasicType::get(VMContext, dwarf::DW_TAG_unspecified_type, Name);
Index: llvm/include/llvm/IR/DIBuilder.h
===
--- llvm/include/llvm/IR/DIBuilder.h
+++ llvm/include/llvm/IR/DIBuilder.h
@@ -181,7 +181,9 @@
  DIFile *File);
 
 /// Create a single enumerator value.
-DIEnumerator *createEnumerator(StringRef Name, int64_t Val, bool IsUnsigned = false);
+DIEnumerator *createEnumerator(StringRef Name, APSInt Value);
+DIEnumerator *createEnumerator(StringRef Name, int64_t Val,
+   bool IsUnsigned = false);
 
 /// Create a DWARF unspecified type.
 DIBasicType *createUnspecifiedType(StringRef Name);
Index: clang/test/CodeGenCXX/debug-info-enum-i128.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/debug-info-enum-i128.cpp

[PATCH] D106585: Fix clang debug info irgen of i128 enums

2021-07-22 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:3117
+llvm::APSInt Value = Enum->getInitVal();
+Value.setIsSigned(IsSigned);
+Enumerators.push_back(DBuilder.createEnumerator(Enum->getName(), Value));

dblaikie wrote:
> Is the value already signed appropriately?
> 
> Removing this line of code (and the `bool IsSigned` variable, so it doesn't 
> break `-Werror=unused-variable`) doesn't cause any tests to fail, that I can 
> see.
I'm afraid it might not be NFC. I took the cautious approach of trying to leave 
things exactly as they were. Enums in C can have surprisingly different 
behavior, IIRC.



Comment at: llvm/lib/IR/DIBuilder.cpp:255
+  assert(!Name.empty() && "Unable to create enumerator without name");
+  return DIEnumerator::get(VMContext, APInt(Value), Value.isUnsigned(), Name);
+}

mizvekov wrote:
> Do I get it right, and this is not the first place that I noticed this, but 
> the terminology here is a bit unconventional with regards to "Signed" vs 
> "Negative"?
> 
> It looks like around the debug info code, an APSInt will be a signed positive 
> value for representing a negative number, and an unsigned one to represent a 
> positive value.
To my knowledge, we try not to store data in a sign-and-magnitude 
representation, it's always twos-complement. Meaning, APInt always stores a 
sequence of bits, typically interpreted as an unsigned positive integer. With 
outside information about the signedness of that data, you can answer the 
question of whether it is negative or not. APSInt adds the extra "signed" field.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106585

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


[PATCH] D104601: [Preprocessor] Implement -fminimize-whitespace.

2021-07-22 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur updated this revision to Diff 360977.
Meinersbur added a comment.

- Introduce types::isDerivedFromC
- Print input type in error message


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104601

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/Types.h
  clang/include/clang/Frontend/PreprocessorOutputOptions.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/Types.cpp
  clang/lib/Frontend/PrintPreprocessedOutput.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/test/Preprocessor/comment_save.c
  clang/test/Preprocessor/first-line-indent.c
  clang/test/Preprocessor/hash_line.c
  clang/test/Preprocessor/line-directive-output-mincol.c
  clang/test/Preprocessor/line-directive-output.c
  clang/test/Preprocessor/macro_space.c
  clang/test/Preprocessor/minimize-whitespace-messages.c
  clang/test/Preprocessor/minimize-whitespace.c
  clang/test/Preprocessor/print_line_include.c
  clang/test/Preprocessor/stringize_space.c

Index: clang/test/Preprocessor/stringize_space.c
===
--- clang/test/Preprocessor/stringize_space.c
+++ clang/test/Preprocessor/stringize_space.c
@@ -1,16 +1,18 @@
 // RUN: %clang_cc1 -E %s | FileCheck --strict-whitespace %s
+// RUN: %clang_cc1 -E -P -fminimize-whitespace %s | FileCheck --strict-whitespace %s --check-prefix=MINWS
 
 #define A(b) -#b  ,  - #b  ,  -# b  ,  - # b
 A()
 
 // CHECK: {{^}}-"" , - "" , -"" , - ""{{$}}
-
+// MINWS: {{^}}-"",-"",-"",-""
 
 #define t(x) #x
 t(a
 c)
 
 // CHECK: {{^}}"a c"{{$}}
+// MINWS-SAME: "a c"
 
 #define str(x) #x
 #define f(x) str(-x)
@@ -18,6 +20,7 @@
 1)
 
 // CHECK: {{^}}"-1"
+// MINWS-SAME: "-1"
 
 #define paste(a,b) str(a&1 | FileCheck %s --strict-whitespace --check-prefix=MINCOL
+// RUN: %clang_cc1 -fminimize-whitespace -E -C %s 2>&1 | FileCheck %s --strict-whitespace --check-prefix=MINCCOL
+// RUN: %clang_cc1 -fminimize-whitespace -E -P %s 2>&1 | FileCheck %s --strict-whitespace --check-prefix=MINWS
+// RUN: %clang_cc1 -fminimize-whitespace -E -C -P %s 2>&1 | FileCheck %s --strict-whitespace --check-prefix=MINCWS
+
+#define NOT_OMP  omp  something
+#define HASH #
+
+  int  a; /*  span-comment  */
+  int  b  ;   //  line-comment
+  _Pragma  (  "omp  barrier"  ) x //  more line-comments
+  #pragma  omp  nothing  //  another comment
+HASH  pragma  NOT_OMP
+  int  e;// again a line
+  int  \
+f  ;
+
+
+// MINCOL:  {{^}}# 9 "{{.*}}minimize-whitespace.c"{{$}}
+// MINCOL:  {{^}}int a;{{$}}
+// MINCOL-NEXT: {{^}}int b;{{$}}
+// MINCOL-NEXT: {{^}}#pragma omp barrier{{$}}
+// MINCOL-NEXT: # 11 "{{.*}}minimize-whitespace.c"
+// MINCOL-NEXT: {{^}}x{{$}}
+// MINCOL-NEXT: {{^}}#pragma omp nothing{{$}}
+// MINCOL-NEXT: {{^ }}#pragma omp something{{$}}
+// MINCOL-NEXT: {{^}}int e;{{$}}
+// MINCOL-NEXT: {{^}}int f;{{$}}
+
+// FIXME: Comments after pragmas disappear, even without -fminimize-whitespace
+// MINCCOL:  {{^}}# 9 "{{.*}}minimize-whitespace.c"{{$}}
+// MINCCOL:  {{^}}int a;/*  span-comment  */{{$}}
+// MINCCOL-NEXT: {{^}}int b;//  line-comment{{$}}
+// MINCCOL-NEXT: {{^}}#pragma omp barrier{{$}}
+// MINCCOL-NEXT: # 11 "{{.*}}minimize-whitespace.c"
+// MINCCOL-NEXT: {{^}}x//  more line-comments{{$}}
+// MINCCOL-NEXT: {{^}}#pragma omp nothing{{$}}
+// MINCCOL-NEXT: {{^ }}#pragma omp something{{$}}
+// MINCCOL-NEXT: {{^}}int e;// again a line{{$}}
+// MINCCOL-NEXT: {{^}}int f;{{$}}
+
+// MINWS:  {{^}}int a;int b;{{$}}
+// MINWS-NEXT: {{^}}#pragma omp barrier{{$}}
+// MINWS-NEXT: {{^}}x{{$}}
+// MINWS-NEXT: {{^}}#pragma omp nothing{{$}}
+// MINWS-NEXT: {{^ }}#pragma omp something int e;int f;{{$}}
+
+// FIXME: Comments after pragmas disappear, even without -fminimize-whitespace
+// MINCWS:  {{^}}int a;/*  span-comment  */int b;//  line-comment{{$}}
+// MINCWS-NEXT: {{^}}#pragma omp barrier{{$}}
+// MINCWS-NEXT: {{^}}x//  more line-comments{{$}}
+// MINCWS-NEXT: {{^}}#pragma omp nothing{{$}}
+// MINCWS-NEXT: {{^ }}#pragma omp something int e;// again a line{{$}}
+// MINCWS-NEXT: {{^}}int f;
+
Index: clang/test/Preprocessor/minimize-whitespace-messages.c
===
--- /dev/null
+++ clang/test/Preprocessor/minimize-whitespace-messages.c
@@ -0,0 +1,8 @@
+// RUN: not %clang -c -fminimize-whitespace %s 2>&1 | FileCheck %s --check-prefix=ON
+// ON: error: invalid argument '-fminimize-whitespace' only allowed with '-E'
+
+// RUN: not %clang -c -fno-minimize-whitespace %s 2>&1 | FileCheck %s  --check-prefix=OFF
+// OFF: error: invalid argument '-fno-minimize-whitespace' only allowed with '-E'
+
+// RUN: not %clang -E -fminimize-whitespace -x assembler-with-cpp %s 2>&1 | FileCheck %s --check-prefix=ASM
+// ASM: error: '-fminimize-whitespace' invalid for input of type assembler-with-cpp
Index: 

[PATCH] D105904: [clangd] Support `#pragma mark` in the outline

2021-07-22 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 360972.
dgoldman added a comment.

Merge pragmas outside of the DocumentOutline


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105904

Files:
  clang-tools-extra/clangd/CollectMacros.cpp
  clang-tools-extra/clangd/CollectMacros.h
  clang-tools-extra/clangd/FindSymbols.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/ParsedAST.h
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/Preamble.h
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
  clang/include/clang/Lex/PPCallbacks.h

Index: clang/include/clang/Lex/PPCallbacks.h
===
--- clang/include/clang/Lex/PPCallbacks.h
+++ clang/include/clang/Lex/PPCallbacks.h
@@ -492,6 +492,11 @@
 Second->PragmaComment(Loc, Kind, Str);
   }
 
+  void PragmaMark(SourceLocation Loc, StringRef Trivia) override {
+First->PragmaMark(Loc, Trivia);
+Second->PragmaMark(Loc, Trivia);
+  }
+
   void PragmaDetectMismatch(SourceLocation Loc, StringRef Name,
 StringRef Value) override {
 First->PragmaDetectMismatch(Loc, Name, Value);
Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -1027,6 +1027,105 @@
 AllOf(WithName("-pur"), WithKind(SymbolKind::Method));
 }
 
+TEST(DocumentSymbolsTest, PragmaMarkGroups) {
+  TestTU TU;
+  TU.ExtraArgs = {"-xobjective-c++", "-Wno-objc-root-class"};
+  Annotations Main(R"cpp(
+  $DogDef[[@interface Dog
+  @end]]
+
+  $DogImpl[[@implementation Dog
+
+  + (id)sharedDoggo { return 0; }
+
+  #pragma $Overrides[[mark - Overrides
+
+  - (id)init {
+return self;
+  }
+  - (void)bark {}]]
+
+  #pragma $Specifics[[mark - Dog Specifics
+
+  - (int)isAGoodBoy {
+return 1;
+  }]]
+  @]]end  // FIXME: Why doesn't this include the 'end'?
+
+  #pragma $End[[mark - End
+]]
+)cpp");
+  TU.Code = Main.code().str();
+  EXPECT_THAT(
+  getSymbols(TU.build()),
+  ElementsAre(
+  AllOf(WithName("Dog"), SymRange(Main.range("DogDef"))),
+  AllOf(WithName("Dog"), SymRange(Main.range("DogImpl")),
+Children(AllOf(WithName("+sharedDoggo"),
+   WithKind(SymbolKind::Method)),
+ AllOf(WithName("Overrides"),
+   SymRange(Main.range("Overrides")),
+   Children(AllOf(WithName("-init"),
+  WithKind(SymbolKind::Method)),
+AllOf(WithName("-bark"),
+  WithKind(SymbolKind::Method,
+ AllOf(WithName("Dog Specifics"),
+   SymRange(Main.range("Specifics")),
+   Children(AllOf(WithName("-isAGoodBoy"),
+  WithKind(SymbolKind::Method)),
+  AllOf(WithName("End"), SymRange(Main.range("End");
+}
+
+TEST(DocumentSymbolsTest, PragmaMarkGroupsNoNesting) {
+  TestTU TU;
+  TU.ExtraArgs = {"-xobjective-c++", "-Wno-objc-root-class"};
+  Annotations Main(R"cpp(
+  #pragma mark Helpers
+  void helpA(id obj) {}
+
+  #pragma mark -
+  #pragma mark Core
+
+  void coreMethod() {}
+)cpp");
+  TU.Code = Main.code().str();
+  EXPECT_THAT(getSymbols(TU.build()),
+  ElementsAre(AllOf(WithName("Helpers")), AllOf(WithName("helpA")),
+  AllOf(WithName("(unnamed group)")),
+  AllOf(WithName("Core")),
+  AllOf(WithName("coreMethod";
+}
+
+TEST(DocumentSymbolsTest, SymbolsAreSorted) {
+  TestTU TU;
+  TU.ExtraArgs = {"-xobjective-c++", "-Wno-objc-root-class"};
+  Annotations Main(R"cpp(
+  @interface MYObject
+  @end
+
+  void someFunctionAbove() {}
+
+  @implementation MYObject
+  - (id)init { return self; }
+
+  void someHelperFunction() {}
+
+  - (void)retain {}
+  - (void)release {}
+  @end
+)cpp");
+  TU.Code = Main.code().str();
+  EXPECT_THAT(getSymbols(TU.build()),
+  ElementsAre(AllOf(WithName("MYObject")),
+  AllOf(WithName("someFunctionAbove")),
+  // FIXME: This should be nested under MYObject below.
+  AllOf(WithName("someHelperFunction")),
+  AllOf(WithName("MYObject"),
+Children(AllOf(WithName("-init")),
+

[PATCH] D106528: [clangd] Improve performance of dex by 45-60%

2021-07-22 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 360970.
kbobyrev added a comment.

Add more comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106528

Files:
  clang-tools-extra/clangd/index/dex/Iterator.cpp


Index: clang-tools-extra/clangd/index/dex/Iterator.cpp
===
--- clang-tools-extra/clangd/index/dex/Iterator.cpp
+++ clang-tools-extra/clangd/index/dex/Iterator.cpp
@@ -104,11 +104,19 @@
 // In this case, just terminate the process.
 if (ReachedEnd)
   return;
+// Cache the result so that peek() is not called again as it may be
+// quite expensive in AND with large subtrees.
+auto Candidate = Child->peek();
 // If any child goes beyond given ID (i.e. ID is not the common item),
 // all children should be advanced to the next common item.
-if (Child->peek() > SyncID) {
-  SyncID = Child->peek();
+if (Candidate > SyncID) {
+  SyncID = Candidate;
   NeedsAdvance = true;
+  // Reset and try to sync again. Sync starts with the first child as
+  // this is the cheapest (smallest size estimate). This way advanceTo
+  // is called on the large posting lists once the sync point is very
+  // likely.
+  break;
 }
   }
 } while (NeedsAdvance);


Index: clang-tools-extra/clangd/index/dex/Iterator.cpp
===
--- clang-tools-extra/clangd/index/dex/Iterator.cpp
+++ clang-tools-extra/clangd/index/dex/Iterator.cpp
@@ -104,11 +104,19 @@
 // In this case, just terminate the process.
 if (ReachedEnd)
   return;
+// Cache the result so that peek() is not called again as it may be
+// quite expensive in AND with large subtrees.
+auto Candidate = Child->peek();
 // If any child goes beyond given ID (i.e. ID is not the common item),
 // all children should be advanced to the next common item.
-if (Child->peek() > SyncID) {
-  SyncID = Child->peek();
+if (Candidate > SyncID) {
+  SyncID = Candidate;
   NeedsAdvance = true;
+  // Reset and try to sync again. Sync starts with the first child as
+  // this is the cheapest (smallest size estimate). This way advanceTo
+  // is called on the large posting lists once the sync point is very
+  // likely.
+  break;
 }
   }
 } while (NeedsAdvance);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106528: [clangd] Improve performance of dex by 45-60%

2021-07-22 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 360968.
kbobyrev added a comment.

Add another 7% compared to the patched version: cache Child->peek() in the
loop.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106528

Files:
  clang-tools-extra/clangd/index/dex/Iterator.cpp


Index: clang-tools-extra/clangd/index/dex/Iterator.cpp
===
--- clang-tools-extra/clangd/index/dex/Iterator.cpp
+++ clang-tools-extra/clangd/index/dex/Iterator.cpp
@@ -106,9 +106,13 @@
   return;
 // If any child goes beyond given ID (i.e. ID is not the common item),
 // all children should be advanced to the next common item.
-if (Child->peek() > SyncID) {
-  SyncID = Child->peek();
+auto Candidate = Child->peek();
+if (Candidate > SyncID) {
+  SyncID = Candidate;
   NeedsAdvance = true;
+  // Reset and make sure advanceTo happens much less frequently on
+  // large posting lists. This accounts for 45-60% performance boost.
+  break;
 }
   }
 } while (NeedsAdvance);


Index: clang-tools-extra/clangd/index/dex/Iterator.cpp
===
--- clang-tools-extra/clangd/index/dex/Iterator.cpp
+++ clang-tools-extra/clangd/index/dex/Iterator.cpp
@@ -106,9 +106,13 @@
   return;
 // If any child goes beyond given ID (i.e. ID is not the common item),
 // all children should be advanced to the next common item.
-if (Child->peek() > SyncID) {
-  SyncID = Child->peek();
+auto Candidate = Child->peek();
+if (Candidate > SyncID) {
+  SyncID = Candidate;
   NeedsAdvance = true;
+  // Reset and make sure advanceTo happens much less frequently on
+  // large posting lists. This accounts for 45-60% performance boost.
+  break;
 }
   }
 } while (NeedsAdvance);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106582: [DebugInfo] Add -fno-ctor-homing for as counterpart to -fuse-ctor-homing

2021-07-22 Thread Amy Huang via Phabricator via cfe-commits
akhuang added a subscriber: jmorse.
akhuang added a comment.

In D106582#2897815 , @dblaikie wrote:

> In D106582#2897678 , @akhuang wrote:
>
>> In D106582#2897599 , @dblaikie 
>> wrote:
>>
>>> Looks alright to me. (bit awkward having a documented cc1 option - since 
>>> the cc1 options aren't meant to be user facing - hadn't really thought 
>>> about/noticed that when reviewing the documentation originally in D95911 
>>> )
>>
>> Oh, true. Since we're making ctor homing default maybe I should just make 
>> them user facing flags.
>
> I have mixed feelings - on the one hand, yeah, we're changing the behavior of 
> `-fno-standalone-debug` and giving people a tool to undo that change if it's 
> problematic is good (less chance we have to churn through reverting the 
> change, fixing, reapplying, etc, if there's a way to opt-out, at least in the 
> short term). But equally I don't want to proliferate various rather arbitrary 
> buckets of debug info type homing - I really want to encourage people to 
> think of it as a fairly all-or-nothing situation, because I don't think 
> there's a good way to explain/improve/modify/use the feature if it's 
> "whatever is good enough for my use case". Especially now that there's the 
> `standalone_debug` attribute that can be used to fix particular use cases 
> where a type is needed across a `-g0` boundary.
>
> So... eh. Could go either way - your call, really. Though if we make it a 
> full driver option, maybe a caveat that we may remove the functionality in 
> the future (but that'll mean probably having to leave the flag in as a 
> no-op/with some deprecation warning for some time after removing the 
> functionality).

Yep, good point. Agree that it should be all-or-nothing but I feel like there 
might be other people in situations like in chrome mac/lldb or what @jmorse 
mentioned, where we use -fno-standalone-debug because it's impractical to use 
fstandalone-debug, and having a flag to keep the previous behavior is easier 
than having people make changes downstream.

Anyway, I think I'll leave it as a cc1 flag for now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106582

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


[PATCH] D106528: [clangd] Improve performance of dex by 45-60%

2021-07-22 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/index/dex/Iterator.cpp:91
   /// sync.
   void sync() {
 ReachedEnd |= Children.front()->reachedEnd();

sammccall wrote:
> I stared at this for a while and this change makes me think about the whole 
> algo differently.
> 
> Effectively, we're just iterating through the items C of front trying to find 
> a valid sync point.
> With the slight optimization that when some other child skips over C to X, we 
> catch up the front to X.
> 
> This leads to two possible simplifications (strictly, unrelated to this patch 
> and totally up to you):
>  
> 1. The initial setup and outer loop has unclear bounds - it's basically a 
> loop over the items of Children.front() but that's not clear.
> 
> Consider rather:
> 
> ```
> auto  = *Children.front(); // smallest
> while ((ReachedEnd |= Front->reachedEnd())) {
>   auto SyncID = Front.peek();
>   bool ValidSync = true;
>   for (auto  : Children {
> ...
> if (Child->peek() > SyncID) {
>   Front->advanceTo(Child->peek()); // XXX
>   ValidSync = false;
>   break;
> }
> ...
>   }
>   if (ValidSync)
> return;
> }
> ```
> 
> This seems basically equivalent and I find the flow control easier to reason 
> about.
> 
> 2. Is the "slight optimization" important? i.e. is 
> `Front->advanceTo(Child->peek())` actually a significant win over 
> `Front->advance()`? I think the flow control is even clearer in this version:
> 
> ```
> for (auto  = *Children.front() ;(ReachedEnd |= Front->reachedEnd()); 
> Front.advance()) {
>   auto SyncID = Front.peek();
>   bool ValidSync = true;
>   for (auto  : Children {
> ...
> if (Child->peek() > SyncID) {
>   ValidSync = false;
>   break;
> }
> ...
>   }
>   if (ValidSync)
> return;
> }
> ```
> Because now the outer loop is *entirely* just a loop over the items of Front.
> 
> Intuitively the average number that advanceTo() advances by here is between 1 
> and 2 (we know it's at least 1, but the remaining items are mostly from the 
> longer iterator so we probably don't skip over any from the shorter iterator).
> And advanceTo is more complicated, if advanceTo turns out to be 2x as 
> expensive as advance in practice, this isn't a win. So this is maybe worth 
> checking.
Re 1: this is really interesting. Even

```
/// Restores class invariants: each child will point to the same element after
/// sync.
void sync() {
  auto SyncID = Children.front()->peek();
  while (!(ReachedEnd |= Children.front()->reachedEnd())) {
bool ValidSync = true;
for (auto  : Children) {
  Child->advanceTo(SyncID);
  ReachedEnd |= Child->reachedEnd();
  // If any child reaches end And iterator can not match any other items.
  // In this case, just terminate the process.
  if (ReachedEnd)
return;
  // If any child goes beyond given ID (i.e. ID is not the common item),
  // all children should be advanced to the next common item.
  if (Child->peek() > SyncID) {
SyncID = Child->peek();
ValidSync = false;
  }
}
if (ValidSync)
  break;
  }
}
```

Is 5% slower than what we have right now, even though it's almost equivalent to 
what is written.

And what you are proposing

```
void sync() {
  auto  = *Children.front(); // smallest
  while (!(ReachedEnd |= Children.front()->reachedEnd())) {
bool ValidSync = true;
auto SyncID = Front.peek();
for (auto  : Children) {
  Child->advanceTo(SyncID);
  ReachedEnd |= Child->reachedEnd();
  // If any child reaches end And iterator can not match any other items.
  // In this case, just terminate the process.
  if (ReachedEnd)
return;
  if (Child->peek() > SyncID) {
Front.advanceTo(Child->peek()); // XXX
ValidSync = false;
break;
  }
}
if (ValidSync)
  break;
  }
}
```

Has exactly the same performance as we have right now (1/100th percent slower).

I gave it some thought and realized that the problem is that the code in 
suggestion does not cache values as the existing one does and incurs overhead. 
That made me realize I don't really cache `Child->peek()` on line 109 now even 
though I should. Doing that gives another 9% performance compared to the 
proposed version!

Using this knowledge, I tried to incorporate caching into your proposal and 
came up with something like this:

```
  void sync() {
if ((ReachedEnd |= Children.front()->reachedEnd()))
  return;
auto SyncID = Children.front()->peek();
while (!ReachedEnd) {
  bool ValidSync = true;
  for (auto  : Children) {
Child->advanceTo(SyncID);
if ((ReachedEnd |= Child->reachedEnd()))
  return;
auto Candidate = Child->peek();
if (Candidate > SyncID) {
  SyncID = Candidate;
  ValidSync = false;
  break;
}
  }
  if (ValidSync)
break;
}
  }
```


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

2021-07-22 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/test/Parser/opencl-atomics-cl20.cl:7
 
-#if defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= CL_VERSION_1_2
+#if defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= CL_VERSION_2_0
 #define LANG_VER_OK

azabaznov wrote:
> As OpenCL C version defaults to 1.2, I think LANG_VER_OK should always be 
> defined now (due to run lines). But OpenCL C 1.2 has never been tested in 
> this test... Is it a mistake in current rest?
Yes this is a typo in the test or something i.e. `LANG_VER_OK` should not be 
defined for the first run line.


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

https://reviews.llvm.org/D106504

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


[PATCH] D105909: [clang][CallGraphSection] Add type id metadata to indirect call and targets

2021-07-22 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse accepted this revision.
morehouse added inline comments.
This revision is now accepted and ready to land.



Comment at: llvm/test/Verifier/operand-bundles.ll:91
+  %l = load i32, i32* %ptr
+   call void @g() [ "type"(metadata !"_ZTSFvE.generalized"), "type"(metadata 
!"_ZTSFvE.generalized") ]
+  call void @g() [ "type"(metadata !"_ZTSFvE.generalized") ]




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105909

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


[PATCH] D93769: [clang] Add support for option -ffp-eval-method and extend #pragma float_control similarly

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

@MaskRay I experience that the failing test 
clang/test/Index/preamble-reparse-changed-module.m is non-deterministic and 
currently I cannot reproduce the fail.  I added details in D95159 
.  Are you able to reproduce if you clean your 
build area? Do you have a suggestion for how I can solve this problem?  Thanks 
a lot


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93769

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


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

2021-07-22 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a subscriber: MaskRay.
mibintc added a comment.

More info about the test failure I'm seeing for 
clang/test/Index/preamble-reparse-changed-module.m

It appears it might be a non-deterministic failure, perhaps some test 
dependencies are missing?

Yesterday before I pushed my clang patch, I saw it fail when I used "ninja 
check-clang".  I quickly executed each step used by this test (llvm-lit -v ; 
then save all the RUN commands to a file ; then "source" the file -- nothing 
was printed to stdout and also the return code was 0).  I thought the fail 
report wasn't real at this point and I pushed the patch.  This was a Debug 
build.

Then I saw a bot failure, @MaskRay pinged my clang patch and said my patch had 
caused this test to fail.  He told me there was an assertion fail.

Then I created a new build area, configured with Debug and "enable llvm 
assertions", and "ninja check-clang".  This time 0 tests reported as fail.

Then I went back into the build-debug build where "ninja check-clang" had 
reported the fail and used gdb to debug.  In the course of debugging gdb told 
me that the build was out-of-date w.r.t. the source file, so I exitted gdb, 
"ninja clean" "ninja check-clang".  But now no tests are failing.  I don't know 
why gdb told me the build was out of date, I believe I did not change any of 
the files but I'm not 100% certain.

I removed the patch and created another build area, and rebuilt with Debug and 
asserts, everything is clean there too.

I captured the stdout from executing c-index-test, there is a difference 
between patched and unpatched. The __FLT_EVAL_METHOD__ line is not present in 
the patched, this is expected.

Can you suggest how to find the problem?  Thanks a lot.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95159

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


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

2021-07-22 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb marked 2 inline comments as done.
cjdb added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:307-310
+def pp_pragma_include_instead_unexpected_token : Warning<
+  "'#pragma include_instead' expects '%0' as its next token; got '%1' 
instead">,
+  InGroup,
+  ShowInSystemHeader;

aaron.ballman wrote:
> No need for a new warning -- I think we can use existing diagnostics for this 
> (like `err_pp_expects_filename`). Also, I think syntax issues should be 
> diagnosed as an error instead of a warning -- we expect a particular 
> syntactic form and it's reasonable for us to enforce that users get it right.
Hmm... the syntax is `#pragma clang include_instead(header)`. This is 
diagnosing the lack of `(` or `)`, not a missing filename. Perhaps there's 
already a diagnostic for that?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106394

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


[PATCH] D106583: [clang] SIGSEGV at DeduceTemplateArgumentsByTypeMatch

2021-07-22 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D106583#2897783 , @ivanmurashko 
wrote:

> @erichkeane, is it OK if the reproducer be added as the LIT test?

That is a typical mechanism way to go, but that reproducer is a little long.  
You should hopefully be able to simplify it to the minimum required to 
reproduce the crash.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106583

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


[PATCH] D105876: OMPIRBuilder for Interop directive

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

you need to squash your commits locally and update this revision with a single 
commit/diff.




Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:6323-6327
+  if (S.hasClausesOfKind() &&
+  !(S.getSingleClause() ||
+S.getSingleClause() ||
+S.getSingleClause()))
+assert("OMPNowaitClause clause is used separately in 
OMPInteropDirective.");

This is not how assertions work.

assert(EXPR && "MESSAGE");


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105876

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


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

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

Thanks for the first pass @aaron.ballman! Some clarifying questions, but I 
think I have enough of your other comments to work on while you ponder these.




Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:303
   InGroup>;
+def pp_pragma_include_instead_not_sysheader : Warning<
+  "'#pragma include_instead' ignored outside of system headers">,

aaron.ballman wrote:
> Design-wise, do we want this one to be an error instead of a warning? I don't 
> have strong feelings one way or the other, but making it an error ensures no 
> one finds creative ways to use it outside of a system header by accident (and 
> we can relax the restriction later if there are reasons to do so).
I'd prefer it to be an error, but I wasn't confident that would be accepted 
(same applies to all your comments re warn vs err). If you're game, I'll make 
the change.



Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:306
+  InGroup,
+  ShowInSystemHeader;
+def pp_pragma_include_instead_unexpected_token : Warning<

aaron.ballman wrote:
> O.o... why do we need to show this one in system headers if the diagnostic 
> can only trigger outside of a system header?
Mostly because I'm scared that there's some toggle that would accidentally make 
the diagnostic observable in a system header and wanted to test the behaviour.



Comment at: clang/lib/Lex/PPLexerChange.cpp:316
+const StringRef Filename = Include.getKey();
+const auto  = Include.getValue();
+const HeaderFileInfo  = HeaderInfo.getFileInfo(IncludeInfo.File);

aaron.ballman wrote:
> Please spell out the type.
The type's currently a private type (that was by design). Do you want me to 
make it a public type or pull it out into `namespace clang`?



Comment at: clang/lib/Lex/Pragma.cpp:559
+Diag(Tok, diag::pp_pragma_include_instead_unexpected_token)
+<< "(" << (spelling == "\n" ? "\\n" : spelling);
+return;

I thought I deleted this.



Comment at: clang/lib/Lex/Pragma.cpp:572
+  if (Tok.isNot(tok::r_paren)) {
+const std::string spelling = getSpelling(Tok);
+Diag(Tok, diag::pp_pragma_include_instead_unexpected_token)

aaron.ballman wrote:
> 
Alternatively: remove `spelling` altogether.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106394

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


[PATCH] D106585: Fix clang debug info irgen of i128 enums

2021-07-22 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:3117
+llvm::APSInt Value = Enum->getInitVal();
+Value.setIsSigned(IsSigned);
+Enumerators.push_back(DBuilder.createEnumerator(Enum->getName(), Value));

Is the value already signed appropriately?

Removing this line of code (and the `bool IsSigned` variable, so it doesn't 
break `-Werror=unused-variable`) doesn't cause any tests to fail, that I can 
see.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106585

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


[PATCH] D104601: [Preprocessor] Implement -fminimize-whitespace.

2021-07-22 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

In D104601#2896091 , @aaron.ballman 
wrote:

> I think there is, but I'm an eternal optimist. :-) This LGTM, but you should 
> wait a day or two before landing it in case @dblaikie or @rsmith have 
> concerns.

Of course.




Comment at: clang/lib/Driver/ToolChains/Clang.cpp:6059-6062
+if (!types::isCXX(InputType) && !types::isOpenCL(InputType) &&
+!types::isObjC(InputType) && !types::isCuda(InputType) &&
+!types::isHIP(InputType) && InputType != types::TY_PP_C &&
+InputType != types::TY_C)

aaron.ballman wrote:
> One downside to this approach as opposed to using a `switch` is that it'll be 
> easy to add new languages and forget to update this. However, we don't do 
> that particularly often and this will loudly tell users about the lack of 
> support, so I think it's fine as-is.
I used the `types::isABC` functions because if a new input type is added, it 
will either be added to one of the `isABC` functions. If not, it would be save 
to not allow whitespace minimization with it until verified.

However, I did not think about the warning for missing enums. I am going to use 
a switch instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104601

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


[PATCH] D106173: [clang-tidy] performance-unnecessary-copy-initialization: Create option to exclude container types from triggering the check.

2021-07-22 Thread Felix Berger via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
flx marked an inline comment as done.
Closed by commit rGcb4c12b6117a: [clang-tidy] 
performance-unnecessary-copy-initialization: Create option to… (authored by 
flx).

Changed prior to commit:
  https://reviews.llvm.org/D106173?vs=360865=360951#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106173

Files:
  clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.h
  
clang-tools-extra/docs/clang-tidy/checks/performance-unnecessary-copy-initialization.rst
  
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization-excluded-container-types.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization-excluded-container-types.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization-excluded-container-types.cpp
@@ -0,0 +1,60 @@
+// RUN: %check_clang_tidy %s performance-unnecessary-copy-initialization %t -- -config="{CheckOptions: [{key: performance-unnecessary-copy-initialization.ExcludedContainerTypes, value: 'ns::ViewType$;::ConstInCorrectType$'}]}" --
+
+namespace ns {
+template 
+struct ViewType {
+  ViewType(const T &);
+  const T () const;
+};
+} // namespace ns
+
+template 
+struct ViewType {
+  ViewType(const T &);
+  const T () const;
+};
+
+struct ExpensiveToCopy {
+  ~ExpensiveToCopy();
+  void constMethod() const;
+};
+
+struct ConstInCorrectType {
+  const ExpensiveToCopy () const;
+};
+
+using NSVTE = ns::ViewType;
+typedef ns::ViewType FewType;
+
+void positiveViewType() {
+  ExpensiveToCopy E;
+  ViewType V(E);
+  const auto O = V.view();
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'O' is copy-constructed
+  // CHECK-FIXES: const auto& O = V.view();
+  O.constMethod();
+}
+
+void excludedViewTypeInNamespace() {
+  ExpensiveToCopy E;
+  ns::ViewType V(E);
+  const auto O = V.view();
+  O.constMethod();
+}
+
+void excludedViewTypeAliased() {
+  ExpensiveToCopy E;
+  NSVTE V(E);
+  const auto O = V.view();
+  O.constMethod();
+
+  FewType F(E);
+  const auto P = F.view();
+  P.constMethod();
+}
+
+void excludedConstIncorrectType() {
+  ConstInCorrectType C;
+  const auto E = C.secretlyMutates();
+  E.constMethod();
+}
Index: clang-tools-extra/docs/clang-tidy/checks/performance-unnecessary-copy-initialization.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/performance-unnecessary-copy-initialization.rst
+++ clang-tools-extra/docs/clang-tidy/checks/performance-unnecessary-copy-initialization.rst
@@ -47,3 +47,15 @@
is empty. If a name in the list contains the sequence `::` it is matched
against the qualified typename (i.e. `namespace::Type`, otherwise it is
matched against only the type name (i.e. `Type`).
+
+.. option:: ExcludedContainerTypes
+
+   A semicolon-separated list of names of types whose methods are allowed to
+   return the const reference the variable is copied from. When an expensive to
+   copy variable is copy initialized by the return value from a type on this
+   list the check does not trigger. This can be used to exclude types known to
+   be const incorrect or where the lifetime or immutability of returned
+   references is not tied to mutations of the container. An example are view
+   types that don't own the underlying data. Like for `AllowedTypes` above,
+   regular expressions are accepted and the inclusion of `::` determines whether
+   the qualified typename is matched or not.
Index: clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.h
===
--- clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.h
+++ clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.h
@@ -43,6 +43,7 @@
   const Stmt , const DeclStmt ,
   bool IssueFix, ASTContext );
   const std::vector AllowedTypes;
+  const std::vector ExcludedContainerTypes;
 };
 
 } // namespace performance
Index: clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
===
--- clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
+++ clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
@@ -75,7 +75,8 @@
   }
 }
 
-AST_MATCHER_FUNCTION(StatementMatcher, isConstRefReturningMethodCall) {
+AST_MATCHER_FUNCTION_P(StatementMatcher, isConstRefReturningMethodCall,
+   std::vector, ExcludedContainerTypes) {
   // Match method call expressions where the `this` argument is only 

[clang-tools-extra] cb4c12b - [clang-tidy] performance-unnecessary-copy-initialization: Create option to exclude container types from triggering the check.

2021-07-22 Thread Felix Berger via cfe-commits

Author: Felix Berger
Date: 2021-07-22T16:20:20-04:00
New Revision: cb4c12b6117a6f2989d5745854a94c75cb6a09ba

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

LOG: [clang-tidy] performance-unnecessary-copy-initialization: Create option to 
exclude container types from triggering the check.

Add string list option of type names analagous to `AllowedTypes` which lets
users specify a list of ExcludedContainerTypes.

Types matching this list will not trigger the check when an expensive variable
is copy initialized from a const accessor method they provide, i.e.:

```
ExcludedContainerTypes = 'ExcludedType'

void foo() {
  ExcludedType Container;
  const ExpensiveToCopy NecessaryCopy = Container.get();
}
```

Even though an expensive to copy variable is copy initialized the check does not
trigger because the container type is excluded.

This is useful for container types that don't own their data, such as view types
where modification of the returned references in other places cannot be reliably
tracked, or const incorrect types.

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

Reviewed-by: ymandel

Added: 

clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization-excluded-container-types.cpp

Modified: 
clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.h

clang-tools-extra/docs/clang-tidy/checks/performance-unnecessary-copy-initialization.rst

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp 
b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
index 9631e06a8f95b..6f9495fd1e66c 100644
--- a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
+++ b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
@@ -75,7 +75,8 @@ void recordRemoval(const DeclStmt , ASTContext ,
   }
 }
 
-AST_MATCHER_FUNCTION(StatementMatcher, isConstRefReturningMethodCall) {
+AST_MATCHER_FUNCTION_P(StatementMatcher, isConstRefReturningMethodCall,
+   std::vector, ExcludedContainerTypes) {
   // Match method call expressions where the `this` argument is only used as
   // const, this will be checked in `check()` part. This returned const
   // reference is highly likely to outlive the local const reference of the
@@ -85,7 +86,11 @@ AST_MATCHER_FUNCTION(StatementMatcher, 
isConstRefReturningMethodCall) {
   return cxxMemberCallExpr(
   callee(cxxMethodDecl(returns(matchers::isReferenceToConst()))
  .bind(MethodDeclId)),
-  on(declRefExpr(to(varDecl().bind(ObjectArgId);
+  on(declRefExpr(to(
+  varDecl(
+  
unless(hasType(qualType(hasCanonicalType(hasDeclaration(namedDecl(
+  matchers::matchesAnyListedName(ExcludedContainerTypes
+  .bind(ObjectArgId);
 }
 
 AST_MATCHER_FUNCTION(StatementMatcher, isConstRefReturningFunctionCall) {
@@ -98,11 +103,13 @@ AST_MATCHER_FUNCTION(StatementMatcher, 
isConstRefReturningFunctionCall) {
   .bind(InitFunctionCallId);
 }
 
-AST_MATCHER_FUNCTION(StatementMatcher, initializerReturnsReferenceToConst) {
+AST_MATCHER_FUNCTION_P(StatementMatcher, initializerReturnsReferenceToConst,
+   std::vector, ExcludedContainerTypes) {
   auto OldVarDeclRef =
   declRefExpr(to(varDecl(hasLocalStorage()).bind(OldVarDeclId)));
   return expr(
-  anyOf(isConstRefReturningFunctionCall(), isConstRefReturningMethodCall(),
+  anyOf(isConstRefReturningFunctionCall(),
+isConstRefReturningMethodCall(ExcludedContainerTypes),
 ignoringImpCasts(OldVarDeclRef),
 ignoringImpCasts(unaryOperator(hasOperatorName("&"),
hasUnaryOperand(OldVarDeclRef);
@@ -120,9 +127,9 @@ AST_MATCHER_FUNCTION(StatementMatcher, 
initializerReturnsReferenceToConst) {
 // the same set of criteria we apply when identifying the unnecessary copied
 // variable in this check to begin with. In this case we check whether the
 // object arg or variable that is referenced is immutable as well.
-static bool isInitializingVariableImmutable(const VarDecl ,
-const Stmt ,
-ASTContext ) {
+static bool isInitializingVariableImmutable(
+const VarDecl , const Stmt , ASTContext ,
+const std::vector ) {
   if (!isOnlyUsedAsConst(InitializingVar, BlockStmt, Context))
 return false;
 
@@ -138,18 +145,21 @@ static bool isInitializingVariableImmutable(const VarDecl 
,
 return true;
   }
 
-  auto Matches = match(initializerReturnsReferenceToConst(),
-

[PATCH] D106582: [DebugInfo] Add -fno-ctor-homing for as counterpart to -fuse-ctor-homing

2021-07-22 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D106582#2897678 , @akhuang wrote:

> In D106582#2897599 , @dblaikie 
> wrote:
>
>> Looks alright to me. (bit awkward having a documented cc1 option - since the 
>> cc1 options aren't meant to be user facing - hadn't really thought 
>> about/noticed that when reviewing the documentation originally in D95911 
>> )
>
> Oh, true. Since we're making ctor homing default maybe I should just make 
> them user facing flags.

I have mixed feelings - on the one hand, yeah, we're changing the behavior of 
`-fno-standalone-debug` and giving people a tool to undo that change if it's 
problematic is good (less chance we have to churn through reverting the change, 
fixing, reapplying, etc, if there's a way to opt-out, at least in the short 
term). But equally I don't want to proliferate various rather arbitrary buckets 
of debug info type homing - I really want to encourage people to think of it as 
a fairly all-or-nothing situation, because I don't think there's a good way to 
explain/improve/modify/use the feature if it's "whatever is good enough for my 
use case". Especially now that there's the `standalone_debug` attribute that 
can be used to fix particular use cases where a type is needed across a `-g0` 
boundary.

So... eh. Could go either way - your call, really. Though if we make it a full 
driver option, maybe a caveat that we may remove the functionality in the 
future (but that'll mean probably having to leave the flag in as a no-op/with 
some deprecation warning for some time after removing the functionality).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106582

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


[PATCH] D106585: Fix clang debug info irgen of i128 enums

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

Small nit but otherwise LGTM :)




Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:3118
+Value.setIsSigned(IsSigned);
+Enumerators.push_back(DBuilder.createEnumerator(Enum->getName(), Value));
   }





Comment at: llvm/lib/IR/DIBuilder.cpp:255
+  assert(!Name.empty() && "Unable to create enumerator without name");
+  return DIEnumerator::get(VMContext, APInt(Value), Value.isUnsigned(), Name);
+}

Do I get it right, and this is not the first place that I noticed this, but the 
terminology here is a bit unconventional with regards to "Signed" vs "Negative"?

It looks like around the debug info code, an APSInt will be a signed positive 
value for representing a negative number, and an unsigned one to represent a 
positive value.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106585

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


[PATCH] D106583: [clang] SIGSEGV at DeduceTemplateArgumentsByTypeMatch

2021-07-22 Thread Ivan Murashko via Phabricator via cfe-commits
ivanmurashko added a comment.

@erichkeane, is it OK if the reproducer will be added as the LIT test?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106583

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


[PATCH] D104797: [WebAssembly] Implementation of global.get/set for reftypes in LLVM IR

2021-07-22 Thread Paulo Matos 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 rG46667a10039b: [WebAssembly] Implementation of global.get/set 
for reftypes in LLVM IR (authored by pmatos).

Changed prior to commit:
  https://reviews.llvm.org/D104797?vs=360055=360946#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104797

Files:
  clang/lib/Basic/Targets/WebAssembly.h
  clang/test/CodeGen/target-data.c
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/include/llvm/CodeGen/ValueTypes.h
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/CodeGen/MachineOperand.cpp
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/lib/CodeGen/TargetLoweringBase.cpp
  llvm/lib/CodeGen/ValueTypes.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h
  llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISD.def
  llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h
  llvm/lib/Target/WebAssembly/WebAssemblyInstrTable.td
  llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/test/CodeGen/WebAssembly/externref-globalget.ll
  llvm/test/CodeGen/WebAssembly/externref-globalset.ll
  llvm/test/CodeGen/WebAssembly/externref-inttoptr.ll
  llvm/test/CodeGen/WebAssembly/externref-ptrtoint.ll
  llvm/test/CodeGen/WebAssembly/externref-undef.ll
  llvm/test/CodeGen/WebAssembly/externref-unsized-load.ll
  llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
  llvm/test/CodeGen/WebAssembly/funcref-call.ll
  llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
  llvm/test/CodeGen/WebAssembly/funcref-globalset.ll

Index: llvm/test/CodeGen/WebAssembly/funcref-globalset.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/funcref-globalset.ll
@@ -0,0 +1,20 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s
+
+%func = type opaque
+%funcref = type %func addrspace(20)* ;; addrspace 20 is nonintegral
+
+@funcref_global = local_unnamed_addr addrspace(1) global %funcref undef
+
+define void @set_funcref_global(%funcref %g) {
+  ;; this generates a global.set of @funcref_global
+  store %funcref %g, %funcref addrspace(1)* @funcref_global
+  ret void
+}
+
+; CHECK-LABEL: set_funcref_global:
+; CHECK-NEXT: functype   set_funcref_global (funcref) -> ()
+; CHECK-NEXT: local.get  0
+; CHECK-NEXT: global.set funcref_global
+; CHECK-NEXT: end_function
+
+; CHECK: .globl funcref_global
Index: llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
@@ -0,0 +1,19 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s
+
+%func = type opaque
+%funcref = type %func addrspace(20)* ;; addrspace 20 is nonintegral
+
+@funcref_global = local_unnamed_addr addrspace(1) global %funcref undef
+
+define %funcref @return_funcref_global() {
+  ;; this generates a global.get of @funcref_global
+  %ref = load %funcref, %funcref addrspace(1)* @funcref_global
+  ret %funcref %ref
+}
+
+; CHECK-LABEL: return_funcref_global:
+; CHECK-NEXT: .functype   return_funcref_global () -> (funcref)
+; CHECK-NEXT: global.get funcref_global
+; CHECK-NEXT: end_function
+
+; CHECK: .globl funcref_global
Index: llvm/test/CodeGen/WebAssembly/funcref-call.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/funcref-call.ll
@@ -0,0 +1,24 @@
+; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s
+
+%func = type void ()
+%funcref = type %func addrspace(20)* ;; addrspace 20 is nonintegral
+
+define void @call_funcref(%funcref %ref) {
+  call addrspace(20) void %ref() 
+  ret void
+}
+
+; CHECK: .tabletype __funcref_call_table, funcref, 1
+
+; CHECK-LABEL: call_funcref:
+; CHECK-NEXT: functype   call_funcref (funcref) -> ()
+; CHECK-NEXT: i32.const 0
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: table.set __funcref_call_table
+; CHECK-NEXT: local.get 0
+; CHECK-NEXT: call_indirect __funcref_call_table, () -> ()
+; CHECK-NEXT: i32.const 0
+; CHECK-NEXT: ref.null func
+; CHECK-NEXT: table.set __funcref_call_table
+; CHECK-NEXT: end_function
+
Index: llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
@@ -0,0 +1,11 @@
+; RUN: not llc --mtriple=wasm32-unknown-unknown 

[clang] 46667a1 - [WebAssembly] Implementation of global.get/set for reftypes in LLVM IR

2021-07-22 Thread Paulo Matos via cfe-commits

Author: Paulo Matos
Date: 2021-07-22T22:07:24+02:00
New Revision: 46667a10039b664b953eb70534c27627b35a267d

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

LOG: [WebAssembly] Implementation of global.get/set for reftypes in LLVM IR

Reland of 31859f896.

This change implements new DAG notes GLOBAL_GET/GLOBAL_SET, and
lowering methods for load and stores of reference types from IR
globals. Once the lowering creates the new nodes, tablegen pattern
matches those and converts them to Wasm global.get/set.

Reviewed By: tlively

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

Added: 
llvm/test/CodeGen/WebAssembly/externref-globalget.ll
llvm/test/CodeGen/WebAssembly/externref-globalset.ll
llvm/test/CodeGen/WebAssembly/externref-inttoptr.ll
llvm/test/CodeGen/WebAssembly/externref-ptrtoint.ll
llvm/test/CodeGen/WebAssembly/externref-undef.ll
llvm/test/CodeGen/WebAssembly/externref-unsized-load.ll
llvm/test/CodeGen/WebAssembly/externref-unsized-store.ll
llvm/test/CodeGen/WebAssembly/funcref-call.ll
llvm/test/CodeGen/WebAssembly/funcref-globalget.ll
llvm/test/CodeGen/WebAssembly/funcref-globalset.ll

Modified: 
clang/lib/Basic/Targets/WebAssembly.h
clang/test/CodeGen/target-data.c
llvm/include/llvm/CodeGen/TargetLowering.h
llvm/include/llvm/CodeGen/ValueTypes.h
llvm/lib/CodeGen/CodeGenPrepare.cpp
llvm/lib/CodeGen/MachineOperand.cpp
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/lib/CodeGen/TargetLoweringBase.cpp
llvm/lib/CodeGen/ValueTypes.cpp
llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.cpp
llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h
llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
llvm/lib/Target/WebAssembly/WebAssemblyISD.def
llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h
llvm/lib/Target/WebAssembly/WebAssemblyInstrTable.td
llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/WebAssembly.h 
b/clang/lib/Basic/Targets/WebAssembly.h
index a43e770eb1e8c..4a5ba25c75e7e 100644
--- a/clang/lib/Basic/Targets/WebAssembly.h
+++ b/clang/lib/Basic/Targets/WebAssembly.h
@@ -150,9 +150,9 @@ class LLVM_LIBRARY_VISIBILITY WebAssembly32TargetInfo
const TargetOptions )
   : WebAssemblyTargetInfo(T, Opts) {
 if (T.isOSEmscripten())
-  resetDataLayout("e-m:e-p:32:32-i64:64-f128:64-n32:64-S128-ni:1");
+  resetDataLayout("e-m:e-p:32:32-i64:64-f128:64-n32:64-S128-ni:1:10:20");
 else
-  resetDataLayout("e-m:e-p:32:32-i64:64-n32:64-S128-ni:1");
+  resetDataLayout("e-m:e-p:32:32-i64:64-n32:64-S128-ni:1:10:20");
   }
 
 protected:
@@ -172,9 +172,9 @@ class LLVM_LIBRARY_VISIBILITY WebAssembly64TargetInfo
 PtrDiffType = SignedLong;
 IntPtrType = SignedLong;
 if (T.isOSEmscripten())
-  resetDataLayout("e-m:e-p:64:64-i64:64-f128:64-n32:64-S128-ni:1");
+  resetDataLayout("e-m:e-p:64:64-i64:64-f128:64-n32:64-S128-ni:1:10:20");
 else
-  resetDataLayout("e-m:e-p:64:64-i64:64-n32:64-S128-ni:1");
+  resetDataLayout("e-m:e-p:64:64-i64:64-n32:64-S128-ni:1:10:20");
   }
 
 protected:

diff  --git a/clang/test/CodeGen/target-data.c 
b/clang/test/CodeGen/target-data.c
index 1d88984530e5b..1be01efd16515 100644
--- a/clang/test/CodeGen/target-data.c
+++ b/clang/test/CodeGen/target-data.c
@@ -108,11 +108,11 @@
 
 // RUN: %clang_cc1 -triple wasm32-unknown-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=WEBASSEMBLY32
-// WEBASSEMBLY32: target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128-ni:1"
+// WEBASSEMBLY32: target datalayout = 
"e-m:e-p:32:32-i64:64-n32:64-S128-ni:1:10:20"
 
 // RUN: %clang_cc1 -triple wasm64-unknown-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=WEBASSEMBLY64
-// WEBASSEMBLY64: target datalayout = "e-m:e-p:64:64-i64:64-n32:64-S128-ni:1"
+// WEBASSEMBLY64: target datalayout = 
"e-m:e-p:64:64-i64:64-n32:64-S128-ni:1:10:20"
 
 // RUN: %clang_cc1 -triple lanai-unknown-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=LANAI

diff  --git a/llvm/include/llvm/CodeGen/TargetLowering.h 
b/llvm/include/llvm/CodeGen/TargetLowering.h
index 1cf6ac0e5f949..9b42cc9dfb3a0 100644
--- a/llvm/include/llvm/CodeGen/TargetLowering.h
+++ b/llvm/include/llvm/CodeGen/TargetLowering.h
@@ -349,7 +349,7 @@ class TargetLoweringBase {
   /// Return the in-memory pointer type for the given address space, defaults 
to
   /// the pointer type from the data layout.  FIXME: The default needs to be
   /// removed once all 

[PATCH] D105909: [clang][CallGraphSection] Add type id metadata to indirect call and targets

2021-07-22 Thread Necip Fazil Yildiran via Phabricator via cfe-commits
necipfazil marked an inline comment as done.
necipfazil added inline comments.



Comment at: llvm/include/llvm/IR/LLVMContext.h:97
 OB_clang_arc_attachedcall = 6, // "clang.arc.attachedcall"
+OB_type = 7,   // "type"
   };

morehouse wrote:
> necipfazil wrote:
> > morehouse wrote:
> > > Do we need to update `LLVMContext::LLVMContext()`?
> > Operand bundles are originally used as input to lowering in 
> > `SelectionDAGBuilder`. Arbitrary operand bundles are not allowed.
> > 
> > To allow `type` operand bundle, we need this change. Please see 
> > `llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp` for related changes.
> So why don't you need to update `LLVMContext::LLVMContext()` then?  All other 
> operand bundle types are there.
I added further verifications in LLVMContext::LLVMContext() and some tests for 
it.

If we requested updates are for somewhere else, could you please provide more 
details?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105909

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


[PATCH] D105477: [AIX] Define __LONGDOUBLE64 macro

2021-07-22 Thread Jake Egan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1b52e9bac207: [AIX] Define __LONGDOUBLE64 macro (authored by 
Jake-Egan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105477

Files:
  clang/lib/Basic/Targets/PPC.cpp
  clang/test/Preprocessor/init-ppc.c


Index: clang/test/Preprocessor/init-ppc.c
===
--- clang/test/Preprocessor/init-ppc.c
+++ clang/test/Preprocessor/init-ppc.c
@@ -758,6 +758,9 @@
 // PPC-AIX-STDC-N-NOT:#define __STDC_NO_ATOMICS__ 1
 // PPC-AIX-STDC-N-NOT:#define __STDC_NO_THREADS__ 1
 
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix7.1.0.0 
-mlong-double-64 < /dev/null | FileCheck -match-full-lines -check-prefix 
PPC-AIX-LD64 %s
+// PPC-AIX-LD64:#define __LONGDOUBLE64 1
+
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-unknown-linux-gnu 
-fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix 
PPC-LINUX %s
 //
 // PPC-LINUX:#define _ARCH_PPC 1
Index: clang/lib/Basic/Targets/PPC.cpp
===
--- clang/lib/Basic/Targets/PPC.cpp
+++ clang/lib/Basic/Targets/PPC.cpp
@@ -296,6 +296,11 @@
   Builder.defineMacro("__LONG_DOUBLE_IBM128__");
   }
 
+  if (getTriple().isOSAIX() && Opts.LongDoubleSize == 64) {
+assert(LongDoubleWidth == 64);
+Builder.defineMacro("__LONGDOUBLE64");
+  }
+
   // Define this for elfv2 (64-bit only) or 64-bit darwin.
   if (ABI == "elfv2" ||
   (getTriple().getOS() == llvm::Triple::Darwin && PointerWidth == 64))


Index: clang/test/Preprocessor/init-ppc.c
===
--- clang/test/Preprocessor/init-ppc.c
+++ clang/test/Preprocessor/init-ppc.c
@@ -758,6 +758,9 @@
 // PPC-AIX-STDC-N-NOT:#define __STDC_NO_ATOMICS__ 1
 // PPC-AIX-STDC-N-NOT:#define __STDC_NO_THREADS__ 1
 
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix7.1.0.0 -mlong-double-64 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX-LD64 %s
+// PPC-AIX-LD64:#define __LONGDOUBLE64 1
+
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-unknown-linux-gnu -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPC-LINUX %s
 //
 // PPC-LINUX:#define _ARCH_PPC 1
Index: clang/lib/Basic/Targets/PPC.cpp
===
--- clang/lib/Basic/Targets/PPC.cpp
+++ clang/lib/Basic/Targets/PPC.cpp
@@ -296,6 +296,11 @@
   Builder.defineMacro("__LONG_DOUBLE_IBM128__");
   }
 
+  if (getTriple().isOSAIX() && Opts.LongDoubleSize == 64) {
+assert(LongDoubleWidth == 64);
+Builder.defineMacro("__LONGDOUBLE64");
+  }
+
   // Define this for elfv2 (64-bit only) or 64-bit darwin.
   if (ABI == "elfv2" ||
   (getTriple().getOS() == llvm::Triple::Darwin && PointerWidth == 64))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 1b52e9b - [AIX] Define __LONGDOUBLE64 macro

2021-07-22 Thread Jake Egan via cfe-commits

Author: Jake Egan
Date: 2021-07-22T16:05:14-04:00
New Revision: 1b52e9bac207cd4bdcd9091178527aa39049c270

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

LOG: [AIX] Define __LONGDOUBLE64 macro

This patch defines the macro __LONGDOUBLE64 for AIX when long double is 8 bytes.

Reviewed By: cebowleratibm

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

Added: 


Modified: 
clang/lib/Basic/Targets/PPC.cpp
clang/test/Preprocessor/init-ppc.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index 409504d054f14..59656888e25f9 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -296,6 +296,11 @@ void PPCTargetInfo::getTargetDefines(const LangOptions 
,
   Builder.defineMacro("__LONG_DOUBLE_IBM128__");
   }
 
+  if (getTriple().isOSAIX() && Opts.LongDoubleSize == 64) {
+assert(LongDoubleWidth == 64);
+Builder.defineMacro("__LONGDOUBLE64");
+  }
+
   // Define this for elfv2 (64-bit only) or 64-bit darwin.
   if (ABI == "elfv2" ||
   (getTriple().getOS() == llvm::Triple::Darwin && PointerWidth == 64))

diff  --git a/clang/test/Preprocessor/init-ppc.c 
b/clang/test/Preprocessor/init-ppc.c
index 4803a8511c7ed..cbcd10fa1ae52 100644
--- a/clang/test/Preprocessor/init-ppc.c
+++ b/clang/test/Preprocessor/init-ppc.c
@@ -758,6 +758,9 @@
 // PPC-AIX-STDC-N-NOT:#define __STDC_NO_ATOMICS__ 1
 // PPC-AIX-STDC-N-NOT:#define __STDC_NO_THREADS__ 1
 
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix7.1.0.0 
-mlong-double-64 < /dev/null | FileCheck -match-full-lines -check-prefix 
PPC-AIX-LD64 %s
+// PPC-AIX-LD64:#define __LONGDOUBLE64 1
+
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-unknown-linux-gnu 
-fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix 
PPC-LINUX %s
 //
 // PPC-LINUX:#define _ARCH_PPC 1



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


[PATCH] D105909: [clang][CallGraphSection] Add type id metadata to indirect call and targets

2021-07-22 Thread Necip Fazil Yildiran via Phabricator via cfe-commits
necipfazil updated this revision to Diff 360942.
necipfazil added a comment.

Verify type operand bundle usage

- Check if type operand bundle id is drifted
- Verify and complain if multiple type operand bundles are used
- Add type operand bundle test to operand bundle verifier tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105909

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/call-graph-section-1.cpp
  clang/test/CodeGen/call-graph-section-2.cpp
  clang/test/CodeGen/call-graph-section-3.cpp
  clang/test/CodeGen/call-graph-section.c
  llvm/include/llvm/IR/LLVMContext.h
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/IR/LLVMContext.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/test/Verifier/operand-bundles.ll

Index: llvm/test/Verifier/operand-bundles.ll
===
--- llvm/test/Verifier/operand-bundles.ll
+++ llvm/test/Verifier/operand-bundles.ll
@@ -81,4 +81,17 @@
   ret void
 }
 
+define void @f_type(i32* %ptr) {
+; CHECK: Multiple "type" operand bundles
+; CHECK-NEXT: call void @g() [ "type"(metadata !"_ZTSFvE.generalized"), "type"(metadata !"_ZTSFvE.generalized") ]
+; CHECK-NOT: call void @g() [ "type"(metadata !"_ZTSFvE.generalized") ]
+
+ entry:
+  %l = load i32, i32* %ptr
+   call void @g() [ "type"(metadata !"_ZTSFvE.generalized"), "type"(metadata !"_ZTSFvE.generalized") ]
+  call void @g() [ "type"(metadata !"_ZTSFvE.generalized") ]
+  %x = add i32 42, 1
+  ret void
+}
+
 attributes #0 = { noreturn }
Index: llvm/lib/IR/Verifier.cpp
===
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -3205,12 +3205,12 @@
   visitIntrinsicCall(ID, Call);
 
   // Verify that a callsite has at most one "deopt", at most one "funclet", at
-  // most one "gc-transition", at most one "cfguardtarget",
+  // most one "gc-transition", at most one "cfguardtarget", at most one "type",
   // and at most one "preallocated" operand bundle.
   bool FoundDeoptBundle = false, FoundFuncletBundle = false,
FoundGCTransitionBundle = false, FoundCFGuardTargetBundle = false,
FoundPreallocatedBundle = false, FoundGCLiveBundle = false,
-   FoundAttachedCallBundle = false;
+   FoundAttachedCallBundle = false, FoundTypeBundle = false;
   for (unsigned i = 0, e = Call.getNumOperandBundles(); i < e; ++i) {
 OperandBundleUse BU = Call.getOperandBundleAt(i);
 uint32_t Tag = BU.getTagID();
@@ -3255,6 +3255,9 @@
   Assert(!FoundAttachedCallBundle,
  "Multiple \"clang.arc.attachedcall\" operand bundles", Call);
   FoundAttachedCallBundle = true;
+} else if (Tag == LLVMContext::OB_type) {
+  Assert(!FoundTypeBundle, "Multiple \"type\" operand bundles", Call);
+  FoundTypeBundle = true;
 }
   }
 
Index: llvm/lib/IR/LLVMContext.cpp
===
--- llvm/lib/IR/LLVMContext.cpp
+++ llvm/lib/IR/LLVMContext.cpp
@@ -84,6 +84,11 @@
  "clang.arc.attachedcall operand bundle id drifted!");
   (void)ClangAttachedCall;
 
+  auto *TypeEntry = pImpl->getOrInsertBundleTag("type");
+  assert(TypeEntry->second == LLVMContext::OB_type &&
+ "type operand bundle id drifted!");
+  (void)TypeEntry;
+
   SyncScope::ID SingleThreadSSID =
   pImpl->getOrInsertSyncScopeID("singlethread");
   assert(SingleThreadSSID == SyncScope::SingleThread &&
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -2877,7 +2877,7 @@
  {LLVMContext::OB_deopt, LLVMContext::OB_gc_transition,
   LLVMContext::OB_gc_live, LLVMContext::OB_funclet,
   LLVMContext::OB_cfguardtarget,
-  LLVMContext::OB_clang_arc_attachedcall}) &&
+  LLVMContext::OB_clang_arc_attachedcall, LLVMContext::OB_type}) &&
  "Cannot lower invokes with arbitrary operand bundles yet!");
 
   const Value *Callee(I.getCalledOperand());
@@ -2960,8 +2960,9 @@
 
   // Deopt bundles are lowered in LowerCallSiteWithDeoptBundle, and we don't
   // have to do anything here to lower funclet bundles.
-  assert(!I.hasOperandBundlesOtherThan(
- {LLVMContext::OB_deopt, LLVMContext::OB_funclet}) &&
+  assert(!I.hasOperandBundlesOtherThan({LLVMContext::OB_deopt,
+LLVMContext::OB_funclet,
+LLVMContext::OB_type}) &&
  "Cannot lower callbrs with arbitrary operand bundles yet!");
 
   assert(I.isInlineAsm() && "Only know how to handle inlineasm callbr");
@@ -8086,7 +8087,7 @@
   assert(!I.hasOperandBundlesOtherThan(
  {LLVMContext::OB_deopt, 

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

2021-07-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Pragmas and magic comments both have ergonomic issues, so it's really about the 
tradeoffs. Personally, I think it's more reasonable to support this as a pragma 
than as a magic-comment. Pragmas are a mystery to users, but they're less of a 
mystery than comments that carry semantic weight. I think it's somewhat more 
advantageous to use a pragma because if a system header uses this pragma in an 
unguarded way, they get told about their mistake (which is somewhat valuable), 
and code editors are far better about autocompleting actual syntax than they 
are with things like magic comments.




Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:303
   InGroup>;
+def pp_pragma_include_instead_not_sysheader : Warning<
+  "'#pragma include_instead' ignored outside of system headers">,

Design-wise, do we want this one to be an error instead of a warning? I don't 
have strong feelings one way or the other, but making it an error ensures no 
one finds creative ways to use it outside of a system header by accident (and 
we can relax the restriction later if there are reasons to do so).



Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:304
+def pp_pragma_include_instead_not_sysheader : Warning<
+  "'#pragma include_instead' ignored outside of system headers">,
+  InGroup,

I think these diagnostics should say `'#pragma clang include_instead'` (we're 
not super consistent about this, but the surrounding single quotes are intended 
to convey syntactic constructs and so it should probably be valid syntax).



Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:306
+  InGroup,
+  ShowInSystemHeader;
+def pp_pragma_include_instead_unexpected_token : Warning<

O.o... why do we need to show this one in system headers if the diagnostic can 
only trigger outside of a system header?



Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:307-310
+def pp_pragma_include_instead_unexpected_token : Warning<
+  "'#pragma include_instead' expects '%0' as its next token; got '%1' 
instead">,
+  InGroup,
+  ShowInSystemHeader;

No need for a new warning -- I think we can use existing diagnostics for this 
(like `err_pp_expects_filename`). Also, I think syntax issues should be 
diagnosed as an error instead of a warning -- we expect a particular syntactic 
form and it's reasonable for us to enforce that users get it right.



Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:311-314
+def pp_pragma_include_instead_file_not_found : Warning<
+  "'%0' file not found">,
+  InGroup,
+  ShowInSystemHeader;

Do we need this one or can we use `err_pp_file_not_found`?



Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:315
+  ShowInSystemHeader;
+def pp_pragma_include_instead_system_reserved : Warning<
+  "header '%0' is an implementation detail; #include %select{'%2'|either '%2' 
or '%3'|one of %2}1 instead">,

Do we want to give this pragma teeth by making this an error? Right now, an 
intrepid user can simply ignore the diagnostic, form the reliance on the 
header, and we've not really solved the problem we set out to solve. Then 
again, perhaps you'd like that as an escape hatch for some reason?



Comment at: clang/include/clang/Lex/PreprocessorLexer.h:188-189
+
+  void addInclude(const StringRef Filename, const FileEntry ,
+  const SourceLocation Location) {
+IncludeHistory.insert({Filename, {, Location}});

It's not wrong, but we don't usually do top-level `const` qualification of 
value types.



Comment at: clang/lib/Lex/PPDirectives.cpp:2025
 
+  // Record the header's filename for later use
+  if (File)





Comment at: clang/lib/Lex/PPLexerChange.cpp:313
+
+  auto IncludeHistory = CurLexer->getIncludeHistory();
+  for (const auto  : IncludeHistory) {

Please spell out the type instead of using `auto` or sink this into the `for` 
loop



Comment at: clang/lib/Lex/PPLexerChange.cpp:315
+  for (const auto  : IncludeHistory) {
+const StringRef Filename = Include.getKey();
+const auto  = Include.getValue();





Comment at: clang/lib/Lex/PPLexerChange.cpp:316
+const StringRef Filename = Include.getKey();
+const auto  = Include.getValue();
+const HeaderFileInfo  = HeaderInfo.getFileInfo(IncludeInfo.File);

Please spell out the type.



Comment at: clang/lib/Lex/PPLexerChange.cpp:335
+  std::string Aliases;
+  llvm::interleave(
+  Info.Aliases,

Can you use `llvm::join()` from `StringExtras.h` for this or does the insertion 
of the single quotes make that awkward?



Comment at: 

[PATCH] D106577: [clang] Define __STDC_ISO_10646__

2021-07-22 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

In D106577#2897588 , @aaron.ballman 
wrote:

> In D106577#2897522 , @jyknight 
> wrote:
>
>> I'm not sure we should be populating this.
>>
>> The _value_ is determined by what libc supports, so it probably needs to be 
>> left up to libc to define it.
>
> Why is the value determined by what libc supports? The definition from the 
> standard is:
>
>   If this symbol is defined, then every character in the Unicode required 
> set, when stored in an
>   object of type wchar_t, has the same value as the short identifier of that 
> character.
>
> That doesn't seem to imply anything about the library, just the size of 
> `wchar_t`.

Huh. So it doesn't! Not sure why I got that idea. Disregard my comment then -- 
I agree that just setting it to some arbitrary unicode version ought to be OK, 
and there's probably no need to ever change it, since the set of possible 
unicode values isn't ever going to change.

And if the C library also defines this macro in its headers, that's ok, since 
-Wmacro-redefinition is suppressed by system headers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106577

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


[PATCH] D106582: [DebugInfo] Add -fno-ctor-homing for as counterpart to -fuse-ctor-homing

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

In D106582#2897599 , @dblaikie wrote:

> Looks alright to me. (bit awkward having a documented cc1 option - since the 
> cc1 options aren't meant to be user facing - hadn't really thought 
> about/noticed that when reviewing the documentation originally in D95911 
> )

Oh, true. Since we're making ctor homing default maybe I should just make them 
user facing flags.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106582

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


[PATCH] D106577: [clang] Define __STDC_ISO_10646__

2021-07-22 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

In D106577#2897588 , @aaron.ballman 
wrote:

> In D106577#2897522 , @jyknight 
> wrote:
>
>> I'm not sure we should be populating this.
>>
>> The _value_ is determined by what libc supports, so it probably needs to be 
>> left up to libc to define it.
>
> Why is the value determined by what libc supports? The definition from the 
> standard is:
>
>   If this symbol is defined, then every character in the Unicode required 
> set, when stored in an
>   object of type wchar_t, has the same value as the short identifier of that 
> character.
>
> That doesn't seem to imply anything about the library, just the size of 
> `wchar_t`.

That's my reading as well.
This is only about representability, not about what the locale features can 
handle (if anything).
In particular, setting it only on linux would be less than useful. 
The primary use of this macro is to detect environments where wchar_t is not 
UTF-32, namely windows and IBM platforms.
So this should be defined on all relevant platforms, not just the ones which 
use glibc

Note that this patch came about because someone had trouble with that macro not 
being present on mac.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106577

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


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

2021-07-22 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added subscribers: dblaikie, MaskRay, LemonBoy.
rnk added a comment.

I decided it would be faster and more convenient to respond in the form of a 
code review for clang, so here it is: D106585 

Assuming that goes through, go ahead and rebase onto that after it lands.




Comment at: clang/test/CodeGenCXX/debug-info-codeview-int128.cpp:1
+// RUN: %clang_cc1 -triple x86_64-windows-gnu -debug-info-kind=limited 
-gcodeview -S -emit-llvm %s -o - | FileCheck %s --check-prefix=LL
+// RUN: %clang_cc1 -triple x86_64-windows-gnu -debug-info-kind=limited 
-gcodeview -S %s -o - | FileCheck %s --check-prefix=ASM

FWIW this actually isn't codeview specific. The existing code crashes if you 
compile for DWARF too:
https://gcc.godbolt.org/z/3ox8c87Y4

To channel @dblaikie , this test should be split up: ensure that clang produces 
the right LLVM IR, then add a codeview specific LLVM IR test case. We prefer to 
test the smallest testable unit.



Comment at: llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp:200
+  int64_t Val =
+  Value.getNumWords() <= 1U ? Value.getSExtValue() : INT64_MIN;
+  return writeEncodedSignedInteger(Val);

You can use `Value.isSingleWord()` for a simpler condition.



Comment at: llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp:204
+uint64_t Val =
+Value.getNumWords() <= 1U ? Value.getZExtValue() : UINT64_MAX;
+return writeEncodedUnsignedInteger(Val);

This can be `Value.getLimitedValue()`.



Comment at: llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp:283
 const Twine ) {
+  // FIXME: There are no test cases covering this function.
   if (Value >= std::numeric_limits::min()) {

I think this particular method is uncovered because of a separate bug. We 
always consider enumerators to be unsigned:
https://github.com/llvm/llvm-project/blob/main/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp#L2120

I'm not sure if that's a bug or if it is intended, but that's why this is 
relatively uncovered.



Comment at: llvm/lib/IR/DIBuilder.cpp:249
   assert(!Name.empty() && "Unable to create enumerator without name");
   return DIEnumerator::get(VMContext, APInt(64, Val, !IsUnsigned), IsUnsigned,
Name);

Since DIEnumerator actually stores an APInt, can you add an overload that 
accepts an APSInt and call that from clang instead? The implementation will 
have to decompose the sign bit and slice out the APInt portion, but that seems 
like a better way of handling this.

I noticed the APInt change to DIEnumerator is new as of D62475, so April 2020. 
+@maskray @LemonBoy 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105320

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


[clang] 7d669e6 - [AIX] Generate large code model relocations when mcmodel=medium on AIX

2021-07-22 Thread Hubert Tong via cfe-commits

Author: Anjan Kumar Guttahalli Krishna
Date: 2021-07-22T15:47:22-04:00
New Revision: 7d669ec1d67c1b4aecd90687013636d8037c

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

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

This patch makes the changes in the driver that converts the medium code
model to large.

Reviewed By: hubert.reinterpretcast

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/mcmodel.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 75bc32916371..0ebbad7e8877 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5136,11 +5136,15 @@ void Clang::ConstructJob(Compilation , const 
JobAction ,
   if (Arg *A = Args.getLastArg(options::OPT_mcmodel_EQ)) {
 StringRef CM = A->getValue();
 if (CM == "small" || CM == "kernel" || CM == "medium" || CM == "large" ||
-CM == "tiny")
-  A->render(Args, CmdArgs);
-else
+CM == "tiny") {
+  if (Triple.isOSAIX() && CM == "medium")
+CmdArgs.push_back("-mcmodel=large");
+  else
+A->render(Args, CmdArgs);
+} else {
   D.Diag(diag::err_drv_invalid_argument_to_option)
   << CM << A->getOption().getName();
+}
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_mtls_size_EQ)) {

diff  --git a/clang/test/Driver/mcmodel.c b/clang/test/Driver/mcmodel.c
index 8df5c6a7e38b..2c74c966744a 100644
--- a/clang/test/Driver/mcmodel.c
+++ b/clang/test/Driver/mcmodel.c
@@ -3,6 +3,8 @@
 // RUN: %clang -target x86_64 -### -S -mcmodel=kernel %s 2>&1 | FileCheck 
--check-prefix=KERNEL %s
 // RUN: %clang -target x86_64 -### -c -mcmodel=medium %s 2>&1 | FileCheck 
--check-prefix=MEDIUM %s
 // RUN: %clang -target x86_64 -### -S -mcmodel=large %s 2>&1 | FileCheck 
--check-prefix=LARGE %s
+// RUN: %clang -target powerpc-unknown-aix -### -S -mcmodel=medium %s 2> %t.log
+// RUN: FileCheck --check-prefix=AIX-MCMEDIUM-OVERRIDE %s < %t.log
 // RUN: not %clang -c -mcmodel=lager %s 2>&1 | FileCheck 
--check-prefix=INVALID %s
 
 // TINY: "-mcmodel=tiny"
@@ -10,5 +12,6 @@
 // KERNEL: "-mcmodel=kernel"
 // MEDIUM: "-mcmodel=medium"
 // LARGE: "-mcmodel=large"
+// AIX-MCMEDIUM-OVERRIDE: "-mcmodel=large"
 
 // INVALID: error: invalid argument 'lager' to -mcmodel=



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


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

2021-07-22 Thread Hubert Tong 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 rG7d669ec1: [AIX] Generate large code model relocations 
when mcmodel=medium on AIX (authored by anjankgk, committed by 
hubert.reinterpretcast).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106371

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/mcmodel.c


Index: clang/test/Driver/mcmodel.c
===
--- clang/test/Driver/mcmodel.c
+++ clang/test/Driver/mcmodel.c
@@ -3,6 +3,8 @@
 // RUN: %clang -target x86_64 -### -S -mcmodel=kernel %s 2>&1 | FileCheck 
--check-prefix=KERNEL %s
 // RUN: %clang -target x86_64 -### -c -mcmodel=medium %s 2>&1 | FileCheck 
--check-prefix=MEDIUM %s
 // RUN: %clang -target x86_64 -### -S -mcmodel=large %s 2>&1 | FileCheck 
--check-prefix=LARGE %s
+// RUN: %clang -target powerpc-unknown-aix -### -S -mcmodel=medium %s 2> %t.log
+// RUN: FileCheck --check-prefix=AIX-MCMEDIUM-OVERRIDE %s < %t.log
 // RUN: not %clang -c -mcmodel=lager %s 2>&1 | FileCheck 
--check-prefix=INVALID %s
 
 // TINY: "-mcmodel=tiny"
@@ -10,5 +12,6 @@
 // KERNEL: "-mcmodel=kernel"
 // MEDIUM: "-mcmodel=medium"
 // LARGE: "-mcmodel=large"
+// AIX-MCMEDIUM-OVERRIDE: "-mcmodel=large"
 
 // INVALID: error: invalid argument 'lager' to -mcmodel=
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5136,11 +5136,15 @@
   if (Arg *A = Args.getLastArg(options::OPT_mcmodel_EQ)) {
 StringRef CM = A->getValue();
 if (CM == "small" || CM == "kernel" || CM == "medium" || CM == "large" ||
-CM == "tiny")
-  A->render(Args, CmdArgs);
-else
+CM == "tiny") {
+  if (Triple.isOSAIX() && CM == "medium")
+CmdArgs.push_back("-mcmodel=large");
+  else
+A->render(Args, CmdArgs);
+} else {
   D.Diag(diag::err_drv_invalid_argument_to_option)
   << CM << A->getOption().getName();
+}
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_mtls_size_EQ)) {


Index: clang/test/Driver/mcmodel.c
===
--- clang/test/Driver/mcmodel.c
+++ clang/test/Driver/mcmodel.c
@@ -3,6 +3,8 @@
 // RUN: %clang -target x86_64 -### -S -mcmodel=kernel %s 2>&1 | FileCheck --check-prefix=KERNEL %s
 // RUN: %clang -target x86_64 -### -c -mcmodel=medium %s 2>&1 | FileCheck --check-prefix=MEDIUM %s
 // RUN: %clang -target x86_64 -### -S -mcmodel=large %s 2>&1 | FileCheck --check-prefix=LARGE %s
+// RUN: %clang -target powerpc-unknown-aix -### -S -mcmodel=medium %s 2> %t.log
+// RUN: FileCheck --check-prefix=AIX-MCMEDIUM-OVERRIDE %s < %t.log
 // RUN: not %clang -c -mcmodel=lager %s 2>&1 | FileCheck --check-prefix=INVALID %s
 
 // TINY: "-mcmodel=tiny"
@@ -10,5 +12,6 @@
 // KERNEL: "-mcmodel=kernel"
 // MEDIUM: "-mcmodel=medium"
 // LARGE: "-mcmodel=large"
+// AIX-MCMEDIUM-OVERRIDE: "-mcmodel=large"
 
 // INVALID: error: invalid argument 'lager' to -mcmodel=
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5136,11 +5136,15 @@
   if (Arg *A = Args.getLastArg(options::OPT_mcmodel_EQ)) {
 StringRef CM = A->getValue();
 if (CM == "small" || CM == "kernel" || CM == "medium" || CM == "large" ||
-CM == "tiny")
-  A->render(Args, CmdArgs);
-else
+CM == "tiny") {
+  if (Triple.isOSAIX() && CM == "medium")
+CmdArgs.push_back("-mcmodel=large");
+  else
+A->render(Args, CmdArgs);
+} else {
   D.Diag(diag::err_drv_invalid_argument_to_option)
   << CM << A->getOption().getName();
+}
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_mtls_size_EQ)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106585: Fix clang debug info irgen of i128 enums

2021-07-22 Thread Reid Kleckner via Phabricator via cfe-commits
rnk created this revision.
rnk added reviewers: mizvekov, dblaikie, MaskRay.
Herald added subscribers: dexonsmith, hiraditya.
rnk requested review of this revision.
Herald added projects: clang, LLVM.
Herald added a subscriber: llvm-commits.

DIEnumerator stores an APInt as of April 2020, so now we don't need to
truncate the enumerator value to 64 bits. Fixes assertions during IRGen.

Split from D105320 , thanks to Matheus 
Izvekov for the test case and
report.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106585

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-enum-i128.cpp
  llvm/include/llvm/IR/DIBuilder.h
  llvm/lib/IR/DIBuilder.cpp


Index: llvm/lib/IR/DIBuilder.cpp
===
--- llvm/lib/IR/DIBuilder.cpp
+++ llvm/lib/IR/DIBuilder.cpp
@@ -250,6 +250,11 @@
Name);
 }
 
+DIEnumerator *DIBuilder::createEnumerator(StringRef Name, APSInt Value) {
+  assert(!Name.empty() && "Unable to create enumerator without name");
+  return DIEnumerator::get(VMContext, APInt(Value), Value.isUnsigned(), Name);
+}
+
 DIBasicType *DIBuilder::createUnspecifiedType(StringRef Name) {
   assert(!Name.empty() && "Unable to create type without name");
   return DIBasicType::get(VMContext, dwarf::DW_TAG_unspecified_type, Name);
Index: llvm/include/llvm/IR/DIBuilder.h
===
--- llvm/include/llvm/IR/DIBuilder.h
+++ llvm/include/llvm/IR/DIBuilder.h
@@ -181,7 +181,9 @@
  DIFile *File);
 
 /// Create a single enumerator value.
-DIEnumerator *createEnumerator(StringRef Name, int64_t Val, bool 
IsUnsigned = false);
+DIEnumerator *createEnumerator(StringRef Name, APSInt Value);
+DIEnumerator *createEnumerator(StringRef Name, int64_t Val,
+   bool IsUnsigned = false);
 
 /// Create a DWARF unspecified type.
 DIBasicType *createUnspecifiedType(StringRef Name);
Index: clang/test/CodeGenCXX/debug-info-enum-i128.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/debug-info-enum-i128.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -triple x86_64-windows-msvc -gcodeview 
-debug-info-kind=limited -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple x86_64-linux-gnu -debug-info-kind=limited 
-emit-llvm -o - | FileCheck %s
+
+enum class uns : __uint128_t { unsval = __uint128_t(1) << 64 };
+uns t1() { return uns::unsval; }
+
+enum class sig : __int128 { sigval = -(__int128(1) << 64) };
+sig t2() { return sig::sigval; }
+
+
+// CHECK-LABEL: !DICompositeType(tag: DW_TAG_enumeration_type, name: "uns", 
{{.*}})
+// CHECK: !DIEnumerator(name: "unsval", value: 18446744073709551616, 
isUnsigned: true)
+
+// CHECK-LABEL: !DICompositeType(tag: DW_TAG_enumeration_type, name: "sig", 
{{.*}})
+// CHECK: !DIEnumerator(name: "sigval", value: -18446744073709551616)
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3113,10 +3113,9 @@
   ED = ED->getDefinition();
   bool IsSigned = ED->getIntegerType()->isSignedIntegerType();
   for (const auto *Enum : ED->enumerators()) {
-const auto  = Enum->getInitVal();
-auto Value = IsSigned ? InitVal.getSExtValue() : InitVal.getZExtValue();
-Enumerators.push_back(
-DBuilder.createEnumerator(Enum->getName(), Value, !IsSigned));
+llvm::APSInt Value = Enum->getInitVal();
+Value.setIsSigned(IsSigned);
+Enumerators.push_back(DBuilder.createEnumerator(Enum->getName(), Value));
   }
 
   // Return a CompositeType for the enum itself.


Index: llvm/lib/IR/DIBuilder.cpp
===
--- llvm/lib/IR/DIBuilder.cpp
+++ llvm/lib/IR/DIBuilder.cpp
@@ -250,6 +250,11 @@
Name);
 }
 
+DIEnumerator *DIBuilder::createEnumerator(StringRef Name, APSInt Value) {
+  assert(!Name.empty() && "Unable to create enumerator without name");
+  return DIEnumerator::get(VMContext, APInt(Value), Value.isUnsigned(), Name);
+}
+
 DIBasicType *DIBuilder::createUnspecifiedType(StringRef Name) {
   assert(!Name.empty() && "Unable to create type without name");
   return DIBasicType::get(VMContext, dwarf::DW_TAG_unspecified_type, Name);
Index: llvm/include/llvm/IR/DIBuilder.h
===
--- llvm/include/llvm/IR/DIBuilder.h
+++ llvm/include/llvm/IR/DIBuilder.h
@@ -181,7 +181,9 @@
  DIFile *File);
 
 /// Create a single enumerator value.
-DIEnumerator *createEnumerator(StringRef Name, int64_t Val, bool IsUnsigned = false);
+DIEnumerator *createEnumerator(StringRef Name, APSInt Value);
+DIEnumerator *createEnumerator(StringRef 

[PATCH] D106583: [clang] SIGSEGV at DeduceTemplateArgumentsByTypeMatch

2021-07-22 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

This seems appropriate of a fix, but it needs a lit test.  I'm not particularly 
sure I know the repercussions of this patch, however perhaps that would help.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106583

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


[PATCH] D106582: [DebugInfo] Add -fno-ctor-homing for as counterpart to -fuse-ctor-homing

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

Looks alright to me. (bit awkward having a documented cc1 option - since the 
cc1 options aren't meant to be user facing - hadn't really thought 
about/noticed that when reviewing the documentation originally in D95911 
)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106582

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


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

2021-07-22 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D106084#2897515 , @jmorse wrote:

> David wrote:
>
>> think what I'm missing here: If -fno-standalone-debug is already in use/the 
>> default and is causing missing types because parts of the program are bulit 
>> without debug info, then I'm not sure what the rationale is for slicing 
>> -fstandalone-debug into a "has ctor homing" and a "doesn't have ctor homing" 
>> strategy. The same general design philosophy applies - that in both cases 
>> (about 4 cases in total now: types that aren't required to be complete, 
>> explicitly instantiated templates, vtables, and now ctor homing) the whole 
>> program must be compiled with debug info enabled for these DWARF size 
>> optimizations to be sound.
>
> It's a matter of degree:
>
> - Some types go missing, but due to the dllimport mechanism mentioned, all 
> the important ones are retained,
> - Switching to -fstandalone-debug increases the amount of DWARF by ~50% in 
> experiments I've run, which for a {single-file-recompile, link, 
> load-into-debugger} round trip will translate to an almost 50% increase in 
> round-trip-time. (What with DWARF being the major part of linking and 
> debugger-loading).
>
> Thus the status quo (-fno-standalone-debug and closed-source libraries) 
> hasn't been conceptually sounds, but it's given a "good enough" debugging 
> experience without major round-trip-time penalty.

I think it'd be unfortunate to split this hair in LLVM/Clang proper & feel like 
that sort of value tradeoff might be better suited in a downstream patch. 
(mostly because eventually it'd be good to get rid of the distinction between 
other type homing and ctor type homing entirely - there's already 3 categories 
of type homing under the existing category (type completeness, explicit 
template instantiations, and vtable based homing) & I don't think there's a 
good line to draw between those and ctor type homing - and module type homing 
(which I think I've already implemented   is under -fno-standalone-debug, 
but no one's using modular code generation right now so it's not super 
interesting to anyone), maybe ThinLTO type homing (which would be a bit more 
robust than the others, since it has whole program-ish view)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106084

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


[PATCH] D106577: [clang] Define __STDC_ISO_10646__

2021-07-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D106577#2897522 , @jyknight wrote:

> I'm not sure we should be populating this.
>
> The _value_ is determined by what libc supports, so it probably needs to be 
> left up to libc to define it.

Why is the value determined by what libc supports? The definition from the 
standard is:

  If this symbol is defined, then every character in the Unicode required set, 
when stored in an
  object of type wchar_t, has the same value as the short identifier of that 
character.

That doesn't seem to imply anything about the library, just the size of 
`wchar_t`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106577

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


[clang] f719dff - [AIX] Clang's library integration support for 128-bit long double is incomplete on AIX.

2021-07-22 Thread Shimin Cui via cfe-commits

Author: Anjan Kumar Guttahalli Krishna
Date: 2021-07-22T15:32:48-04:00
New Revision: f719dff043962832f221dd8e28af2344a0ab80e0

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

LOG: [AIX] Clang's library integration support for 128-bit long double is 
incomplete on AIX.

Emit the unsupported option error until the Clang's library integration support 
for 128-bit long double is available for AIX.

Reviewed By: Whitney, cebowleratibm

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/unsupported-option.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 837ead86d620..75bc32916371 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4841,6 +4841,14 @@ void Clang::ConstructJob(Compilation , const JobAction 
,
   CmdArgs.push_back("-mabi=vec-default");
   }
 
+  if (Arg *A = Args.getLastArg(options::OPT_mlong_double_128)) {
+// Emit the unsupported option error until the Clang's library integration
+// support for 128-bit long double is available for AIX.
+if (Triple.isOSAIX())
+  D.Diag(diag::err_drv_unsupported_opt_for_target)
+  << A->getSpelling() << RawTriple.str();
+  }
+
   if (Arg *A = Args.getLastArg(options::OPT_Wframe_larger_than_EQ)) {
 StringRef v = A->getValue();
 // FIXME: Validate the argument here so we don't produce meaningless errors

diff  --git a/clang/test/Driver/unsupported-option.c 
b/clang/test/Driver/unsupported-option.c
index 975440352259..c263bb0b853c 100644
--- a/clang/test/Driver/unsupported-option.c
+++ b/clang/test/Driver/unsupported-option.c
@@ -21,3 +21,11 @@
 // RUN: not %clang -fprofile-generate -flto=thin --target=powerpc64-ibm-aix %s 
2>&1 | \
 // RUN: FileCheck %s --check-prefix=AIX-PROFILE-THINLTO
 // AIX-PROFILE-THINLTO: error: invalid argument '-fprofile-generate' only 
allowed with '-flto'
+
+// RUN: not %clang --target=powerpc-ibm-aix %s -mlong-double-128 2>&1 | \
+// RUN: FileCheck %s --check-prefix=AIX-LONGDOUBLE128-ERR
+// AIX-LONGDOUBLE128-ERR: error: unsupported option '-mlong-double-128' for 
target 'powerpc-ibm-aix'
+
+// RUN: not %clang --target=powerpc64-ibm-aix %s -mlong-double-128 2>&1 | \
+// RUN: FileCheck %s --check-prefix=AIX64-LONGDOUBLE128-ERR
+// AIX64-LONGDOUBLE128-ERR: error: unsupported option '-mlong-double-128' for 
target 'powerpc64-ibm-aix'



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


[PATCH] D106074: [AIX] Clang's library integration support for 128-bit long double is incomplete on AIX.

2021-07-22 Thread Shimin Cui 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 rGf719dff04396: [AIX] Clangs library integration support 
for 128-bit long double is incomplete… (authored by anjankgk, committed by 
scui).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106074

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/unsupported-option.c


Index: clang/test/Driver/unsupported-option.c
===
--- clang/test/Driver/unsupported-option.c
+++ clang/test/Driver/unsupported-option.c
@@ -21,3 +21,11 @@
 // RUN: not %clang -fprofile-generate -flto=thin --target=powerpc64-ibm-aix %s 
2>&1 | \
 // RUN: FileCheck %s --check-prefix=AIX-PROFILE-THINLTO
 // AIX-PROFILE-THINLTO: error: invalid argument '-fprofile-generate' only 
allowed with '-flto'
+
+// RUN: not %clang --target=powerpc-ibm-aix %s -mlong-double-128 2>&1 | \
+// RUN: FileCheck %s --check-prefix=AIX-LONGDOUBLE128-ERR
+// AIX-LONGDOUBLE128-ERR: error: unsupported option '-mlong-double-128' for 
target 'powerpc-ibm-aix'
+
+// RUN: not %clang --target=powerpc64-ibm-aix %s -mlong-double-128 2>&1 | \
+// RUN: FileCheck %s --check-prefix=AIX64-LONGDOUBLE128-ERR
+// AIX64-LONGDOUBLE128-ERR: error: unsupported option '-mlong-double-128' for 
target 'powerpc64-ibm-aix'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4841,6 +4841,14 @@
   CmdArgs.push_back("-mabi=vec-default");
   }
 
+  if (Arg *A = Args.getLastArg(options::OPT_mlong_double_128)) {
+// Emit the unsupported option error until the Clang's library integration
+// support for 128-bit long double is available for AIX.
+if (Triple.isOSAIX())
+  D.Diag(diag::err_drv_unsupported_opt_for_target)
+  << A->getSpelling() << RawTriple.str();
+  }
+
   if (Arg *A = Args.getLastArg(options::OPT_Wframe_larger_than_EQ)) {
 StringRef v = A->getValue();
 // FIXME: Validate the argument here so we don't produce meaningless errors


Index: clang/test/Driver/unsupported-option.c
===
--- clang/test/Driver/unsupported-option.c
+++ clang/test/Driver/unsupported-option.c
@@ -21,3 +21,11 @@
 // RUN: not %clang -fprofile-generate -flto=thin --target=powerpc64-ibm-aix %s 2>&1 | \
 // RUN: FileCheck %s --check-prefix=AIX-PROFILE-THINLTO
 // AIX-PROFILE-THINLTO: error: invalid argument '-fprofile-generate' only allowed with '-flto'
+
+// RUN: not %clang --target=powerpc-ibm-aix %s -mlong-double-128 2>&1 | \
+// RUN: FileCheck %s --check-prefix=AIX-LONGDOUBLE128-ERR
+// AIX-LONGDOUBLE128-ERR: error: unsupported option '-mlong-double-128' for target 'powerpc-ibm-aix'
+
+// RUN: not %clang --target=powerpc64-ibm-aix %s -mlong-double-128 2>&1 | \
+// RUN: FileCheck %s --check-prefix=AIX64-LONGDOUBLE128-ERR
+// AIX64-LONGDOUBLE128-ERR: error: unsupported option '-mlong-double-128' for target 'powerpc64-ibm-aix'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4841,6 +4841,14 @@
   CmdArgs.push_back("-mabi=vec-default");
   }
 
+  if (Arg *A = Args.getLastArg(options::OPT_mlong_double_128)) {
+// Emit the unsupported option error until the Clang's library integration
+// support for 128-bit long double is available for AIX.
+if (Triple.isOSAIX())
+  D.Diag(diag::err_drv_unsupported_opt_for_target)
+  << A->getSpelling() << RawTriple.str();
+  }
+
   if (Arg *A = Args.getLastArg(options::OPT_Wframe_larger_than_EQ)) {
 StringRef v = A->getValue();
 // FIXME: Validate the argument here so we don't produce meaningless errors
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106583: [clang] SIGSEGV at DeduceTemplateArgumentsByTypeMatch

2021-07-22 Thread Ivan Murashko via Phabricator via cfe-commits
ivanmurashko created this revision.
ivanmurashko added reviewers: rsmith, DmitryPolukhin.
ivanmurashko requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

There is a SIGSEGV at DeduceTemplateArgumentsByTypeMatch. See BUG description 
and reproducer at https://bugs.llvm.org/show_bug.cgi?id=51171

The stack trace is below:

   #0 0x055afcb9 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
/home/ivanmurashko/local/llvm-project/llvm/lib/Support/Unix/Signals.inc:565:22
   #1 0x055afd70 PrintStackTraceSignalHandler(void*) 
/home/ivanmurashko/local/llvm-project/llvm/lib/Support/Unix/Signals.inc:632:1
   #2 0x055add2d llvm::sys::RunSignalHandlers() 
/home/ivanmurashko/local/llvm-project/llvm/lib/Support/Signals.cpp:97:20
   #3 0x055af701 SignalHandler(int) 
/home/ivanmurashko/local/llvm-project/llvm/lib/Support/Unix/Signals.inc:407:1
   #4 0x77bc2b20 __restore_rt sigaction.c:0:0
   #5 0x766a337f raise (/lib64/libc.so.6+0x3737f)
   #6 0x7668ddb5 abort (/lib64/libc.so.6+0x21db5)
   #7 0x7668dc89 _nl_load_domain.cold.0 loadmsgcat.c:0:0
   #8 0x7669ba76 .annobin___GI___assert_fail.end assert.c:0:0
   #9 0x0594b210 clang::QualType::getCommonPtr() const 
/home/ivanmurashko/local/llvm-project/clang/include/clang/AST/Type.h:684:5
  #10 0x05a12ca6 clang::QualType::getCanonicalType() const 
/home/ivanmurashko/local/llvm-project/clang/include/clang/AST/Type.h:6467:36
  #11 0x05a137a6 clang::ASTContext::getCanonicalType(clang::QualType) 
const 
/home/ivanmurashko/local/llvm-project/clang/include/clang/AST/ASTContext.h:2433:58
  #12 0x09204584 DeduceTemplateArgumentsByTypeMatch(clang::Sema&, 
clang::TemplateParameterList*, clang::QualType, clang::QualType, 
clang::sema::TemplateDeductionInfo&, 
llvm::SmallVectorImpl&, unsigned int, bool, 
bool) 
/home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaTemplateDeduction.cpp:1355:54
  #13 0x0920df0d 
clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*, 
clang::TemplateArgumentListInfo*, clang::QualType, clang::FunctionDecl*&, 
clang::sema::TemplateDeductionInfo&, bool) 
/home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaTemplateDeduction.cpp:4354:47
  #14 0x09012b09 (anonymous 
namespace)::AddressOfFunctionResolver::AddMatchingTemplateFunction(clang::FunctionTemplateDecl*,
 clang::DeclAccessPair const&) 
/home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaOverload.cpp:12026:38
  #15 0x09013030 (anonymous 
namespace)::AddressOfFunctionResolver::FindAllFunctionsThatMatchTargetTypeExactly()
 /home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaOverload.cpp:12119:9
  #16 0x09012679 (anonymous 
namespace)::AddressOfFunctionResolver::AddressOfFunctionResolver(clang::Sema&, 
clang::Expr*, clang::QualType const&, bool) 
/home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaOverload.cpp:11931:5
  #17 0x09013c91 
clang::Sema::ResolveAddressOfOverloadedFunction(clang::Expr*, clang::QualType, 
bool, clang::DeclAccessPair&, bool*) 
/home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaOverload.cpp:12286:42
  #18 0x08fed85d IsStandardConversion(clang::Sema&, clang::Expr*, 
clang::QualType, bool, clang::StandardConversionSequence&, bool, bool) 
/home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaOverload.cpp:1712:49
  #19 0x08fec8ea TryImplicitConversion(clang::Sema&, clang::Expr*, 
clang::QualType, bool, clang::Sema::AllowedExplicit, bool, bool, bool, bool) 
/home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaOverload.cpp:1433:27
  #20 0x08ff90ba TryCopyInitialization(clang::Sema&, clang::Expr*, 
clang::QualType, bool, bool, bool, bool) 
/home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaOverload.cpp:5273:71
  #21 0x090024fb clang::Sema::AddBuiltinCandidate(clang::QualType*, 
llvm::ArrayRef, clang::OverloadCandidateSet&, bool, unsigned int) 
/home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaOverload.cpp:7755:32
  #22 0x0900513f (anonymous 
namespace)::BuiltinOperatorOverloadBuilder::addGenericBinaryArithmeticOverloads()
 /home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaOverload.cpp:8633:30
  #23 0x09007624 
clang::Sema::AddBuiltinOperatorCandidates(clang::OverloadedOperatorKind, 
clang::SourceLocation, llvm::ArrayRef, 
clang::OverloadCandidateSet&) 
/home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaOverload.cpp:9205:51
  #24 0x09018734 
clang::Sema::LookupOverloadedBinOp(clang::OverloadCandidateSet&, 
clang::OverloadedOperatorKind, clang::UnresolvedSetImpl const&, 
llvm::ArrayRef, bool) 
/home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaOverload.cpp:13469:1
  #25 0x09018d56 
clang::Sema::CreateOverloadedBinOp(clang::SourceLocation, 
clang::BinaryOperatorKind, clang::UnresolvedSetImpl const&, clang::Expr*, 
clang::Expr*, bool, bool, 

[PATCH] D106582: [DebugInfo] Add -fno-ctor-homing for as counterpart to -fuse-ctor-homing

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

add actual flag


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106582

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp


Index: clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp
===
--- clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp
+++ clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp
@@ -8,6 +8,9 @@
 // RUN:| FileCheck %s -check-prefix=NO_DEBUG
 // RUN: %clang -cc1 -fuse-ctor-homing -emit-llvm %s -o - \
 // RUN:| FileCheck %s -check-prefix=NO_DEBUG
+//
+// RUN: %clang -cc1 -debug-info-kind=constructor -fno-use-ctor-homing \
+// RUN:-emit-llvm %s -o - | FileCheck %s -check-prefix=FULL_DEBUG
 
 // This tests that the -fuse-ctor-homing is only used if limited debug info 
would have
 // been used otherwise.
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1369,9 +1369,6 @@
   if (DebugInfoVal)
 GenerateArg(Args, OPT_debug_info_kind_EQ, *DebugInfoVal, SA);
 
-  if (Opts.DebugInfo == codegenoptions::DebugInfoConstructor)
-GenerateArg(Args, OPT_fuse_ctor_homing, SA);
-
   for (const auto  : Opts.DebugPrefixMap)
 GenerateArg(Args, OPT_fdebug_prefix_map_EQ,
 Prefix.first + "=" + Prefix.second, SA);
@@ -1627,10 +1624,16 @@
   }
 
   // If -fuse-ctor-homing is set and limited debug info is already on, then use
-  // constructor homing.
-  if (Args.getLastArg(OPT_fuse_ctor_homing))
-if (Opts.getDebugInfo() == codegenoptions::LimitedDebugInfo)
+  // constructor homing, and vice versa for -fno-use-ctor-homing.
+  if (const Arg *A =
+  Args.getLastArg(OPT_fuse_ctor_homing, OPT_fno_use_ctor_homing)) {
+if (A->getOption().matches(OPT_fuse_ctor_homing) &&
+Opts.getDebugInfo() == codegenoptions::LimitedDebugInfo)
   Opts.setDebugInfo(codegenoptions::DebugInfoConstructor);
+if (A->getOption().matches(OPT_fno_use_ctor_homing) &&
+Opts.getDebugInfo() == codegenoptions::DebugInfoConstructor)
+  Opts.setDebugInfo(codegenoptions::LimitedDebugInfo);
+  }
 
   for (const auto  : Args.getAllArgValues(OPT_fdebug_prefix_map_EQ)) {
 auto Split = StringRef(Arg).split('=');
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4836,6 +4836,8 @@
 def fno_math_builtin : Flag<["-"], "fno-math-builtin">,
   HelpText<"Disable implicit builtin knowledge of math functions">,
   MarshallingInfoFlag>;
+def fno_use_ctor_homing: Flag<["-"], "fno-use-ctor-homing">,
+HelpText<"Don't use constructor homing for debug info">;
 def fuse_ctor_homing: Flag<["-"], "fuse-ctor-homing">,
 HelpText<"Use constructor homing if we are using limited debug info 
already">;
 }
Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -2563,7 +2563,8 @@
non-trivial, non-aggregate C++ class in the modules that contain a
definition of one of its constructors. This relies on the additional
assumption that all classes that are not trivially constructible have a
-   non-trivial constructor that is used somewhere.
+   non-trivial constructor that is used somewhere. The negation,
+   -fno-use-ctor-homing, ensures that constructor homing is not used.
 
This flag is not enabled by default, and needs to be used with -cc1 or
-Xclang.


Index: clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp
===
--- clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp
+++ clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp
@@ -8,6 +8,9 @@
 // RUN:| FileCheck %s -check-prefix=NO_DEBUG
 // RUN: %clang -cc1 -fuse-ctor-homing -emit-llvm %s -o - \
 // RUN:| FileCheck %s -check-prefix=NO_DEBUG
+//
+// RUN: %clang -cc1 -debug-info-kind=constructor -fno-use-ctor-homing \
+// RUN:-emit-llvm %s -o - | FileCheck %s -check-prefix=FULL_DEBUG
 
 // This tests that the -fuse-ctor-homing is only used if limited debug info would have
 // been used otherwise.
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1369,9 +1369,6 @@
   if (DebugInfoVal)
 GenerateArg(Args, OPT_debug_info_kind_EQ, *DebugInfoVal, SA);
 
-  if 

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

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

In D106084#2897515 , @jmorse wrote:

> David wrote:
>
>> think what I'm missing here: If -fno-standalone-debug is already in use/the 
>> default and is causing missing types because parts of the program are bulit 
>> without debug info, then I'm not sure what the rationale is for slicing 
>> -fstandalone-debug into a "has ctor homing" and a "doesn't have ctor homing" 
>> strategy. The same general design philosophy applies - that in both cases 
>> (about 4 cases in total now: types that aren't required to be complete, 
>> explicitly instantiated templates, vtables, and now ctor homing) the whole 
>> program must be compiled with debug info enabled for these DWARF size 
>> optimizations to be sound.
>
> It's a matter of degree:
>
> - Some types go missing, but due to the dllimport mechanism mentioned, all 
> the important ones are retained,
> - Switching to -fstandalone-debug increases the amount of DWARF by ~50% in 
> experiments I've run, which for a {single-file-recompile, link, 
> load-into-debugger} round trip will translate to an almost 50% increase in 
> round-trip-time. (What with DWARF being the major part of linking and 
> debugger-loading).
>
> Thus the status quo (-fno-standalone-debug and closed-source libraries) 
> hasn't been conceptually sounds, but it's given a "good enough" debugging 
> experience without major round-trip-time penalty.

Right, I think chromium on mac does the same thing (build with 
-fno-standalone-debug even though it drops some types, because 
-fstandalone-debug is too large).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106084

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


[PATCH] D106582: [DebugInfo] Add -fno-ctor-homing for as counterpart to -fuse-ctor-homing

2021-07-22 Thread Amy Huang via Phabricator via cfe-commits
akhuang created this revision.
akhuang added reviewers: dblaikie, probinson.
akhuang requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Add an opt out flag for constructor homing.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106582

Files:
  clang/docs/UsersManual.rst
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp


Index: clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp
===
--- clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp
+++ clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp
@@ -8,6 +8,9 @@
 // RUN:| FileCheck %s -check-prefix=NO_DEBUG
 // RUN: %clang -cc1 -fuse-ctor-homing -emit-llvm %s -o - \
 // RUN:| FileCheck %s -check-prefix=NO_DEBUG
+//
+// RUN: %clang -cc1 -debug-info-kind=constructor -fno-use-ctor-homing \
+// RUN:-emit-llvm %s -o - | FileCheck %s -check-prefix=FULL_DEBUG
 
 // This tests that the -fuse-ctor-homing is only used if limited debug info 
would have
 // been used otherwise.
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1369,9 +1369,6 @@
   if (DebugInfoVal)
 GenerateArg(Args, OPT_debug_info_kind_EQ, *DebugInfoVal, SA);
 
-  if (Opts.DebugInfo == codegenoptions::DebugInfoConstructor)
-GenerateArg(Args, OPT_fuse_ctor_homing, SA);
-
   for (const auto  : Opts.DebugPrefixMap)
 GenerateArg(Args, OPT_fdebug_prefix_map_EQ,
 Prefix.first + "=" + Prefix.second, SA);
@@ -1627,10 +1624,16 @@
   }
 
   // If -fuse-ctor-homing is set and limited debug info is already on, then use
-  // constructor homing.
-  if (Args.getLastArg(OPT_fuse_ctor_homing))
-if (Opts.getDebugInfo() == codegenoptions::LimitedDebugInfo)
+  // constructor homing, and vice versa for -fno-use-ctor-homing.
+  if (const Arg *A =
+  Args.getLastArg(OPT_fuse_ctor_homing, OPT_fno_use_ctor_homing)) {
+if (A->getOption().matches(OPT_fuse_ctor_homing) &&
+Opts.getDebugInfo() == codegenoptions::LimitedDebugInfo)
   Opts.setDebugInfo(codegenoptions::DebugInfoConstructor);
+if (A->getOption().matches(OPT_fno_use_ctor_homing) &&
+Opts.getDebugInfo() == codegenoptions::DebugInfoConstructor)
+  Opts.setDebugInfo(codegenoptions::LimitedDebugInfo);
+  }
 
   for (const auto  : Args.getAllArgValues(OPT_fdebug_prefix_map_EQ)) {
 auto Split = StringRef(Arg).split('=');
Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -2563,7 +2563,8 @@
non-trivial, non-aggregate C++ class in the modules that contain a
definition of one of its constructors. This relies on the additional
assumption that all classes that are not trivially constructible have a
-   non-trivial constructor that is used somewhere.
+   non-trivial constructor that is used somewhere. The negation,
+   -fno-use-ctor-homing, ensures that constructor homing is not used.
 
This flag is not enabled by default, and needs to be used with -cc1 or
-Xclang.


Index: clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp
===
--- clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp
+++ clang/test/CodeGenCXX/debug-info-ctor-homing-flag.cpp
@@ -8,6 +8,9 @@
 // RUN:| FileCheck %s -check-prefix=NO_DEBUG
 // RUN: %clang -cc1 -fuse-ctor-homing -emit-llvm %s -o - \
 // RUN:| FileCheck %s -check-prefix=NO_DEBUG
+//
+// RUN: %clang -cc1 -debug-info-kind=constructor -fno-use-ctor-homing \
+// RUN:-emit-llvm %s -o - | FileCheck %s -check-prefix=FULL_DEBUG
 
 // This tests that the -fuse-ctor-homing is only used if limited debug info would have
 // been used otherwise.
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1369,9 +1369,6 @@
   if (DebugInfoVal)
 GenerateArg(Args, OPT_debug_info_kind_EQ, *DebugInfoVal, SA);
 
-  if (Opts.DebugInfo == codegenoptions::DebugInfoConstructor)
-GenerateArg(Args, OPT_fuse_ctor_homing, SA);
-
   for (const auto  : Opts.DebugPrefixMap)
 GenerateArg(Args, OPT_fdebug_prefix_map_EQ,
 Prefix.first + "=" + Prefix.second, SA);
@@ -1627,10 +1624,16 @@
   }
 
   // If -fuse-ctor-homing is set and limited debug info is already on, then use
-  // constructor homing.
-  if (Args.getLastArg(OPT_fuse_ctor_homing))
-if (Opts.getDebugInfo() == codegenoptions::LimitedDebugInfo)
+  // constructor homing, and vice versa for -fno-use-ctor-homing.
+  if (const Arg *A =
+  

[PATCH] D106577: [clang] Define __STDC_ISO_10646__

2021-07-22 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

I'm not sure we should be populating this.

The _value_ is determined by what libc supports, so it probably needs to be 
left up to libc to define it.

In glibc, this define is set by the file /usr/include/stdc-predef.h, which GCC 
implicitly includes into all TUs whether they include libc headers or not. 
(Clang almost got that feature too in https://reviews.llvm.org/D34158 but it 
was reverted due to some test failures)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106577

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


[PATCH] D106011: [clang-tidy] performance-unnecessary-copy-initialization: Disable check when variable and initializer have different replaced template param types.

2021-07-22 Thread Felix Berger via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG00edae9203c9: [clang-tidy] 
performance-unnecessary-copy-initialization: Disable check when… (authored by 
flx).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106011

Files:
  clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
@@ -17,6 +17,9 @@
   Iterator end() const;
   void nonConstMethod();
   bool constMethod() const;
+  template 
+  const A () const;
+  operator int() const; // Implicit conversion to int.
 };
 
 struct TrivialToCopyType {
@@ -659,3 +662,54 @@
   C.constMethod();
   D.constMethod();
 }
+
+template 
+const A ();
+
+template 
+void negativeTemplateTypes() {
+  A Orig;
+  // Different replaced template type params do not trigger the check. In some
+  // template instantiation this might not be a copy but an implicit
+  // conversion, so converting this to a reference might not work.
+  B AmbiguousCopy = Orig;
+  // CHECK-NOT-FIXES: B AmbiguousCopy = Orig;
+
+  B NecessaryCopy = templatedReference();
+  // CHECK-NOT-FIXES: B NecessaryCopy = templatedReference();
+
+  B NecessaryCopy2 = Orig.template templatedAccessor();
+
+  // Non-dependent types in template still trigger the check.
+  const auto UnnecessaryCopy = ExpensiveTypeReference();
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'UnnecessaryCopy' is copy-constructed
+  // CHECK-FIXES: const auto& UnnecessaryCopy = ExpensiveTypeReference();
+  UnnecessaryCopy.constMethod();
+}
+
+void instantiateNegativeTemplateTypes() {
+  negativeTemplateTypes();
+  // This template instantiation would not compile if the `AmbiguousCopy` above was made a reference.
+  negativeTemplateTypes();
+}
+
+template 
+void positiveSingleTemplateType() {
+  A Orig;
+  A SingleTmplParmTypeCopy = Orig;
+  // CHECK-MESSAGES: [[@LINE-1]]:5: warning: local copy 'SingleTmplParmTypeCopy' of the variable 'Orig' is never modified
+  // CHECK-FIXES: const A& SingleTmplParmTypeCopy = Orig;
+  SingleTmplParmTypeCopy.constMethod();
+
+  A UnnecessaryCopy2 = templatedReference();
+  // CHECK-MESSAGES: [[@LINE-1]]:5: warning: the variable 'UnnecessaryCopy2' is copy-constructed from a const reference
+  // CHECK-FIXES: const A& UnnecessaryCopy2 = templatedReference();
+  UnnecessaryCopy2.constMethod();
+
+  A UnnecessaryCopy3 = Orig.template templatedAccessor();
+  // CHECK-MESSAGES: [[@LINE-1]]:5: warning: the variable 'UnnecessaryCopy3' is copy-constructed from a const reference
+  // CHECK-FIXES: const A& UnnecessaryCopy3 = Orig.template templatedAccessor();
+  UnnecessaryCopy3.constMethod();
+}
+
+void instantiatePositiveSingleTemplateType() { positiveSingleTemplateType(); }
Index: clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
===
--- clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
+++ clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
@@ -27,6 +27,8 @@
 
 static constexpr StringRef ObjectArgId = "objectArg";
 static constexpr StringRef InitFunctionCallId = "initFunctionCall";
+static constexpr StringRef MethodDeclId = "methodDecl";
+static constexpr StringRef FunctionDeclId = "functionDecl";
 static constexpr StringRef OldVarDeclId = "oldVarDecl";
 
 void recordFixes(const VarDecl , ASTContext ,
@@ -81,7 +83,8 @@
   // returned either points to a global static variable or to a member of the
   // called object.
   return cxxMemberCallExpr(
-  callee(cxxMethodDecl(returns(matchers::isReferenceToConst(,
+  callee(cxxMethodDecl(returns(matchers::isReferenceToConst()))
+ .bind(MethodDeclId)),
   on(declRefExpr(to(varDecl().bind(ObjectArgId);
 }
 
@@ -89,7 +92,8 @@
   // Only allow initialization of a const reference from a free function if it
   // has no arguments. Otherwise it could return an alias to one of its
   // arguments and the arguments need to be checked for const use as well.
-  return callExpr(callee(functionDecl(returns(matchers::isReferenceToConst(,
+  return callExpr(callee(functionDecl(returns(matchers::isReferenceToConst()))
+ .bind(FunctionDeclId)),
   argumentCountIs(0), unless(callee(cxxMethodDecl(
   .bind(InitFunctionCallId);
 }
@@ -155,6 +159,45 @@
   return allDeclRefExprs(Var, BlockStmt, Context).empty();
 }
 
+const SubstTemplateTypeParmType 

[clang-tools-extra] 00edae9 - [clang-tidy] performance-unnecessary-copy-initialization: Disable check when variable and initializer have different replaced template param types.

2021-07-22 Thread Felix Berger via cfe-commits

Author: Felix Berger
Date: 2021-07-22T15:17:24-04:00
New Revision: 00edae9203c9a4f50da058d4bd25dc2e6a4930c1

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

LOG: [clang-tidy] performance-unnecessary-copy-initialization: Disable check 
when variable and initializer have different replaced template param types.

This can happen when a template with two parameter types is instantiated with a
single type. The fix would only be valid for this instantiation but fail for
others that rely on an implicit type conversion.

The test cases illustrate when the check should trigger and when not.

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp

clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp 
b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
index f6b8e44785b5f..9631e06a8f95b 100644
--- a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
+++ b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
@@ -27,6 +27,8 @@ using utils::decl_ref_expr::isOnlyUsedAsConst;
 
 static constexpr StringRef ObjectArgId = "objectArg";
 static constexpr StringRef InitFunctionCallId = "initFunctionCall";
+static constexpr StringRef MethodDeclId = "methodDecl";
+static constexpr StringRef FunctionDeclId = "functionDecl";
 static constexpr StringRef OldVarDeclId = "oldVarDecl";
 
 void recordFixes(const VarDecl , ASTContext ,
@@ -81,7 +83,8 @@ AST_MATCHER_FUNCTION(StatementMatcher, 
isConstRefReturningMethodCall) {
   // returned either points to a global static variable or to a member of the
   // called object.
   return cxxMemberCallExpr(
-  callee(cxxMethodDecl(returns(matchers::isReferenceToConst(,
+  callee(cxxMethodDecl(returns(matchers::isReferenceToConst()))
+ .bind(MethodDeclId)),
   on(declRefExpr(to(varDecl().bind(ObjectArgId);
 }
 
@@ -89,7 +92,8 @@ AST_MATCHER_FUNCTION(StatementMatcher, 
isConstRefReturningFunctionCall) {
   // Only allow initialization of a const reference from a free function if it
   // has no arguments. Otherwise it could return an alias to one of its
   // arguments and the arguments need to be checked for const use as well.
-  return 
callExpr(callee(functionDecl(returns(matchers::isReferenceToConst(,
+  return callExpr(callee(functionDecl(returns(matchers::isReferenceToConst()))
+ .bind(FunctionDeclId)),
   argumentCountIs(0), unless(callee(cxxMethodDecl(
   .bind(InitFunctionCallId);
 }
@@ -155,6 +159,45 @@ bool isVariableUnused(const VarDecl , const Stmt 
,
   return allDeclRefExprs(Var, BlockStmt, Context).empty();
 }
 
+const SubstTemplateTypeParmType *getSubstitutedType(const QualType ,
+ASTContext ) {
+  auto Matches = match(
+  qualType(anyOf(substTemplateTypeParmType().bind("subst"),
+ 
hasDescendant(substTemplateTypeParmType().bind("subst",
+  Type, Context);
+  return selectFirst("subst", Matches);
+}
+
+bool 
diff erentReplacedTemplateParams(const QualType ,
+ const QualType ,
+ ASTContext ) {
+  if (const SubstTemplateTypeParmType *VarTmplType =
+  getSubstitutedType(VarType, Context)) {
+if (const SubstTemplateTypeParmType *InitializerTmplType =
+getSubstitutedType(InitializerType, Context)) {
+  return VarTmplType->getReplacedParameter()
+ ->desugar()
+ .getCanonicalType() !=
+ InitializerTmplType->getReplacedParameter()
+ ->desugar()
+ .getCanonicalType();
+}
+  }
+  return false;
+}
+
+QualType constructorArgumentType(const VarDecl *OldVar,
+ const BoundNodes ) {
+  if (OldVar) {
+return OldVar->getType();
+  }
+  if (const auto *FuncDecl = Nodes.getNodeAs(FunctionDeclId)) {
+return FuncDecl->getReturnType();
+  }
+  const auto *MethodDecl = Nodes.getNodeAs(MethodDeclId);
+  return MethodDecl->getReturnType();
+}
+
 } // namespace
 
 UnnecessaryCopyInitialization::UnnecessaryCopyInitialization(
@@ -222,6 +265,16 @@ void UnnecessaryCopyInitialization::check(
 if (!CtorCall->getArg(I)->isDefaultArgument())
   return;
 
+  // Don't apply the check if the variable and its initializer have 
diff erent
+  // replaced template parameter types. In this case the check triggers for a
+  // template instantiation where the substituted types are the 

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

2021-07-22 Thread Jeremy Morse via Phabricator via cfe-commits
jmorse added a comment.

David wrote:

> think what I'm missing here: If -fno-standalone-debug is already in use/the 
> default and is causing missing types because parts of the program are bulit 
> without debug info, then I'm not sure what the rationale is for slicing 
> -fstandalone-debug into a "has ctor homing" and a "doesn't have ctor homing" 
> strategy. The same general design philosophy applies - that in both cases 
> (about 4 cases in total now: types that aren't required to be complete, 
> explicitly instantiated templates, vtables, and now ctor homing) the whole 
> program must be compiled with debug info enabled for these DWARF size 
> optimizations to be sound.

It's a matter of degree:

- Some types go missing, but due to the dllimport mechanism mentioned, all the 
important ones are retained,
- Switching to -fstandalone-debug increases the amount of DWARF by ~50% in 
experiments I've run, which for a {single-file-recompile, link, 
load-into-debugger} round trip will translate to an almost 50% increase in 
round-trip-time. (What with DWARF being the major part of linking and 
debugger-loading).

Thus the status quo (-fno-standalone-debug and closed-source libraries) hasn't 
been conceptually sounds, but it's given a "good enough" debugging experience 
without major round-trip-time penalty.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106084

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


[PATCH] D106577: [clang] Define __STDC_ISO_10646__

2021-07-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

In D106577#2897450 , @cor3ntin wrote:

> In D106577#2897312 , @aaron.ballman 
> wrote:
>
>> Can you also add a test that explicitly uses `-fshort-wchar` to verify that 
>> we don't predefine the macro?
>
> There is one already! (init.c L288)

Oh, thank you for pointing that out!

LGTM!




Comment at: clang/lib/Frontend/InitPreprocessor.cpp:430-435
+  // Because Clang only supports UTF-32 or UTF-16 as the
+  // wide execution encoding, any platform that doesn't uses
+  // short wchar can represent the entire Unicode code space
+  // Unicode 13 was released in December 2020.
+  // Note that new Unicode version are *very* unlikely to affect
+  // representability

cor3ntin wrote:
> aaron.ballman wrote:
> > Are we going to have to remember to update this value each time Unicode 
> > updates?
> No. But I don't think it's matter, as long as it is defined, GCC hasn't 
> updated since 2017
Okay, I don't mind updating the value when it becomes a problem someone notices.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106577

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


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

2021-07-22 Thread Amy Huang via Phabricator via cfe-commits
akhuang updated this revision to Diff 360918.
akhuang added a comment.

Remove fno-use-ctor-homing flag


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106084

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

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

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

2021-07-22 Thread Amy Huang via Phabricator via cfe-commits
akhuang added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:1636
+if (Opts.getDebugInfo() == codegenoptions::DebugInfoConstructor)
+  Opts.setDebugInfo(codegenoptions::LimitedDebugInfo);
 

probinson wrote:
> No... you want to check both options in one call, otherwise 
> `-fno-use-ctor-homing -fuse-ctor-homing` will prefer the `no` version instead 
> of last-one-wins.
> 
> I suggest fiddling the options should be done separately.
> Also if you want to make it a clang option, the option name should have 
> `debug` in it; pretty sure all the -f options related to debug info do that, 
> and in any case it's a good idea.
ah, right. 

I'll move this to a separate patch. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106084

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


[PATCH] D106577: [clang] Define __STDC_ISO_10646__

2021-07-22 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 360914.
cor3ntin added a comment.

Remove braces, improve comment (Thanks Aaron)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106577

Files:
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/Preprocessor/init-aarch64.c
  clang/test/Preprocessor/init-x86.c
  clang/test/Preprocessor/init.c

Index: clang/test/Preprocessor/init.c
===
--- clang/test/Preprocessor/init.c
+++ clang/test/Preprocessor/init.c
@@ -89,6 +89,7 @@
 // RUN: %clang_cc1 -std=iso9899:2011 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix C11 %s
 // RUN: %clang_cc1 -std=iso9899:201x -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix C11 %s
 //
+// C11:#define __STDC_ISO_10646__ 202012L
 // C11:#define __STDC_UTF_16__ 1
 // C11:#define __STDC_UTF_32__ 1
 // C11:#define __STDC_VERSION__ 201112L
@@ -284,6 +285,7 @@
 // RUN: %clang_cc1 -dM -fwchar-type=short -fno-signed-wchar -triple=x86_64-unknown-windows-cygnus -E /dev/null | FileCheck -match-full-lines -check-prefix SHORTWCHAR %s
 //
 // SHORTWCHAR: #define __SIZEOF_WCHAR_T__ 2
+// SHORTWCHAR-NOT: #define __STDC_ISO_10646__
 // SHORTWCHAR: #define __WCHAR_MAX__ 65535
 // SHORTWCHAR: #define __WCHAR_TYPE__ unsigned short
 // SHORTWCHAR: #define __WCHAR_WIDTH__ 16
@@ -292,6 +294,7 @@
 // RUN: %clang_cc1 -E -dM -fwchar-type=int -triple=x86_64-unknown-unknown < /dev/null | FileCheck -match-full-lines -check-prefix SHORTWCHAR2 %s
 //
 // SHORTWCHAR2: #define __SIZEOF_WCHAR_T__ 4
+// SHORTWCHAR2: #define __STDC_ISO_10646__ 202012L
 // SHORTWCHAR2: #define __WCHAR_WIDTH__ 32
 // Other definitions vary from platform to platform
 
@@ -1739,6 +1742,7 @@
 // WEBASSEMBLY-NOT:#define __STDC_NO_COMPLEX__
 // WEBASSEMBLY-NOT:#define __STDC_NO_VLA__
 // WEBASSEMBLY-NOT:#define __STDC_NO_THREADS__
+// WEBASSEMBLY-NEXT:#define __STDC_ISO_10646__ 202012L
 // WEBASSEMBLY-NEXT:#define __STDC_UTF_16__ 1
 // WEBASSEMBLY-NEXT:#define __STDC_UTF_32__ 1
 // WEBASSEMBLY-NEXT:#define __STDC_VERSION__ 201710L
@@ -2310,6 +2314,7 @@
 // RISCV32: #define __SIZE_TYPE__ unsigned int
 // RISCV32: #define __SIZE_WIDTH__ 32
 // RISCV32: #define __STDC_HOSTED__ 0
+// RISCV32: #define __STDC_ISO_10646__ 202012L
 // RISCV32: #define __STDC_UTF_16__ 1
 // RISCV32: #define __STDC_UTF_32__ 1
 // RISCV32: #define __STDC_VERSION__ 201710L
@@ -2517,6 +2522,7 @@
 // RISCV64: #define __SIZE_TYPE__ long unsigned int
 // RISCV64: #define __SIZE_WIDTH__ 64
 // RISCV64: #define __STDC_HOSTED__ 0
+// RISCV64: #define __STDC_ISO_10646__ 202012L
 // RISCV64: #define __STDC_UTF_16__ 1
 // RISCV64: #define __STDC_UTF_32__ 1
 // RISCV64: #define __STDC_VERSION__ 201710L
Index: clang/test/Preprocessor/init-x86.c
===
--- clang/test/Preprocessor/init-x86.c
+++ clang/test/Preprocessor/init-x86.c
@@ -1199,7 +1199,7 @@
 // X86_64-CLOUDABI:#define __SSE_MATH__ 1
 // X86_64-CLOUDABI:#define __SSE__ 1
 // X86_64-CLOUDABI:#define __STDC_HOSTED__ 0
-// X86_64-CLOUDABI:#define __STDC_ISO_10646__ 201206L
+// X86_64-CLOUDABI:#define __STDC_ISO_10646__ 202012L
 // X86_64-CLOUDABI:#define __STDC_UTF_16__ 1
 // X86_64-CLOUDABI:#define __STDC_UTF_32__ 1
 // X86_64-CLOUDABI:#define __STDC_VERSION__ 201710L
Index: clang/test/Preprocessor/init-aarch64.c
===
--- clang/test/Preprocessor/init-aarch64.c
+++ clang/test/Preprocessor/init-aarch64.c
@@ -235,6 +235,7 @@
 // AARCH64_CXX: #define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
 // AARCH64_CXX: #define __STDCPP_THREADS__ 1
 // AARCH64-NEXT: #define __STDC_HOSTED__ 1
+// AARCH64: #define __STDC_ISO_10646__ 202012L
 // AARCH64-NEXT: #define __STDC_UTF_16__ 1
 // AARCH64-NEXT: #define __STDC_UTF_32__ 1
 // AARCH64_C: #define __STDC_VERSION__ 201710L
@@ -648,6 +649,7 @@
 // AARCH64-MSVC: #define __SIZE_TYPE__ long long unsigned int
 // AARCH64-MSVC: #define __SIZE_WIDTH__ 64
 // AARCH64-MSVC: #define __STDC_HOSTED__ 0
+// AARCH64-MSVC-NOT: #define __STDC_ISO_10646__
 // AARCH64-MSVC: #define __STDC_UTF_16__ 1
 // AARCH64-MSVC: #define __STDC_UTF_32__ 1
 // AARCH64-MSVC: #define __STDC_VERSION__ 201710L
Index: clang/lib/Frontend/InitPreprocessor.cpp
===
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -427,6 +427,16 @@
   Builder.defineMacro("__STDC_UTF_16__", "1");
   Builder.defineMacro("__STDC_UTF_32__", "1");
 
+  // Because Clang only supports UTF-32 or UTF-16 as the
+  // wide execution encoding, any platform that doesn't use
+  // short wchar_t can represent the entire Unicode code space.
+  // Unicode 13 was released in December 2020, which is why we're
+  // expanding to 202012L. Note that new Unicode versions are
+  // *very* unlikely 

[PATCH] D106577: [clang] Define __STDC_ISO_10646__

2021-07-22 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

In D106577#2897312 , @aaron.ballman 
wrote:

> Can you also add a test that explicitly uses `-fshort-wchar` to verify that 
> we don't predefine the macro?

There is one already! (init.c L288)




Comment at: clang/lib/Frontend/InitPreprocessor.cpp:430-435
+  // Because Clang only supports UTF-32 or UTF-16 as the
+  // wide execution encoding, any platform that doesn't uses
+  // short wchar can represent the entire Unicode code space
+  // Unicode 13 was released in December 2020.
+  // Note that new Unicode version are *very* unlikely to affect
+  // representability

aaron.ballman wrote:
> Are we going to have to remember to update this value each time Unicode 
> updates?
No. But I don't think it's matter, as long as it is defined, GCC hasn't updated 
since 2017


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106577

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


[clang] 178c2b4 - Correctly diagnose taking the address of a register variable in C

2021-07-22 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2021-07-22T14:53:23-04:00
New Revision: 178c2b4c1eb12b2153adb384ac7f22a8791edc86

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

LOG: Correctly diagnose taking the address of a register variable in C

We caught the cases where the user would explicitly use the & operator,
but we were missing implicit conversions such as array decay.

Fixes PR26336. Thanks to Samuel Neves for inspiration for the patch.

Added: 


Modified: 
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/Sema/expr-address-of.c

Removed: 




diff  --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index fbbb347f57da..054a65265079 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -629,16 +629,36 @@ ExprResult Sema::ImpCastExprToType(Expr *E, QualType Ty,
   if (ExprTy == TypeTy)
 return E;
 
-  // C++1z [conv.array]: The temporary materialization conversion is applied.
-  // We also use this to fuel C++ DR1213, which applies to C++11 onwards.
-  if (Kind == CK_ArrayToPointerDecay && getLangOpts().CPlusPlus &&
-  E->getValueKind() == VK_PRValue) {
-// The temporary is an lvalue in C++98 and an xvalue otherwise.
-ExprResult Materialized = CreateMaterializeTemporaryExpr(
-E->getType(), E, !getLangOpts().CPlusPlus11);
-if (Materialized.isInvalid())
-  return ExprError();
-E = Materialized.get();
+  if (Kind == CK_ArrayToPointerDecay) {
+// C++1z [conv.array]: The temporary materialization conversion is applied.
+// We also use this to fuel C++ DR1213, which applies to C++11 onwards.
+if (getLangOpts().CPlusPlus && E->getValueKind() == VK_PRValue) {
+  // The temporary is an lvalue in C++98 and an xvalue otherwise.
+  ExprResult Materialized = CreateMaterializeTemporaryExpr(
+  E->getType(), E, !getLangOpts().CPlusPlus11);
+  if (Materialized.isInvalid())
+return ExprError();
+  E = Materialized.get();
+}
+// C17 6.7.1p6 footnote 124: The implementation can treat any register
+// declaration simply as an auto declaration. However, whether or not
+// addressable storage is actually used, the address of any part of an
+// object declared with storage-class specifier register cannot be
+// computed, either explicitly(by use of the unary & operator as discussed
+// in 6.5.3.2) or implicitly(by converting an array name to a pointer as
+// discussed in 6.3.2.1).Thus, the only operator that can be applied to an
+// array declared with storage-class specifier register is sizeof.
+if (VK == VK_PRValue && !getLangOpts().CPlusPlus && !E->isPRValue()) {
+  if (const auto *DRE = dyn_cast(E)) {
+if (const auto *VD = dyn_cast(DRE->getDecl())) {
+  if (VD->getStorageClass() == SC_Register) {
+Diag(E->getExprLoc(), diag::err_typecheck_address_of)
+<< /*register variable*/ 3 << E->getSourceRange();
+return ExprError();
+  }
+}
+  }
+}
   }
 
   if (ImplicitCastExpr *ImpCast = dyn_cast(E)) {

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 3926c49077ce..d19eb8475e9f 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -525,9 +525,13 @@ ExprResult Sema::DefaultFunctionArrayConversion(Expr *E, 
bool Diagnose) {
 // An lvalue or rvalue of type "array of N T" or "array of unknown bound of
 // T" can be converted to an rvalue of type "pointer to T".
 //
-if (getLangOpts().C99 || getLangOpts().CPlusPlus || E->isLValue())
-  E = ImpCastExprToType(E, Context.getArrayDecayedType(Ty),
-CK_ArrayToPointerDecay).get();
+if (getLangOpts().C99 || getLangOpts().CPlusPlus || E->isLValue()) {
+  ExprResult Res = ImpCastExprToType(E, Context.getArrayDecayedType(Ty),
+ CK_ArrayToPointerDecay);
+  if (Res.isInvalid())
+return ExprError();
+  E = Res.get();
+}
   }
   return E;
 }

diff  --git a/clang/test/Sema/expr-address-of.c 
b/clang/test/Sema/expr-address-of.c
index 480871afad2a..aed488284ab1 100644
--- a/clang/test/Sema/expr-address-of.c
+++ b/clang/test/Sema/expr-address-of.c
@@ -45,24 +45,27 @@ void f0() {
   int *_dummy1 = &(*(x1 + 1));
 }
 
-// FIXME: The checks for this function are broken; we should error
-// on promoting a register array to a pointer! (C99 6.3.2.1p3)
 void f1() {
   register int x0[10];
-  int *_dummy00 = x0; // fixme-error {{address of register variable requested}}
-  int *_dummy01 = &(*x0); // fixme-error {{address of register variable 
requested}}
+  int *_dummy00 = x0; // expected-error {{address of register variable 
requested}}
+  int *_dummy01 = &(*x0); // expected-error 

[PATCH] D106074: [AIX] Clang's library integration support for 128-bit long double is incomplete on AIX.

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

Since Whitny and Chris are busy, I have requested Shimin to commit this in.
Thanks Shimin!


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

https://reviews.llvm.org/D106074

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


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

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

Since Hubert is busy, I have requested Shimin to commit this in.
Thanks Shimin!


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

https://reviews.llvm.org/D106371

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


[PATCH] D106277: [SVE] Remove the interface for getMaxVScale in favour of the IR attributes

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



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:507
+CurFn->addFnAttr(
+llvm::Attribute::getWithVScaleRangeArgs(getLLVMContext(), 0, 16));
   }

Thinking about this more, maybe these values should be returned from a new 
interface on TargetInfo? Maybe using Optional so you can default to None for 
other targets? This way you don't have AArch64 specific numbers hardcoded in a 
file that doesn't belong to AArch64? But maybe the damage was already done with 
the "/ 128" in the ArmSveVectorBits code above. Maybe you can unify both into a 
new TargetInfo function? Does TargetInfo have access to LangOpts?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106277

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


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

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

Looks good, could you also add a note in the relasenotes.rst?


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

https://reviews.llvm.org/D106349

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


  1   2   3   >