[PATCH] D84932: [builtins] Add more test cases for __div[sdt]f3 LibCalls

2020-08-18 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

In D84932#2223559 , @atrosinenko wrote:

> @sepavloff
>
> Thank you for the test cases. Looks like it is worth completely rewriting the 
> three tests as table-driven tests

Tests are not required to be compact. It is more important to have clear 
checks, which can be easily extracted. Table-driven tests are suitable if 
number of test cases is large, I think this is not the case.




Comment at: compiler-rt/test/builtins/Unit/divdf3_test.c:80
+// divisor is 1.0 as UQ1.31
+if (test__divdf3(0x1.0p+0, 0x1.0001p+0, UINT64_C(0x3fefffe0)))
   return 1;

atrosinenko wrote:
> sepavloff wrote:
> > Is 0x1.0001p+0 equal to 1.0 in UQ1.31?
> Divisor is `1.(31 zeroes)1` after restoring the implicit bit, so it is 
> **truncated** to 1.0 as UQ1.31. Instead of counting bits carefully, it would 
> probably be better to add several tests with the `1` bit shifted 1-2 places 
> left/right as well as if the divisor is round up instead of truncating - 
> //just in case//. :) So, with table-driven test it would probably be simpler 
> to not make extra assumptions on the implementation.
> Divisor is 1.(31 zeroes)1

So it is **not** `1.0` and the comment is misleading. Try rewording the comment 
to avoid confusion. Maybe `divisor is truncated to 1.0 in UQ1.31` or something 
like that. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84932

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


[PATCH] D85384: [X86] Add basic support for -mtune command line option in clang

2020-08-18 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D85384#2225459 , @echristo wrote:

> This would be because at that point the default cpu was that and it
> probably had something to do with fallbacks.
>
> At this point it can be changed I imagine to whatever makes sense.

The issue seems to be that its somehow only being applied to one set of command 
lines. And the IR from the two sets of command lines are being differed. So I 
don't think there's any value that makes sense. Its existence is causing the 
diff somehow.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85384

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


[PATCH] D85384: [X86] Add basic support for -mtune command line option in clang

2020-08-18 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a subscriber: ddunbar.
craig.topper added a comment.

In D85384#2225434 , @phosek wrote:

> This seems to have broken our Mac builders with the following error:
>
>   -- Testing: 25226 tests, 24 workers --
>   Testing:  0.. 10.. 20.
>   FAIL: Clang :: Frontend/ast-main.c (6834 of 25226)
>    TEST 'Clang :: Frontend/ast-main.c' FAILED 
> 
>   Script:
>   --
>   : 'RUN: at line 1';   env SDKROOT="/" 
> /b/s/w/ir/k/staging/llvm_build/bin/clang -emit-llvm -S -o 
> /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.c.tmp1.ll
>  -x c - < /b/s/w/ir/k/llvm-project/clang/test/Frontend/ast-main.c
>   : 'RUN: at line 2';   env SDKROOT="/" 
> /b/s/w/ir/k/staging/llvm_build/bin/clang -emit-ast -o 
> /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.c.tmp.ast
>  /b/s/w/ir/k/llvm-project/clang/test/Frontend/ast-main.c
>   : 'RUN: at line 3';   env SDKROOT="/" 
> /b/s/w/ir/k/staging/llvm_build/bin/clang -emit-llvm -S -o 
> /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.c.tmp2.ll
>  -x ast - < 
> /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.c.tmp.ast
>   : 'RUN: at line 4';   diff 
> /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.c.tmp1.ll
>  
> /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.c.tmp2.ll
>   --
>   Exit Code: 1
>   
>   Command Output (stdout):
>   --
>   14c14
>   < attributes #0 = { noinline nounwind optnone ssp uwtable 
> "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" 
> "frame-pointer"="all" "less-precise-fpmad"="false" 
> "min-legal-vector-width"="0" "no-infs-fp-math"="false" 
> "no-jump-tables"="false" "no-nans-fp-math"="false" 
> "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" 
> "stack-protector-buffer-size"="8" "target-cpu"="penryn" 
> "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87"
>  "tune-cpu"="core2" "unsafe-fp-math"="false" "use-soft-float"="false" }
>   ---
>   > attributes #0 = { noinline nounwind optnone ssp uwtable 
> "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" 
> "frame-pointer"="all" "less-precise-fpmad"="false" 
> "min-legal-vector-width"="0" "no-infs-fp-math"="false" 
> "no-jump-tables"="false" "no-nans-fp-math"="false" 
> "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" 
> "stack-protector-buffer-size"="8" "target-cpu"="penryn" 
> "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87"
>  "unsafe-fp-math"="false" "use-soft-float"="false" }
>   
>   --
>   
>   
>   Testing:  0.. 10.. 20.
>   FAIL: Clang :: Frontend/ast-main.cpp (6835 of 25226)
>    TEST 'Clang :: Frontend/ast-main.cpp' FAILED 
> 
>   Script:
>   --
>   : 'RUN: at line 1';   env SDKROOT="/" 
> /b/s/w/ir/k/staging/llvm_build/bin/clang -emit-llvm -S -o 
> /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.cpp.tmp1.ll
>  -x c++ - < /b/s/w/ir/k/llvm-project/clang/test/Frontend/ast-main.cpp
>   : 'RUN: at line 2';   env SDKROOT="/" 
> /b/s/w/ir/k/staging/llvm_build/bin/clang -fno-delayed-template-parsing 
> -emit-ast -o 
> /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.cpp.tmp.ast
>  /b/s/w/ir/k/llvm-project/clang/test/Frontend/ast-main.cpp
>   : 'RUN: at line 3';   env SDKROOT="/" 
> /b/s/w/ir/k/staging/llvm_build/bin/clang -emit-llvm -S -o 
> /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.cpp.tmp2.ll
>  -x ast - < 
> /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.cpp.tmp.ast
>   : 'RUN: at line 4';   diff 
> /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.cpp.tmp1.ll
>  
> /b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.cpp.tmp2.ll
>   --
>   Exit Code: 1
>   
>   Command Output (stdout):
>   --
>   37,39c37,39
>   < attributes #0 = { noinline optnone ssp uwtable 
> "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" 
> "frame-pointer"="all" "less-precise-fpmad"="false" 
> "min-legal-vector-width"="0" "no-infs-fp-math"="false" 
> "no-jump-tables"="false" "no-nans-fp-math"="false" 
> "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" 
> "stack-protector-buffer-size"="8" "target-cpu"="penryn" 
> "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87"
>  "tune-cpu"="core2" "unsafe-fp-math"="false" "use-soft-float"="false" }
>   < attributes #1 = { noinline nounwind optnone ssp uwtable 
> "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" 
> "frame-pointer"="all" "less-precise-fpmad"="false" 
> "min-legal-vector-width"="0" "no-infs-fp-math"="false" 
> "no-jump-tables"="false" "no-nans-fp-math"="false" 
> "no-signed-zeros-fp-math"="false" 

[PATCH] D86193: [CSSPGO] Pseudo probe instrumentation for basic blocks

2020-08-18 Thread Hongtao Yu via Phabricator via cfe-commits
hoy updated this revision to Diff 286476.
hoy added a comment.

Updating D86193 : [CSSPGO] Pseudo probe 
instrumentation for basic blocks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86193

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/emit-pseudo-probe.c
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/include/llvm/CodeGen/ISDOpcodes.h
  llvm/include/llvm/CodeGen/MachineInstr.h
  llvm/include/llvm/CodeGen/SelectionDAG.h
  llvm/include/llvm/CodeGen/SelectionDAGNodes.h
  llvm/include/llvm/IR/BasicBlock.h
  llvm/include/llvm/IR/IntrinsicInst.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/include/llvm/Support/TargetOpcodes.def
  llvm/include/llvm/Target/Target.td
  llvm/include/llvm/Transforms/IPO/SampleProfileProbe.h
  llvm/lib/Analysis/AliasSetTracker.cpp
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/lib/Analysis/VectorUtils.cpp
  llvm/lib/CodeGen/Analysis.cpp
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
  llvm/lib/IR/BasicBlock.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/IPO/CMakeLists.txt
  llvm/lib/Transforms/IPO/SampleProfileProbe.cpp
  llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
  llvm/lib/Transforms/Utils/Evaluator.cpp
  llvm/lib/Transforms/Utils/SimplifyCFG.cpp
  llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
  llvm/test/Transforms/SampleProfile/emit-pseudo-probe.ll

Index: llvm/test/Transforms/SampleProfile/emit-pseudo-probe.ll
===
--- /dev/null
+++ llvm/test/Transforms/SampleProfile/emit-pseudo-probe.ll
@@ -0,0 +1,29 @@
+; RUN: opt < %s -passes=pseudo-probe -function-sections -S -o %t
+; RUN: FileCheck %s < %t --check-prefix=CHECK-IL
+; RUN: llc %t -stop-after=instruction-select -o - | FileCheck %s --check-prefix=CHECK-MIR
+;
+;; Check the generation of pseudoprobe intrinsic call.
+
+define void @foo(i32 %x) {
+bb0:
+  %cmp = icmp eq i32 %x, 0
+; CHECK-IL: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 1)
+; CHECK-MIR: PSEUDO_PROBE [[#GUID:]], 1, 0
+  br i1 %cmp, label %bb1, label %bb2
+
+bb1:
+; CHECK-IL: call void @llvm.pseudoprobe(i64 [[#GUID]], i64 2)
+; CHECK-MIR: PSEUDO_PROBE [[#GUID]], 3, 0
+; CHECK-MIR: PSEUDO_PROBE [[#GUID]], 4, 0
+  br label %bb3
+
+bb2:
+; CHECK-IL: call void @llvm.pseudoprobe(i64 [[#GUID]], i64 3)
+; CHECK-MIR: PSEUDO_PROBE [[#GUID]], 2, 0
+; CHECK-MIR: PSEUDO_PROBE [[#GUID]], 4, 0
+  br label %bb3
+
+bb3:
+; CHECK-IL: call void @llvm.pseudoprobe(i64 [[#GUID]], i64 4)
+  ret void
+}
Index: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
===
--- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -5122,7 +5122,9 @@
 
 if (I->mayReadOrWriteMemory() &&
 (!isa(I) ||
- cast(I)->getIntrinsicID() != Intrinsic::sideeffect)) {
+ (cast(I)->getIntrinsicID() != Intrinsic::sideeffect &&
+  cast(I)->getIntrinsicID() !=
+  Intrinsic::pseudoprobe))) {
   // Update the linked list of memory accessing instructions.
   if (CurrentLoadStore) {
 CurrentLoadStore->NextLoadStore = SD;
Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -7167,7 +7167,8 @@
 
   Intrinsic::ID ID = getVectorIntrinsicIDForCall(CI, TLI);
   if (ID && (ID == Intrinsic::assume || ID == Intrinsic::lifetime_end ||
- ID == Intrinsic::lifetime_start || ID == Intrinsic::sideeffect))
+ ID == Intrinsic::lifetime_start || ID == Intrinsic::sideeffect ||
+ ID == Intrinsic::pseudoprobe))
 return nullptr;
 
   auto willWiden = [&](unsigned VF) -> bool {
Index: llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
===
--- llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
+++ llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
@@ -666,6 +666,10 @@

[PATCH] D86193: [CSSPGO] Pseudo probe instrumentation for basic blocks

2020-08-18 Thread Hongtao Yu via Phabricator via cfe-commits
hoy created this revision.
Herald added subscribers: llvm-commits, cfe-commits, dang, laytonio, asbirlea, 
hiraditya, mgorny.
Herald added projects: clang, LLVM.
hoy requested review of this revision.
Herald added a subscriber: jdoerfert.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86193

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/emit-pseudo-probe.c
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/include/llvm/CodeGen/ISDOpcodes.h
  llvm/include/llvm/CodeGen/MachineInstr.h
  llvm/include/llvm/CodeGen/Passes.h
  llvm/include/llvm/CodeGen/SelectionDAG.h
  llvm/include/llvm/CodeGen/SelectionDAGNodes.h
  llvm/include/llvm/IR/BasicBlock.h
  llvm/include/llvm/IR/IntrinsicInst.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/include/llvm/Support/TargetOpcodes.def
  llvm/include/llvm/Target/Target.td
  llvm/include/llvm/Transforms/IPO/SampleProfileProbe.h
  llvm/lib/Analysis/AliasSetTracker.cpp
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/lib/Analysis/VectorUtils.cpp
  llvm/lib/CodeGen/Analysis.cpp
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
  llvm/lib/IR/BasicBlock.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/IPO/CMakeLists.txt
  llvm/lib/Transforms/IPO/SampleProfileProbe.cpp
  llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
  llvm/lib/Transforms/Utils/Evaluator.cpp
  llvm/lib/Transforms/Utils/SimplifyCFG.cpp
  llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
  llvm/test/Transforms/SampleProfile/emit-pseudo-probe.ll

Index: llvm/test/Transforms/SampleProfile/emit-pseudo-probe.ll
===
--- /dev/null
+++ llvm/test/Transforms/SampleProfile/emit-pseudo-probe.ll
@@ -0,0 +1,29 @@
+; RUN: opt < %s -passes=pseudo-probe -function-sections -S -o %t
+; RUN: FileCheck %s < %t --check-prefix=CHECK-IL
+; RUN: llc %t -stop-after=instruction-select -o - | FileCheck %s --check-prefix=CHECK-MIR
+;
+;; Check the generation of pseudoprobe intrinsic call.
+
+define void @foo(i32 %x) {
+bb0:
+  %cmp = icmp eq i32 %x, 0
+; CHECK-IL: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 1)
+; CHECK-MIR: PSEUDO_PROBE [[#GUID:]], 1, 0
+  br i1 %cmp, label %bb1, label %bb2
+
+bb1:
+; CHECK-IL: call void @llvm.pseudoprobe(i64 [[#GUID]], i64 2)
+; CHECK-MIR: PSEUDO_PROBE [[#GUID]], 3, 0
+; CHECK-MIR: PSEUDO_PROBE [[#GUID]], 4, 0
+  br label %bb3
+
+bb2:
+; CHECK-IL: call void @llvm.pseudoprobe(i64 [[#GUID]], i64 3)
+; CHECK-MIR: PSEUDO_PROBE [[#GUID]], 2, 0
+; CHECK-MIR: PSEUDO_PROBE [[#GUID]], 4, 0
+  br label %bb3
+
+bb3:
+; CHECK-IL: call void @llvm.pseudoprobe(i64 [[#GUID]], i64 4)
+  ret void
+}
Index: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
===
--- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -5122,7 +5122,9 @@
 
 if (I->mayReadOrWriteMemory() &&
 (!isa(I) ||
- cast(I)->getIntrinsicID() != Intrinsic::sideeffect)) {
+ (cast(I)->getIntrinsicID() != Intrinsic::sideeffect &&
+  cast(I)->getIntrinsicID() !=
+  Intrinsic::pseudoprobe))) {
   // Update the linked list of memory accessing instructions.
   if (CurrentLoadStore) {
 CurrentLoadStore->NextLoadStore = SD;
Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -7167,7 +7167,8 @@
 
   Intrinsic::ID ID = getVectorIntrinsicIDForCall(CI, TLI);
   if (ID && (ID == Intrinsic::assume || ID == Intrinsic::lifetime_end ||
- ID == Intrinsic::lifetime_start || ID == Intrinsic::sideeffect))
+ ID == Intrinsic::lifetime_start || ID == Intrinsic::sideeffect ||
+ ID == Intrinsic::pseudoprobe))
 return nullptr;
 
   auto willWiden = [&](unsigned VF) -> bool {
Index: llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
===
--- llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
+++ llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
@@ 

[PATCH] D85384: [X86] Add basic support for -mtune command line option in clang

2020-08-18 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

This seems to have broken our Mac builders with the following error:

  -- Testing: 25226 tests, 24 workers --
  Testing:  0.. 10.. 20.
  FAIL: Clang :: Frontend/ast-main.c (6834 of 25226)
   TEST 'Clang :: Frontend/ast-main.c' FAILED 

  Script:
  --
  : 'RUN: at line 1';   env SDKROOT="/" 
/b/s/w/ir/k/staging/llvm_build/bin/clang -emit-llvm -S -o 
/b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.c.tmp1.ll
 -x c - < /b/s/w/ir/k/llvm-project/clang/test/Frontend/ast-main.c
  : 'RUN: at line 2';   env SDKROOT="/" 
/b/s/w/ir/k/staging/llvm_build/bin/clang -emit-ast -o 
/b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.c.tmp.ast
 /b/s/w/ir/k/llvm-project/clang/test/Frontend/ast-main.c
  : 'RUN: at line 3';   env SDKROOT="/" 
/b/s/w/ir/k/staging/llvm_build/bin/clang -emit-llvm -S -o 
/b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.c.tmp2.ll
 -x ast - < 
/b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.c.tmp.ast
  : 'RUN: at line 4';   diff 
/b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.c.tmp1.ll
 
/b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.c.tmp2.ll
  --
  Exit Code: 1
  
  Command Output (stdout):
  --
  14c14
  < attributes #0 = { noinline nounwind optnone ssp uwtable 
"correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" 
"frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" 
"no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" 
"no-signed-zeros-fp-math"="false" "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-cpu"="penryn" 
"target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87"
 "tune-cpu"="core2" "unsafe-fp-math"="false" "use-soft-float"="false" }
  ---
  > attributes #0 = { noinline nounwind optnone ssp uwtable 
"correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" 
"frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" 
"no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" 
"no-signed-zeros-fp-math"="false" "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-cpu"="penryn" 
"target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87"
 "unsafe-fp-math"="false" "use-soft-float"="false" }
  
  --
  
  
  Testing:  0.. 10.. 20.
  FAIL: Clang :: Frontend/ast-main.cpp (6835 of 25226)
   TEST 'Clang :: Frontend/ast-main.cpp' FAILED 

  Script:
  --
  : 'RUN: at line 1';   env SDKROOT="/" 
/b/s/w/ir/k/staging/llvm_build/bin/clang -emit-llvm -S -o 
/b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.cpp.tmp1.ll
 -x c++ - < /b/s/w/ir/k/llvm-project/clang/test/Frontend/ast-main.cpp
  : 'RUN: at line 2';   env SDKROOT="/" 
/b/s/w/ir/k/staging/llvm_build/bin/clang -fno-delayed-template-parsing 
-emit-ast -o 
/b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.cpp.tmp.ast
 /b/s/w/ir/k/llvm-project/clang/test/Frontend/ast-main.cpp
  : 'RUN: at line 3';   env SDKROOT="/" 
/b/s/w/ir/k/staging/llvm_build/bin/clang -emit-llvm -S -o 
/b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.cpp.tmp2.ll
 -x ast - < 
/b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.cpp.tmp.ast
  : 'RUN: at line 4';   diff 
/b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.cpp.tmp1.ll
 
/b/s/w/ir/k/staging/llvm_build/tools/clang/test/Frontend/Output/ast-main.cpp.tmp2.ll
  --
  Exit Code: 1
  
  Command Output (stdout):
  --
  37,39c37,39
  < attributes #0 = { noinline optnone ssp uwtable 
"correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" 
"frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" 
"no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" 
"no-signed-zeros-fp-math"="false" "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-cpu"="penryn" 
"target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87"
 "tune-cpu"="core2" "unsafe-fp-math"="false" "use-soft-float"="false" }
  < attributes #1 = { noinline nounwind optnone ssp uwtable 
"correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" 
"frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" 
"no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" 
"no-signed-zeros-fp-math"="false" "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-cpu"="penryn" 
"target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87"
 "tune-cpu"="core2" "unsafe-fp-math"="false" "use-soft-float"="false" }
  < attributes #2 = { noinline norecurse nounwind optnone ssp uwtable 

[PATCH] D75045: [analyzer] Improved check of `fgetc` in StreamChecker.

2020-08-18 Thread Balázs Kéri via Phabricator via cfe-commits
balazske planned changes to this revision.
balazske added a comment.
Herald added subscribers: ASDenysPetrov, whisperity.

Something like this can be added to StreamChecker but it has changed in many 
places so a new review would be needed. The main problem is with this `fgetc` 
check is that it would be good to check the standard stream version `getc` too, 
but that is hard to implement because global nature of the standard streams 
(`stdin`).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75045

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


[clang] a11ab6e - Fix test hip-target-id.hip

2020-08-18 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2020-08-19T00:41:14-04:00
New Revision: a11ab6e04c199c2a33d81c451e9e26bf18636dfc

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

LOG: Fix test hip-target-id.hip

Some build bot has lld in the directory name, which caused pattern match
issue in the list test.

Added: 


Modified: 
clang/test/Driver/hip-target-id.hip

Removed: 




diff  --git a/clang/test/Driver/hip-target-id.hip 
b/clang/test/Driver/hip-target-id.hip
index ce1a4f6c9d89..c4a5c5c6737e 100644
--- a/clang/test/Driver/hip-target-id.hip
+++ b/clang/test/Driver/hip-target-id.hip
@@ -35,8 +35,7 @@
 // TMP-SAME: "-target-feature" "+sram-ecc"
 // TMP-SAME: "-target-feature" "+xnack"
 
-// CHECK: [[LLD:"[^"]*lld[^"]*"]]
-// CHECK-SAME: "-plugin-opt=mcpu=gfx908"
+// CHECK: [[LLD:"[^"]*lld[^"]*"]] {{.*}} "-plugin-opt=mcpu=gfx908"
 // CHECK-SAME: "-plugin-opt=-mattr=+sram-ecc,+xnack"
 
 // CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
@@ -44,8 +43,7 @@
 // CHECK-SAME: "-target-feature" "-sram-ecc"
 // CHECK-SAME: "-target-feature" "+xnack"
 
-// CHECK: [[LLD]]
-// CHECK-SAME: "-plugin-opt=mcpu=gfx908"
+// CHECK: [[LLD]] {{.*}} "-plugin-opt=mcpu=gfx908"
 // CHECK-SAME: "-plugin-opt=-mattr=-sram-ecc,+xnack"
 
 // CHECK: {{"[^"]*clang-offload-bundler[^"]*"}}



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


[PATCH] D71510: [clang][checkers] Added new checker 'error-return-checker'.

2020-08-18 Thread Balázs Kéri via Phabricator via cfe-commits
balazske planned changes to this revision.
balazske added a comment.
Herald added subscribers: martong, Charusso.

This patch is here for code reference only. Although the whole checker does not 
work safe in this way the idea behind this approach can be useful.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71510

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


[PATCH] D83088: Introduce CfgTraits abstraction

2020-08-18 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D83088#2224297 , @nhaehnle wrote:

>> Not sure that's the best place to be designing this fairly integral and 
>> complicated piece of infrastructure from, but hoping we can find some good 
>> places/solutions/etc.
>
> I sent an email to llvm-dev several weeks ago, but things seem to have moved 
> here. Either way is fine with me.

Yeah, sorry, I did see it - but didn't follow it in sufficient detail to 
understand the motivation/tradeoffs so well. (I do usually prefer to keep the 
design discussion on the design discussion threads, before worrying about the 
code specifics - but sometimes hard to understand it without code)

>> But I guess coming back to the original/broader design: What problems is 
>> this intended to solve? The inability to write non-template algorithms over 
>> graphs? What cost does that come with? Are there algorithms that are a bit 
>> too complicated/unwieldy when done as templates? 
>> If it's specifically the static/dynamic dispatch issue - I'm not sure the 
>> type erasure and runtime overhead may be worth the tradeoff here, though if 
>> it is - it'd be good to keep the non-dynamic version common, rather than now 
>> having GraphTraits and CfgTraits done a bit differently, etc.
>
> It's not just over graphs, but taking SSA values into account as well -- that 
> is the key distinction between GraphTraits and CfgTraits.

Not sure I follow - could you give an example of a graph where the GraphTraits 
concept of the Graph and the CfgTraits concept of the graph (or, perhaps more 
importantly - features of the graph/API surface area/properties you can expose 
through the CFG API/concept/thing but not through GraphTraits?

> The most immediate problem is divergence analysis, which is extremely complex 
> and difficult to get right. If I had tried to fight the accidental complexity 
> that comes with attempting to write such an algorithm as C++ templates in 
> addition to the inherent complexity of the algorithm at the same time, I'm 
> not sure I would have been able to produce anything workable at all.
>
> Frankly, I suspect that our dominator tree implementation also suffer because 
> of this, though at least dominator trees are much more well studied in the 
> academic literature, so that helps keep the inherent complexity under control.

I'm totally open to discussing making APIs more usable, for sure - though I'm 
thinking it's likely a concept (like containers in the C++ standard library) 
might be the better direction.

Perhaps some code samples showing how one would interact (probably not whole 
algorithms - maybe something simple like generating a dot diagram for a graph) 
with these things given different APIs (traits, concepts, and runtime 
polymorphism) - and implementations of each kind too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83088

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


[PATCH] D86049: RFC: Implement optional exportable wrapper function generation for objc_direct methods.

2020-08-18 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi added a comment.

In D86049#2225202 , @rjmccall wrote:

> I think that, if we want to do this, we need to think carefully about what 
> exactly we want the ABI to be.

I agree with this very much. Open to suggestions and ideas. Already started 
noticing some interesting characteristic with the symbol naming and dylib 
loading.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86049

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


[clang] 7546b29 - [HIP] Support target id by --offload-arch

2020-08-18 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2020-08-18T23:43:53-04:00
New Revision: 7546b29e761687eeeaefcd8d963c19a2dac98d37

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

LOG: [HIP] Support target id by --offload-arch

This patch introduces support of target id by
-offload-arch.

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

Added: 
clang/include/clang/Basic/TargetID.h
clang/lib/Basic/TargetID.cpp
clang/test/Driver/Inputs/rocm/amdgcn/bitcode/oclc_isa_version_908.bc
clang/test/Driver/hip-invalid-target-id.hip
clang/test/Driver/hip-target-id.hip
clang/test/Driver/invalid-target-id.cl
clang/test/Driver/target-id-macros.cl
clang/test/Driver/target-id-macros.hip
clang/test/Driver/target-id.cl

Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Basic/TargetInfo.h
clang/include/clang/Driver/Compilation.h
clang/include/clang/Driver/Options.td
clang/lib/Basic/CMakeLists.txt
clang/lib/Basic/Targets/AMDGPU.cpp
clang/lib/Basic/Targets/AMDGPU.h
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/AMDGPU.cpp
clang/lib/Driver/ToolChains/AMDGPU.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/HIP.cpp
clang/test/Driver/amdgpu-features.c
clang/test/Driver/amdgpu-macros.cl
clang/test/Driver/amdgpu-mcpu.cl
clang/test/Driver/hip-toolchain-features.hip
llvm/include/llvm/Support/TargetParser.h
llvm/lib/Support/TargetParser.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index e6b51cfd7a8a..f66d6ae70583 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -73,6 +73,11 @@ def warn_drv_unknown_cuda_version: Warning<
   InGroup;
 def err_drv_cuda_host_arch : Error<"unsupported architecture '%0' for host 
compilation.">;
 def err_drv_mix_cuda_hip : Error<"Mixed Cuda and HIP compilation is not 
supported.">;
+def err_drv_bad_target_id : Error<"Invalid target ID: %0 (A target ID is a 
processor name "
+  "followed by an optional list of predefined features post-fixed by a plus or 
minus sign deliminated "
+  "by colon, e.g. 'gfx908:sram-ecc+:xnack-')">;
+def err_drv_bad_offload_arch_combo : Error<"Invalid offload arch combinations: 
%0 and %1 (For a specific "
+  "processor, a feature should either exist in all offload archs, or not exist 
in any offload archs)">;
 def err_drv_invalid_thread_model_for_target : Error<
   "invalid thread model '%0' in '%1' for this target">;
 def err_drv_invalid_linker_name : Error<

diff  --git a/clang/include/clang/Basic/TargetID.h 
b/clang/include/clang/Basic/TargetID.h
new file mode 100644
index ..95fd61d22eb1
--- /dev/null
+++ b/clang/include/clang/Basic/TargetID.h
@@ -0,0 +1,56 @@
+//===--- TargetID.h - Utilities for target ID ---*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_BASIC_TARGET_ID_H
+#define LLVM_CLANG_BASIC_TARGET_ID_H
+
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/Triple.h"
+#include 
+
+namespace clang {
+
+/// Get all feature strings that can be used in target ID for \p Processor.
+/// Target ID is a processor name with optional feature strings
+/// postfixed by a plus or minus sign delimited by colons, e.g.
+/// gfx908:xnack+:sram-ecc-. Each processor have a limited
+/// number of predefined features when showing up in a target ID.
+const llvm::SmallVector
+getAllPossibleTargetIDFeatures(const llvm::Triple ,
+   llvm::StringRef Processor);
+
+/// Get processor name from target ID.
+/// Returns canonical processor name or empty if the processor name is invalid.
+llvm::StringRef getProcessorFromTargetID(const llvm::Triple ,
+ llvm::StringRef OffloadArch);
+
+/// Parse a target ID to get processor and feature map.
+/// Returns canonicalized processor name or None if the target ID is invalid.
+/// Returns target ID features in \p FeatureMap if it is not null pointer.
+/// This function assumes \p OffloadArch is a valid target ID.
+/// If the target ID contains feature+, map it to true.
+/// If the target ID contains feature-, map it to false.
+/// If the target ID does not contain a feature (default), do not map it.
+llvm::Optional
+parseTargetID(const llvm::Triple , llvm::StringRef 

[PATCH] D60620: [HIP] Support target id by --offload-arch

2020-08-18 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7546b29e7616: [HIP] Support target id by --offload-arch 
(authored by yaxunl).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D60620?vs=285482=286469#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60620

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/TargetID.h
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Driver/Compilation.h
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/TargetID.cpp
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/AMDGPU.h
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/AMDGPU.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/oclc_isa_version_908.bc
  clang/test/Driver/amdgpu-features.c
  clang/test/Driver/amdgpu-macros.cl
  clang/test/Driver/amdgpu-mcpu.cl
  clang/test/Driver/hip-invalid-target-id.hip
  clang/test/Driver/hip-target-id.hip
  clang/test/Driver/hip-toolchain-features.hip
  clang/test/Driver/invalid-target-id.cl
  clang/test/Driver/target-id-macros.cl
  clang/test/Driver/target-id-macros.hip
  clang/test/Driver/target-id.cl
  llvm/include/llvm/Support/TargetParser.h
  llvm/lib/Support/TargetParser.cpp

Index: llvm/lib/Support/TargetParser.cpp
===
--- llvm/lib/Support/TargetParser.cpp
+++ llvm/lib/Support/TargetParser.cpp
@@ -83,26 +83,26 @@
   {{"mullins"},   {"gfx703"},  GK_GFX703,  FEATURE_NONE},
   {{"gfx704"},{"gfx704"},  GK_GFX704,  FEATURE_NONE},
   {{"bonaire"},   {"gfx704"},  GK_GFX704,  FEATURE_NONE},
-  {{"gfx801"},{"gfx801"},  GK_GFX801,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"carrizo"},   {"gfx801"},  GK_GFX801,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx802"},{"gfx802"},  GK_GFX802,  FEATURE_FAST_DENORMAL_F32},
-  {{"iceland"},   {"gfx802"},  GK_GFX802,  FEATURE_FAST_DENORMAL_F32},
-  {{"tonga"}, {"gfx802"},  GK_GFX802,  FEATURE_FAST_DENORMAL_F32},
-  {{"gfx803"},{"gfx803"},  GK_GFX803,  FEATURE_FAST_DENORMAL_F32},
-  {{"fiji"},  {"gfx803"},  GK_GFX803,  FEATURE_FAST_DENORMAL_F32},
-  {{"polaris10"}, {"gfx803"},  GK_GFX803,  FEATURE_FAST_DENORMAL_F32},
-  {{"polaris11"}, {"gfx803"},  GK_GFX803,  FEATURE_FAST_DENORMAL_F32},
-  {{"gfx810"},{"gfx810"},  GK_GFX810,  FEATURE_FAST_DENORMAL_F32},
-  {{"stoney"},{"gfx810"},  GK_GFX810,  FEATURE_FAST_DENORMAL_F32},
-  {{"gfx900"},{"gfx900"},  GK_GFX900,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx902"},{"gfx902"},  GK_GFX902,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx904"},{"gfx904"},  GK_GFX904,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx906"},{"gfx906"},  GK_GFX906,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx908"},{"gfx908"},  GK_GFX908,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx909"},{"gfx909"},  GK_GFX909,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx1010"},   {"gfx1010"}, GK_GFX1010, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32},
-  {{"gfx1011"},   {"gfx1011"}, GK_GFX1011, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32},
-  {{"gfx1012"},   {"gfx1012"}, GK_GFX1012, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32},
+  {{"gfx801"},{"gfx801"},  GK_GFX801,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"carrizo"},   {"gfx801"},  GK_GFX801,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"gfx802"},{"gfx802"},  GK_GFX802,  FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"iceland"},   {"gfx802"},  GK_GFX802,  FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"tonga"}, {"gfx802"},  GK_GFX802,  FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"gfx803"},{"gfx803"},  GK_GFX803,  FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"fiji"},  {"gfx803"},  GK_GFX803,  FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"polaris10"}, {"gfx803"},  GK_GFX803,  FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"polaris11"}, {"gfx803"},  GK_GFX803,  FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"gfx810"},{"gfx810"},  GK_GFX810,  FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"stoney"},{"gfx810"},  GK_GFX810,  FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"gfx900"},{"gfx900"},  GK_GFX900,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"gfx902"},{"gfx902"},  GK_GFX902,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"gfx904"},{"gfx904"},  GK_GFX904,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK},
+  {{"gfx906"},

[PATCH] D85810: [clang] Pass-through remarks options to linker

2020-08-18 Thread Wei Wang via Phabricator via cfe-commits
weiwang updated this revision to Diff 286468.
weiwang marked an inline comment as done.
weiwang added a comment.

fix typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85810

Files:
  clang/include/clang/Driver/Driver.h
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/opt-record.c

Index: clang/test/Driver/opt-record.c
===
--- clang/test/Driver/opt-record.c
+++ clang/test/Driver/opt-record.c
@@ -18,7 +18,17 @@
 // RUN: %clang -### -S -o FOO -fsave-optimization-record -fsave-optimization-record=some-format %s 2>&1 | FileCheck %s -check-prefix=CHECK-EQ-FORMAT
 // RUN: %clang -### -S -o FOO -fsave-optimization-record=some-format %s 2>&1 | FileCheck %s -check-prefix=CHECK-EQ-FORMAT
 // RUN: %clang -### -S -o FOO -fsave-optimization-record=some-format -fno-save-optimization-record %s 2>&1 | FileCheck %s --check-prefix=CHECK-FOPT-DISABLE-FORMAT
-//
+
+// Test remarks options pass-through
+// No pass-through: lto is disabled
+// RUN: %clang -target x86_64-linux-gnu -### -o FOO -fdiagnostics-hotness-threshold=100 -fsave-optimization-record %s 2>&1 | not FileCheck %s -check-prefix=CHECK-PASS
+
+// Pass-through:
+// RUN: %clang -target x86_64-linux-gnu -### -o FOO -fuse-ld=lld -flto -fdiagnostics-hotness-threshold=100 -fsave-optimization-record -foptimization-record-passes=inline %s 2>&1 | FileCheck %s -check-prefix=CHECK-PASS
+// RUN: %clang -target x86_64-linux-gnu -### -o FOO -fuse-ld=gold -flto -fdiagnostics-hotness-threshold=100 -fsave-optimization-record -foptimization-record-passes=inline %s 2>&1 | FileCheck %s -check-prefix=CHECK-PASS
+// RUN: %clang -target x86_64-linux-gnu -### -o FOO -fuse-ld=lld -flto=thin -fdiagnostics-hotness-threshold=100 -fsave-optimization-record=some-format -foptimization-record-file=FOO.txt %s 2>&1 | FileCheck %s -check-prefix=CHECK-PASS-CUSTOM
+// RUN: %clang -target x86_64-linux-gnu -### -o FOO -fuse-ld=lld -flto=thin -fdiagnostics-hotness-threshold=100 -Rpass=inline -Rpass-missed=inline -Rpass-analysis=inline %s 2>&1 | FileCheck %s -check-prefix=CHECK-PASS-RPASS
+
 // CHECK: "-cc1"
 // CHECK: "-opt-record-file" "FOO.opt.yaml"
 
@@ -41,3 +51,17 @@
 // CHECK-EQ-FORMAT: "-opt-record-format" "some-format"
 
 // CHECK-FOPT-DISABLE-FORMAT-NOT: "-fno-save-optimization-record"
+
+// CHECK-PASS: "--plugin-opt=opt-remarks-filename=FOO.opt.ld.yaml"
+// CHECK-PASS: "--plugin-opt=opt-remarks-passes=inline"
+// CHECK-PASS: "--plugin-opt=opt-remarks-format=yaml"
+// CHECK-PASS: "--plugin-opt=opt-remarks-hotness-threshold=100"
+
+// CHECK-PASS-CUSTOM: "--plugin-opt=opt-remarks-filename=FOO.txt.opt.ld.some-format"
+// CHECK-PASS-CUSTOM: "--plugin-opt=opt-remarks-format=some-format"
+// CHECK-PASS-CUSTOM: "--plugin-opt=opt-remarks-hotness-threshold=100"
+
+// CHECK-PASS-RPASS: "--plugin-opt=-pass-remarks=inline"
+// CHECK-PASS-RPASS: "--plugin-opt=-pass-remarks-missed=inline"
+// CHECK-PASS-RPASS: "--plugin-opt=-pass-remarks-analysis=inline"
+// CHECK-PASS-RPASS: "--plugin-opt=opt-remarks-hotness-threshold=100"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -60,6 +60,66 @@
 using namespace clang;
 using namespace llvm::opt;
 
+static void renderRpassOptions(const ArgList , ArgStringList ) {
+  if (const Arg *A = Args.getLastArg(options::OPT_Rpass_EQ))
+CmdArgs.push_back(Args.MakeArgString(Twine("--plugin-opt=-pass-remarks=") +
+ A->getValue()));
+
+  if (const Arg *A = Args.getLastArg(options::OPT_Rpass_missed_EQ))
+CmdArgs.push_back(Args.MakeArgString(
+Twine("--plugin-opt=-pass-remarks-missed=") + A->getValue()));
+
+  if (const Arg *A = Args.getLastArg(options::OPT_Rpass_analysis_EQ))
+CmdArgs.push_back(Args.MakeArgString(
+Twine("--plugin-opt=-pass-remarks-analysis=") + A->getValue()));
+}
+
+static void renderRemarksOptions(const ArgList , ArgStringList ,
+ const llvm::Triple ,
+ const InputInfo ,
+ const InputInfo ) {
+  StringRef Format = "yaml";
+  if (const Arg *A = Args.getLastArg(options::OPT_fsave_optimization_record_EQ))
+Format = A->getValue();
+
+  SmallString<128> F;
+  const Arg *A = Args.getLastArg(options::OPT_foptimization_record_file_EQ);
+  if (A) {
+F = A->getValue();
+  } else {
+if (Output.isFilename())
+  F = Output.getFilename();
+
+// Use the input filename.
+if (F.empty())
+  F = llvm::sys::path::stem(Input.getBaseInput());
+  }
+  // Append "opt.ld." to the end of the file name.
+  CmdArgs.push_back(
+  Args.MakeArgString(Twine("--plugin-opt=opt-remarks-filename=") + F +
+ Twine(".opt.ld.") 

[PATCH] D85810: [clang] Pass-through remarks options to linker

2020-08-18 Thread Wei Wang via Phabricator via cfe-commits
weiwang marked 5 inline comments as done.
weiwang added inline comments.



Comment at: clang/include/clang/Driver/Driver.h:638
+/// This checks for clang specific R-value ('-Rpass-*') group.
+bool hasRpassOptions(const llvm::opt::ArgList );
+

bruno wrote:
> Nitpicking here, how about `usesRpassOptions`?
Thanks! Suggested name makes more sense. fixed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85810

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


[PATCH] D85810: [clang] Pass-through remarks options to linker

2020-08-18 Thread Wei Wang via Phabricator via cfe-commits
weiwang updated this revision to Diff 286467.
weiwang added a comment.

coding style change


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85810

Files:
  clang/include/clang/Driver/Driver.h
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/opt-record.c

Index: clang/test/Driver/opt-record.c
===
--- clang/test/Driver/opt-record.c
+++ clang/test/Driver/opt-record.c
@@ -18,7 +18,17 @@
 // RUN: %clang -### -S -o FOO -fsave-optimization-record -fsave-optimization-record=some-format %s 2>&1 | FileCheck %s -check-prefix=CHECK-EQ-FORMAT
 // RUN: %clang -### -S -o FOO -fsave-optimization-record=some-format %s 2>&1 | FileCheck %s -check-prefix=CHECK-EQ-FORMAT
 // RUN: %clang -### -S -o FOO -fsave-optimization-record=some-format -fno-save-optimization-record %s 2>&1 | FileCheck %s --check-prefix=CHECK-FOPT-DISABLE-FORMAT
-//
+
+// Test remarks options pass-through
+// No pass-through: lto is disabled
+// RUN: %clang -target x86_64-linux-gnu -### -o FOO -fdiagnostics-hotness-threshold=100 -fsave-optimization-record %s 2>&1 | not FileCheck %s -check-prefix=CHECK-PASS
+
+// Pass-through:
+// RUN: %clang -target x86_64-linux-gnu -### -o FOO -fuse-ld=lld -flto -fdiagnostics-hotness-threshold=100 -fsave-optimization-record -foptimization-record-passes=inline %s 2>&1 | FileCheck %s -check-prefix=CHECK-PASS
+// RUN: %clang -target x86_64-linux-gnu -### -o FOO -fuse-ld=gold -flto -fdiagnostics-hotness-threshold=100 -fsave-optimization-record -foptimization-record-passes=inline %s 2>&1 | FileCheck %s -check-prefix=CHECK-PASS
+// RUN: %clang -target x86_64-linux-gnu -### -o FOO -fuse-ld=lld -flto=thin -fdiagnostics-hotness-threshold=100 -fsave-optimization-record=some-format -foptimization-record-file=FOO.txt %s 2>&1 | FileCheck %s -check-prefix=CHECK-PASS-CUSTOM
+// RUN: %clang -target x86_64-linux-gnu -### -o FOO -fuse-ld=lld -flto=thin -fdiagnostics-hotness-threshold=100 -Rpass=inline -Rpass-missed=inline -Rpass-analysis=inline %s 2>&1 | FileCheck %s -check-prefix=CHECK-PASS-RPASS
+
 // CHECK: "-cc1"
 // CHECK: "-opt-record-file" "FOO.opt.yaml"
 
@@ -41,3 +51,17 @@
 // CHECK-EQ-FORMAT: "-opt-record-format" "some-format"
 
 // CHECK-FOPT-DISABLE-FORMAT-NOT: "-fno-save-optimization-record"
+
+// CHECK-PASS: "--plugin-opt=opt-remarks-filename=FOO.opt.ld.yaml"
+// CHECK-PASS: "--plugin-opt=opt-remarks-passes=inline"
+// CHECK-PASS: "--plugin-opt=opt-remarks-format=yaml"
+// CHECK-PASS: "--plugin-opt=opt-remarks-hotness-threshold=100"
+
+// CHECK-PASS-CUSTOM: "--plugin-opt=opt-remarks-filename=FOO.txt.opt.ld.some-format"
+// CHECK-PASS-CUSTOM: "--plugin-opt=opt-remarks-format=some-format"
+// CHECK-PASS-CUSTOM: "--plugin-opt=opt-remarks-hotness-threshold=100"
+
+// CHECK-PASS-RPASS: "--plugin-opt=-pass-remarks=inline"
+// CHECK-PASS-RPASS: "--plugin-opt=-pass-remarks-missed=inline"
+// CHECK-PASS-RPASS: "--plugin-opt=-pass-remarks-analysis=inline"
+// CHECK-PASS-RPASS: "--plugin-opt=opt-remarks-hotness-threshold=100"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -60,6 +60,66 @@
 using namespace clang;
 using namespace llvm::opt;
 
+static void renderRpassOptions(const ArgList , ArgStringList ) {
+  if (const Arg *A = Args.getLastArg(options::OPT_Rpass_EQ))
+CmdArgs.push_back(Args.MakeArgString(Twine("--plugin-opt=-pass-remarks=") +
+ A->getValue()));
+
+  if (const Arg *A = Args.getLastArg(options::OPT_Rpass_missed_EQ))
+CmdArgs.push_back(Args.MakeArgString(
+Twine("--plugin-opt=-pass-remarks-missed=") + A->getValue()));
+
+  if (const Arg *A = Args.getLastArg(options::OPT_Rpass_analysis_EQ))
+CmdArgs.push_back(Args.MakeArgString(
+Twine("--plugin-opt=-pass-remarks-analysis=") + A->getValue()));
+}
+
+static void renderRemarksOptions(const ArgList , ArgStringList ,
+ const llvm::Triple ,
+ const InputInfo ,
+ const InputInfo ) {
+  StringRef Format = "yaml";
+  if (const Arg *A = Args.getLastArg(options::OPT_fsave_optimization_record_EQ))
+Format = A->getValue();
+
+  SmallString<128> F;
+  const Arg *A = Args.getLastArg(options::OPT_foptimization_record_file_EQ);
+  if (A) {
+F = A->getValue();
+  } else {
+if (Output.isFilename())
+  F = Output.getFilename();
+
+// Use the input filename.
+if (F.empty())
+  F = llvm::sys::path::stem(Input.getBaseInput());
+  }
+  // Append "opt.ld." to the end of the file name.
+  CmdArgs.push_back(
+  Args.MakeArgString(Twine("--plugin-opt=opt-remarks-filename=") + F +
+ Twine(".opt.ld.") + Format));
+
+  if (const Arg 

[PATCH] D85981: [clang][Modules] Use File Names Instead of inodes As Loaded Module Keys

2020-08-18 Thread Robert Widmann via Phabricator via cfe-commits
CodaFi added a comment.

@aprantl Good idea. Updated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85981

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


[PATCH] D85981: [clang][Modules] Use File Names Instead of inodes As Loaded Module Keys

2020-08-18 Thread Robert Widmann via Phabricator via cfe-commits
CodaFi updated this revision to Diff 286460.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85981

Files:
  clang/include/clang/Serialization/ModuleManager.h
  clang/lib/Serialization/ModuleManager.cpp

Index: clang/lib/Serialization/ModuleManager.cpp
===
--- clang/lib/Serialization/ModuleManager.cpp
+++ clang/lib/Serialization/ModuleManager.cpp
@@ -59,7 +59,7 @@
 }
 
 ModuleFile *ModuleManager::lookup(const FileEntry *File) const {
-  auto Known = Modules.find(File);
+  auto Known = Modules.find(EntryKey{File});
   if (Known == Modules.end())
 return nullptr;
 
@@ -72,7 +72,7 @@
/*CacheFailure=*/false);
   if (!Entry)
 return nullptr;
-  return std::move(InMemoryBuffers[*Entry]);
+  return std::move(InMemoryBuffers[EntryKey{*Entry}]);
 }
 
 static bool checkSignature(ASTFileSignature Signature,
@@ -133,7 +133,7 @@
   }
 
   // Check whether we already loaded this module, before
-  if (ModuleFile *ModuleEntry = Modules.lookup(Entry)) {
+  if (ModuleFile *ModuleEntry = Modules.lookup(EntryKey{Entry})) {
 // Check the stored signature.
 if (checkSignature(ModuleEntry->Signature, ExpectedSignature, ErrorStr))
   return OutOfDate;
@@ -208,7 +208,7 @@
 return OutOfDate;
 
   // We're keeping this module.  Store it everywhere.
-  Module = Modules[Entry] = NewModule.get();
+  Module = Modules[EntryKey{Entry}] = NewModule.get();
 
   updateModuleImports(*NewModule, ImportedBy, ImportLoc);
 
@@ -255,7 +255,7 @@
 
   // Delete the modules and erase them from the various structures.
   for (ModuleIterator victim = First; victim != Last; ++victim) {
-Modules.erase(victim->File);
+Modules.erase(EntryKey{victim->File});
 
 if (modMap) {
   StringRef ModuleName = victim->ModuleName;
@@ -274,7 +274,7 @@
  std::unique_ptr Buffer) {
   const FileEntry *Entry =
   FileMgr.getVirtualFile(FileName, Buffer->getBufferSize(), 0);
-  InMemoryBuffers[Entry] = std::move(Buffer);
+  InMemoryBuffers[EntryKey{Entry}] = std::move(Buffer);
 }
 
 ModuleManager::VisitState *ModuleManager::allocateVisitState() {
Index: clang/include/clang/Serialization/ModuleManager.h
===
--- clang/include/clang/Serialization/ModuleManager.h
+++ clang/include/clang/Serialization/ModuleManager.h
@@ -59,8 +59,50 @@
   // to implement short-circuiting logic when running DFS over the dependencies.
   SmallVector Roots;
 
+  /// An \c EntryKey is a thin wrapper around a \c FileEntry that implements
+  /// a richer notion of identity.
+  ///
+  /// A plain \c FileEntry has its identity tied to inode numbers. When the
+  /// module cache regenerates a PCM, some filesystem allocators may reuse
+  /// inode numbers for distinct modules, which can cause the cache to return
+  /// mismatched entries. An \c EntryKey ensures that the size and modification
+  /// time are taken into account when determining the identity of a key, which
+  /// significantly decreases - but does not eliminate - the chance of
+  /// a collision.
+  struct EntryKey {
+const FileEntry *Entry;
+
+struct Info {
+  static inline EntryKey getEmptyKey() {
+return EntryKey{llvm::DenseMapInfo::getEmptyKey()};
+  }
+  static inline EntryKey getTombstoneKey() {
+return EntryKey{
+llvm::DenseMapInfo::getTombstoneKey()};
+  }
+  static unsigned getHashValue(const EntryKey ) {
+return llvm::DenseMapInfo::getHashValue(Val.Entry);
+  }
+  static bool isEqual(const EntryKey , const EntryKey ) {
+if (LHS.Entry == getEmptyKey().Entry ||
+LHS.Entry == getTombstoneKey().Entry ||
+RHS.Entry == getEmptyKey().Entry ||
+RHS.Entry == getTombstoneKey().Entry) {
+  return LHS.Entry == RHS.Entry;
+}
+if (LHS.Entry == nullptr || RHS.Entry == nullptr) {
+  return LHS.Entry == RHS.Entry;
+}
+return LHS.Entry == RHS.Entry &&
+   LHS.Entry->getSize() == RHS.Entry->getSize() &&
+   LHS.Entry->getModificationTime() ==
+   RHS.Entry->getModificationTime();
+  }
+};
+  };
+
   /// All loaded modules, indexed by name.
-  llvm::DenseMap Modules;
+  llvm::DenseMap Modules;
 
   /// FileManager that handles translating between filenames and
   /// FileEntry *.
@@ -76,7 +118,7 @@
   const HeaderSearch 
 
   /// A lookup of in-memory (virtual file) buffers
-  llvm::DenseMap>
+  llvm::DenseMap, EntryKey::Info>
   InMemoryBuffers;
 
   /// The visitation order.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84886: Create LoopNestPass

2020-08-18 Thread Ta-Wei Tu via Phabricator via cfe-commits
TaWeiTu added a comment.

Hi @Whitney, @fhahn, @ychen, thank you all for your comments and suggestions! 
Sorry about the late reply.
I was trying to convert the `LoopInterchange` pass into a loop-nest pass. 
However, there seems to be no corresponding loop pass for the NPM.
Any particular reason for this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84886

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


[PATCH] D83154: clang: Add -fcoverage-prefix-map

2020-08-18 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.

Yes I do, sorry I've been a bit busy, I will try to get to this later this week


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83154

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


[PATCH] D83154: clang: Add -fcoverage-prefix-map

2020-08-18 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

@keith do you plan on finishing this? I think we should change the name from 
`-fcoverage-prefix-map` to `-fprofile-prefix-map`, but otherwise it might be 
good to go.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83154

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


[PATCH] D86187: [X86] Add support 'tune' in target attribute

2020-08-18 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: echristo, erichkeane, spatel, RKSimon.
Herald added a reviewer: aaron.ballman.
craig.topper requested review of this revision.

This adds parsing and codegen support for tune in target attribute.

I've implemented this so that arch in the target attribute implicitly disables 
tune from the command line. I'm not sure what gcc does here. But since -march 
implies -mtune. I assume 'arch' in the target attribute implies tune in the 
target attribute.


https://reviews.llvm.org/D86187

Files:
  clang/include/clang/AST/Attr.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/attr-target-x86.c
  clang/test/Sema/attr-target.c

Index: clang/test/Sema/attr-target.c
===
--- clang/test/Sema/attr-target.c
+++ clang/test/Sema/attr-target.c
@@ -1,9 +1,12 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-linux-gnu  -fsyntax-only -verify %s
+
+#ifdef __x86_64__
 
 int __attribute__((target("avx,sse4.2,arch=ivybridge"))) foo() { return 4; }
 //expected-error@+1 {{'target' attribute takes one argument}}
 int __attribute__((target())) bar() { return 4; }
-//expected-warning@+1 {{unsupported 'tune=' in the 'target' attribute string; 'target' attribute ignored}}
+// no warning, tune is supported for x86
 int __attribute__((target("tune=sandybridge"))) baz() { return 4; }
 //expected-warning@+1 {{unsupported 'fpmath=' in the 'target' attribute string; 'target' attribute ignored}}
 int __attribute__((target("fpmath=387"))) walrus() { return 4; }
@@ -19,4 +22,13 @@
 int __attribute__((target("arch=ivybridge,arch=haswell"))) oak_tree() { return 4; }
 //expected-warning@+1 {{unsupported 'branch-protection' in the 'target' attribute string; 'target' attribute ignored}}
 int __attribute__((target("branch-protection=none"))) birch_tree() { return 5; }
+//expected-warning@+1 {{unsupported tune 'hiss' in the 'target' attribute string; 'target' attribute ignored}}
+int __attribute__((target("tune=hiss,tune=woof"))) apple_tree() { return 4; }
+
+#else
+
+// tune is not supported by other targets.
+//expected-warning@+1 {{unsupported 'tune=' in the 'target' attribute string; 'target' attribute ignored}}
+int __attribute__((target("tune=hiss"))) baz() { return 4; }
 
+#endif
Index: clang/test/CodeGen/attr-target-x86.c
===
--- clang/test/CodeGen/attr-target-x86.c
+++ clang/test/CodeGen/attr-target-x86.c
@@ -1,10 +1,9 @@
-// RUN: %clang_cc1 -triple i686-linux-gnu -target-cpu i686 -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple i686-linux-gnu -target-cpu i686 -tune-cpu i686 -emit-llvm %s -o - | FileCheck %s
 
 int baz(int a) { return 4; }
 
 int __attribute__((target("avx,sse4.2,arch=ivybridge"))) foo(int a) { return 4; }
 
-int __attribute__((target("tune=sandybridge"))) walrus(int a) { return 4; }
 int __attribute__((target("fpmath=387"))) koala(int a) { return 4; }
 
 int __attribute__((target("no-sse2"))) echidna(int a) { return 4; }
@@ -31,12 +30,11 @@
   return 5;
 }
 
+int __attribute__((target("tune=sandybridge"))) walrus(int a) { return 4; }
 
 // Check that we emit the additional subtarget and cpu features for foo and not for baz or bar.
 // CHECK: baz{{.*}} #0
 // CHECK: foo{{.*}} #1
-// We ignore the tune attribute so walrus should be identical to baz and bar.
-// CHECK: walrus{{.*}} #0
 // We're currently ignoring the fpmath attribute so koala should be identical to baz and bar.
 // CHECK: koala{{.*}} #0
 // CHECK: echidna{{.*}} #2
@@ -48,11 +46,16 @@
 // CHECK: qq{{.*}} #6
 // CHECK: lake{{.*}} #7
 // CHECK: use_before_def{{.*}} #7
-// CHECK: #0 = {{.*}}"target-cpu"="i686" "target-features"="+cx8,+x87"
+// CHECK: walrus{{.*}} #8
+// CHECK: #0 = {{.*}}"target-cpu"="i686" "target-features"="+cx8,+x87" "tune-cpu"="i686"
 // CHECK: #1 = {{.*}}"target-cpu"="ivybridge" "target-features"="+avx,+cx16,+cx8,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sahf,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt"
-// CHECK: #2 = {{.*}}"target-cpu"="i686" "target-features"="+cx8,+x87,-aes,-avx,-avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,-f16c,-fma,-fma4,-gfni,-pclmul,-sha,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-vaes,-vpclmulqdq,-xop"
-// CHECK: #3 = {{.*}}"target-cpu"="i686" "target-features"="+cx8,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87"
-// CHECK: #4 = {{.*}}"target-cpu"="i686" 

[PATCH] D86049: RFC: Implement optional exportable wrapper function generation for objc_direct methods.

2020-08-18 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I think that, if we want to do this, we need to think carefully about what 
exactly we want the ABI to be.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86049

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


[clang] d9ff48d - WCharType and WIntType are always signed int on OpenBSD.

2020-08-18 Thread Brad Smith via cfe-commits

Author: Brad Smith
Date: 2020-08-18T19:59:54-04:00
New Revision: d9ff48d03817f83d4059b610a776c797308de2e5

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

LOG: WCharType and WIntType are always signed int on OpenBSD.

Added: 


Modified: 
clang/lib/Basic/Targets/OSTargets.h

Removed: 




diff  --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index f89eb0add553..a2c0fd42f26d 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -465,6 +465,7 @@ class LLVM_LIBRARY_VISIBILITY OpenBSDTargetInfo : public 
OSTargetInfo {
 public:
   OpenBSDTargetInfo(const llvm::Triple , const TargetOptions )
   : OSTargetInfo(Triple, Opts) {
+this->WCharType = this->WIntType = this->SignedInt;
 this->IntMaxType = TargetInfo::SignedLongLong;
 this->Int64Type = TargetInfo::SignedLongLong;
 switch (Triple.getArch()) {



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


[PATCH] D85990: [Clang] Fix BZ47169, loader_uninitialized on incomplete types

2020-08-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Were you able to make any progress on this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85990

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


[clang] 592b899 - Hook up OpenBSD 64-bit RISC-V support

2020-08-18 Thread Brad Smith via cfe-commits

Author: Brad Smith
Date: 2020-08-18T18:59:55-04:00
New Revision: 592b8996bf9b55eec21e1c9e563f51b6108ec2d2

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

LOG: Hook up OpenBSD 64-bit RISC-V support

Added: 


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

Removed: 




diff  --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index c90becd9f012..50a3b0e83a56 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -391,6 +391,8 @@ TargetInfo *AllocateTarget(const llvm::Triple ,
 switch (os) {
 case llvm::Triple::FreeBSD:
   return new FreeBSDTargetInfo(Triple, Opts);
+case llvm::Triple::OpenBSD:
+  return new OpenBSDTargetInfo(Triple, Opts);
 case llvm::Triple::Fuchsia:
   return new FuchsiaTargetInfo(Triple, Opts);
 case llvm::Triple::Linux:

diff  --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c
index 65928b08be8e..63a96f20de88 100644
--- a/clang/test/Preprocessor/init.c
+++ b/clang/test/Preprocessor/init.c
@@ -1607,6 +1607,7 @@
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=mips64-unknown-openbsd6.1 < 
/dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=mips64el-unknown-openbsd6.1 < 
/dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc64-unknown-openbsd6.1 < 
/dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=riscv64-unknown-openbsd6.1 < 
/dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
 // OPENBSD:#define __ELF__ 1
 // OPENBSD:#define __INT16_TYPE__ short
 // OPENBSD:#define __INT32_TYPE__ int



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


[PATCH] D86176: [clang-tidy] readability-simplify-boolean-expr detects negated literals

2020-08-18 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: aaron.ballman, gribozavr2, alexfh.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.
njames93 requested review of this revision.

Adds support for detecting cases like `if (!true) ...`.
Addresses readability-simplify-boolean-expr not detected for negated boolean 
literals. 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86176

Files:
  clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
  clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.h
  clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr.cpp
@@ -98,6 +98,46 @@
   // CHECK-FIXES-NEXT: {{^  i = 11;$}}
 }
 
+void if_with_negated_bool_condition() {
+  int i = 10;
+  if (!true) {
+i = 11;
+  } else {
+i = 12;
+  }
+  i = 13;
+  // CHECK-MESSAGES: :[[@LINE-6]]:7: warning: {{.*}} in if statement condition
+  // CHECK-FIXES:  {{^  int i = 10;$}}
+  // CHECK-FIXES-NEXT: {{^  {$}}
+  // CHECK-FIXES-NEXT: {{^i = 12;$}}
+  // CHECK-FIXES-NEXT: {{^  }$}}
+  // CHECK-FIXES-NEXT: {{^  i = 13;$}}
+
+  i = 14;
+  if (!false) {
+i = 15;
+  } else {
+i = 16;
+  }
+  i = 17;
+  // CHECK-MESSAGES: :[[@LINE-6]]:7: warning: {{.*}} in if statement condition
+  // CHECK-FIXES:  {{^  i = 14;$}}
+  // CHECK-FIXES-NEXT: {{^  {$}}
+  // CHECK-FIXES-NEXT: {{^i = 15;$}}
+  // CHECK-FIXES-NEXT: {{^  }$}}
+  // CHECK-FIXES-NEXT: {{^  i = 17;$}}
+
+  i = 18;
+  if (!true) {
+i = 19;
+  }
+  i = 20;
+  // CHECK-MESSAGES: :[[@LINE-4]]:7: warning: {{.*}} in if statement condition
+  // CHECK-FIXES:  {{^  i = 18;$}}
+  // CHECK-FIXES-NEXT: {{^  $}}
+  // CHECK-FIXES-NEXT: {{^  i = 20;$}}
+}
+
 void operator_equals() {
   int i = 0;
   bool b1 = (i > 2);
Index: clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.h
===
--- clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.h
+++ clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.h
@@ -51,11 +51,11 @@
 
   void
   replaceWithThenStatement(const ast_matchers::MatchFinder::MatchResult ,
-   const CXXBoolLiteralExpr *BoolLiteral);
+   const Expr *BoolLiteral);
 
   void
   replaceWithElseStatement(const ast_matchers::MatchFinder::MatchResult ,
-   const CXXBoolLiteralExpr *FalseConditionRemoved);
+   const Expr *FalseConditionRemoved);
 
   void
   replaceWithCondition(const ast_matchers::MatchFinder::MatchResult ,
Index: clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
@@ -58,16 +58,28 @@
 const char SimplifyConditionalReturnDiagnostic[] =
 "redundant boolean literal in conditional return statement";
 
-const CXXBoolLiteralExpr *getBoolLiteral(const MatchFinder::MatchResult ,
- StringRef Id) {
-  const auto *Literal = Result.Nodes.getNodeAs(Id);
-  return (Literal && Literal->getBeginLoc().isMacroID()) ? nullptr : Literal;
+const Expr *getBoolLiteral(const MatchFinder::MatchResult ,
+   StringRef Id) {
+  if (const Expr *Literal = Result.Nodes.getNodeAs(Id))
+return Literal->getBeginLoc().isMacroID() ? nullptr : Literal;
+  if (const auto *Negated = Result.Nodes.getNodeAs(Id)) {
+if (Negated->getOpcode() == UO_LNot &&
+isa(Negated->getSubExpr()))
+  return Negated->getBeginLoc().isMacroID() ? nullptr : Negated;
+  }
+  return nullptr;
+}
+
+internal::BindableMatcher literalOrNegatedBool(bool Value) {
+  return expr(anyOf(cxxBoolLiteral(equals(Value)),
+unaryOperator(hasUnaryOperand(ignoringParenImpCasts(
+  cxxBoolLiteral(equals(!Value,
+  hasOperatorName("!";
 }
 
 internal::Matcher returnsBool(bool Value, StringRef Id = "ignored") {
-  auto SimpleReturnsBool =
-  returnStmt(has(cxxBoolLiteral(equals(Value)).bind(Id)))
-  .bind("returns-bool");
+  auto SimpleReturnsBool = returnStmt(has(literalOrNegatedBool(Value).bind(Id)))
+   .bind("returns-bool");
   return anyOf(SimpleReturnsBool,
compoundStmt(statementCountIs(1), has(SimpleReturnsBool)));
 }
@@ -269,16 +281,25 @@
   return asBool(getText(Result, *E), 

[PATCH] D85384: [X86] Add basic support for -mtune command line option in clang

2020-08-18 Thread Craig Topper via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4cbceb74bb56: [X86] Add basic support for -mtune command 
line option in clang (authored by craig.topper).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D85384?vs=283456=286409#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85384

Files:
  clang/include/clang/Basic/TargetOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Misc/target-invalid-cpu-note.c

Index: clang/test/Misc/target-invalid-cpu-note.c
===
--- clang/test/Misc/target-invalid-cpu-note.c
+++ clang/test/Misc/target-invalid-cpu-note.c
@@ -8,6 +8,11 @@
 // AARCH64: note: valid target CPU values are:
 // AARCH64-SAME: cortex-a35,
 
+// RUN: not %clang_cc1 -triple arm64--- -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE_AARCH64
+// TUNE_AARCH64: error: unknown target CPU 'not-a-cpu'
+// TUNE_AARCH64: note: valid target CPU values are:
+// TUNE_AARCH64-SAME: cortex-a35,
+
 // RUN: not %clang_cc1 -triple i386--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix X86
 // X86: error: unknown target CPU 'not-a-cpu'
 // X86: note: valid target CPU values are: i386, i486, winchip-c6, winchip2, c3,
@@ -32,6 +37,30 @@
 // X86_64-SAME: athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1,
 // X86_64-SAME: btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, x86-64
 
+// RUN: not %clang_cc1 -triple i386--- -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE_X86
+// TUNE_X86: error: unknown target CPU 'not-a-cpu'
+// TUNE_X86: note: valid target CPU values are: i386, i486, winchip-c6, winchip2, c3,
+// TUNE_X86-SAME: i586, pentium, pentium-mmx, pentiumpro, i686, pentium2, pentium3,
+// TUNE_X86-SAME: pentium3m, pentium-m, c3-2, yonah, pentium4, pentium4m, prescott,
+// TUNE_X86-SAME: nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont,
+// TUNE_X86-SAME: nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge,
+// TUNE_X86-SAME: core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512,
+// TUNE_X86-SAME: skx, cascadelake, cooperlake, cannonlake, icelake-client, icelake-server, tigerlake, knl, knm, lakemont, k6, k6-2, k6-3,
+// TUNE_X86-SAME: athlon, athlon-tbird, athlon-xp, athlon-mp, athlon-4, k8, athlon64,
+// TUNE_X86-SAME: athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10,
+// TUNE_X86-SAME: barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2,
+// TUNE_X86-SAME: x86-64, geode
+
+// RUN: not %clang_cc1 -triple x86_64--- -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE_X86_64
+// TUNE_X86_64: error: unknown target CPU 'not-a-cpu'
+// TUNE_X86_64: note: valid target CPU values are: nocona, core2, penryn, bonnell,
+// TUNE_X86_64-SAME: atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere,
+// TUNE_X86_64-SAME: sandybridge, corei7-avx, ivybridge, core-avx-i, haswell,
+// TUNE_X86_64-SAME: core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake,
+// TUNE_X86_64-SAME: icelake-client, icelake-server, tigerlake, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3,
+// TUNE_X86_64-SAME: athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1,
+// TUNE_X86_64-SAME: btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, x86-64
+
 // RUN: not %clang_cc1 -triple nvptx--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix NVPTX
 // NVPTX: error: unknown target CPU 'not-a-cpu'
 // NVPTX: note: valid target CPU values are: sm_20, sm_21, sm_30, sm_32, sm_35,
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3658,6 +3658,7 @@
   Opts.EABIVersion = EABIVersion;
   }
   Opts.CPU = std::string(Args.getLastArgValue(OPT_target_cpu));
+  Opts.TuneCPU = std::string(Args.getLastArgValue(OPT_tune_cpu));
   Opts.FPMath = std::string(Args.getLastArgValue(OPT_mfpmath));
   Opts.FeaturesAsWritten = Args.getAllArgValues(OPT_target_feature);
   Opts.LinkerVersion =
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -39,6 +39,7 @@
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/Compression.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Host.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
 #include 

[clang] 4cbceb7 - [X86] Add basic support for -mtune command line option in clang

2020-08-18 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2020-08-18T15:13:19-07:00
New Revision: 4cbceb74bb5676d0181d4d0cab5194d90a42c2ec

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

LOG: [X86] Add basic support for -mtune command line option in clang

Building on the backend support from D85165. This parses the command line 
option in the driver, passes it on to CC1 and adds a function attribute.

-Still need to support tune on the target attribute.
-Need to use "generic" as the tuning by default. But need to change generic in 
the backend first.
-Need to set tune if march is specified and mtune isn't.
-May need to disable getHostCPUName's ability to guess CPU name from features 
when it doesn't have a family/model match for mtune=native. That's what gcc 
appears to do.

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

Added: 


Modified: 
clang/include/clang/Basic/TargetOptions.h
clang/include/clang/Driver/Options.td
clang/lib/Basic/Targets.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/Misc/target-invalid-cpu-note.c

Removed: 




diff  --git a/clang/include/clang/Basic/TargetOptions.h 
b/clang/include/clang/Basic/TargetOptions.h
index 4a5d469b8e54..d1cc024957da 100644
--- a/clang/include/clang/Basic/TargetOptions.h
+++ b/clang/include/clang/Basic/TargetOptions.h
@@ -35,6 +35,9 @@ class TargetOptions {
   /// If given, the name of the target CPU to generate code for.
   std::string CPU;
 
+  /// If given, the name of the target CPU to tune code for.
+  std::string TuneCPU;
+
   /// If given, the unit to use for floating point math.
   std::string FPMath;
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 9d36dc6cc393..6827c877acf8 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2715,7 +2715,7 @@ def module_file_info : Flag<["-"], "module-file-info">, 
Flags<[DriverOption,CC1O
   HelpText<"Provide information about a particular module file">;
 def mthumb : Flag<["-"], "mthumb">, Group;
 def mtune_EQ : Joined<["-"], "mtune=">, Group,
-  HelpText<"Accepted for compatibility with GCC. Currently has no effect.">;
+  HelpText<"Only supported on X86. Otherwise accepted for compatibility with 
GCC.">;
 def multi__module : Flag<["-"], "multi_module">;
 def multiply__defined__unused : Separate<["-"], "multiply_defined_unused">;
 def multiply__defined : Separate<["-"], "multiply_defined">;
@@ -3490,6 +3490,8 @@ let Flags = [CC1Option, CC1AsOption, NoDriverOption] in {
 
 def target_cpu : Separate<["-"], "target-cpu">,
   HelpText<"Target a specific cpu type">;
+def tune_cpu : Separate<["-"], "tune-cpu">,
+  HelpText<"Tune for a specific cpu type">;
 def target_feature : Separate<["-"], "target-feature">,
   HelpText<"Target specific attributes">;
 def triple : Separate<["-"], "triple">,

diff  --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index e4456ea7fa0f..c90becd9f012 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -652,6 +652,16 @@ TargetInfo::CreateTargetInfo(DiagnosticsEngine ,
 return nullptr;
   }
 
+  // Check the TuneCPU name if specified.
+  if (!Opts->TuneCPU.empty() && !Target->isValidCPUName(Opts->TuneCPU)) {
+Diags.Report(diag::err_target_unknown_cpu) << Opts->TuneCPU;
+SmallVector ValidList;
+Target->fillValidCPUList(ValidList);
+if (!ValidList.empty())
+  Diags.Report(diag::note_valid_options) << llvm::join(ValidList, ", ");
+return nullptr;
+  }
+
   // Set the target ABI if specified.
   if (!Opts->ABI.empty() && !Target->setABI(Opts->ABI)) {
 Diags.Report(diag::err_target_unknown_abi) << Opts->ABI;

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index ff35d94626d1..23d35f68e141 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1749,6 +1749,7 @@ bool 
CodeGenModule::GetCPUAndFeaturesAttributes(GlobalDecl GD,
   // we have a decl for the function and it has a target attribute then
   // parse that and add it to the feature set.
   StringRef TargetCPU = getTarget().getTargetOpts().CPU;
+  StringRef TuneCPU = getTarget().getTargetOpts().TuneCPU;
   std::vector Features;
   const auto *FD = dyn_cast_or_null(GD.getDecl());
   FD = FD ? FD->getMostRecentDecl() : FD;
@@ -1783,6 +1784,10 @@ bool 
CodeGenModule::GetCPUAndFeaturesAttributes(GlobalDecl GD,
 Attrs.addAttribute("target-cpu", TargetCPU);
 AddedAttr = true;
   }
+  if (TuneCPU != "") {
+Attrs.addAttribute("tune-cpu", TuneCPU);
+AddedAttr = true;
+  }
   if (!Features.empty()) {
 llvm::sort(Features);
 

[clang] b34b1e3 - [Analysis] Bug fix for exploded graph branching in evalCall for constructor

2020-08-18 Thread Nithin Vadukkumchery Rajendrakumar via cfe-commits

Author: Nithin Vadukkumchery Rajendrakumar
Date: 2020-08-19T00:03:31+02:00
New Revision: b34b1e38381fa4d1b1d9751a6b5233b68e734cfe

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

LOG: [Analysis] Bug fix for exploded graph branching in evalCall for constructor

Summary:
Make exactly single NodeBuilder exists at any given time

Reviewers: NoQ, Szelethus, vsavchenko, xazax.hun

Reviewed By: NoQ

Subscribers: martong, cfe-commits
Tags: #clang

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
clang/test/Analysis/smart-ptr-text-output.cpp
clang/test/Analysis/smart-ptr.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp 
b/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
index 38a680eb04c00..802bc934cfb06 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -602,11 +602,11 @@ void ExprEngine::handleConstructor(const Expr *E,
 *Call, *this);
 
   ExplodedNodeSet DstEvaluated;
-  StmtNodeBuilder Bldr(DstPreCall, DstEvaluated, *currBldrCtx);
 
   if (CE && CE->getConstructor()->isTrivial() &&
   CE->getConstructor()->isCopyOrMoveConstructor() &&
   !CallOpts.IsArrayCtorOrDtor) {
+StmtNodeBuilder Bldr(DstPreCall, DstEvaluated, *currBldrCtx);
 // FIXME: Handle other kinds of trivial constructors as well.
 for (ExplodedNodeSet::iterator I = DstPreCall.begin(), E = 
DstPreCall.end();
  I != E; ++I)
@@ -626,6 +626,8 @@ void ExprEngine::handleConstructor(const Expr *E,
   // in the CFG, would be called at the end of the full expression or
   // later (for life-time extended temporaries) -- but avoids infeasible
   // paths when no-return temporary destructors are used for assertions.
+  ExplodedNodeSet DstEvaluatedPostProcessed;
+  StmtNodeBuilder Bldr(DstEvaluated, DstEvaluatedPostProcessed, *currBldrCtx);
   const AnalysisDeclContext *ADC = LCtx->getAnalysisDeclContext();
   if (!ADC->getCFGBuildOptions().AddTemporaryDtors) {
 if (llvm::isa_and_nonnull(TargetRegion) &&
@@ -655,7 +657,7 @@ void ExprEngine::handleConstructor(const Expr *E,
   }
 
   ExplodedNodeSet DstPostArgumentCleanup;
-  for (ExplodedNode *I : DstEvaluated)
+  for (ExplodedNode *I : DstEvaluatedPostProcessed)
 finishArgumentConstruction(DstPostArgumentCleanup, I, *Call);
 
   // If there were other constructors called for object-type arguments

diff  --git a/clang/test/Analysis/smart-ptr-text-output.cpp 
b/clang/test/Analysis/smart-ptr-text-output.cpp
index 5280d0021884d..1132a37fa6679 100644
--- a/clang/test/Analysis/smart-ptr-text-output.cpp
+++ b/clang/test/Analysis/smart-ptr-text-output.cpp
@@ -36,14 +36,15 @@ void derefAfterCtrWithNullVariable() {
 }
 
 void derefAfterRelease() {
-  std::unique_ptr P(new A());
+  std::unique_ptr P(new A()); // expected-note {{Smart pointer 'P' is 
constructed}}
+  // FIXME: should mark region as uninteresting after release, so above note 
will not be there
   P.release(); // expected-note {{Smart pointer 'P' is released and set to 
null}}
   P->foo(); // expected-warning {{Dereference of null smart pointer 'P' 
[alpha.cplusplus.SmartPtr]}}
   // expected-note@-1{{Dereference of null smart pointer 'P'}}
 }
 
 void derefAfterReset() {
-  std::unique_ptr P(new A());
+  std::unique_ptr P(new A()); // expected-note {{Smart pointer 'P' is 
constructed}}
   P.reset(); // expected-note {{Smart pointer 'P' reset using a null value}}
   P->foo(); // expected-warning {{Dereference of null smart pointer 'P' 
[alpha.cplusplus.SmartPtr]}}
   // expected-note@-1{{Dereference of null smart pointer 'P'}}
@@ -51,7 +52,7 @@ void derefAfterReset() {
 
 void derefAfterResetWithNull() {
   A *NullInnerPtr = nullptr; // expected-note {{'NullInnerPtr' initialized to 
a null pointer value}}
-  std::unique_ptr P(new A());
+  std::unique_ptr P(new A()); // expected-note {{Smart pointer 'P' is 
constructed}}
   P.reset(NullInnerPtr); // expected-note {{Smart pointer 'P' reset using a 
null value}}
   P->foo(); // expected-warning {{Dereference of null smart pointer 'P' 
[alpha.cplusplus.SmartPtr]}}
   // expected-note@-1{{Dereference of null smart pointer 'P'}}
@@ -67,7 +68,7 @@ void derefOnReleasedNullRawPtr() {
 }
 
 void derefOnSwappedNullPtr() {
-  std::unique_ptr P(new A());
+  std::unique_ptr P(new A()); // expected-note {{Smart pointer 'P' is 
constructed}}
   std::unique_ptr PNull; // expected-note {{Default constructed smart 
pointer 'PNull' is null}}
   P.swap(PNull); // expected-note {{Swapped null smart pointer 'PNull' with 
smart pointer 'P'}}
   PNull->foo(); // No warning.
@@ -77,13 +78,11 @@ void derefOnSwappedNullPtr() {
 
 // FIXME: Fix 

[PATCH] D85796: [Analysis] Bug fix for exploded graph branching in evalCall for constructor

2020-08-18 Thread Nithin VR 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 rGb34b1e38381f: [Analysis] Bug fix for exploded graph 
branching in evalCall for constructor (authored by vrnithinkumar).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85796

Files:
  clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  clang/test/Analysis/smart-ptr-text-output.cpp
  clang/test/Analysis/smart-ptr.cpp

Index: clang/test/Analysis/smart-ptr.cpp
===
--- clang/test/Analysis/smart-ptr.cpp
+++ clang/test/Analysis/smart-ptr.cpp
@@ -41,6 +41,7 @@
 
 void derefAfterValidCtr() {
   std::unique_ptr P(new A());
+  clang_analyzer_numTimesReached(); // expected-warning {{1}}
   P->foo(); // No warning.
 }
 
@@ -50,17 +51,20 @@
 
 void derefAfterDefaultCtr() {
   std::unique_ptr P;
+  clang_analyzer_numTimesReached(); // expected-warning {{1}}
   P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
 }
 
 void derefAfterCtrWithNull() {
   std::unique_ptr P(nullptr);
+  clang_analyzer_numTimesReached(); // expected-warning {{1}}
   *P; // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
 }
 
 void derefAfterCtrWithNullVariable() {
   A *InnerPtr = nullptr;
   std::unique_ptr P(InnerPtr);
+  clang_analyzer_numTimesReached(); // expected-warning {{1}}
   P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
 }
 
@@ -87,6 +91,7 @@
 void derefAfterResetWithNonNull() {
   std::unique_ptr P;
   P.reset(new A());
+  clang_analyzer_numTimesReached(); // expected-warning {{1}}
   P->foo(); // No warning.
 }
 
@@ -116,37 +121,40 @@
 void pass_smart_ptr_by_ptr(std::unique_ptr *a);
 void pass_smart_ptr_by_const_ptr(const std::unique_ptr *a);
 
-void regioninvalidationTest() {
-  {
-std::unique_ptr P;
-pass_smart_ptr_by_ref(P);
-P->foo(); // no-warning
-  }
-  {
-std::unique_ptr P;
-pass_smart_ptr_by_const_ref(P);
-P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
-  }
-  {
-std::unique_ptr P;
-pass_smart_ptr_by_rvalue_ref(std::move(P));
-P->foo(); // no-warning
-  }
-  {
-std::unique_ptr P;
-pass_smart_ptr_by_const_rvalue_ref(std::move(P));
-P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
-  }
-  {
-std::unique_ptr P;
-pass_smart_ptr_by_ptr();
-P->foo();
-  }
-  {
-std::unique_ptr P;
-pass_smart_ptr_by_const_ptr();
-P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
-  }
+void regioninvalidationWithPassByRef() {
+  std::unique_ptr P;
+  pass_smart_ptr_by_ref(P);
+  P->foo(); // no-warning
+}
+
+void regioninvalidationWithPassByCostRef() {
+  std::unique_ptr P;
+  pass_smart_ptr_by_const_ref(P);
+  P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+}
+
+void regioninvalidationWithPassByRValueRef() {
+  std::unique_ptr P;
+  pass_smart_ptr_by_rvalue_ref(std::move(P));
+  P->foo(); // no-warning
+}
+
+void regioninvalidationWithPassByConstRValueRef() {
+  std::unique_ptr P;
+  pass_smart_ptr_by_const_rvalue_ref(std::move(P));
+  P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+}
+
+void regioninvalidationWithPassByPtr() {
+  std::unique_ptr P;
+  pass_smart_ptr_by_ptr();
+  P->foo();
+}
+
+void regioninvalidationWithPassByConstPtr() {
+  std::unique_ptr P;
+  pass_smart_ptr_by_const_ptr();
+  P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
 }
 
 struct StructWithSmartPtr {
@@ -160,37 +168,40 @@
 void pass_struct_with_smart_ptr_by_ptr(StructWithSmartPtr *a);
 void pass_struct_with_smart_ptr_by_const_ptr(const StructWithSmartPtr *a);
 
-void regioninvalidationTestWithinStruct() {
-  {
-StructWithSmartPtr S;
-pass_struct_with_smart_ptr_by_ref(S);
-S.P->foo(); // no-warning
-  }
-  {
-StructWithSmartPtr S;
-pass_struct_with_smart_ptr_by_const_ref(S);
-S.P->foo(); // expected-warning {{Dereference of null smart pointer 'S.P' [alpha.cplusplus.SmartPtr]}}
-  }
-  {
-StructWithSmartPtr S;
-pass_struct_with_smart_ptr_by_rvalue_ref(std::move(S));
-S.P->foo(); // no-warning
-  }
-  {
-StructWithSmartPtr S;
-pass_struct_with_smart_ptr_by_const_rvalue_ref(std::move(S));
-S.P->foo(); // expected-warning {{Dereference of null smart pointer 'S.P' [alpha.cplusplus.SmartPtr]}}
-  }
-  {
-StructWithSmartPtr S;
-pass_struct_with_smart_ptr_by_ptr();
-S.P->foo();
-  }
-  {
-StructWithSmartPtr S;
-pass_struct_with_smart_ptr_by_const_ptr();
-S.P->foo(); // expected-warning {{Dereference of null 

[PATCH] D85384: [X86] Add basic support for -mtune command line option in clang

2020-08-18 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/test/Misc/target-invalid-cpu-note.c:49
+
+// RUN: not %clang_cc1 -triple x86_64--- -tune-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix TUNE_X86_64
+// TUNE_X86_64: error: unknown target CPU 'not-a-cpu'

efriedma wrote:
> Should we have a test for tune-cpu for some non-x86 target?  Or are we happy 
> to just assume this works correctly because we already have coverage for 
> target-cpu?
I copied the AARCH64 test above an added a -tune-cpu version of it. That will 
be included with my commit


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

https://reviews.llvm.org/D85384

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


[PATCH] D86065: [SVE] Make ElementCount members private

2020-08-18 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> Perhaps now would be a good time to combine TypeSize and ElementCount into a 
> single Polynomial type? We don't have to implement the whole abstraction of 
> c*x^n (since we currently don't use the exponent, and don't distinguish 
> between X's) but if it's ever needed in the future it will be obvious where 
> to add it, and it will Just Work.

Even if the types are structurally similar, I'd prefer to keep them separate.  
The uses are distinct, the usage in a function signature indicates what kind of 
value we actually expect.  (It's particularly easy to perform incorrect 
conversions with types representing size and alignment.)




Comment at: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:3522
+  DAG.getNode(ISD::EXTRACT_SUBVECTOR, Dl,
+  MemVT.getHalfNumVectorElementsVT(*DAG.getContext()),
+  StoreNode->getValue(),

ctetreau wrote:
> What is this `>>` thing? Some indicator of whitespace change, or is this a 
> hard tab?
It's an indicator of a whitespace change; I think they started showing up with 
the recent Phabricator upgrade


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86065

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


[libunwind] a20f5fe - Default to disabling the libunwind frameheader cache.

2020-08-18 Thread Sterling Augustine via cfe-commits

Author: Sterling Augustine
Date: 2020-08-18T14:37:36-07:00
New Revision: a20f5fe70810e0a768c1814d69d10862965c21e4

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

LOG: Default to disabling the libunwind frameheader cache.

Although it works fine with glibc, as currently implemented the
frameheader cache is incompatible with certain platforms with
slightly different locking semantics inside dl_iterate_phdr.

Therefore only enable it when it is turned on explicitly with
a configure-time option.

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

Added: 


Modified: 
libunwind/CMakeLists.txt
libunwind/src/AddressSpace.hpp
libunwind/test/frameheadercache_test.pass.cpp

Removed: 




diff  --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt
index 8419d851ab7f..f4243f3d2791 100644
--- a/libunwind/CMakeLists.txt
+++ b/libunwind/CMakeLists.txt
@@ -138,6 +138,7 @@ option(LIBUNWIND_WEAK_PTHREAD_LIB "Use weak references to 
refer to pthread funct
 option(LIBUNWIND_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF)
 option(LIBUNWIND_INCLUDE_DOCS "Build the libunwind documentation." 
${LLVM_INCLUDE_DOCS})
 option(LIBUNWIND_IS_BAREMETAL "Build libunwind for baremetal targets." OFF)
+option(LIBUNWIND_USE_FRAME_HEADER_CACHE "Cache frame headers for unwinding. 
Requires locking dl_iterate_phdr." OFF)
 
 set(LIBUNWIND_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING
 "Define suffix of library directory name (32/64)")
@@ -368,6 +369,10 @@ if(LIBUNWIND_IS_BAREMETAL)
   add_compile_definitions(_LIBUNWIND_IS_BAREMETAL)
 endif()
 
+if(LIBUNWIND_USE_FRAME_HEADER_CACHE)
+  add_compile_definitions(_LIBUNWIND_USE_FRAME_HEADER_CACHE)
+endif()
+
 # This is the _ONLY_ place where add_definitions is called.
 if (MSVC)
   add_definitions(-D_CRT_SECURE_NO_WARNINGS)

diff  --git a/libunwind/src/AddressSpace.hpp b/libunwind/src/AddressSpace.hpp
index 78d2dd110865..2443bd761cc4 100644
--- a/libunwind/src/AddressSpace.hpp
+++ b/libunwind/src/AddressSpace.hpp
@@ -411,10 +411,12 @@ struct _LIBUNWIND_HIDDEN dl_iterate_cb_data {
 #error "_LIBUNWIND_SUPPORT_DWARF_UNWIND requires 
_LIBUNWIND_SUPPORT_DWARF_INDEX on this platform."
   #endif
 
+#if defined(_LIBUNWIND_USE_FRAME_HEADER_CACHE)
 #include "FrameHeaderCache.hpp"
 
 // There should be just one of these per process.
 static FrameHeaderCache ProcessFrameHeaderCache;
+#endif
 
 static bool checkAddrInSegment(const Elf_Phdr *phdr, size_t image_base,
dl_iterate_cb_data *cbdata) {
@@ -435,8 +437,10 @@ int findUnwindSectionsByPhdr(struct dl_phdr_info *pinfo, 
size_t pinfo_size,
   auto cbdata = static_cast(data);
   if (pinfo->dlpi_phnum == 0 || cbdata->targetAddr < pinfo->dlpi_addr)
 return 0;
+#if defined(_LIBUNWIND_USE_FRAME_HEADER_CACHE)
   if (ProcessFrameHeaderCache.find(pinfo, pinfo_size, data))
 return 1;
+#endif
 
   Elf_Addr image_base = calculateImageBase(pinfo);
   bool found_obj = false;
@@ -464,7 +468,9 @@ int findUnwindSectionsByPhdr(struct dl_phdr_info *pinfo, 
size_t pinfo_size,
   found_obj = checkAddrInSegment(phdr, image_base, cbdata);
 }
 if (found_obj && found_hdr) {
+#if defined(_LIBUNWIND_USE_FRAME_HEADER_CACHE)
   ProcessFrameHeaderCache.add(cbdata->sects);
+#endif
   return 1;
 }
   }

diff  --git a/libunwind/test/frameheadercache_test.pass.cpp 
b/libunwind/test/frameheadercache_test.pass.cpp
index 9397e70d66cb..ebbc00464e07 100644
--- a/libunwind/test/frameheadercache_test.pass.cpp
+++ b/libunwind/test/frameheadercache_test.pass.cpp
@@ -6,7 +6,7 @@
 // The frame header cache should work fine for other architectures,
 // but the #ifdefs end up being even more complicated than this.
 
-#ifdef __x86_64__
+#if defined(__x86_64__) && defined(_LIBUNWIND_USE_FRAME_HEADER_CACHE)
 
 // This #if chain is ugly, but see the comments in AddressSpace.hpp for
 // the reasoning.



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


[PATCH] D85977: [release][docs] Update contributions to LLVM 11 for SVE.

2020-08-18 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added a comment.

I merged it in the release branch as 
https://github.com/llvm/llvm-project/commit/7e6bf0bfe6de9e0d0e58764a66f93210f296bbfa


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85977

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


[PATCH] D86101: [AArch64][SVE] Add missing debug info for ACLE types.

2020-08-18 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:734
+  if (Info.ElementType == CGM.getContext().BoolTy)
+NumElemsPerVG /= 8;
+

I guess NumElemsPerVG of a bool vector is always divisible by 8 because we 
don't expose `` etc.?



Comment at: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp:1404
+  ? Subrange->getCount().get()->getSExtValue()
+  : 0;
 

Do we need a test for this change?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86101

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


[PATCH] D85981: [clang][Modules] Use File Names Instead of inodes As Loaded Module Keys

2020-08-18 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: clang/include/clang/Serialization/ModuleManager.h:62
 
+  struct EntryKey {
+const FileEntry *Entry;

aprantl wrote:
> Can you add a doxygen comment explaining why we compute our own hashing as 
> opposed to using the FileEntry pointer?
Basically what you wrote in the description of the review...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85981

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


[PATCH] D85981: [clang][Modules] Use File Names Instead of inodes As Loaded Module Keys

2020-08-18 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: clang/include/clang/Serialization/ModuleManager.h:62
 
+  struct EntryKey {
+const FileEntry *Entry;

Can you add a doxygen comment explaining why we compute our own hashing as 
opposed to using the FileEntry pointer?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85981

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


[PATCH] D85981: [clang][Modules] Use File Names Instead of inodes As Loaded Module Keys

2020-08-18 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: clang/include/clang/Serialization/ModuleManager.h:62
 
-  /// All loaded modules, indexed by name.
-  llvm::DenseMap Modules;
+  /// All loaded modules, indexed by file name.
+  llvm::StringMap Modules;

CodaFi wrote:
> aprantl wrote:
> > aprantl wrote:
> > > Is it literally the file name, or something like the absolute realpath? 
> > > And just because I'm curious: Is this the name of the .pcm or of the 
> > > module map file?
> > I just realized @vsapsai already asked the same question :-)
> It's the file path the module cache has computed for the PCM. I could try to 
> use the real path to the file, but I'm not sure how portable/stable that 
> interface is relative to this one.
If it's the path to the `.pcm` there's no point in wasting time on realpath — 
there should only be one module cache path and we don't care where exactly it 
is on disk, and the paths inside the module cache ought to be unique anyway, 
because we just computed them. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85981

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


[PATCH] D86130: [AST] Fix a crash on mangling a binding decl from a DeclRefExpr.

2020-08-18 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Here's a testcase that produces a name with external linkage:

  struct X { int i, j; };
  auto [a,b] = X{1,2};
  template void f(decltype(a + T())) {}
  template void f(int);

We should make sure that we mangle the reference to `a` as `_Z1aE` here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86130

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


[PATCH] D86156: [BFI] Preserve BFI information through loop passes via VH callbacks inside LoopStandardAnalysisResults

2020-08-18 Thread Di Mo via Phabricator via cfe-commits
modimo updated this revision to Diff 286392.
modimo added a comment.

Commit my changes (crazy I know) so that the diff is actually updated for 
linting


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

https://reviews.llvm.org/D86156

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/include/llvm/Analysis/BlockFrequencyInfo.h
  llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
  llvm/include/llvm/Analysis/LoopAnalysisManager.h
  llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
  llvm/lib/Analysis/BlockFrequencyInfo.cpp
  llvm/lib/Transforms/Scalar/LoopDistribute.cpp
  llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
  llvm/lib/Transforms/Utils/LoopVersioning.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/test/Other/loop-pm-invalidation.ll
  llvm/test/Other/new-pass-manager.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/pass-pipelines.ll
  llvm/test/Transforms/LoopRotate/pr35210.ll
  llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp

Index: llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
===
--- llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
+++ llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
@@ -9,7 +9,10 @@
 #include "llvm/Transforms/Scalar/LoopPassManager.h"
 #include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Analysis/AssumptionCache.h"
+#include "llvm/Analysis/BlockFrequencyInfo.h"
+#include "llvm/Analysis/BranchProbabilityInfo.h"
 #include "llvm/Analysis/MemorySSA.h"
+#include "llvm/Analysis/PostDominators.h"
 #include "llvm/Analysis/ScalarEvolution.h"
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
@@ -294,6 +297,9 @@
 // those.
 FAM.registerPass([&] { return AAManager(); });
 FAM.registerPass([&] { return AssumptionAnalysis(); });
+FAM.registerPass([&] { return BlockFrequencyAnalysis(); });
+FAM.registerPass([&] { return BranchProbabilityAnalysis(); });
+FAM.registerPass([&] { return PostDominatorTreeAnalysis(); });
 FAM.registerPass([&] { return MemorySSAAnalysis(); });
 FAM.registerPass([&] { return ScalarEvolutionAnalysis(); });
 FAM.registerPass([&] { return TargetLibraryAnalysis(); });
Index: llvm/test/Transforms/LoopRotate/pr35210.ll
===
--- llvm/test/Transforms/LoopRotate/pr35210.ll
+++ llvm/test/Transforms/LoopRotate/pr35210.ll
@@ -19,12 +19,15 @@
 ; CHECK-NEXT: Running analysis: TargetLibraryAnalysis on f
 ; CHECK-NEXT: Running analysis: ScalarEvolutionAnalysis on f
 ; CHECK-NEXT: Running analysis: TargetIRAnalysis on f
+; CHECK-NEXT: Running analysis: BlockFrequencyAnalysis on f
+; CHECK-NEXT: Running analysis: BranchProbabilityAnalysis on f
 ; CHECK-NEXT: Running analysis: InnerAnalysisManagerProxy{{.*}} on f
 ; CHECK-NEXT: Starting Loop pass manager run.
 ; CHECK-NEXT: Running pass: LoopRotatePass on Loop at depth 1 containing: %bb,%bb4
 ; CHECK-NEXT: Folding loop latch bb4 into bb
 ; CHECK-NEXT: Finished Loop pass manager run.
 ; CHECK-NEXT: Invalidating analysis: PostDominatorTreeAnalysis on f
+; CHECK-NEXT: Invalidating analysis: BranchProbabilityAnalysis on f
 ; CHECK-NEXT: Running pass: ADCEPass on f
 ; CHECK-NEXT: Running analysis: PostDominatorTreeAnalysis on f
 ; CHECK-NEXT: Finished llvm::Function pass manager run.
@@ -44,12 +47,15 @@
 ; MSSA-NEXT: Running analysis: TargetLibraryAnalysis on f
 ; MSSA-NEXT: Running analysis: ScalarEvolutionAnalysis on f
 ; MSSA-NEXT: Running analysis: TargetIRAnalysis on f
+; MSSA-NEXT: Running analysis: BlockFrequencyAnalysis on f
+; MSSA-NEXT: Running analysis: BranchProbabilityAnalysis on f
 ; MSSA-NEXT: Running analysis: InnerAnalysisManagerProxy{{.*}} on f
 ; MSSA-NEXT: Starting Loop pass manager run.
 ; MSSA-NEXT: Running pass: LoopRotatePass on Loop at depth 1 containing: %bb,%bb4
 ; MSSA-NEXT: Folding loop latch bb4 into bb
 ; MSSA-NEXT: Finished Loop pass manager run.
 ; MSSA-NEXT: Invalidating analysis: PostDominatorTreeAnalysis on f
+; MSSA-NEXT: Invalidating analysis: BranchProbabilityAnalysis on f
 ; MSSA-NEXT: Running pass: ADCEPass on f
 ; MSSA-NEXT: Running analysis: PostDominatorTreeAnalysis on f
 ; MSSA-NEXT: Finished llvm::Function pass manager run.
Index: llvm/test/Other/pass-pipelines.ll
===
--- llvm/test/Other/pass-pipelines.ll
+++ llvm/test/Other/pass-pipelines.ll
@@ -54,7 +54,7 @@
 ; CHECK-O2-NOT: Manager
 ; CHECK-O2: Loop Pass Manager
 ; CHECK-O2: Loop Pass Manager
-; CHECK-O2-NOT: Manager
+; Requiring block frequency for LICM will place ICM and rotation under separate Loop Pass Manager
 ; FIXME: We shouldn't be pulling out to simplify-cfg and instcombine and
 ; causing new loop pass managers.
 ; CHECK-O2: Simplify the CFG
Index: llvm/test/Other/new-pm-thinlto-defaults.ll

[PATCH] D86156: [BFI] Preserve BFI information through loop passes via VH callbacks inside LoopStandardAnalysisResults

2020-08-18 Thread Di Mo via Phabricator via cfe-commits
modimo updated this revision to Diff 286390.
modimo added a comment.

Linting


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

https://reviews.llvm.org/D86156

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/include/llvm/Analysis/BlockFrequencyInfo.h
  llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
  llvm/include/llvm/Analysis/LoopAnalysisManager.h
  llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
  llvm/lib/Analysis/BlockFrequencyInfo.cpp
  llvm/lib/Transforms/Scalar/LoopDistribute.cpp
  llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
  llvm/lib/Transforms/Utils/LoopVersioning.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/test/Other/loop-pm-invalidation.ll
  llvm/test/Other/new-pass-manager.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/pass-pipelines.ll
  llvm/test/Transforms/LoopRotate/pr35210.ll
  llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp

Index: llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
===
--- llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
+++ llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
@@ -10,6 +10,9 @@
 #include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Analysis/AssumptionCache.h"
 #include "llvm/Analysis/MemorySSA.h"
+#include "llvm/Analysis/BlockFrequencyInfo.h"
+#include "llvm/Analysis/BranchProbabilityInfo.h"
+#include "llvm/Analysis/PostDominators.h"
 #include "llvm/Analysis/ScalarEvolution.h"
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
@@ -294,6 +297,9 @@
 // those.
 FAM.registerPass([&] { return AAManager(); });
 FAM.registerPass([&] { return AssumptionAnalysis(); });
+FAM.registerPass([&] { return BlockFrequencyAnalysis(); });
+FAM.registerPass([&] { return BranchProbabilityAnalysis(); });
+FAM.registerPass([&] { return PostDominatorTreeAnalysis(); });
 FAM.registerPass([&] { return MemorySSAAnalysis(); });
 FAM.registerPass([&] { return ScalarEvolutionAnalysis(); });
 FAM.registerPass([&] { return TargetLibraryAnalysis(); });
Index: llvm/test/Transforms/LoopRotate/pr35210.ll
===
--- llvm/test/Transforms/LoopRotate/pr35210.ll
+++ llvm/test/Transforms/LoopRotate/pr35210.ll
@@ -19,12 +19,15 @@
 ; CHECK-NEXT: Running analysis: TargetLibraryAnalysis on f
 ; CHECK-NEXT: Running analysis: ScalarEvolutionAnalysis on f
 ; CHECK-NEXT: Running analysis: TargetIRAnalysis on f
+; CHECK-NEXT: Running analysis: BlockFrequencyAnalysis on f
+; CHECK-NEXT: Running analysis: BranchProbabilityAnalysis on f
 ; CHECK-NEXT: Running analysis: InnerAnalysisManagerProxy{{.*}} on f
 ; CHECK-NEXT: Starting Loop pass manager run.
 ; CHECK-NEXT: Running pass: LoopRotatePass on Loop at depth 1 containing: %bb,%bb4
 ; CHECK-NEXT: Folding loop latch bb4 into bb
 ; CHECK-NEXT: Finished Loop pass manager run.
 ; CHECK-NEXT: Invalidating analysis: PostDominatorTreeAnalysis on f
+; CHECK-NEXT: Invalidating analysis: BranchProbabilityAnalysis on f
 ; CHECK-NEXT: Running pass: ADCEPass on f
 ; CHECK-NEXT: Running analysis: PostDominatorTreeAnalysis on f
 ; CHECK-NEXT: Finished llvm::Function pass manager run.
@@ -44,12 +47,15 @@
 ; MSSA-NEXT: Running analysis: TargetLibraryAnalysis on f
 ; MSSA-NEXT: Running analysis: ScalarEvolutionAnalysis on f
 ; MSSA-NEXT: Running analysis: TargetIRAnalysis on f
+; MSSA-NEXT: Running analysis: BlockFrequencyAnalysis on f
+; MSSA-NEXT: Running analysis: BranchProbabilityAnalysis on f
 ; MSSA-NEXT: Running analysis: InnerAnalysisManagerProxy{{.*}} on f
 ; MSSA-NEXT: Starting Loop pass manager run.
 ; MSSA-NEXT: Running pass: LoopRotatePass on Loop at depth 1 containing: %bb,%bb4
 ; MSSA-NEXT: Folding loop latch bb4 into bb
 ; MSSA-NEXT: Finished Loop pass manager run.
 ; MSSA-NEXT: Invalidating analysis: PostDominatorTreeAnalysis on f
+; MSSA-NEXT: Invalidating analysis: BranchProbabilityAnalysis on f
 ; MSSA-NEXT: Running pass: ADCEPass on f
 ; MSSA-NEXT: Running analysis: PostDominatorTreeAnalysis on f
 ; MSSA-NEXT: Finished llvm::Function pass manager run.
Index: llvm/test/Other/pass-pipelines.ll
===
--- llvm/test/Other/pass-pipelines.ll
+++ llvm/test/Other/pass-pipelines.ll
@@ -54,7 +54,7 @@
 ; CHECK-O2-NOT: Manager
 ; CHECK-O2: Loop Pass Manager
 ; CHECK-O2: Loop Pass Manager
-; CHECK-O2-NOT: Manager
+; Requiring block frequency for LICM will place ICM and rotation under separate Loop Pass Manager
 ; FIXME: We shouldn't be pulling out to simplify-cfg and instcombine and
 ; causing new loop pass managers.
 ; CHECK-O2: Simplify the CFG
Index: llvm/test/Other/new-pm-thinlto-defaults.ll
===
--- llvm/test/Other/new-pm-thinlto-defaults.ll
+++ 

[PATCH] D86169: Initial support for letting plugins perform custom parsing of attribute arguments.

2020-08-18 Thread Jonathan Protzenko via Phabricator via cfe-commits
jonathan.protzenko created this revision.
jonathan.protzenko added a reviewer: aaron.ballman.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
jonathan.protzenko requested review of this revision.

This is a preliminary patch that I hope can serve as a basis for discussion. The
design summary below is copy/pasted from 
https://bugs.llvm.org/show_bug.cgi?id=46446#c7

(I'm intentionally posting a work-in-progress so that I can make sure that 
things
are roughly looking good; I'd like to defer details (clang-format'ing my
changes, naming conventions, tests) to later once the design is settled.)

The patch essentially adds the ability for a plugin to handle the parsing of a
CXX11 attribute's arguments. This means that with this patch, plugin-defined
CXX11 attributes are no longer limited to constant attributes that take no
arguments.

The patch intentionally gives the plugin a fair amount of freedom, to enable
interesting use-cases (see below).

The patch does not (yet) tackle the ability for out-of-tree plugins to extend
Attr.td. I'd be happy to work on that once the present patch makes progress.

Design
==

I chose to extend the ParsedAttrInfo class. This allows reusing the logic that
searches for an attribute plugin that has registered a matching spelling, and
reusing the existing registry of plugins. (I contemplated a separate registry,
but thought it would duplicate the spelling-search logic and would also lead to
code duplication in the plugin itself.)

By default, ParsedAttrInfo's (most of which do *not* come from plugins) are
happy to let the built-in clang parsing logic take effect, enforcing tweaking
knobs such as NumArgs and OptArgs. Plugins can, if they are so inclined, elect
to bypass clang's parsing logic (which, as we saw on Bugzilla, ignores CXX11
attribute arguments when they're not known to clang). In that case, plugins are
on their own; they are expected to handle all of the parsing, as well as pushing
the resulting ParsedAttr into the ParsedAttributes. They then report whether the
arguments are syntactically valid or not and the rest of the parsing code
handles error reporting.

(Side-note: this means that it's a three-state return value, and I'm currently
reusing the existing AttrHandling enum, but it could be improved with either
better names or a separate enum.)

The plugin receives, in addition to location information, two key parameters:

- the parser, obviously
- a possibly-null Declarator representing the partially parsed declaration that 
the attribute is attached to, if any.

The second parameter may be the most surprising part of this patch, so let me
try to provide some motivation and context.

My goal is to enable plugins to perform advanced static analysis and code
generation, relying on rich CXX11 attributes capturing deep semantic information
relating, say, a function's parameters, or a struct's fields.

You can easily imagine someone authoring a static analyzer that recognizes:

  typedef struct
  {
size_t len;
uint8_t *chars;
  [[ my_analyzer::invariant(strlen(chars) == len) ]];
  }
  managed_string;

The point here being to leverage a nice CXX11 attribute that benefits from
typo-checking, proper name and macro resolution, etc. rather than using some
unreliable syntax embedded in comments like so many other tools are doing, or
worse, a custom C++ parser.

In our case, we're auto-generating parsers and serializers from a struct type
definition (see https://www.usenix.org/system/files/sec19-ramananandro_0.pdf for
more info), so I'd like to author:

  typedef struct {
uint32_t min_version;
uint32_t max_version
  [[ everparse::constraint (max_version >= min_version && min_version >= 2 
&& max_version <= 4) ]];
  } my_network_format;
  `

Of course, our actual network formats are much more complicated, but this is
just for the sake of example. My point is that allowing plugins a substantial
degree of freedom is likely to enable a flurry of novel and exciting use-cases
based on clang.

Back to the design of the patch, receiving the Declarator allows me to do things
like this (in the plugin):

  Sema  = P->getActions();
  TypeSourceInfo *T = S.GetTypeForDeclarator(*D, P->getCurScope());
  QualType R = T->getType();
  VarDecl *VD = VarDecl::Create(S.getASTContext(), S.CurContext,
  D->getBeginLoc(), D->getIdentifierLoc(), D->getIdentifier(), R,
  T,
  SC_None);
  // Doing this makes sure Sema is aware of the new scope entry, meaning this 
name
  // will be in scope when parsing the expression. (Parsing and scope
  // resolution are intertwined.)
  VD->setImplicit(true);
  S.PushOnScopeChains(VD, P->getCurScope());

This allows my plugin to successfully parse and recognize complex arguments that
refer to the current declarator, in effect letting my plugin define its own
extended syntax and scoping rules.

I hope this helps, I'll keep working on the patch (this is the first version
that seems to do something useful) but 

[PATCH] D86116: [Coverage] Adjust skipped regions only if {Prev,Next}TokLoc is in the same file as regions' {start, end}Loc

2020-08-18 Thread Zequan Wu 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 rG84fffa672831: [Coverage] Adjust skipped regions only if 
{Prev,Next}TokLoc is in the same file… (authored by zequanwu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86116

Files:
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/test/CoverageMapping/Inputs/comment.h
  clang/test/CoverageMapping/comment.cpp


Index: clang/test/CoverageMapping/comment.cpp
===
--- /dev/null
+++ clang/test/CoverageMapping/comment.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -emit-llvm-only %s | FileCheck %s
+
+int f() {
+  int x = 0;
+#include "Inputs/comment.h" /*
+*/
+  return x;
+}
+
+// CHECK: File 0, 3:9 -> 8:2 = #0
+// CHECK-NEXT: Expansion,File 0, 5:10 -> 5:28 = #0
+// CHECK-NEXT: Skipped,File 0, 6:1 -> 6:7 = 0
+// CHECK-NEXT: File 1, 1:1 -> 7:1 = #0
Index: clang/test/CoverageMapping/Inputs/comment.h
===
--- /dev/null
+++ clang/test/CoverageMapping/Inputs/comment.h
@@ -0,0 +1,6 @@
+
+
+
+
+
+x = 0;
Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===
--- clang/lib/CodeGen/CoverageMappingGen.cpp
+++ clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -44,7 +44,8 @@
   PP.setTokenWatcher([CoverageInfo](clang::Token Tok) {
 // Update previous token location.
 CoverageInfo->PrevTokLoc = Tok.getLocation();
-CoverageInfo->updateNextTokLoc(Tok.getLocation());
+if (Tok.getKind() != clang::tok::eod)
+  CoverageInfo->updateNextTokLoc(Tok.getLocation());
   });
   return CoverageInfo;
 }
@@ -305,20 +306,24 @@
   /// non-comment token. If shrinking the skipped range would make it empty,
   /// this returns None.
   Optional adjustSkippedRange(SourceManager ,
-  SpellingRegion SR,
+  SourceLocation LocStart,
+  SourceLocation LocEnd,
   SourceLocation PrevTokLoc,
   SourceLocation NextTokLoc) {
+SpellingRegion SR{SM, LocStart, LocEnd};
 // If Range begin location is invalid, it's not a comment region.
 if (PrevTokLoc.isInvalid())
   return SR;
 unsigned PrevTokLine = SM.getSpellingLineNumber(PrevTokLoc);
 unsigned NextTokLine = SM.getSpellingLineNumber(NextTokLoc);
 SpellingRegion newSR(SR);
-if (SR.LineStart == PrevTokLine) {
+if (SM.isWrittenInSameFile(LocStart, PrevTokLoc) &&
+SR.LineStart == PrevTokLine) {
   newSR.LineStart = SR.LineStart + 1;
   newSR.ColumnStart = 1;
 }
-if (SR.LineEnd == NextTokLine) {
+if (SM.isWrittenInSameFile(LocEnd, NextTokLoc) &&
+SR.LineEnd == NextTokLine) {
   newSR.LineEnd = SR.LineEnd - 1;
   newSR.ColumnEnd = SR.ColumnStart + 1;
 }
@@ -354,14 +359,13 @@
   auto CovFileID = getCoverageFileID(LocStart);
   if (!CovFileID)
 continue;
-  SpellingRegion SR{SM, LocStart, LocEnd};
-  if (Optional res =
-  adjustSkippedRange(SM, SR, I.PrevTokLoc, I.NextTokLoc))
-SR = res.getValue();
-  else
+  Optional SR =
+  adjustSkippedRange(SM, LocStart, LocEnd, I.PrevTokLoc, I.NextTokLoc);
+  if (!SR.hasValue())
 continue;
   auto Region = CounterMappingRegion::makeSkipped(
-  *CovFileID, SR.LineStart, SR.ColumnStart, SR.LineEnd, SR.ColumnEnd);
+  *CovFileID, SR->LineStart, SR->ColumnStart, SR->LineEnd,
+  SR->ColumnEnd);
   // Make sure that we only collect the regions that are inside
   // the source code of this function.
   if (Region.LineStart >= FileLineRanges[*CovFileID].first &&


Index: clang/test/CoverageMapping/comment.cpp
===
--- /dev/null
+++ clang/test/CoverageMapping/comment.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %s | FileCheck %s
+
+int f() {
+  int x = 0;
+#include "Inputs/comment.h" /*
+*/
+  return x;
+}
+
+// CHECK: File 0, 3:9 -> 8:2 = #0
+// CHECK-NEXT: Expansion,File 0, 5:10 -> 5:28 = #0
+// CHECK-NEXT: Skipped,File 0, 6:1 -> 6:7 = 0
+// CHECK-NEXT: File 1, 1:1 -> 7:1 = #0
Index: clang/test/CoverageMapping/Inputs/comment.h
===
--- /dev/null
+++ clang/test/CoverageMapping/Inputs/comment.h
@@ -0,0 +1,6 @@
+
+
+
+
+
+x = 0;
Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===
--- 

[clang] 84fffa6 - [Coverage] Adjust skipped regions only if {Prev,Next}TokLoc is in the same file as regions' {start, end}Loc

2020-08-18 Thread Zequan Wu via cfe-commits

Author: Zequan Wu
Date: 2020-08-18T13:26:19-07:00
New Revision: 84fffa67283139954b7764328966b5f766db1003

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

LOG: [Coverage] Adjust skipped regions only if {Prev,Next}TokLoc is in the same 
file as regions' {start, end}Loc

Fix a bug if {Prev, Next}TokLoc is in different file from skipped regions' 
{start, end}Loc

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

Added: 
clang/test/CoverageMapping/Inputs/comment.h
clang/test/CoverageMapping/comment.cpp

Modified: 
clang/lib/CodeGen/CoverageMappingGen.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CoverageMappingGen.cpp 
b/clang/lib/CodeGen/CoverageMappingGen.cpp
index e6e1b2111935..8277804d27c0 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -44,7 +44,8 @@ CoverageMappingModuleGen::setUpCoverageCallbacks(Preprocessor 
) {
   PP.setTokenWatcher([CoverageInfo](clang::Token Tok) {
 // Update previous token location.
 CoverageInfo->PrevTokLoc = Tok.getLocation();
-CoverageInfo->updateNextTokLoc(Tok.getLocation());
+if (Tok.getKind() != clang::tok::eod)
+  CoverageInfo->updateNextTokLoc(Tok.getLocation());
   });
   return CoverageInfo;
 }
@@ -305,20 +306,24 @@ class CoverageMappingBuilder {
   /// non-comment token. If shrinking the skipped range would make it empty,
   /// this returns None.
   Optional adjustSkippedRange(SourceManager ,
-  SpellingRegion SR,
+  SourceLocation LocStart,
+  SourceLocation LocEnd,
   SourceLocation PrevTokLoc,
   SourceLocation NextTokLoc) {
+SpellingRegion SR{SM, LocStart, LocEnd};
 // If Range begin location is invalid, it's not a comment region.
 if (PrevTokLoc.isInvalid())
   return SR;
 unsigned PrevTokLine = SM.getSpellingLineNumber(PrevTokLoc);
 unsigned NextTokLine = SM.getSpellingLineNumber(NextTokLoc);
 SpellingRegion newSR(SR);
-if (SR.LineStart == PrevTokLine) {
+if (SM.isWrittenInSameFile(LocStart, PrevTokLoc) &&
+SR.LineStart == PrevTokLine) {
   newSR.LineStart = SR.LineStart + 1;
   newSR.ColumnStart = 1;
 }
-if (SR.LineEnd == NextTokLine) {
+if (SM.isWrittenInSameFile(LocEnd, NextTokLoc) &&
+SR.LineEnd == NextTokLine) {
   newSR.LineEnd = SR.LineEnd - 1;
   newSR.ColumnEnd = SR.ColumnStart + 1;
 }
@@ -354,14 +359,13 @@ class CoverageMappingBuilder {
   auto CovFileID = getCoverageFileID(LocStart);
   if (!CovFileID)
 continue;
-  SpellingRegion SR{SM, LocStart, LocEnd};
-  if (Optional res =
-  adjustSkippedRange(SM, SR, I.PrevTokLoc, I.NextTokLoc))
-SR = res.getValue();
-  else
+  Optional SR =
+  adjustSkippedRange(SM, LocStart, LocEnd, I.PrevTokLoc, I.NextTokLoc);
+  if (!SR.hasValue())
 continue;
   auto Region = CounterMappingRegion::makeSkipped(
-  *CovFileID, SR.LineStart, SR.ColumnStart, SR.LineEnd, SR.ColumnEnd);
+  *CovFileID, SR->LineStart, SR->ColumnStart, SR->LineEnd,
+  SR->ColumnEnd);
   // Make sure that we only collect the regions that are inside
   // the source code of this function.
   if (Region.LineStart >= FileLineRanges[*CovFileID].first &&

diff  --git a/clang/test/CoverageMapping/Inputs/comment.h 
b/clang/test/CoverageMapping/Inputs/comment.h
new file mode 100644
index ..eec5833c2bd0
--- /dev/null
+++ b/clang/test/CoverageMapping/Inputs/comment.h
@@ -0,0 +1,6 @@
+
+
+
+
+
+x = 0;

diff  --git a/clang/test/CoverageMapping/comment.cpp 
b/clang/test/CoverageMapping/comment.cpp
new file mode 100644
index ..f8e4b4912e18
--- /dev/null
+++ b/clang/test/CoverageMapping/comment.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -emit-llvm-only %s | FileCheck %s
+
+int f() {
+  int x = 0;
+#include "Inputs/comment.h" /*
+*/
+  return x;
+}
+
+// CHECK: File 0, 3:9 -> 8:2 = #0
+// CHECK-NEXT: Expansion,File 0, 5:10 -> 5:28 = #0
+// CHECK-NEXT: Skipped,File 0, 6:1 -> 6:7 = 0
+// CHECK-NEXT: File 1, 1:1 -> 7:1 = #0



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


[PATCH] D86116: [Coverage] Adjust skipped regions only if {Prev,Next}TokLoc is in the same file as regions' {start, end}Loc

2020-08-18 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 286387.
zequanwu added a comment.

Minor fix on test case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86116

Files:
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/test/CoverageMapping/Inputs/comment.h
  clang/test/CoverageMapping/comment.cpp


Index: clang/test/CoverageMapping/comment.cpp
===
--- /dev/null
+++ clang/test/CoverageMapping/comment.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -emit-llvm-only %s | FileCheck %s
+
+int f() {
+  int x = 0;
+#include "Inputs/comment.h" /*
+*/
+  return x;
+}
+
+// CHECK: File 0, 3:9 -> 8:2 = #0
+// CHECK-NEXT: Expansion,File 0, 5:10 -> 5:28 = #0
+// CHECK-NEXT: Skipped,File 0, 6:1 -> 6:7 = 0
+// CHECK-NEXT: File 1, 1:1 -> 7:1 = #0
Index: clang/test/CoverageMapping/Inputs/comment.h
===
--- /dev/null
+++ clang/test/CoverageMapping/Inputs/comment.h
@@ -0,0 +1,6 @@
+
+
+
+
+
+x = 0;
Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===
--- clang/lib/CodeGen/CoverageMappingGen.cpp
+++ clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -44,7 +44,8 @@
   PP.setTokenWatcher([CoverageInfo](clang::Token Tok) {
 // Update previous token location.
 CoverageInfo->PrevTokLoc = Tok.getLocation();
-CoverageInfo->updateNextTokLoc(Tok.getLocation());
+if (Tok.getKind() != clang::tok::eod)
+  CoverageInfo->updateNextTokLoc(Tok.getLocation());
   });
   return CoverageInfo;
 }
@@ -305,20 +306,24 @@
   /// non-comment token. If shrinking the skipped range would make it empty,
   /// this returns None.
   Optional adjustSkippedRange(SourceManager ,
-  SpellingRegion SR,
+  SourceLocation LocStart,
+  SourceLocation LocEnd,
   SourceLocation PrevTokLoc,
   SourceLocation NextTokLoc) {
+SpellingRegion SR{SM, LocStart, LocEnd};
 // If Range begin location is invalid, it's not a comment region.
 if (PrevTokLoc.isInvalid())
   return SR;
 unsigned PrevTokLine = SM.getSpellingLineNumber(PrevTokLoc);
 unsigned NextTokLine = SM.getSpellingLineNumber(NextTokLoc);
 SpellingRegion newSR(SR);
-if (SR.LineStart == PrevTokLine) {
+if (SM.isWrittenInSameFile(LocStart, PrevTokLoc) &&
+SR.LineStart == PrevTokLine) {
   newSR.LineStart = SR.LineStart + 1;
   newSR.ColumnStart = 1;
 }
-if (SR.LineEnd == NextTokLine) {
+if (SM.isWrittenInSameFile(LocEnd, NextTokLoc) &&
+SR.LineEnd == NextTokLine) {
   newSR.LineEnd = SR.LineEnd - 1;
   newSR.ColumnEnd = SR.ColumnStart + 1;
 }
@@ -354,14 +359,13 @@
   auto CovFileID = getCoverageFileID(LocStart);
   if (!CovFileID)
 continue;
-  SpellingRegion SR{SM, LocStart, LocEnd};
-  if (Optional res =
-  adjustSkippedRange(SM, SR, I.PrevTokLoc, I.NextTokLoc))
-SR = res.getValue();
-  else
+  Optional SR =
+  adjustSkippedRange(SM, LocStart, LocEnd, I.PrevTokLoc, I.NextTokLoc);
+  if (!SR.hasValue())
 continue;
   auto Region = CounterMappingRegion::makeSkipped(
-  *CovFileID, SR.LineStart, SR.ColumnStart, SR.LineEnd, SR.ColumnEnd);
+  *CovFileID, SR->LineStart, SR->ColumnStart, SR->LineEnd,
+  SR->ColumnEnd);
   // Make sure that we only collect the regions that are inside
   // the source code of this function.
   if (Region.LineStart >= FileLineRanges[*CovFileID].first &&


Index: clang/test/CoverageMapping/comment.cpp
===
--- /dev/null
+++ clang/test/CoverageMapping/comment.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %s | FileCheck %s
+
+int f() {
+  int x = 0;
+#include "Inputs/comment.h" /*
+*/
+  return x;
+}
+
+// CHECK: File 0, 3:9 -> 8:2 = #0
+// CHECK-NEXT: Expansion,File 0, 5:10 -> 5:28 = #0
+// CHECK-NEXT: Skipped,File 0, 6:1 -> 6:7 = 0
+// CHECK-NEXT: File 1, 1:1 -> 7:1 = #0
Index: clang/test/CoverageMapping/Inputs/comment.h
===
--- /dev/null
+++ clang/test/CoverageMapping/Inputs/comment.h
@@ -0,0 +1,6 @@
+
+
+
+
+
+x = 0;
Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===
--- clang/lib/CodeGen/CoverageMappingGen.cpp
+++ clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -44,7 +44,8 @@
   PP.setTokenWatcher([CoverageInfo](clang::Token Tok) {
 // Update previous token location.
 

[PATCH] D85191: [AST] Get field size in chars rather than bits in RecordLayoutBuilder.

2020-08-18 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

I'm still concerned your approach to the computation of getTypeSize() is a 
ticking time bomb, but I'll take the cleanup even if the underlying motivation 
doesn't really make sense.




Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1847
+IsIncompleteArrayType ? CharUnits::Zero() : TI.first;
+AlignIsRequired = Context.getTypeInfo(D->getType()).AlignIsRequired;
   };

Can we fix getTypeInfoInChars so it returns all the necessary info, so we don't 
look up the typeinfo twice?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85191

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


[PATCH] D85810: [clang] Pass-through remarks options to linker

2020-08-18 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

Hi Wei, this looks handy! Minor stylish comments below.




Comment at: clang/include/clang/Driver/Driver.h:638
+/// This checks for clang specific R-value ('-Rpass-*') group.
+bool hasRpassOptions(const llvm::opt::ArgList );
+

Nitpicking here, how about `usesRpassOptions`?



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:67
+ A->getValue()));
+  }
+

You can also remove curly braces from here.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:72
+Twine("--plugin-opt=-pass-remarks-missed=") + A->getValue()));
+  }
+

and here.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:77
+Twine("--plugin-opt=-pass-remarks-analysis=") + A->getValue()));
+  }
+}

and here.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:99
+  F = llvm::sys::path::stem(Input.getBaseInput());
+}
+  }

and here, hoist the comment above the `if`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85810

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


[clang] 673dbe1 - [clang codegen] Use IR "align" attribute for static array arguments.

2020-08-18 Thread Eli Friedman via cfe-commits

Author: Eli Friedman
Date: 2020-08-18T12:51:16-07:00
New Revision: 673dbe1b5eef09db39783c828a84f1213a47bad0

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

LOG: [clang codegen] Use IR "align" attribute for static array arguments.

Without the "align" attribute, marking the argument dereferenceable is
basically useless.  See also D80166.

Fixes https://bugs.llvm.org/show_bug.cgi?id=46876 .

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

Added: 


Modified: 
clang/lib/CodeGen/CGCall.cpp
clang/test/CodeGen/vla.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 9d225b23e3c3..98ba1efc20de 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -2520,6 +2520,9 @@ void CodeGenFunction::EmitFunctionProlog(const 
CGFunctionInfo ,
 // bytes).
 if (ArrTy->getSizeModifier() == ArrayType::Static) {
   QualType ETy = ArrTy->getElementType();
+  llvm::Align Alignment =
+  CGM.getNaturalTypeAlignment(ETy).getAsAlign();
+  AI->addAttrs(llvm::AttrBuilder().addAlignmentAttr(Alignment));
   uint64_t ArrSize = ArrTy->getSize().getZExtValue();
   if (!ETy->isIncompleteType() && ETy->isConstantSizeType() &&
   ArrSize) {
@@ -2539,10 +2542,15 @@ void CodeGenFunction::EmitFunctionProlog(const 
CGFunctionInfo ,
 // For C99 VLAs with the static keyword, we don't know the size so
 // we can't use the dereferenceable attribute, but in addrspace(0)
 // we know that it must be nonnull.
-if (ArrTy->getSizeModifier() == VariableArrayType::Static &&
-!getContext().getTargetAddressSpace(ArrTy->getElementType()) &&
-!CGM.getCodeGenOpts().NullPointerIsValid)
-  AI->addAttr(llvm::Attribute::NonNull);
+if (ArrTy->getSizeModifier() == VariableArrayType::Static) {
+  QualType ETy = ArrTy->getElementType();
+  llvm::Align Alignment =
+  CGM.getNaturalTypeAlignment(ETy).getAsAlign();
+  AI->addAttrs(llvm::AttrBuilder().addAlignmentAttr(Alignment));
+  if (!getContext().getTargetAddressSpace(ETy) &&
+  !CGM.getCodeGenOpts().NullPointerIsValid)
+AI->addAttr(llvm::Attribute::NonNull);
+}
   }
 
   // Set `align` attribute if any.

diff  --git a/clang/test/CodeGen/vla.c b/clang/test/CodeGen/vla.c
index 16b82f4acc7d..3142050149aa 100644
--- a/clang/test/CodeGen/vla.c
+++ b/clang/test/CodeGen/vla.c
@@ -200,13 +200,13 @@ void test7(int a[b(0)]) {
 // Make sure we emit dereferenceable or nonnull when the static keyword is
 // provided.
 void test8(int a[static 3]) { }
-// CHECK: define void @test8(i32* dereferenceable(12) %a)
+// CHECK: define void @test8(i32* align 4 dereferenceable(12) %a)
 
 void test9(int n, int a[static n]) { }
-// NULL-INVALID: define void @test9(i32 %n, i32* nonnull %a)
-// NULL-VALID: define void @test9(i32 %n, i32* %a)
+// NULL-INVALID: define void @test9(i32 %n, i32* nonnull align 4 %a)
+// NULL-VALID: define void @test9(i32 %n, i32* align 4 %a)
 
 // Make sure a zero-sized static array extent is still required to be nonnull.
 void test10(int a[static 0]) {}
-// NULL-INVALID: define void @test10(i32* nonnull %a)
-// NULL-VALID: define void @test10(i32* %a)
+// NULL-INVALID: define void @test10(i32* nonnull align 4 %a)
+// NULL-VALID: define void @test10(i32* align 4 %a)



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


[PATCH] D84992: [clang codegen] Use IR "align" attribute for static array arguments.

2020-08-18 Thread Eli Friedman 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 rG673dbe1b5eef: [clang codegen] Use IR align 
attribute for static array arguments. (authored by efriedma).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84992

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGen/vla.c


Index: clang/test/CodeGen/vla.c
===
--- clang/test/CodeGen/vla.c
+++ clang/test/CodeGen/vla.c
@@ -200,13 +200,13 @@
 // Make sure we emit dereferenceable or nonnull when the static keyword is
 // provided.
 void test8(int a[static 3]) { }
-// CHECK: define void @test8(i32* dereferenceable(12) %a)
+// CHECK: define void @test8(i32* align 4 dereferenceable(12) %a)
 
 void test9(int n, int a[static n]) { }
-// NULL-INVALID: define void @test9(i32 %n, i32* nonnull %a)
-// NULL-VALID: define void @test9(i32 %n, i32* %a)
+// NULL-INVALID: define void @test9(i32 %n, i32* nonnull align 4 %a)
+// NULL-VALID: define void @test9(i32 %n, i32* align 4 %a)
 
 // Make sure a zero-sized static array extent is still required to be nonnull.
 void test10(int a[static 0]) {}
-// NULL-INVALID: define void @test10(i32* nonnull %a)
-// NULL-VALID: define void @test10(i32* %a)
+// NULL-INVALID: define void @test10(i32* nonnull align 4 %a)
+// NULL-VALID: define void @test10(i32* align 4 %a)
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -2520,6 +2520,9 @@
 // bytes).
 if (ArrTy->getSizeModifier() == ArrayType::Static) {
   QualType ETy = ArrTy->getElementType();
+  llvm::Align Alignment =
+  CGM.getNaturalTypeAlignment(ETy).getAsAlign();
+  AI->addAttrs(llvm::AttrBuilder().addAlignmentAttr(Alignment));
   uint64_t ArrSize = ArrTy->getSize().getZExtValue();
   if (!ETy->isIncompleteType() && ETy->isConstantSizeType() &&
   ArrSize) {
@@ -2539,10 +2542,15 @@
 // For C99 VLAs with the static keyword, we don't know the size so
 // we can't use the dereferenceable attribute, but in addrspace(0)
 // we know that it must be nonnull.
-if (ArrTy->getSizeModifier() == VariableArrayType::Static &&
-!getContext().getTargetAddressSpace(ArrTy->getElementType()) &&
-!CGM.getCodeGenOpts().NullPointerIsValid)
-  AI->addAttr(llvm::Attribute::NonNull);
+if (ArrTy->getSizeModifier() == VariableArrayType::Static) {
+  QualType ETy = ArrTy->getElementType();
+  llvm::Align Alignment =
+  CGM.getNaturalTypeAlignment(ETy).getAsAlign();
+  AI->addAttrs(llvm::AttrBuilder().addAlignmentAttr(Alignment));
+  if (!getContext().getTargetAddressSpace(ETy) &&
+  !CGM.getCodeGenOpts().NullPointerIsValid)
+AI->addAttr(llvm::Attribute::NonNull);
+}
   }
 
   // Set `align` attribute if any.


Index: clang/test/CodeGen/vla.c
===
--- clang/test/CodeGen/vla.c
+++ clang/test/CodeGen/vla.c
@@ -200,13 +200,13 @@
 // Make sure we emit dereferenceable or nonnull when the static keyword is
 // provided.
 void test8(int a[static 3]) { }
-// CHECK: define void @test8(i32* dereferenceable(12) %a)
+// CHECK: define void @test8(i32* align 4 dereferenceable(12) %a)
 
 void test9(int n, int a[static n]) { }
-// NULL-INVALID: define void @test9(i32 %n, i32* nonnull %a)
-// NULL-VALID: define void @test9(i32 %n, i32* %a)
+// NULL-INVALID: define void @test9(i32 %n, i32* nonnull align 4 %a)
+// NULL-VALID: define void @test9(i32 %n, i32* align 4 %a)
 
 // Make sure a zero-sized static array extent is still required to be nonnull.
 void test10(int a[static 0]) {}
-// NULL-INVALID: define void @test10(i32* nonnull %a)
-// NULL-VALID: define void @test10(i32* %a)
+// NULL-INVALID: define void @test10(i32* nonnull align 4 %a)
+// NULL-VALID: define void @test10(i32* align 4 %a)
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -2520,6 +2520,9 @@
 // bytes).
 if (ArrTy->getSizeModifier() == ArrayType::Static) {
   QualType ETy = ArrTy->getElementType();
+  llvm::Align Alignment =
+  CGM.getNaturalTypeAlignment(ETy).getAsAlign();
+  AI->addAttrs(llvm::AttrBuilder().addAlignmentAttr(Alignment));
   uint64_t ArrSize = ArrTy->getSize().getZExtValue();
   if (!ETy->isIncompleteType() && ETy->isConstantSizeType() &&
   

[PATCH] D83261: [OPENMP]Redesign of OMPExecutableDirective representation.

2020-08-18 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D83261#2224619 , @cchen wrote:

> In PR45212 comment 5 (https://bugs.llvm.org/show_bug.cgi?id=45212#c5), there 
> is a reduced test case that failed after adding this patch. The assertion is 
> from OMPChildren::getInnermostCapturedStmt.
>
> Test case:
>
>   #include 
>   #include 
>   #include 
>   
>   class Myclass
>   {
> public:
> double A[10];
> double B[10];
>   
> void add(int i)
> {
>   for (int k = 0; k < 10; k++) {
>   #pragma omp atomic
> B[k] += A[i];
>   }
> }
>   };
>   
>   int main(int argc, char* argv[]){
> Myclass foo;
>
> for (int i = 0; i < 10; i++) {
> foo.A[i] = i;
> foo.B[i] = 0;
> }
>   
>   #pragma omp target teams distribute parallel for
> for (int i = 0; i < 10; i++) {
> foo.add(i);
> }
>   
> printf("Correctness check: B[2]= %f \n",foo.B[2]);
> return 0;
>   }
>
> Backtrace:
>
>   Assertion failed: (isa(Val) && "cast() argument of incompatible 
> type!"), function cast, file 
> /Users/cchen/workspace/llvm-project/llvm/include/llvm/Support/Casting.h, line 
> 269.
>   PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash 
> backtrace, preprocessed source, and associated run script.
>   Stack dump:
>   0.  Program arguments: /Users/cchen/llvm/bin/clang-10 -cc1 -triple nvptx64 
> -aux-triple x86_64-apple-darwin18.7.0 -Wundef-prefix=TARGET_OS_ 
> -Werror=undef-prefix -Wdeprecated-objc-isa-usage 
> -Werror=deprecated-objc-isa-usage -emit-llvm -disable-free -main-file-name 
> test.cpp -mrelocation-model static -mframe-pointer=all -fno-rounding-math 
> -fno-verbose-asm -no-integrated-as 
> -fcompatibility-qualified-id-block-type-checking -target-cpu sm_35 
> -fno-split-dwarf-inlining -debugger-tuning=gdb -target-linker-version 512.4 
> -resource-dir /Users/cchen/llvm/lib/clang/12.0.0 -internal-isystem 
> /Users/cchen/llvm/lib/clang/12.0.0/include/openmp_wrappers -include 
> __clang_openmp_device_functions.h -internal-isystem 
> /Users/cchen/llvm/bin/../include/c++/v1 -internal-isystem /usr/include/c++/v1 
> -internal-isystem /Users/cchen/llvm/bin/../include/c++/v1 -internal-isystem 
> /usr/include/c++/v1 -internal-isystem /usr/local/include -internal-isystem 
> /Users/cchen/llvm/lib/clang/12.0.0/include -internal-externc-isystem 
> /usr/include -internal-isystem /usr/local/include -internal-isystem 
> /Users/cchen/llvm/lib/clang/12.0.0/include -internal-externc-isystem 
> /usr/include -fdeprecated-macro -fno-dwarf-directory-asm 
> -fdebug-compilation-dir /Users/cchen/workspace/llvm-project/bugfix/45212 
> -ferror-limit 19 -fopenmp -fopenmp-version=50 
> -fopenmp-cuda-parallel-target-regions -fgnuc-version=4.2.1 -fcxx-exceptions 
> -fexceptions -fcolor-diagnostics -fopenmp-is-device 
> -fopenmp-host-ir-file-path 
> /var/folders/rx/8phxx7k53pqghv8kjxkbv2ch006fcl/T/test-c282ef.bc -o 
> /var/folders/rx/8phxx7k53pqghv8kjxkbv2ch006fcl/T/test-f0824e.ll -x c++ 
> test.cpp
>   1.  test.cpp:20:1: current parser token 'int'
>   2.  test.cpp:5:7: LLVM IR generation of declaration 'Myclass'
>   0  clang-10 0x000108bead4c 
> llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 60
>   1  clang-10 0x000108beb309 
> PrintStackTraceSignalHandler(void*) + 25
>   2  clang-10 0x000108be8c46 
> llvm::sys::RunSignalHandlers() + 118
>   3  clang-10 0x000108bed070 SignalHandler(int) + 208
>   4  libsystem_platform.dylib 0x7fff7bd98b5d _sigtramp + 29
>   5  clang-10 0x00010fdc6ae2 
> llvm::DenseMapInfo::Tombstone + 2998754
>   6  libsystem_c.dylib0x7fff7bc526a6 abort + 127
>   7  libsystem_c.dylib0x7fff7bc1b20d basename_r + 0
>   8  clang-10 0x00010e908344 
> llvm::cast_retty::ret_type 
> llvm::cast(clang::Stmt*) + 100
>   9  clang-10 0x00010d4097b3 
> clang::OMPChildren::getInnermostCapturedStmt(llvm::ArrayRef)
>  + 227
>   10 clang-10 0x00010d3f67d5 
> clang::OMPExecutableDirective::getInnermostCapturedStmt() + 197
>   11 clang-10 0x00010959a555 
> clang::OMPExecutableDirective::getInnermostCapturedStmt() const + 21
>   12 clang-10 0x000109599d89 
> clang::CodeGen::CGOpenMPRuntime::scanForTargetRegionsFunctions(clang::Stmt 
> const*, llvm::StringRef) + 1305
>   13 clang-10 0x000109599eab 
> clang::CodeGen::CGOpenMPRuntime::scanForTargetRegionsFunctions(clang::Stmt 
> const*, llvm::StringRef) + 1595
>   14 clang-10 0x000109599eab 
> clang::CodeGen::CGOpenMPRuntime::scanForTargetRegionsFunctions(clang::Stmt 
> const*, llvm::StringRef) + 1595
>   15 clang-10 0x000109599eab 
> clang::CodeGen::CGOpenMPRuntime::scanForTargetRegionsFunctions(clang::Stmt 
> const*, llvm::StringRef) + 1595
>   16 

[PATCH] D83261: [OPENMP]Redesign of OMPExecutableDirective representation.

2020-08-18 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen added a comment.

In PR45212 comment 5 (https://bugs.llvm.org/show_bug.cgi?id=45212#c5), there is 
a reduced test case that failed after adding this patch. The assertion is from 
OMPChildren::getInnermostCapturedStmt.

Test case:

  #include 
  #include 
  #include 
  
  class Myclass
  {
public:
  double A[10];
  double B[10];
  
void add(int i)
{
  for (int k = 0; k < 10; k++) {
  #pragma omp atomic
B[k] += A[i];
  }
}
  };
  
  int main(int argc, char* argv[]){
Myclass foo;
   
for (int i = 0; i < 10; i++) {
foo.A[i] = i;
foo.B[i] = 0;
}
  
  #pragma omp target teams distribute parallel for
for (int i = 0; i < 10; i++) {
foo.add(i);
}
  
printf("Correctness check: B[2]= %f \n",foo.B[2]);
return 0;
  }

Backtrace:

  Assertion failed: (isa(Val) && "cast() argument of incompatible 
type!"), function cast, file 
/Users/cchen/workspace/llvm-project/llvm/include/llvm/Support/Casting.h, line 
269.
  PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash 
backtrace, preprocessed source, and associated run script.
  Stack dump:
  0.Program arguments: /Users/cchen/llvm/bin/clang-10 -cc1 -triple nvptx64 
-aux-triple x86_64-apple-darwin18.7.0 -Wundef-prefix=TARGET_OS_ 
-Werror=undef-prefix -Wdeprecated-objc-isa-usage 
-Werror=deprecated-objc-isa-usage -emit-llvm -disable-free -main-file-name 
test.cpp -mrelocation-model static -mframe-pointer=all -fno-rounding-math 
-fno-verbose-asm -no-integrated-as 
-fcompatibility-qualified-id-block-type-checking -target-cpu sm_35 
-fno-split-dwarf-inlining -debugger-tuning=gdb -target-linker-version 512.4 
-resource-dir /Users/cchen/llvm/lib/clang/12.0.0 -internal-isystem 
/Users/cchen/llvm/lib/clang/12.0.0/include/openmp_wrappers -include 
__clang_openmp_device_functions.h -internal-isystem 
/Users/cchen/llvm/bin/../include/c++/v1 -internal-isystem /usr/include/c++/v1 
-internal-isystem /Users/cchen/llvm/bin/../include/c++/v1 -internal-isystem 
/usr/include/c++/v1 -internal-isystem /usr/local/include -internal-isystem 
/Users/cchen/llvm/lib/clang/12.0.0/include -internal-externc-isystem 
/usr/include -internal-isystem /usr/local/include -internal-isystem 
/Users/cchen/llvm/lib/clang/12.0.0/include -internal-externc-isystem 
/usr/include -fdeprecated-macro -fno-dwarf-directory-asm 
-fdebug-compilation-dir /Users/cchen/workspace/llvm-project/bugfix/45212 
-ferror-limit 19 -fopenmp -fopenmp-version=50 
-fopenmp-cuda-parallel-target-regions -fgnuc-version=4.2.1 -fcxx-exceptions 
-fexceptions -fcolor-diagnostics -fopenmp-is-device -fopenmp-host-ir-file-path 
/var/folders/rx/8phxx7k53pqghv8kjxkbv2ch006fcl/T/test-c282ef.bc -o 
/var/folders/rx/8phxx7k53pqghv8kjxkbv2ch006fcl/T/test-f0824e.ll -x c++ test.cpp
  1.test.cpp:20:1: current parser token 'int'
  2.test.cpp:5:7: LLVM IR generation of declaration 'Myclass'
  0  clang-10 0x000108bead4c 
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 60
  1  clang-10 0x000108beb309 
PrintStackTraceSignalHandler(void*) + 25
  2  clang-10 0x000108be8c46 llvm::sys::RunSignalHandlers() 
+ 118
  3  clang-10 0x000108bed070 SignalHandler(int) + 208
  4  libsystem_platform.dylib 0x7fff7bd98b5d _sigtramp + 29
  5  clang-10 0x00010fdc6ae2 
llvm::DenseMapInfo::Tombstone + 2998754
  6  libsystem_c.dylib0x7fff7bc526a6 abort + 127
  7  libsystem_c.dylib0x7fff7bc1b20d basename_r + 0
  8  clang-10 0x00010e908344 
llvm::cast_retty::ret_type 
llvm::cast(clang::Stmt*) + 100
  9  clang-10 0x00010d4097b3 
clang::OMPChildren::getInnermostCapturedStmt(llvm::ArrayRef)
 + 227
  10 clang-10 0x00010d3f67d5 
clang::OMPExecutableDirective::getInnermostCapturedStmt() + 197
  11 clang-10 0x00010959a555 
clang::OMPExecutableDirective::getInnermostCapturedStmt() const + 21
  12 clang-10 0x000109599d89 
clang::CodeGen::CGOpenMPRuntime::scanForTargetRegionsFunctions(clang::Stmt 
const*, llvm::StringRef) + 1305
  13 clang-10 0x000109599eab 
clang::CodeGen::CGOpenMPRuntime::scanForTargetRegionsFunctions(clang::Stmt 
const*, llvm::StringRef) + 1595
  14 clang-10 0x000109599eab 
clang::CodeGen::CGOpenMPRuntime::scanForTargetRegionsFunctions(clang::Stmt 
const*, llvm::StringRef) + 1595
  15 clang-10 0x000109599eab 
clang::CodeGen::CGOpenMPRuntime::scanForTargetRegionsFunctions(clang::Stmt 
const*, llvm::StringRef) + 1595
  16 clang-10 0x00010959a6f0 
clang::CodeGen::CGOpenMPRuntime::emitTargetFunctions(clang::GlobalDecl) + 320
  17 clang-10 0x00010959b97e 
clang::CodeGen::CGOpenMPRuntime::emitTargetGlobal(clang::GlobalDecl) + 142
  18 clang-10 0x00010973c53e 

[PATCH] D86164: [OPENMP]Fix PR47158, case 2: do not report host-only functions in unused function in device mode.

2020-08-18 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D86164#2224577 , @jdoerfert wrote:

> LGTM, nit: Is there a "not" missing in the the commit message?

Yes, will add it, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86164

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


[PATCH] D86116: [Coverage] Adjust skipped regions only if {Prev,Next}TokLoc is in the same file as regions' {start, end}Loc

2020-08-18 Thread Vedant Kumar via Phabricator via cfe-commits
vsk accepted this revision.
vsk added a comment.
This revision is now accepted and ready to land.

Lgtm, thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86116

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


[PATCH] D85384: [X86] Add basic support for -mtune command line option in clang

2020-08-18 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM with one minor comment




Comment at: clang/test/Misc/target-invalid-cpu-note.c:49
+
+// RUN: not %clang_cc1 -triple x86_64--- -tune-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix TUNE_X86_64
+// TUNE_X86_64: error: unknown target CPU 'not-a-cpu'

Should we have a test for tune-cpu for some non-x86 target?  Or are we happy to 
just assume this works correctly because we already have coverage for 
target-cpu?


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

https://reviews.llvm.org/D85384

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


[clang] 6b1f9f2 - [X86] Don't call SemaBuiltinConstantArg from CheckX86BuiltinTileDuplicate if Argument is Type or Value Dependent.

2020-08-18 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2020-08-18T12:33:40-07:00
New Revision: 6b1f9f2bd4437910804d571284b7c5bb66eac250

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

LOG: [X86] Don't call SemaBuiltinConstantArg from CheckX86BuiltinTileDuplicate 
if Argument is Type or Value Dependent.

SemaBuiltinConstantArg has an early exit for that case that doesn't
produce an error and doesn't update the APInt. We need to detect that
case and not use the APInt value.

While there delete the signature of CheckX86BuiltinTileArgumentsRange
that takes a single Argument index to check. There's another version
that takes an ArrayRef and single value is convertible to an ArrayRef.

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaChecking.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 1d12551a8ad2..19d58b889ef7 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -12192,7 +12192,6 @@ class Sema final {
   bool CheckX86BuiltinTileArguments(unsigned BuiltinID, CallExpr *TheCall);
   bool CheckX86BuiltinTileArgumentsRange(CallExpr *TheCall,
  ArrayRef ArgNums);
-  bool CheckX86BuiltinTileArgumentsRange(CallExpr *TheCall, int ArgNum);
   bool CheckX86BuiltinTileDuplicate(CallExpr *TheCall, ArrayRef ArgNums);
   bool CheckX86BuiltinTileRangeAndDuplicate(CallExpr *TheCall,
 ArrayRef ArgNums);

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 70d3a682fc70..deceffdb0ba5 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -3705,7 +3705,7 @@ bool Sema::CheckX86BuiltinGatherScatterScale(unsigned 
BuiltinID,
 enum { TileRegLow = 0, TileRegHigh = 7 };
 
 bool Sema::CheckX86BuiltinTileArgumentsRange(CallExpr *TheCall,
-ArrayRef ArgNums) {
+ ArrayRef ArgNums) {
   for (int ArgNum : ArgNums) {
 if (SemaBuiltinConstantArgRange(TheCall, ArgNum, TileRegLow, TileRegHigh))
   return true;
@@ -3713,19 +3713,20 @@ bool Sema::CheckX86BuiltinTileArgumentsRange(CallExpr 
*TheCall,
   return false;
 }
 
-bool Sema::CheckX86BuiltinTileArgumentsRange(CallExpr *TheCall, int ArgNum) {
-  return SemaBuiltinConstantArgRange(TheCall, ArgNum, TileRegLow, TileRegHigh);
-}
-
 bool Sema::CheckX86BuiltinTileDuplicate(CallExpr *TheCall,
 ArrayRef ArgNums) {
   // Because the max number of tile register is TileRegHigh + 1, so here we use
   // each bit to represent the usage of them in bitset.
   std::bitset ArgValues;
   for (int ArgNum : ArgNums) {
-llvm::APSInt Arg;
-SemaBuiltinConstantArg(TheCall, ArgNum, Arg);
-int ArgExtValue = Arg.getExtValue();
+Expr *Arg = TheCall->getArg(ArgNum);
+if (Arg->isTypeDependent() || Arg->isValueDependent())
+  continue;
+
+llvm::APSInt Result;
+if (SemaBuiltinConstantArg(TheCall, ArgNum, Result))
+  return true;
+int ArgExtValue = Result.getExtValue();
 assert((ArgExtValue >= TileRegLow || ArgExtValue <= TileRegHigh) &&
"Incorrect tile register num.");
 if (ArgValues.test(ArgExtValue))



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


[PATCH] D84988: [Coverage] Add empty line regions to SkippedRegions

2020-08-18 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added inline comments.



Comment at: llvm/lib/ProfileData/Coverage/CoverageMapping.cpp:483
   bool GapRegion = CR.value().Kind == CounterMappingRegion::GapRegion;
 
   if (CR.index() + 1 == Regions.size() ||

zequanwu wrote:
> vsk wrote:
> > Why is this deletion necessary? Do we need to introduce 0-length regions 
> > which alter the count? An example would help.
> Because a single empty line will be a 0 length region. I don't know why is 
> this condition necessary before. Does zero-length region exists before this 
> change?
> 
> example:
> ```
> int main() {
> 
>   return 0;
> }
> ```
> Before, llvm-cov gives the following.
> ```
> Counter in file 0 1:12 -> 4:2, #0
> Counter in file 0 2:1 -> 2:1, 0
> Emitting segments for file: /tmp/a.c
> Combined regions:
>   1:12 -> 4:2 (count=1)
>   2:1 -> 2:1 (count=0)
> Segment at 1:12 (count = 1), RegionEntry
> Segment at 2:1 (count = 0), RegionEntry, Skipped
> Segment at 4:2 (count = 0), Skipped
> 1|  1|int main() {
> 2|   |
> 3|   |return 0;
> 4|   |}
> ```
> After:
> ```
> Counter in file 0 1:12 -> 4:2, #0
> Counter in file 0 2:1 -> 2:1, 0
> Emitting segments for file: /tmp/a.c
> Combined regions:
>   1:12 -> 4:2 (count=1)
>   2:1 -> 2:1 (count=0)
> Segment at 1:12 (count = 1), RegionEntry
> Segment at 2:1 (count = 0), RegionEntry, Skipped
> Segment at 2:1 (count = 1)
> Segment at 4:2 (count = 0), Skipped
> 1|  1|int main() {
> 2|   |
> 3|  1|return 0;
> 4|  1|}
> ```
It looks like we do occasionally see 0-length regions, possibly due to bugs in 
the frontend 
(http://lab.llvm.org:8080/coverage/coverage-reports/coverage/Users/buildslave/jenkins/workspace/coverage/llvm-project/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp.html#L485).

I don't expect the reporting tools to be able to handle duplicate segments in a 
robust way. Having duplicate segments was the source of "messed up" coverage 
bugs in the past, due to the contradiction inherent in having two different 
segments begin at the same source location.

Do you see some other way to represent empty lines? Perhaps, if we emit a 
skipped region for an empty line, we can emit a follow-up segment that restores 
the previously-active region starting on the next line? So in this case:

Segment at 1:12 (count = 1), RegionEntry
Segment at 2:1 (count = 0), RegionEntry, Skipped
Segment at 3:1 (count = 1)
Segment at 4:2 (count = 0), Skipped


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84988

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


[PATCH] D85384: [X86] Add basic support for -mtune command line option in clang

2020-08-18 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:1752
   StringRef TargetCPU = getTarget().getTargetOpts().CPU;
+  StringRef TuneCPU = getTarget().getTargetOpts().TuneCPU;
   std::vector Features;

erichkeane wrote:
> craig.topper wrote:
> > erichkeane wrote:
> > > Does this lead to a situation in 'attribute-target' where we have a 
> > > 'tune' setting to a processor that is 'before' the 'TargetCPU'?  Should 
> > > this enforce some sort of hierarchy to make sure we only do it if it is 
> > > 'newer' (read, more feature rich) than the target?
> > TuneCPU is only supposed to control microarchitectural things like should i 
> > prefer an "ADD 1" over "INC" instruction. Or should I use more immediate 
> > controlled shuffles over a single variable controlled shuffle. As such that 
> > things we get from tune don't have a straightforward relationship with 
> > architectural features.
> My concern is more.  Say:
> 
> TargetCPU == "nahalem"
> 
> Does it make sense for 
> TuneCPU == "pentium"?
> 
> It would seem to me that is pretty nonsensical.  I've definitely seen the 
> reverse (in within x86_64 at least, where Tune is newer than Target), but 
> tuning for an older CPU seems like nonsense.
From a behavior standpoint, its not any different than what this does today

-march=pentium -msse4.2 -mpopcnt -mfxsr 


I don't think gcc enforces any ordering.  



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

https://reviews.llvm.org/D85384

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


[PATCH] D86164: [OPENMP]Fix PR47158, case 2: do not report host-only functions in unused function in device mode.

2020-08-18 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

LGTM, nit: Is there a "not" missing in the the commit message?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86164

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


[PATCH] D86164: [OPENMP]Fix PR47158, case 2: do not report host-only functions in unused function in device mode.

2020-08-18 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added reviewers: jdoerfert, cchen.
Herald added subscribers: guansong, yaxunl.
Herald added a project: clang.
ABataev requested review of this revision.
Herald added a subscriber: sstefan1.

If the function is not marked exlicitly as declare target and it calls
function(s), marked as declare target device_type(host), these host-only
functions should be dignosed as used in device mode, if the caller
function is not used in device mode too.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86164

Files:
  clang/lib/Sema/Sema.cpp
  clang/test/OpenMP/declare_target_messages.cpp


Index: clang/test/OpenMP/declare_target_messages.cpp
===
--- clang/test/OpenMP/declare_target_messages.cpp
+++ clang/test/OpenMP/declare_target_messages.cpp
@@ -167,7 +167,7 @@
 #pragma omp declare target to(bazzz) device_type(nohost) // omp45-error 
{{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}}
 void any() {bazz();} // host5-error {{function with 'device_type(nohost)' is 
not available on host}}
 void host1() {bazz();} // host5-error {{function with 'device_type(nohost)' is 
not available on host}}
-#pragma omp declare target to(host1) device_type(host) // omp45-error 
{{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}} 
dev5-note 4 {{marked as 'device_type(host)' here}}
+#pragma omp declare target to(host1) device_type(host) // omp45-error 
{{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}} 
dev5-note 3 {{marked as 'device_type(host)' here}}
 void host2() {bazz();} //host5-error {{function with 'device_type(nohost)' is 
not available on host}}
 #pragma omp declare target to(host2)
 void device() {host1();} // dev5-error {{function with 'device_type(host)' is 
not available on device}}
@@ -183,7 +183,7 @@
 #pragma omp end declare target
 
 void any5() {any();}
-void any6() {host1();} // dev5-error {{function with 'device_type(host)' is 
not available on device}}
+void any6() {host1();}
 void any7() {device();} // host5-error {{function with 'device_type(nohost)' 
is not available on host}}
 void any8() {any2();}
 
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1551,7 +1551,8 @@
 S.shouldIgnoreInHostDeviceCheck(FD) || InUsePath.count(FD))
   return;
 // Finalize analysis of OpenMP-specific constructs.
-if (Caller && S.LangOpts.OpenMP && UsePath.size() == 1)
+if (Caller && S.LangOpts.OpenMP && UsePath.size() == 1 &&
+(ShouldEmitRootNode || InOMPDeviceContext))
   S.finalizeOpenMPDelayedAnalysis(Caller, FD, Loc);
 if (Caller)
   S.DeviceKnownEmittedFns[FD] = {Caller, Loc};


Index: clang/test/OpenMP/declare_target_messages.cpp
===
--- clang/test/OpenMP/declare_target_messages.cpp
+++ clang/test/OpenMP/declare_target_messages.cpp
@@ -167,7 +167,7 @@
 #pragma omp declare target to(bazzz) device_type(nohost) // omp45-error {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}}
 void any() {bazz();} // host5-error {{function with 'device_type(nohost)' is not available on host}}
 void host1() {bazz();} // host5-error {{function with 'device_type(nohost)' is not available on host}}
-#pragma omp declare target to(host1) device_type(host) // omp45-error {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}} dev5-note 4 {{marked as 'device_type(host)' here}}
+#pragma omp declare target to(host1) device_type(host) // omp45-error {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}} dev5-note 3 {{marked as 'device_type(host)' here}}
 void host2() {bazz();} //host5-error {{function with 'device_type(nohost)' is not available on host}}
 #pragma omp declare target to(host2)
 void device() {host1();} // dev5-error {{function with 'device_type(host)' is not available on device}}
@@ -183,7 +183,7 @@
 #pragma omp end declare target
 
 void any5() {any();}
-void any6() {host1();} // dev5-error {{function with 'device_type(host)' is not available on device}}
+void any6() {host1();}
 void any7() {device();} // host5-error {{function with 'device_type(nohost)' is not available on host}}
 void any8() {any2();}
 
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1551,7 +1551,8 @@
 S.shouldIgnoreInHostDeviceCheck(FD) || InUsePath.count(FD))
   return;
 // Finalize analysis of OpenMP-specific constructs.
-if (Caller && S.LangOpts.OpenMP && UsePath.size() == 1)
+if (Caller && S.LangOpts.OpenMP && UsePath.size() == 1 &&
+(ShouldEmitRootNode || InOMPDeviceContext))
   S.finalizeOpenMPDelayedAnalysis(Caller, FD, Loc);
 if (Caller)
   

[PATCH] D82118: [clang][module] Improve incomplete-umbrella warning

2020-08-18 Thread Zixu Wang via Phabricator via cfe-commits
zixuw added a comment.

Hey Bruno! Thanks for the review.

In D82118#2224423 , @bruno wrote:

> Hi Zixu, thanks for working on improving this.
>
> I agree with @vsapsai on the the `GenModuleActionWrapper` approach. Also, it 
> seems to me that even though it would somehow improve the accuracy, it would 
> be solving a more general problem, not really specific to this patch.

Yes the wrapper is definitely problematic. I'm checking how the diagnostic 
itself is handled correctly and start from there when I have time. For now 
would it be better to separate this into multiple patches and get the 
diagnostic improvement in first?




Comment at: 
clang/test/Modules/Inputs/incomplete-umbrella/normal-module/Umbrella.h:1-3
+// Umbrella.h
+// CHECK: #import "A1.h"
+// CHECK: #import "A2.h"

> What about `CHECK`s for the introduced fix-its? I don't see a `#include` or 
> `#import` being matched in the tests.

Is this the check you're looking for? It is checked in 
`incomplete-umbrella-fixit.m`:
```
RUN: %clang_cc1 -fmodules -fmodule-map-file=%t/module.modulemap 
-fmodules-cache-path=%t -Wno-everything -Wincomplete-umbrella -fixit %s && 
FileCheck %t/Umbrella.h --input-file %t/Umbrella.h --match-full-lines
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82118

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


[PATCH] D80263: [HeaderSearch] Fix processing #import-ed headers multiple times with modules enabled.

2020-08-18 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno accepted this revision.
bruno added a comment.
This revision is now accepted and ready to land.

Nice catch! LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80263

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


[PATCH] D85150: [OpenMP] Ensure testing for versions 4.5 and default - Part 2

2020-08-18 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam added a comment.

Please let me know if there are any changes/suggestions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85150

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


[PATCH] D85981: [clang][Modules] Use File Names Instead of inodes As Loaded Module Keys

2020-08-18 Thread Robert Widmann via Phabricator via cfe-commits
CodaFi updated this revision to Diff 286361.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85981

Files:
  clang/include/clang/Serialization/ModuleManager.h
  clang/lib/Serialization/ModuleManager.cpp

Index: clang/lib/Serialization/ModuleManager.cpp
===
--- clang/lib/Serialization/ModuleManager.cpp
+++ clang/lib/Serialization/ModuleManager.cpp
@@ -59,7 +59,7 @@
 }
 
 ModuleFile *ModuleManager::lookup(const FileEntry *File) const {
-  auto Known = Modules.find(File);
+  auto Known = Modules.find(EntryKey{File});
   if (Known == Modules.end())
 return nullptr;
 
@@ -72,7 +72,7 @@
/*CacheFailure=*/false);
   if (!Entry)
 return nullptr;
-  return std::move(InMemoryBuffers[*Entry]);
+  return std::move(InMemoryBuffers[EntryKey{*Entry}]);
 }
 
 static bool checkSignature(ASTFileSignature Signature,
@@ -133,7 +133,7 @@
   }
 
   // Check whether we already loaded this module, before
-  if (ModuleFile *ModuleEntry = Modules.lookup(Entry)) {
+  if (ModuleFile *ModuleEntry = Modules.lookup(EntryKey{Entry})) {
 // Check the stored signature.
 if (checkSignature(ModuleEntry->Signature, ExpectedSignature, ErrorStr))
   return OutOfDate;
@@ -208,7 +208,7 @@
 return OutOfDate;
 
   // We're keeping this module.  Store it everywhere.
-  Module = Modules[Entry] = NewModule.get();
+  Module = Modules[EntryKey{Entry}] = NewModule.get();
 
   updateModuleImports(*NewModule, ImportedBy, ImportLoc);
 
@@ -255,7 +255,7 @@
 
   // Delete the modules and erase them from the various structures.
   for (ModuleIterator victim = First; victim != Last; ++victim) {
-Modules.erase(victim->File);
+Modules.erase(EntryKey{victim->File});
 
 if (modMap) {
   StringRef ModuleName = victim->ModuleName;
@@ -274,7 +274,7 @@
  std::unique_ptr Buffer) {
   const FileEntry *Entry =
   FileMgr.getVirtualFile(FileName, Buffer->getBufferSize(), 0);
-  InMemoryBuffers[Entry] = std::move(Buffer);
+  InMemoryBuffers[EntryKey{Entry}] = std::move(Buffer);
 }
 
 ModuleManager::VisitState *ModuleManager::allocateVisitState() {
Index: clang/include/clang/Serialization/ModuleManager.h
===
--- clang/include/clang/Serialization/ModuleManager.h
+++ clang/include/clang/Serialization/ModuleManager.h
@@ -59,8 +59,40 @@
   // to implement short-circuiting logic when running DFS over the dependencies.
   SmallVector Roots;
 
+  struct EntryKey {
+const FileEntry *Entry;
+
+struct Info {
+  static inline EntryKey getEmptyKey() {
+return EntryKey{llvm::DenseMapInfo::getEmptyKey()};
+  }
+  static inline EntryKey getTombstoneKey() {
+return EntryKey{
+llvm::DenseMapInfo::getTombstoneKey()};
+  }
+  static unsigned getHashValue(const EntryKey ) {
+return llvm::DenseMapInfo::getHashValue(Val.Entry);
+  }
+  static bool isEqual(const EntryKey , const EntryKey ) {
+if (LHS.Entry == getEmptyKey().Entry ||
+LHS.Entry == getTombstoneKey().Entry ||
+RHS.Entry == getEmptyKey().Entry ||
+RHS.Entry == getTombstoneKey().Entry) {
+  return LHS.Entry == RHS.Entry;
+}
+if (LHS.Entry == nullptr || RHS.Entry == nullptr) {
+  return LHS.Entry == RHS.Entry;
+}
+return LHS.Entry == RHS.Entry &&
+   LHS.Entry->getSize() == RHS.Entry->getSize() &&
+   LHS.Entry->getModificationTime() ==
+   RHS.Entry->getModificationTime();
+  }
+};
+  };
+
   /// All loaded modules, indexed by name.
-  llvm::DenseMap Modules;
+  llvm::DenseMap Modules;
 
   /// FileManager that handles translating between filenames and
   /// FileEntry *.
@@ -76,7 +108,7 @@
   const HeaderSearch 
 
   /// A lookup of in-memory (virtual file) buffers
-  llvm::DenseMap>
+  llvm::DenseMap, EntryKey::Info>
   InMemoryBuffers;
 
   /// The visitation order.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82118: [clang][module] Improve incomplete-umbrella warning

2020-08-18 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

Hi Zixu, thanks for working on improving this.

I agree with @vsapsai on the the `GenModuleActionWrapper` approach. Also, it 
seems to me that even though it would somehow improve the accuracy, it would be 
solving a more general problem, not really specific to this patch. What about 
`CHECK`s for the introduced fix-its? I don't see a `#include` or `#import` 
being matched in the tests.




Comment at: clang/lib/Lex/PPLexerChange.cpp:299
+  ? Twine{"#import \"" + RelativePath + "\"\n"}.str()
+  : Twine{"#include \"" + RelativePath + "\"\n"}.str();
+  unsigned EndOffset = SourceMgr.getDecomposedLoc(EndLoc).second;

Is it possible to incorporate the string selection as part of the diagnostic 
description in the `.td` file?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82118

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


[PATCH] D86156: [BFI] Preserve BFI information through loop passes via VH callbacks inside LoopStandardAnalysisResults

2020-08-18 Thread Di Mo via Phabricator via cfe-commits
modimo created this revision.
modimo added reviewers: wenlei, asbirlea, vsk.
modimo added a project: LLVM.
Herald added subscribers: llvm-commits, cfe-commits, dexonsmith, steven_wu, 
hiraditya.
Herald added a project: clang.
modimo requested review of this revision.

D65060  uncovered that trying to use BFI in 
loop passes can lead to non-deterministic behavior when blocks are re-used 
while retaining old BFI data.

To make sure BFI is preserved through loop passes a Value Handle (VH) callback 
is registered on blocks themselves. When a block is freed it now also wipes out 
the accompanying BFI entry such that stale BFI data can no longer persist 
resolving the determinism issue.

An optimistic approach would be to incrementally update BFI information 
throughout the loop passes rather than only invalidating them on removed 
blocks. The issues with that are:

1. It is not clear how BFI information should be incrementally updated: If a 
block is duplicated does its BFI information come with? How about if it's 
split/modified/moved around?
2. Assuming we can address these problems the implementation here will be a 
massive undertaking.

There's a known need of BFI in LICM analysis which requires correct but not 
incrementally updated BFI data. Other loop passes can now also use this level 
of information and richer updates can be made as needed.

This diff also moves BFI to be a part of LoopStandardAnalysisResults since the 
previous method using getCachedResults now (correctly!) statically asserts 
(D72893 ) that this data isn't static through 
the loop passes.

Testing
Ninja check


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86156

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/include/llvm/Analysis/BlockFrequencyInfo.h
  llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
  llvm/include/llvm/Analysis/LoopAnalysisManager.h
  llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
  llvm/lib/Analysis/BlockFrequencyInfo.cpp
  llvm/lib/Transforms/Scalar/LoopDistribute.cpp
  llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
  llvm/lib/Transforms/Utils/LoopVersioning.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/test/Other/loop-pm-invalidation.ll
  llvm/test/Other/new-pass-manager.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/pass-pipelines.ll
  llvm/test/Transforms/LoopRotate/pr35210.ll
  llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp

Index: llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
===
--- llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
+++ llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
@@ -10,6 +10,9 @@
 #include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Analysis/AssumptionCache.h"
 #include "llvm/Analysis/MemorySSA.h"
+#include "llvm/Analysis/BlockFrequencyInfo.h"
+#include "llvm/Analysis/BranchProbabilityInfo.h"
+#include "llvm/Analysis/PostDominators.h"
 #include "llvm/Analysis/ScalarEvolution.h"
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
@@ -294,6 +297,9 @@
 // those.
 FAM.registerPass([&] { return AAManager(); });
 FAM.registerPass([&] { return AssumptionAnalysis(); });
+FAM.registerPass([&] { return BlockFrequencyAnalysis(); });
+FAM.registerPass([&] { return BranchProbabilityAnalysis(); });
+FAM.registerPass([&] { return PostDominatorTreeAnalysis(); });
 FAM.registerPass([&] { return MemorySSAAnalysis(); });
 FAM.registerPass([&] { return ScalarEvolutionAnalysis(); });
 FAM.registerPass([&] { return TargetLibraryAnalysis(); });
Index: llvm/test/Transforms/LoopRotate/pr35210.ll
===
--- llvm/test/Transforms/LoopRotate/pr35210.ll
+++ llvm/test/Transforms/LoopRotate/pr35210.ll
@@ -19,12 +19,15 @@
 ; CHECK-NEXT: Running analysis: TargetLibraryAnalysis on f
 ; CHECK-NEXT: Running analysis: ScalarEvolutionAnalysis on f
 ; CHECK-NEXT: Running analysis: TargetIRAnalysis on f
+; CHECK-NEXT: Running analysis: BlockFrequencyAnalysis on f
+; CHECK-NEXT: Running analysis: BranchProbabilityAnalysis on f
 ; CHECK-NEXT: Running analysis: InnerAnalysisManagerProxy{{.*}} on f
 ; CHECK-NEXT: Starting Loop pass manager run.
 ; CHECK-NEXT: Running pass: LoopRotatePass on Loop at depth 1 containing: %bb,%bb4
 ; CHECK-NEXT: Folding loop latch bb4 into bb
 ; CHECK-NEXT: Finished Loop pass manager run.
 ; CHECK-NEXT: Invalidating analysis: PostDominatorTreeAnalysis on f
+; CHECK-NEXT: Invalidating analysis: BranchProbabilityAnalysis on f
 ; CHECK-NEXT: Running pass: ADCEPass on f
 ; CHECK-NEXT: Running analysis: PostDominatorTreeAnalysis on f
 ; CHECK-NEXT: Finished llvm::Function pass manager run.
@@ -44,12 +47,15 @@
 ; MSSA-NEXT: Running analysis: TargetLibraryAnalysis on f
 ; MSSA-NEXT: 

[PATCH] D83088: Introduce CfgTraits abstraction

2020-08-18 Thread Nicolai Hähnle via Phabricator via cfe-commits
nhaehnle added a comment.

> Not sure that's the best place to be designing this fairly integral and 
> complicated piece of infrastructure from, but hoping we can find some good 
> places/solutions/etc.

I sent an email to llvm-dev several weeks ago, but things seem to have moved 
here. Either way is fine with me.

> But I guess coming back to the original/broader design: What problems is this 
> intended to solve? The inability to write non-template algorithms over 
> graphs? What cost does that come with? Are there algorithms that are a bit 
> too complicated/unwieldy when done as templates? 
> If it's specifically the static/dynamic dispatch issue - I'm not sure the 
> type erasure and runtime overhead may be worth the tradeoff here, though if 
> it is - it'd be good to keep the non-dynamic version common, rather than now 
> having GraphTraits and CfgTraits done a bit differently, etc.

It's not just over graphs, but taking SSA values into account as well -- that 
is the key distinction between GraphTraits and CfgTraits. The most immediate 
problem is divergence analysis, which is extremely complex and difficult to get 
right. If I had tried to fight the accidental complexity that comes with 
attempting to write such an algorithm as C++ templates in addition to the 
inherent complexity of the algorithm at the same time, I'm not sure I would 
have been able to produce anything workable at all.

Frankly, I suspect that our dominator tree implementation also suffer because 
of this, though at least dominator trees are much more well studied in the 
academic literature, so that helps keep the inherent complexity under control.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83088

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


[PATCH] D86154: AMDGPU: Add llvm.amdgcn.{read,readfirst,write}lane2 intrinsics with type overloads

2020-08-18 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D86154#2224270 , @nhaehnle wrote:

> Note that part of my motivation here over D84639 
>  is to support more general types on the 
> lane intrinsics, since they also express some semantic content which would be 
> interesting to be able to express e.g. on descriptors. I wasn't able to bend 
> the SelectionDAG type legalization to my will, so that's why I instead 
> "legalize" the intrinsics in the AMDGPUCodeGenPrepare pass.

Don't you just need to handle this in ReplaceNodeResults the same way?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86154

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


[PATCH] D86154: AMDGPU: Add llvm.amdgcn.{read,readfirst,write}lane2 intrinsics with type overloads

2020-08-18 Thread Nicolai Hähnle via Phabricator via cfe-commits
nhaehnle added a comment.

Note that part of my motivation here over D84639 
 is to support more general types on the lane 
intrinsics, since they also express some semantic content which would be 
interesting to be able to express e.g. on descriptors. I wasn't able to bend 
the SelectionDAG type legalization to my will, so that's why I instead 
"legalize" the intrinsics in the AMDGPUCodeGenPrepare pass.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86154

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


[PATCH] D84458: [Modules] Improve error message when cannot find parent module for submodule definition.

2020-08-18 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno accepted this revision.
bruno added a comment.
This revision is now accepted and ready to land.

LGTM as is, minor suggestion below.




Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:700
+  "no module named '%0' %select{found|in '%2'}1, "
+  "expected parent module to be defined before the submodule">;
 def err_mmap_top_level_inferred_submodule : Error<

vsapsai wrote:
> Not sure about this second part of the message ("expected..."). Wanted to 
> make it more actionable but not entirely happy with the wording. Any 
> suggestions including removal are welcome.
How about `, parent module must be defined before the submodule`? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84458

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


[PATCH] D84736: [analyzer] Handle pointer difference of ElementRegion and SymbolicRegion

2020-08-18 Thread Balázs Benics via Phabricator via cfe-commits
steakhal updated this revision to Diff 286318.
steakhal marked 4 inline comments as done.
steakhal retitled this revision from "[analyzer][RFC] Handle pointer difference 
of ElementRegion and SymbolicRegion" to "[analyzer] Handle pointer difference 
of ElementRegion and SymbolicRegion".
steakhal edited the summary of this revision.
steakhal added a comment.

- Refined documentation comments as noted.
- Added tests.
- Removed the complicated `ByteOffsetOfElement` lambda.
- Rename revision.

---

Before this patch, only these reported `Unknown` instead of the currently 
expected value.
Besides that all tests passed as-is on master:

  clang_analyzer_dump_int(p - p0);   // expected-warning {{0 S32b}}
  clang_analyzer_dump_int(p - p1);   // expected-warning {{-1 S32b}}
  clang_analyzer_dump_int(p - pn);   // expected-warning-re {{0 - 
(reg_${{[0-9]+}})}}
  clang_analyzer_dump_int((p + 1) - p);  // expected-warning {{1 S32b}}
  
  // Swapped operands:
  clang_analyzer_dump_int(p0 - p);   // expected-warning {{0 S32b}}
  clang_analyzer_dump_int(p1 - p);   // expected-warning {{1 S32b}}
  clang_analyzer_dump_int(pn - p);   // expected-warning-re 
{{reg_${{[0-9]+
  clang_analyzer_dump_int(p - (p + 1));  // expected-warning {{-1 S32b}}



---

Further notes:
Element{X, n, Ty1} and Element{X, m, Ty2} should compare equal if and only if 
the `n * sizeof(Ty1)` equals to `n * sizeof(Ty2)`.
However, previously it did not take the size of the types into account (there 
is the corresponding FIXIT).
I'm not fixing this either for now.

The analyzer returns `Unknown` for this call:
clang_analyzer_dump_int((p + 1) - q);
However, IMO it should hold the expression 'p+1+q' instead - regardless of `p` 
alias (or not) the same memory region of `p`
There is a FIXME in the testcode for this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84736

Files:
  clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  clang/test/Analysis/pointer-arithmetic.c

Index: clang/test/Analysis/pointer-arithmetic.c
===
--- clang/test/Analysis/pointer-arithmetic.c
+++ clang/test/Analysis/pointer-arithmetic.c
@@ -1,4 +1,9 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false -verify %s
+
+void clang_analyzer_eval(int);
+void clang_analyzer_dump_ptr(int *);
+void clang_analyzer_dump_int(int);
 
 int test1() {
   int *p = (int *)sizeof(int);
@@ -28,3 +33,88 @@
   p += 1;
   return *p; // expected-warning {{Dereference of null pointer}}
 }
+
+void simplify_symregion_and_elementregion_pointer_arithmetic_and_comparison(int *p, int n, int m, int *q) {
+  // 'q' is SymReg{q}
+  // 'p' is SymReg{p}
+  int *p1 = p + 1;  // Element{p,1}
+  int *p0 = p1 - 1; // Element{p,0}
+  int *pn = p + n;  // Element{p,n}
+  int *pm = p + m;  // Element{p,m}
+
+  clang_analyzer_dump_ptr(q);
+  clang_analyzer_dump_ptr(p);
+  clang_analyzer_dump_ptr(p0);
+  clang_analyzer_dump_ptr(p1);
+  clang_analyzer_dump_ptr(pn);
+  clang_analyzer_dump_ptr(pm);
+  // expected-warning-re@-6 {{{reg_${{[0-9]+}
+  // expected-warning-re@-6 {{{reg_${{[0-9]+}
+  // expected-warning-re@-6 {{{SymRegion{reg_${{[0-9]+}}},0 S64b,int
+  // expected-warning-re@-6 {{{SymRegion{reg_${{[0-9]+}}},1 S64b,int}}}
+  // expected-warning-re@-6 {{{SymRegion{reg_${{[0-9]+}}},reg_${{[0-9]+}},int}}}
+  // expected-warning-re@-6 {{{SymRegion{reg_${{[0-9]+}}},reg_${{[0-9]+}},int}}}
+
+  // Test the equality operator:
+  clang_analyzer_eval(p == p0);  // expected-warning {{TRUE}}
+  clang_analyzer_eval(p == p1);  // expected-warning {{FALSE}}
+  clang_analyzer_eval(p1 == pn); // expected-warning {{UNKNOWN}}
+  clang_analyzer_eval(pn == pm); // expected-warning {{UNKNOWN}}
+
+  // Reverse operands:
+  clang_analyzer_eval(p0 == p);  // expected-warning {{TRUE}}
+  clang_analyzer_eval(p1 == p);  // expected-warning {{FALSE}}
+  clang_analyzer_eval(pn == p1); // expected-warning {{UNKNOWN}}
+  clang_analyzer_eval(pm == pn); // expected-warning {{UNKNOWN}}
+
+  // Test the inequality operator:
+  clang_analyzer_eval(p != p0);  // expected-warning {{FALSE}}
+  clang_analyzer_eval(p != p1);  // expected-warning {{TRUE}}
+  clang_analyzer_eval(p1 != pn); // expected-warning {{UNKNOWN}}
+  clang_analyzer_eval(pn != pm); // expected-warning {{UNKNOWN}}
+
+  // Reverse operands:
+  clang_analyzer_eval(p0 != p);  // expected-warning {{FALSE}}
+  clang_analyzer_eval(p1 != p);  // expected-warning {{TRUE}}
+  clang_analyzer_eval(pn != p1); // expected-warning {{UNKNOWN}}
+  clang_analyzer_eval(pm != pn); // expected-warning {{UNKNOWN}}
+
+  // Test the subtraction operator:
+  clang_analyzer_dump_int(p - q);// expected-warning-re {{(reg_${{[0-9]+}}) - (reg_${{[0-9]+}})}}
+  clang_analyzer_dump_int(p - p);   

[PATCH] D86154: AMDGPU: Add llvm.amdgcn.{read,readfirst,write}lane2 intrinsics with type overloads

2020-08-18 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

Do we really have to use worse names here? Keeping the name works even if 
suboptimal for the attributes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86154

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


[PATCH] D86154: AMDGPU: Add llvm.amdgcn.{read,readfirst,write}lane2 intrinsics with type overloads

2020-08-18 Thread Nicolai Hähnle via Phabricator via cfe-commits
nhaehnle created this revision.
nhaehnle added a reviewer: arsenm.
Herald added subscribers: cfe-commits, kerbowa, jfb, hiraditya, t-tye, tpr, 
dstuttard, yaxunl, jvesely, kzhuravl.
Herald added projects: clang, LLVM.
nhaehnle requested review of this revision.
Herald added a subscriber: wdng.

These intrinsics should work at least with standard integer and floating
point sizes, pointers, and vectors of those.

This fixes selection for non-s32 types when readfirstlane is inserted
for SGPR return values.

Moving the atomic optimizer pass in the pass pipeline so that it can be
simplified and rely on the more general support of lane intrinsics.

API users should move to these new intrinsics so that we can remove the
old versions.

Change-Id: I1c5e7e7858890e1c30d3b46c8551e74ab7027552
Based-on: https://reviews.llvm.org/D84639


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86154

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGenOpenCL/builtins-amdgcn.cl
  llvm/include/llvm/IR/IntrinsicsAMDGPU.td
  llvm/lib/Target/AMDGPU/AMDGPUAtomicOptimizer.cpp
  llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
  llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp
  llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
  llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
  llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
  llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
  llvm/lib/Target/AMDGPU/AMDGPUSearchableTables.td
  llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
  llvm/lib/Target/AMDGPU/SIISelLowering.cpp
  llvm/lib/Target/AMDGPU/SIInstructions.td
  llvm/lib/Target/AMDGPU/VOP1Instructions.td
  llvm/lib/Target/AMDGPU/VOP2Instructions.td
  llvm/test/CodeGen/AMDGPU/GlobalISel/inst-select-amdgcn.readfirstlane.mir
  llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-amdgpu_ps.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-amdgpu_vs.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-amdgcn.readfirstlane.mir
  llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-amdgcn.readlane.mir
  llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-amdgcn.s.buffer.load.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-amdgcn.writelane.mir
  llvm/test/CodeGen/AMDGPU/llvm.amdgcn.readfirstlane.ll
  llvm/test/CodeGen/AMDGPU/llvm.amdgcn.readlane.ll
  llvm/test/CodeGen/AMDGPU/llvm.amdgcn.writelane.ll
  llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll

Index: llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll
===
--- llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll
+++ llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll
@@ -2507,8 +2507,8 @@
 
 define amdgpu_kernel void @readfirstlane_constant(i32 %arg) {
 ; CHECK-LABEL: @readfirstlane_constant(
-; CHECK-NEXT:[[VAR:%.*]] = call i32 @llvm.amdgcn.readfirstlane(i32 [[ARG:%.*]])
-; CHECK-NEXT:store volatile i32 [[VAR]], i32* undef, align 4
+; CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.amdgcn.readfirstlane2.i32(i32 [[ARG:%.*]])
+; CHECK-NEXT:store volatile i32 [[TMP1]], i32* undef, align 4
 ; CHECK-NEXT:store volatile i32 0, i32* undef, align 4
 ; CHECK-NEXT:store volatile i32 123, i32* undef, align 4
 ; CHECK-NEXT:store volatile i32 ptrtoint (i32* @gv to i32), i32* undef, align 4
@@ -2530,8 +2530,8 @@
 
 define i32 @readfirstlane_idempotent(i32 %arg) {
 ; CHECK-LABEL: @readfirstlane_idempotent(
-; CHECK-NEXT:[[READ0:%.*]] = call i32 @llvm.amdgcn.readfirstlane(i32 [[ARG:%.*]])
-; CHECK-NEXT:ret i32 [[READ0]]
+; CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.amdgcn.readfirstlane2.i32(i32 [[ARG:%.*]])
+; CHECK-NEXT:ret i32 [[TMP1]]
 ;
   %read0 = call i32 @llvm.amdgcn.readfirstlane(i32 %arg)
   %read1 = call i32 @llvm.amdgcn.readfirstlane(i32 %read0)
@@ -2541,8 +2541,8 @@
 
 define i32 @readfirstlane_readlane(i32 %arg) {
 ; CHECK-LABEL: @readfirstlane_readlane(
-; CHECK-NEXT:[[READ0:%.*]] = call i32 @llvm.amdgcn.readfirstlane(i32 [[ARG:%.*]])
-; CHECK-NEXT:ret i32 [[READ0]]
+; CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.amdgcn.readfirstlane2.i32(i32 [[ARG:%.*]])
+; CHECK-NEXT:ret i32 [[TMP1]]
 ;
   %read0 = call i32 @llvm.amdgcn.readfirstlane(i32 %arg)
   %read1 = call i32 @llvm.amdgcn.readlane(i32 %read0, i32 0)
@@ -2552,11 +2552,11 @@
 define i32 @readfirstlane_readfirstlane_different_block(i32 %arg) {
 ; CHECK-LABEL: @readfirstlane_readfirstlane_different_block(
 ; CHECK-NEXT:  bb0:
-; CHECK-NEXT:[[READ0:%.*]] = call i32 @llvm.amdgcn.readfirstlane(i32 [[ARG:%.*]])
+; CHECK-NEXT:[[TMP0:%.*]] = call i32 @llvm.amdgcn.readfirstlane2.i32(i32 [[ARG:%.*]])
 ; CHECK-NEXT:br label [[BB1:%.*]]
 ; CHECK:   bb1:
-; CHECK-NEXT:[[READ1:%.*]] = call i32 @llvm.amdgcn.readfirstlane(i32 [[READ0]])
-; CHECK-NEXT:ret i32 [[READ1]]
+; CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.amdgcn.readfirstlane2.i32(i32 [[TMP0]])
+; CHECK-NEXT:ret i32 [[TMP1]]
 ;
 

[PATCH] D84736: [analyzer] Handle pointer difference of ElementRegion and SymbolicRegion

2020-08-18 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: clang/test/Analysis/pointer-arithmetic.c:88
+  clang_analyzer_dump_int(p - pn);   // expected-warning-re {{0 - 
(reg_${{[0-9]+}})}}
+  clang_analyzer_dump_int((p + 1) - q);  // expected-warning {{Unknown}} // 
FIXME: Might point to the same region, we should hold the expression 'p+1+q' 
instead.
+  clang_analyzer_dump_int((p + 1) - p);  // expected-warning {{1 S32b}}

The suggested expression should be `p+1-q`.



Comment at: clang/test/Analysis/pointer-arithmetic.c:100
+  clang_analyzer_dump_int(pn - p);   // expected-warning-re 
{{reg_${{[0-9]+
+  clang_analyzer_dump_int(q - (p + 1));  // expected-warning {{Unknown}} // 
FIXME: Might point to the same region, we should hold the expression 'p+1+q' 
instead.
+  clang_analyzer_dump_int(p - (p + 1));  // expected-warning {{-1 S32b}}

The suggested expression should be `q-p+1`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84736

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


[PATCH] D84736: [analyzer] Handle pointer difference of ElementRegion and SymbolicRegion

2020-08-18 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: clang/test/Analysis/pointer-arithmetic.c:88
+  clang_analyzer_dump_int(p - pn);   // expected-warning-re {{0 - 
(reg_${{[0-9]+}})}}
+  clang_analyzer_dump_int((p + 1) - q);  // expected-warning {{Unknown}} // 
FIXME: Might point to the same region, we should hold the expression 'p+1+q' 
instead.
+  clang_analyzer_dump_int((p + 1) - p);  // expected-warning {{1 S32b}}

steakhal wrote:
> The suggested expression should be `p+1-q`.
xD more like `(p+1)-q`



Comment at: clang/test/Analysis/pointer-arithmetic.c:100
+  clang_analyzer_dump_int(pn - p);   // expected-warning-re 
{{reg_${{[0-9]+
+  clang_analyzer_dump_int(q - (p + 1));  // expected-warning {{Unknown}} // 
FIXME: Might point to the same region, we should hold the expression 'p+1+q' 
instead.
+  clang_analyzer_dump_int(p - (p + 1));  // expected-warning {{-1 S32b}}

steakhal wrote:
> The suggested expression should be `q-p+1`.
`q-(p+1)`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84736

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


[PATCH] D85981: [clang][Modules] Use File Names Instead of inodes As Loaded Module Keys

2020-08-18 Thread Robert Widmann via Phabricator via cfe-commits
CodaFi added a comment.

Switched tactics here. Rather than just change the source of the entropy, let's 
increase it from just inodes to (64-bits of inode) plus (file size) plus (mod 
time). It is still possible to defeat this scheme, but it means an attacker 
would have to replace the PCM with one that has been padded out to the same 
size then backdate its modtime to match the one in the cache - or some 
cascading failure of the syscalls providing these data conspires to make this 
happen.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85981

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


[PATCH] D85981: [clang][Modules] Use File Names Instead of inodes As Loaded Module Keys

2020-08-18 Thread Robert Widmann via Phabricator via cfe-commits
CodaFi updated this revision to Diff 286334.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85981

Files:
  clang/include/clang/Serialization/ModuleManager.h
  clang/lib/Serialization/ModuleManager.cpp

Index: clang/lib/Serialization/ModuleManager.cpp
===
--- clang/lib/Serialization/ModuleManager.cpp
+++ clang/lib/Serialization/ModuleManager.cpp
@@ -59,7 +59,7 @@
 }
 
 ModuleFile *ModuleManager::lookup(const FileEntry *File) const {
-  auto Known = Modules.find(File);
+  auto Known = Modules.find(EntryKey{File});
   if (Known == Modules.end())
 return nullptr;
 
@@ -72,7 +72,7 @@
/*CacheFailure=*/false);
   if (!Entry)
 return nullptr;
-  return std::move(InMemoryBuffers[*Entry]);
+  return std::move(InMemoryBuffers[EntryKey{*Entry}]);
 }
 
 static bool checkSignature(ASTFileSignature Signature,
@@ -133,7 +133,7 @@
   }
 
   // Check whether we already loaded this module, before
-  if (ModuleFile *ModuleEntry = Modules.lookup(Entry)) {
+  if (ModuleFile *ModuleEntry = Modules.lookup(EntryKey{Entry})) {
 // Check the stored signature.
 if (checkSignature(ModuleEntry->Signature, ExpectedSignature, ErrorStr))
   return OutOfDate;
@@ -208,7 +208,7 @@
 return OutOfDate;
 
   // We're keeping this module.  Store it everywhere.
-  Module = Modules[Entry] = NewModule.get();
+  Module = Modules[EntryKey{Entry}] = NewModule.get();
 
   updateModuleImports(*NewModule, ImportedBy, ImportLoc);
 
@@ -255,7 +255,7 @@
 
   // Delete the modules and erase them from the various structures.
   for (ModuleIterator victim = First; victim != Last; ++victim) {
-Modules.erase(victim->File);
+Modules.erase(EntryKey{victim->File});
 
 if (modMap) {
   StringRef ModuleName = victim->ModuleName;
@@ -274,7 +274,7 @@
  std::unique_ptr Buffer) {
   const FileEntry *Entry =
   FileMgr.getVirtualFile(FileName, Buffer->getBufferSize(), 0);
-  InMemoryBuffers[Entry] = std::move(Buffer);
+  InMemoryBuffers[EntryKey{Entry}] = std::move(Buffer);
 }
 
 ModuleManager::VisitState *ModuleManager::allocateVisitState() {
Index: clang/include/clang/Serialization/ModuleManager.h
===
--- clang/include/clang/Serialization/ModuleManager.h
+++ clang/include/clang/Serialization/ModuleManager.h
@@ -59,8 +59,36 @@
   // to implement short-circuiting logic when running DFS over the dependencies.
   SmallVector Roots;
 
+  struct EntryKey {
+const FileEntry *Entry;
+
+struct Info {
+  static inline EntryKey getEmptyKey() {
+return EntryKey{llvm::DenseMapInfo::getEmptyKey()};
+  }
+  static inline EntryKey getTombstoneKey() {
+return EntryKey{
+llvm::DenseMapInfo::getTombstoneKey()};
+  }
+  static unsigned getHashValue(const EntryKey ) {
+return llvm::hash_combine(Val.Entry, Val.Entry->getSize(),
+  Val.Entry->getModificationTime());
+  }
+  static bool isEqual(const EntryKey , const EntryKey ) {
+if (RHS.Entry == getEmptyKey().Entry)
+  return LHS.Entry == getEmptyKey().Entry;
+if (RHS.Entry == getTombstoneKey().Entry)
+  return LHS.Entry == getTombstoneKey().Entry;
+return LHS.Entry == RHS.Entry &&
+   LHS.Entry->getSize() == RHS.Entry->getSize() &&
+   LHS.Entry->getModificationTime() ==
+   RHS.Entry->getModificationTime();
+  }
+};
+  };
+
   /// All loaded modules, indexed by name.
-  llvm::DenseMap Modules;
+  llvm::DenseMap Modules;
 
   /// FileManager that handles translating between filenames and
   /// FileEntry *.
@@ -76,7 +104,7 @@
   const HeaderSearch 
 
   /// A lookup of in-memory (virtual file) buffers
-  llvm::DenseMap>
+  llvm::DenseMap, EntryKey::Info>
   InMemoryBuffers;
 
   /// The visitation order.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84049: Disable use of _ExtInt with '__atomic' builtins

2020-08-18 Thread Mott, Jeffrey T via Phabricator via cfe-commits
jtmott-intel added a comment.

Committed to master, and created bug to cherry pick into 11.0.

https://bugs.llvm.org/show_bug.cgi?id=47222


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84049

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


[PATCH] D84049: Disable use of _ExtInt with '__atomic' builtins

2020-08-18 Thread Mott, Jeffrey T via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGca77ab494aa2: Disable use of _ExtInt with 
__atomic builtins (authored by jtmott-intel).
Herald added projects: clang, libc++.
Herald added subscribers: libcxx-commits, cfe-commits.
Herald added a reviewer: libc++.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84049

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/Sema/builtins.c
  clang/test/SemaCXX/ext-int.cpp
  libcxx/test/libcxx/atomics/ext-int.verify.cpp

Index: libcxx/test/libcxx/atomics/ext-int.verify.cpp
===
--- /dev/null
+++ libcxx/test/libcxx/atomics/ext-int.verify.cpp
@@ -0,0 +1,11 @@
+// REQUIRES: clang-11
+
+#include 
+
+int main(int, char**)
+{
+  // expected-error@atomic:*1 {{_Atomic cannot be applied to integer type '_ExtInt(32)'}}
+  std::atomic<_ExtInt(32)> x {42};
+
+  return 0;
+}
Index: clang/test/SemaCXX/ext-int.cpp
===
--- clang/test/SemaCXX/ext-int.cpp
+++ clang/test/SemaCXX/ext-int.cpp
@@ -91,10 +91,11 @@
 _Complex _ExtInt(3) Cmplx;
 
 // Reject cases of _Atomic:
-// expected-error@+1{{_Atomic cannot be applied to integer type '_ExtInt(4)' with less than 1 byte of precision}}
+// expected-error@+1{{_Atomic cannot be applied to integer type '_ExtInt(4)'}}
 _Atomic _ExtInt(4) TooSmallAtomic;
-// expected-error@+1{{_Atomic cannot be applied to integer type '_ExtInt(9)' with a non power of 2 precision}}
+// expected-error@+1{{_Atomic cannot be applied to integer type '_ExtInt(9)'}}
 _Atomic _ExtInt(9) NotPow2Atomic;
+// expected-error@+1{{_Atomic cannot be applied to integer type '_ExtInt(128)'}}
 _Atomic _ExtInt(128) JustRightAtomic;
 
 // Test result types of Unary/Bitwise/Binary Operations:
Index: clang/test/Sema/builtins.c
===
--- clang/test/Sema/builtins.c
+++ clang/test/Sema/builtins.c
@@ -285,12 +285,16 @@
   __sync_fetch_and_add(ptr, value); // expected-error {{Atomic memory operand must have a power-of-two size}}
   // expected-warning@+1 {{the semantics of this intrinsic changed with GCC version 4.4 - the newer semantics are provided here}}
   __sync_nand_and_fetch(ptr, value); // expected-error {{Atomic memory operand must have a power-of-two size}}
+
+  __atomic_fetch_add(ptr, 1, 0); // expected-error {{argument to atomic builtin of type '_ExtInt' is not supported}}
 }
 
 void test_ei_i64i(_ExtInt(64) *ptr, int value) {
   __sync_fetch_and_add(ptr, value); // expect success
   // expected-warning@+1 {{the semantics of this intrinsic changed with GCC version 4.4 - the newer semantics are provided here}}
   __sync_nand_and_fetch(ptr, value); // expect success
+
+  __atomic_fetch_add(ptr, 1, 0); // expected-error {{argument to atomic builtin of type '_ExtInt' is not supported}}
 }
 
 void test_ei_ii42(int *ptr, _ExtInt(42) value) {
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -8963,11 +8963,8 @@
 else if (!T.isTriviallyCopyableType(Context))
   // Some other non-trivially-copyable type (probably a C++ class)
   DisallowedKind = 7;
-else if (auto *ExtTy = T->getAs()) {
-  if (ExtTy->getNumBits() < 8)
+else if (T->isExtIntType()) {
 DisallowedKind = 8;
-  else if (!llvm::isPowerOf2_32(ExtTy->getNumBits()))
-DisallowedKind = 9;
 }
 
 if (DisallowedKind != -1) {
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -5050,6 +5050,11 @@
 ? 0
 : 1);
 
+  if (ValType->isExtIntType()) {
+Diag(Ptr->getExprLoc(), diag::err_atomic_builtin_ext_int_prohibit);
+return ExprError();
+  }
+
   return AE;
 }
 
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6038,9 +6038,8 @@
 def err_atomic_specifier_bad_type
 : Error<"_Atomic cannot be applied to "
 "%select{incomplete |array |function |reference |atomic |qualified "
-"|sizeless ||integer |integer }0type "
-"%1 %select{|||which is not trivially copyable|with less than "
-"1 byte of precision|with a non power of 2 precision}0">;
+"|sizeless ||integer }0type "
+"%1 %select{|||which is not trivially copyable|}0">;
 
 // Expressions.
 def ext_sizeof_alignof_function_type : Extension<
@@ -7967,6 +7966,8 @@
   " 1,2,4 or 8 byte type (%0 

[PATCH] D86146: [ARM][BFloat16] Change types of some Arm and AArch64 bf16 intrinsics

2020-08-18 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki created this revision.
miyuki added reviewers: dmgreen, simon_tatham, ostannard.
Herald added subscribers: llvm-commits, cfe-commits, danielkiss, hiraditya, 
kristof.beyls.
Herald added projects: clang, LLVM.
miyuki requested review of this revision.

This patch adjusts the following ARM/AArch64 LLVM IR intrinsics:

- neon_bfmmla
- neon_bfmlalb
- neon_bfmlalt

so that they take and return bf16 and float types. Previously these
intrinsics used <8 x i8> and <4 x i8> vectors (a rudiment from
implementation lacking bf16 IR type).

This patch makes the generated IR cleaner (less useless bitcasts are
produced), but it does not affect the final assembly.

This patch does not touch the dot product intrinsics yet because they
require some changes in the shuffle pattern recognition.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86146

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-bf16-dotprod-intrinsics.c
  clang/test/CodeGen/arm-bf16-dotprod-intrinsics.c
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/AArch64/AArch64InstrFormats.td
  llvm/lib/Target/ARM/ARMInstrNEON.td
  llvm/test/CodeGen/AArch64/aarch64-bf16-dotprod-intrinsics.ll
  llvm/test/CodeGen/ARM/arm-bf16-dotprod-intrinsics.ll

Index: llvm/test/CodeGen/ARM/arm-bf16-dotprod-intrinsics.ll
===
--- llvm/test/CodeGen/ARM/arm-bf16-dotprod-intrinsics.ll
+++ llvm/test/CodeGen/ARM/arm-bf16-dotprod-intrinsics.ll
@@ -89,10 +89,8 @@
 ; CHECK-NEXT:vmmla.bf16 q0, q1, q2
 ; CHECK-NEXT:bx lr
 entry:
-  %0 = bitcast <8 x bfloat> %a to <16 x i8>
-  %1 = bitcast <8 x bfloat> %b to <16 x i8>
-  %vbfmmla1.i = call <4 x float> @llvm.arm.neon.bfmmla.v4f32.v16i8(<4 x float> %r, <16 x i8> %0, <16 x i8> %1)
-  ret <4 x float> %vbfmmla1.i
+  %vbfmmlaq_v3.i = call <4 x float> @llvm.arm.neon.bfmmla(<4 x float> %r, <8 x bfloat> %a, <8 x bfloat> %b)
+  ret <4 x float> %vbfmmlaq_v3.i
 }
 
 define <4 x float> @test_vbfmlalbq_f32(<4 x float> %r, <8 x bfloat> %a, <8 x bfloat> %b) {
@@ -101,10 +99,8 @@
 ; CHECK-NEXT:vfmab.bf16 q0, q1, q2
 ; CHECK-NEXT:bx lr
 entry:
-  %0 = bitcast <8 x bfloat> %a to <16 x i8>
-  %1 = bitcast <8 x bfloat> %b to <16 x i8>
-  %vbfmlalb1.i = call <4 x float> @llvm.arm.neon.bfmlalb.v4f32.v16i8(<4 x float> %r, <16 x i8> %0, <16 x i8> %1)
-  ret <4 x float> %vbfmlalb1.i
+  %vbfmlalbq_v3.i = call <4 x float> @llvm.arm.neon.bfmlalb(<4 x float> %r, <8 x bfloat> %a, <8 x bfloat> %b)
+  ret <4 x float> %vbfmlalbq_v3.i
 }
 
 define <4 x float> @test_vbfmlaltq_f32(<4 x float> %r, <8 x bfloat> %a, <8 x bfloat> %b) {
@@ -113,10 +109,8 @@
 ; CHECK-NEXT:vfmat.bf16 q0, q1, q2
 ; CHECK-NEXT:bx lr
 entry:
-  %0 = bitcast <8 x bfloat> %a to <16 x i8>
-  %1 = bitcast <8 x bfloat> %b to <16 x i8>
-  %vbfmlalt1.i = call <4 x float> @llvm.arm.neon.bfmlalt.v4f32.v16i8(<4 x float> %r, <16 x i8> %0, <16 x i8> %1)
-  ret <4 x float> %vbfmlalt1.i
+  %vbfmlaltq_v3.i = call <4 x float> @llvm.arm.neon.bfmlalt(<4 x float> %r, <8 x bfloat> %a, <8 x bfloat> %b)
+  ret <4 x float> %vbfmlaltq_v3.i
 }
 
 define <4 x float> @test_vbfmlalbq_lane_f32(<4 x float> %r, <8 x bfloat> %a, <4 x bfloat> %b) {
@@ -127,10 +121,8 @@
 ; CHECK-NEXT:bx lr
 entry:
   %vecinit35 = shufflevector <4 x bfloat> %b, <4 x bfloat> undef, <8 x i32> zeroinitializer
-  %0 = bitcast <8 x bfloat> %a to <16 x i8>
-  %1 = bitcast <8 x bfloat> %vecinit35 to <16 x i8>
-  %vbfmlalb1.i = call <4 x float> @llvm.arm.neon.bfmlalb.v4f32.v16i8(<4 x float> %r, <16 x i8> %0, <16 x i8> %1)
-  ret <4 x float> %vbfmlalb1.i
+  %vbfmlalbq_v3.i = call <4 x float> @llvm.arm.neon.bfmlalb(<4 x float> %r, <8 x bfloat> %a, <8 x bfloat> %vecinit35)
+  ret <4 x float> %vbfmlalbq_v3.i
 }
 
 define <4 x float> @test_vbfmlalbq_laneq_f32(<4 x float> %r, <8 x bfloat> %a, <8 x bfloat> %b) {
@@ -140,10 +132,8 @@
 ; CHECK-NEXT:bx lr
 entry:
   %vecinit35 = shufflevector <8 x bfloat> %b, <8 x bfloat> undef, <8 x i32> 
-  %0 = bitcast <8 x bfloat> %a to <16 x i8>
-  %1 = bitcast <8 x bfloat> %vecinit35 to <16 x i8>
-  %vbfmlalb1.i = call <4 x float> @llvm.arm.neon.bfmlalb.v4f32.v16i8(<4 x float> %r, <16 x i8> %0, <16 x i8> %1)
-  ret <4 x float> %vbfmlalb1.i
+  %vbfmlalbq_v3.i = call <4 x float> @llvm.arm.neon.bfmlalb(<4 x float> %r, <8 x bfloat> %a, <8 x bfloat> %vecinit35)
+  ret <4 x float> %vbfmlalbq_v3.i
 }
 
 define <4 x float> @test_vbfmlaltq_lane_f32(<4 x float> %r, <8 x bfloat> %a, <4 x bfloat> %b) {
@@ -154,10 +144,8 @@
 ; CHECK-NEXT:bx lr
 entry:
   %vecinit35 = shufflevector <4 x bfloat> %b, <4 x bfloat> undef, <8 x i32> zeroinitializer
-  %0 = bitcast <8 x bfloat> %a to <16 x i8>
-  %1 = bitcast <8 x bfloat> %vecinit35 to <16 x i8>
-  %vbfmlalt1.i = call <4 x float> @llvm.arm.neon.bfmlalt.v4f32.v16i8(<4 x float> %r, <16 x i8> %0, <16 x i8> %1)
-  ret <4 x float> %vbfmlalt1.i
+  %vbfmlaltq_v3.i = call <4 x float> @llvm.arm.neon.bfmlalt(<4 x float> 

[clang] ca77ab4 - Disable use of _ExtInt with '__atomic' builtins

2020-08-18 Thread via cfe-commits

Author: Mott, Jeffrey T
Date: 2020-08-18T09:17:26-07:00
New Revision: ca77ab494aa29f7521ff797d230cd1b36cbe4e62

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

LOG: Disable use of _ExtInt with '__atomic' builtins

We're (temporarily) disabling ExtInt for the '__atomic' builtins so we can 
better design their behavior later. The idea is until we do an audit/design for 
the way atomic builtins are supposed to work with _ExtInt, we should leave them 
restricted so they don't limit our future options, such as by binding us to a 
sub-optimal implementation via ABI.

Example after this change:

$ cat test.c

void f(_ExtInt(64) *ptr) {
  __atomic_fetch_add(ptr, 1, 0);
}

$ clang -c test.c

test.c:2:22: error: argument to atomic builtin of type '_ExtInt' is not 
supported
  __atomic_fetch_add(ptr, 1, 0);
 ^
1 error generated.

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

Added: 
libcxx/test/libcxx/atomics/ext-int.verify.cpp

Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaType.cpp
clang/test/Sema/builtins.c
clang/test/SemaCXX/ext-int.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index fd21285b1f79..a63fae5b5f72 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6038,9 +6038,8 @@ def err_func_def_incomplete_result : Error<
 def err_atomic_specifier_bad_type
 : Error<"_Atomic cannot be applied to "
 "%select{incomplete |array |function |reference |atomic |qualified 
"
-"|sizeless ||integer |integer }0type "
-"%1 %select{|||which is not trivially copyable|with less than "
-"1 byte of precision|with a non power of 2 precision}0">;
+"|sizeless ||integer }0type "
+"%1 %select{|||which is not trivially copyable|}0">;
 
 // Expressions.
 def ext_sizeof_alignof_function_type : Extension<
@@ -7967,6 +7966,8 @@ def err_atomic_exclusive_builtin_pointer_size : Error<
   " 1,2,4 or 8 byte type (%0 invalid)">;
 def err_atomic_builtin_ext_int_size : Error<
   "Atomic memory operand must have a power-of-two size">;
+def err_atomic_builtin_ext_int_prohibit : Error<
+  "argument to atomic builtin of type '_ExtInt' is not supported">;
 def err_atomic_op_needs_atomic : Error<
   "address argument to atomic operation must be a pointer to _Atomic "
   "type (%0 invalid)">;

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 4efd62f58d2e..70d3a682fc70 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -5050,6 +5050,11 @@ ExprResult Sema::BuildAtomicExpr(SourceRange CallRange, 
SourceRange ExprRange,
 ? 0
 : 1);
 
+  if (ValType->isExtIntType()) {
+Diag(Ptr->getExprLoc(), diag::err_atomic_builtin_ext_int_prohibit);
+return ExprError();
+  }
+
   return AE;
 }
 

diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index b2be31ac0990..4ab5cc5fd8b9 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -8963,11 +8963,8 @@ QualType Sema::BuildAtomicType(QualType T, 
SourceLocation Loc) {
 else if (!T.isTriviallyCopyableType(Context))
   // Some other non-trivially-copyable type (probably a C++ class)
   DisallowedKind = 7;
-else if (auto *ExtTy = T->getAs()) {
-  if (ExtTy->getNumBits() < 8)
+else if (T->isExtIntType()) {
 DisallowedKind = 8;
-  else if (!llvm::isPowerOf2_32(ExtTy->getNumBits()))
-DisallowedKind = 9;
 }
 
 if (DisallowedKind != -1) {

diff  --git a/clang/test/Sema/builtins.c b/clang/test/Sema/builtins.c
index 4b445724f712..e4093edb5f00 100644
--- a/clang/test/Sema/builtins.c
+++ b/clang/test/Sema/builtins.c
@@ -285,12 +285,16 @@ void test_ei_i42i(_ExtInt(42) *ptr, int value) {
   __sync_fetch_and_add(ptr, value); // expected-error {{Atomic memory operand 
must have a power-of-two size}}
   // expected-warning@+1 {{the semantics of this intrinsic changed with GCC 
version 4.4 - the newer semantics are provided here}}
   __sync_nand_and_fetch(ptr, value); // expected-error {{Atomic memory operand 
must have a power-of-two size}}
+
+  __atomic_fetch_add(ptr, 1, 0); // expected-error {{argument to atomic 
builtin of type '_ExtInt' is not supported}}
 }
 
 void test_ei_i64i(_ExtInt(64) *ptr, int value) {
   __sync_fetch_and_add(ptr, value); // expect success
   // expected-warning@+1 {{the semantics of this intrinsic changed with GCC 
version 4.4 - the newer semantics are provided here}}
   

[PATCH] D86100: [Clang][SVE] NFC: Move info about ACLE types into separate function.

2020-08-18 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes accepted this revision.
c-rhodes added a comment.
This revision is now accepted and ready to land.

LGTM, just one minor nit but seems like a nice improvement




Comment at: clang/include/clang/AST/ASTContext.h:1318
+  BuiltinVectorTypeInfo
+  getElementTypeForBuiltinVector(const BuiltinType *VecTy) const;
+

nit: not sure on the name here since it's returning more than the element type, 
how about `getBuiltinVectorTypeInfo`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86100

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


[clang-tools-extra] 8c9ffe3 - [NFC][clang-tidy] Put abseil headers in alphabetical order

2020-08-18 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-08-18T15:52:47+01:00
New Revision: 8c9ffe34d932e2e17cbcf351d6e37783ea5453ae

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

LOG: [NFC][clang-tidy] Put abseil headers in alphabetical order

Added: 


Modified: 
clang-tools-extra/clang-tidy/abseil/AbseilMatcher.h

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/abseil/AbseilMatcher.h 
b/clang-tools-extra/clang-tidy/abseil/AbseilMatcher.h
index f58ff5bc44b2..335c333573f4 100644
--- a/clang-tools-extra/clang-tidy/abseil/AbseilMatcher.h
+++ b/clang-tools-extra/clang-tidy/abseil/AbseilMatcher.h
@@ -47,14 +47,18 @@ AST_POLYMORPHIC_MATCHER(
   if (PrefixPosition == StringRef::npos)
 return false;
   Path = Path.drop_front(PrefixPosition + AbslPrefix.size());
-  static const char *AbseilLibraries[] = {
-  "algorithm", "base", "container",   "debugging", "flags",
-  "hash",  "iterator", "memory",  "meta",  "numeric",
-  "random","strings",  "synchronization", "status","time",
-  "types", "utility"};
-  return std::any_of(
-  std::begin(AbseilLibraries), std::end(AbseilLibraries),
-  [&](const char *Library) { return Path.startswith(Library); });
+  static const char *AbseilLibraries[] = {"algorithm", "base",
+  "container", "debugging",
+  "flags", "hash",
+  "iterator",  "memory",
+  "meta",  "numeric",
+  "random","status",
+  "strings",   "synchronization",
+  "time",  "types",
+  "utility"};
+  return llvm::any_of(AbseilLibraries, [&](const char *Library) {
+return Path.startswith(Library);
+  });
 }
 
 } // namespace ast_matchers



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


[PATCH] D86135: [analyzer][MacroExpansion] Fix a crash where multiple parameters resolved to __VA_ARGS__

2020-08-18 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp:1226
+TStream.injextRange(
+const_cast(PrevParamMap)[__VA_ARGS__II]);
+TStream.next(TheTok);

Oh, this has to be fixed as well. `at()` should be fine, we messed something up 
really bad if the information we gathered from containing macro has no mention 
of `__VA_ARGS__`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86135

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


[PATCH] D86139: [SyntaxTree] Split tests related to Namespace

2020-08-18 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp:2151
+
+TEST_P(SyntaxTreeTest, Namepace_UsingDirective) {
+  if (!GetParam().isCXX()) {

I think grouping this test under Namespace_ is not the best choice, because 
what's being tested here is the `using`, not the `namespace`.



Comment at: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp:2171
+
+TEST_P(SyntaxTreeTest, Namespace_UsingDeclaration) {
+  if (!GetParam().isCXX()) {

Ditto.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86139

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


[PATCH] D86139: [SyntaxTree] Split tests related to Namespace

2020-08-18 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
eduucaldas requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86139

Files:
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp

Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -2081,7 +2081,7 @@
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, Namespaces) {
+TEST_P(SyntaxTreeTest, Namespace_Nested) {
   if (!GetParam().isCXX()) {
 return;
   }
@@ -2089,9 +2089,6 @@
   R"cpp(
 namespace a { namespace b {} }
 namespace a::b {}
-namespace {}
-
-namespace foo = a;
 )cpp",
   R"txt(
 *: TranslationUnit
@@ -2105,82 +2102,91 @@
 | | |-{
 | | `-}
 | `-}
-|-NamespaceDefinition
-| |-namespace
-| |-a
-| |-::
-| |-b
-| |-{
-| `-}
-|-NamespaceDefinition
-| |-namespace
-| |-{
-| `-}
-`-NamespaceAliasDefinition
+`-NamespaceDefinition
   |-namespace
-  |-foo
-  |-=
   |-a
-  `-;
+  |-::
+  |-b
+  |-{
+  `-}
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, UsingDirective) {
+TEST_P(SyntaxTreeTest, Namespace_Unnamed) {
   if (!GetParam().isCXX()) {
 return;
   }
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
-namespace ns {}
-using namespace ::ns;
+namespace {}
 )cpp",
   R"txt(
 *: TranslationUnit
-|-NamespaceDefinition
-| |-namespace
-| |-ns
-| |-{
-| `-}
-`-UsingNamespaceDirective
-  |-using
+`-NamespaceDefinition
   |-namespace
-  |-NestedNameSpecifier
-  | `-::
-  |-ns
-  `-;
+  |-{
+  `-}
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, UsingDeclaration) {
+TEST_P(SyntaxTreeTest, Namespace_Alias) {
   if (!GetParam().isCXX()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+  R"cpp(
+namespace a {}
+[[namespace foo = a;]]
+)cpp",
+  {R"txt(
+NamespaceAliasDefinition
+|-namespace
+|-foo
+|-=
+|-a
+`-;
+)txt"}));
+}
+
+TEST_P(SyntaxTreeTest, Namepace_UsingDirective) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+  R"cpp(
+namespace ns {}
+[[using namespace ::ns;]]
+)cpp",
+  {R"txt(
+UsingNamespaceDirective
+|-using
+|-namespace
+|-NestedNameSpecifier
+| `-::
+|-ns
+`-;
+)txt"}));
+}
+
+TEST_P(SyntaxTreeTest, Namespace_UsingDeclaration) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 namespace ns { int a; }
-using ns::a;
+[[using ns::a;]]
 )cpp",
-  R"txt(
-*: TranslationUnit
-|-NamespaceDefinition
-| |-namespace
-| |-ns
-| |-{
-| |-SimpleDeclaration
-| | |-int
-| | |-SimpleDeclarator
-| | | `-a
-| | `-;
-| `-}
-`-UsingDeclaration
-  |-using
-  |-NestedNameSpecifier
-  | |-IdentifierNameSpecifier
-  | | `-ns
-  | `-::
-  |-a
-  `-;
-)txt"));
+  {R"txt(
+UsingDeclaration
+|-using
+|-NestedNameSpecifier
+| |-IdentifierNameSpecifier
+| | `-ns
+| `-::
+|-a
+`-;
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, FreeStandingClasses) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86048: [AST][RecoveryExpr] Popagate the error-bit from a VarDecl's initializer to DeclRefExpr.

2020-08-18 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 286274.
hokein added a comment.

update.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86048

Files:
  clang/lib/AST/ComputeDependence.cpp
  clang/test/Sema/invalid-member.cpp
  clang/test/SemaCXX/invalid-template-base-specifier.cpp


Index: clang/test/SemaCXX/invalid-template-base-specifier.cpp
===
--- clang/test/SemaCXX/invalid-template-base-specifier.cpp
+++ clang/test/SemaCXX/invalid-template-base-specifier.cpp
@@ -26,3 +26,10 @@
 };
 
 void test3() { Crash3(); } // expected-note {{in instantiation of 
template class}}
+
+constexpr int N = undef; // expected-error {{use of undeclared identifier}}
+
+class Crash4 : decltype(N) {
+};
+
+static_assert(sizeof(Crash4) == 1, "");
Index: clang/test/Sema/invalid-member.cpp
===
--- clang/test/Sema/invalid-member.cpp
+++ clang/test/Sema/invalid-member.cpp
@@ -19,3 +19,10 @@
 };
 // Should be able to evaluate sizeof without crashing.
 static_assert(sizeof(Z) == 1, "No valid members");
+
+constexpr int N = undef; // expected-error {{use of undeclared identifier}}
+
+class T {
+  decltype(N) member;
+};
+static_assert(sizeof(T) == 1, "No valid members");
Index: clang/lib/AST/ComputeDependence.cpp
===
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -466,10 +466,12 @@
  : Var->getType()->isIntegralOrEnumerationType()) &&
 (Var->getType().isConstQualified() ||
  Var->getType()->isReferenceType())) {
-  if (const Expr *Init = Var->getAnyInitializer())
-if (Init->isValueDependent()) {
+  if (const Expr *Init = Var->getAnyInitializer()) {
+if (Init->isValueDependent())
   Deps |= ExprDependence::ValueInstantiation;
-}
+if (Init->containsErrors())
+  Deps |= ExprDependence::Error;
+  }
 }
 
 // (VD) - FIXME: Missing from the standard:


Index: clang/test/SemaCXX/invalid-template-base-specifier.cpp
===
--- clang/test/SemaCXX/invalid-template-base-specifier.cpp
+++ clang/test/SemaCXX/invalid-template-base-specifier.cpp
@@ -26,3 +26,10 @@
 };
 
 void test3() { Crash3(); } // expected-note {{in instantiation of template class}}
+
+constexpr int N = undef; // expected-error {{use of undeclared identifier}}
+
+class Crash4 : decltype(N) {
+};
+
+static_assert(sizeof(Crash4) == 1, "");
Index: clang/test/Sema/invalid-member.cpp
===
--- clang/test/Sema/invalid-member.cpp
+++ clang/test/Sema/invalid-member.cpp
@@ -19,3 +19,10 @@
 };
 // Should be able to evaluate sizeof without crashing.
 static_assert(sizeof(Z) == 1, "No valid members");
+
+constexpr int N = undef; // expected-error {{use of undeclared identifier}}
+
+class T {
+  decltype(N) member;
+};
+static_assert(sizeof(T) == 1, "No valid members");
Index: clang/lib/AST/ComputeDependence.cpp
===
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -466,10 +466,12 @@
  : Var->getType()->isIntegralOrEnumerationType()) &&
 (Var->getType().isConstQualified() ||
  Var->getType()->isReferenceType())) {
-  if (const Expr *Init = Var->getAnyInitializer())
-if (Init->isValueDependent()) {
+  if (const Expr *Init = Var->getAnyInitializer()) {
+if (Init->isValueDependent())
   Deps |= ExprDependence::ValueInstantiation;
-}
+if (Init->containsErrors())
+  Deps |= ExprDependence::Error;
+  }
 }
 
 // (VD) - FIXME: Missing from the standard:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D85762: [OPENMP]Do not allow threadprivates as base for array-like reduction.

2020-08-18 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 286272.
ABataev added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85762

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


Index: clang/test/OpenMP/parallel_reduction_messages.cpp
===
--- clang/test/OpenMP/parallel_reduction_messages.cpp
+++ clang/test/OpenMP/parallel_reduction_messages.cpp
@@ -92,6 +92,8 @@
 
 S3 h, k;
 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or 
thread local}}
+int *gptr;
+#pragma omp threadprivate(gptr) // expected-note {{defined as threadprivate or 
thread local}}
 
 template// expected-note {{declared here}}
 T tmain(T argc) {
@@ -277,6 +279,8 @@
   m++;
 #pragma omp parallel reduction(task, + : m) // omp45-error 2 {{expected 
expression}} omp45-warning {{missing ':' after reduction identifier - ignoring}}
   m++;
+#pragma omp parallel reduction(+:gptr[:argc]) // expected-error 
{{threadprivate or thread local variable cannot be reduction}}
+  ;
 
   return tmain(argc) + tmain(fl); // expected-note {{in instantiation of 
function template specialization 'tmain' requested here}} expected-note 
{{in instantiation of function template specialization 'tmain' requested 
here}}
 }
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -15116,6 +15116,17 @@
   continue;
 }
   }
+} else {
+  // Threadprivates cannot be shared between threads, so dignose if the 
base
+  // is a threadprivate variable.
+  DSAStackTy::DSAVarData DVar = Stack->getTopDSA(D, /*FromParent=*/false);
+  if (DVar.CKind == OMPC_threadprivate) {
+S.Diag(ELoc, diag::err_omp_wrong_dsa)
+<< getOpenMPClauseName(DVar.CKind)
+<< getOpenMPClauseName(OMPC_reduction);
+reportOriginalDsa(S, Stack, D, DVar);
+continue;
+  }
 }
 
 // Try to find 'declare reduction' corresponding construct before using


Index: clang/test/OpenMP/parallel_reduction_messages.cpp
===
--- clang/test/OpenMP/parallel_reduction_messages.cpp
+++ clang/test/OpenMP/parallel_reduction_messages.cpp
@@ -92,6 +92,8 @@
 
 S3 h, k;
 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
+int *gptr;
+#pragma omp threadprivate(gptr) // expected-note {{defined as threadprivate or thread local}}
 
 template// expected-note {{declared here}}
 T tmain(T argc) {
@@ -277,6 +279,8 @@
   m++;
 #pragma omp parallel reduction(task, + : m) // omp45-error 2 {{expected expression}} omp45-warning {{missing ':' after reduction identifier - ignoring}}
   m++;
+#pragma omp parallel reduction(+:gptr[:argc]) // expected-error {{threadprivate or thread local variable cannot be reduction}}
+  ;
 
   return tmain(argc) + tmain(fl); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}}
 }
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -15116,6 +15116,17 @@
   continue;
 }
   }
+} else {
+  // Threadprivates cannot be shared between threads, so dignose if the base
+  // is a threadprivate variable.
+  DSAStackTy::DSAVarData DVar = Stack->getTopDSA(D, /*FromParent=*/false);
+  if (DVar.CKind == OMPC_threadprivate) {
+S.Diag(ELoc, diag::err_omp_wrong_dsa)
+<< getOpenMPClauseName(DVar.CKind)
+<< getOpenMPClauseName(OMPC_reduction);
+reportOriginalDsa(S, Stack, D, DVar);
+continue;
+  }
 }
 
 // Try to find 'declare reduction' corresponding construct before using
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79293: [clang-format] [PR45218] Fix an issue where < and > and >> in a for loop gets incorrectly interpreted at a TemplateOpener/Closer

2020-08-18 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

I suppose this is just piling on heuristics, but I guess it fixes the reported 
bug. Krasimir, what do you think?


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

https://reviews.llvm.org/D79293

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


[PATCH] D84887: [OPENMP]Fix codegen for is_device_ptr component, captured by reference.

2020-08-18 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 286270.
ABataev added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84887

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


Index: clang/test/OpenMP/target_is_device_ptr_codegen.cpp
===
--- clang/test/OpenMP/target_is_device_ptr_codegen.cpp
+++ clang/test/OpenMP/target_is_device_ptr_codegen.cpp
@@ -285,4 +285,41 @@
   ++arg;
 }
 #endif
+///==///
+// RUN: %clang_cc1 -DCK3 -verify -fopenmp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple 
powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix 
CK3 --check-prefix CK3-64
+// RUN: %clang_cc1 -DCK3 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ 
-triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck %s  --check-prefix CK3 --check-prefix CK3-64
+// RUN: %clang_cc1 -DCK3 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu 
-x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s  
--check-prefix CK3 --check-prefix CK3-32
+// RUN: %clang_cc1 -DCK3 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ 
-std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple 
i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | 
FileCheck %s  --check-prefix CK3 --check-prefix CK3-32
+
+// RUN: %clang_cc1 -DCK3 -verify -fopenmp-simd 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple 
powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix 
SIMD-ONLY1 %s
+// RUN: %clang_cc1 -DCK3 -fopenmp-simd 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x 
c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// RUN: %clang_cc1 -DCK3 -verify -fopenmp-simd 
-fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// RUN: %clang_cc1 -DCK3 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x 
c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ 
-triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm 
-o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// SIMD-ONLY1-NOT: {{__kmpc|__tgt}}
+#ifdef CK3
+
+// CK3-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i[[SZ:64|32]]] [i{{64|32}} 
{{8|4}}]
+// OMP_MAP_TARGET_PARAM = 0x20 | OMP_MAP_TO = 0x1 = 0x21
+// CK3-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i64] [i64 [[#0x21]]]
+void bar() {
+  __attribute__((aligned(64))) double *ptr;
+  // CK3-DAG: call i32 @__tgt_target_mapper(i64 {{.+}}, i8* {{.+}}, i32 1, 
i8** [[BPGEP:%[0-9]+]], i8** [[PGEP:%[0-9]+]], {{.+}}[[SIZES]]{{.+}}, 
{{.+}}[[TYPES]]{{.+}}, i8** null)
+  // CK3-DAG: [[BPGEP]] = getelementptr inbounds {{.+}}[[BPS:%[^,]+]], i32 0, 
i32 0
+  // CK3-DAG: [[PGEP]] = getelementptr inbounds {{.+}}[[PS:%[^,]+]], i32 0, 
i32 0
+  // CK3-DAG: [[BP1:%.+]] = getelementptr inbounds {{.+}}[[BPS]], i32 0, i32 0
+  // CK3-DAG: [[P1:%.+]] = getelementptr inbounds {{.+}}[[PS]], i32 0, i32 0
+  // CK3-DAG: [[CBP1:%.+]] = bitcast i8** [[BP1]] to double***
+  // CK3-DAG: [[CP1:%.+]] = bitcast i8** [[P1]] to double***
+  // CK3-DAG: store double** [[PTR:%.+]], double*** [[CBP1]]
+  // CK3-DAG: store double** [[PTR]], double*** [[CP1]]
+
+  // CK3: call void [[KERNEL:@.+]](double** [[PTR]])
+#pragma omp target is_device_ptr(ptr)
+  *ptr = 0;
+}
+#endif
 #endif
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -8436,10 +8436,12 @@
 if (DevPointersMap.count(VD)) {
   CombinedInfo.BasePointers.emplace_back(Arg, VD);
   CombinedInfo.Pointers.push_back(Arg);
-  CombinedInfo.Sizes.push_back(
-  
CGF.Builder.CreateIntCast(CGF.getTypeSize(CGF.getContext().VoidPtrTy),
-CGF.Int64Ty, /*isSigned=*/true));
-  CombinedInfo.Types.push_back(OMP_MAP_LITERAL | OMP_MAP_TARGET_PARAM);
+  CombinedInfo.Sizes.push_back(CGF.Builder.CreateIntCast(
+  CGF.getTypeSize(CGF.getContext().VoidPtrTy), CGF.Int64Ty,
+  /*isSigned=*/true));
+  CombinedInfo.Types.push_back(
+  (Cap->capturesVariable() ? OMP_MAP_TO : 

[PATCH] D86132: [clang][driver]Add quotation mark in test/fortran.f95 to avoid false positive

2020-08-18 Thread David Truby via Phabricator via cfe-commits
DavidTruby accepted this revision.
DavidTruby added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86132

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


[PATCH] D86069: [clang] When loading preamble from AST file, re-export modules in Sema.

2020-08-18 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz added inline comments.



Comment at: clang/test/PCH/preamble-modules.cpp:8
+
+#ifndef MAIN_FILE
+#define MAIN_FILE

sammccall wrote:
> what are these ifdefs about? you never seem to define this symbol
> 
> (Possible you're copying from a test that is doing something tricky like 
> being run in two modes or including itself? Or did you mean to give different 
> flags for the include vs emit pch?)
Oh, I stole this trick from Kadir. You compile this file twice. First one is to 
generate a PCH for preamble. MAIN_FILE is not set, so it only reads the 
preamble section. The second one has -include-pch. That means MAIN_FILE is now 
set (from the preamble PCH file), so we only compile the main section.

It's a creative solution to a problem I wish I didn't have ;-)
Is there a better way to do this, without splitting the file in two? 
preamble_bytes seems fragile.



Comment at: clang/test/PCH/preamble-modules.cpp:14
+// Main section.
+MyType foo;
+#endif

sammccall wrote:
> This seems like currently it's never getting parsed as MAIN_FILE is never 
> defined.
It's parsed. Without this fix, there's a warning generated here. See comment 
above for explanation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86069

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


[PATCH] D76323: [AST] Fix handling of long double and bool in __builtin_bit_cast

2020-08-18 Thread Raul Tambre via Phabricator via cfe-commits
tambre added a comment.

For reference, I've been using this + D75960  
in my employer's Clang build for almost two months. We have been using 
`std::bit_cast` in our codebase quite a bit and haven't encountered any issues 
with these two changes. It would be nice too see this merged.


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

https://reviews.llvm.org/D76323

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


[PATCH] D85321: [OPENMP]Do not capture base pointer by reference if it is used as a base for array-like reduction.

2020-08-18 Thread Alexey Bataev 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 rG1b93ebccaa09: [OPENMP]Do not capture base pointer by 
reference if it is used as a base for… (authored by ABataev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85321

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/distribute_parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/for_reduction_task_codegen.cpp
  clang/test/OpenMP/parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/parallel_master_reduction_task_codegen.cpp
  clang/test/OpenMP/parallel_reduction_task_codegen.cpp
  clang/test/OpenMP/parallel_sections_reduction_task_codegen.cpp
  clang/test/OpenMP/sections_reduction_task_codegen.cpp
  clang/test/OpenMP/target_parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/target_parallel_reduction_task_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_reduction_task_codegen.cpp

Index: clang/test/OpenMP/teams_distribute_parallel_for_reduction_task_codegen.cpp
===
--- clang/test/OpenMP/teams_distribute_parallel_for_reduction_task_codegen.cpp
+++ clang/test/OpenMP/teams_distribute_parallel_for_reduction_task_codegen.cpp
@@ -20,9 +20,9 @@
   }
 }
 
-// CHECK: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* @{{.+}}, i32 4, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i64, i64, i32*, i8***)* [[OUTLINED:@.+]] to void (i32*, i32*, ...)*), i64 %{{.+}}, i64 %{{.+}}, i32* %{{.+}}, i8*** %{{.+}})
+// CHECK: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* @{{.+}}, i32 4, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i64, i64, i32*, i8**)* [[OUTLINED:@.+]] to void (i32*, i32*, ...)*), i64 %{{.+}}, i64 %{{.+}}, i32* %{{.+}}, i8** %{{.+}})
 
-// CHECK: define internal void [[OUTLINED]](i32* noalias %{{.+}}, i32* noalias %{{.+}}, i64 %{{.+}}, i64 %{{.+}}, i32* {{.+}}, i8*** {{.+}})
+// CHECK: define internal void [[OUTLINED]](i32* noalias %{{.+}}, i32* noalias %{{.+}}, i64 %{{.+}}, i64 %{{.+}}, i32* {{.+}}, i8** {{.+}})
 // CHECK: alloca i32,
 // CHECK: [[ARGC_FP_ADDR:%.+]] = alloca i32,
 // CHECK: [[TR:%.+]] = alloca [2 x [[TASKRED_TY:%struct.kmp_taskred_input_t.*]]],
@@ -124,7 +124,6 @@
 // CHECK_DAG: [[TG]] = load i8*, i8** [[TG_ADDR]],
 // CHECK-DAG: [[ARGV_REF]] = load i8*, i8** [[ARGV_ADDR:%.+]],
 // CHECK-DAG: [[ARGV_ADDR]] = load i8**, i8*** [[ARGV_ADDR_REF:%.+]],
-// CHECK-DAG: [[ARGV_ADDR_REF:%.+]] = load i8***, i8 [[ARGV:%.+]],
-// CHECK-DAG: [[ARGV]] = getelementptr inbounds [[CAPS_TY]], [[CAPS_TY]]* [[CAP]], i32 0, i32 2
+// CHECK-DAG: [[ARGV_ADDR_REF]] = getelementptr inbounds [[CAPS_TY]], [[CAPS_TY]]* [[CAP]], i32 0, i32 2
 
 #endif
Index: clang/test/OpenMP/target_teams_distribute_parallel_for_reduction_task_codegen.cpp
===
--- clang/test/OpenMP/target_teams_distribute_parallel_for_reduction_task_codegen.cpp
+++ clang/test/OpenMP/target_teams_distribute_parallel_for_reduction_task_codegen.cpp
@@ -19,9 +19,9 @@
   }
 }
 
-// CHECK: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* @{{.+}}, i32 4, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i64, i64, i32*, i8***)* [[OUTLINED:@.+]] to void (i32*, i32*, ...)*), i64 %{{.+}}, i64 %{{.+}}, i32* %{{.+}}, i8*** %{{.+}})
+// CHECK: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* @{{.+}}, i32 4, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i64, i64, i32*, i8**)* [[OUTLINED:@.+]] to void (i32*, i32*, ...)*), i64 %{{.+}}, i64 %{{.+}}, i32* %{{.+}}, i8** %{{.+}})
 
-// CHECK: define internal void [[OUTLINED]](i32* noalias %{{.+}}, i32* noalias %{{.+}}, i64 %{{.+}}, i64 %{{.+}}, i32* {{.+}}, i8*** {{.+}})
+// CHECK: define internal void [[OUTLINED]](i32* noalias %{{.+}}, i32* noalias %{{.+}}, i64 %{{.+}}, i64 %{{.+}}, i32* {{.+}}, i8** {{.+}})
 // CHECK: alloca i32,
 // CHECK: [[ARGC_FP_ADDR:%.+]] = alloca i32,
 // CHECK: [[TR:%.+]] = alloca [2 x [[TASKRED_TY:%struct.kmp_taskred_input_t.*]]],
@@ -123,7 +123,6 @@
 // CHECK_DAG: [[TG]] = load i8*, i8** [[TG_ADDR]],
 // CHECK-DAG: [[ARGV_REF]] = load i8*, i8** [[ARGV_ADDR:%.+]],
 // CHECK-DAG: [[ARGV_ADDR]] = load i8**, i8*** [[ARGV_ADDR_REF:%.+]],
-// CHECK-DAG: [[ARGV_ADDR_REF:%.+]] = load i8***, i8 [[ARGV:%.+]],
-// CHECK-DAG: [[ARGV]] = getelementptr inbounds [[CAPS_TY]], [[CAPS_TY]]* [[CAP]], i32 0, i32 2
+// CHECK-DAG: [[ARGV_ADDR_REF]] = getelementptr inbounds [[CAPS_TY]], [[CAPS_TY]]* [[CAP]], i32 0, i32 2
 
 #endif
Index: clang/test/OpenMP/target_parallel_reduction_task_codegen.cpp

[clang] 1b93ebc - [OPENMP]Do not capture base pointer by reference if it is used as a base for array-like reduction.

2020-08-18 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-08-18T09:05:35-04:00
New Revision: 1b93ebccaa094c079db7ad729e2f7fea7bac2f34

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

LOG: [OPENMP]Do not capture base pointer by reference if it is used as a base 
for array-like reduction.

If the declaration is used in the reduction clause, it is captured by
reference by default. But if the declaration is a pointer and it is a
base for array-like reduction, this declaration can be captured by
value, since the pointee is reduced but not the original declaration.

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

Added: 


Modified: 
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/distribute_parallel_for_reduction_task_codegen.cpp
clang/test/OpenMP/for_reduction_task_codegen.cpp
clang/test/OpenMP/parallel_for_reduction_task_codegen.cpp
clang/test/OpenMP/parallel_master_reduction_task_codegen.cpp
clang/test/OpenMP/parallel_reduction_task_codegen.cpp
clang/test/OpenMP/parallel_sections_reduction_task_codegen.cpp
clang/test/OpenMP/sections_reduction_task_codegen.cpp
clang/test/OpenMP/target_parallel_for_reduction_task_codegen.cpp
clang/test/OpenMP/target_parallel_reduction_task_codegen.cpp

clang/test/OpenMP/target_teams_distribute_parallel_for_reduction_task_codegen.cpp
clang/test/OpenMP/teams_distribute_parallel_for_reduction_task_codegen.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index a493f3114dc29..53917ef98acdf 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -70,12 +70,15 @@ class DSAStackTy {
 const Expr *RefExpr = nullptr;
 DeclRefExpr *PrivateCopy = nullptr;
 SourceLocation ImplicitDSALoc;
+bool AppliedToPointee = false;
 DSAVarData() = default;
 DSAVarData(OpenMPDirectiveKind DKind, OpenMPClauseKind CKind,
const Expr *RefExpr, DeclRefExpr *PrivateCopy,
-   SourceLocation ImplicitDSALoc, unsigned Modifier)
+   SourceLocation ImplicitDSALoc, unsigned Modifier,
+   bool AppliedToPointee)
 : DKind(DKind), CKind(CKind), Modifier(Modifier), RefExpr(RefExpr),
-  PrivateCopy(PrivateCopy), ImplicitDSALoc(ImplicitDSALoc) {}
+  PrivateCopy(PrivateCopy), ImplicitDSALoc(ImplicitDSALoc),
+  AppliedToPointee(AppliedToPointee) {}
   };
   using OperatorOffsetTy =
   llvm::SmallVector, 4>;
@@ -99,6 +102,9 @@ class DSAStackTy {
 /// variable is marked as lastprivate(true) or not (false).
 llvm::PointerIntPair RefExpr;
 DeclRefExpr *PrivateCopy = nullptr;
+/// true if the attribute is applied to the pointee, not the variable
+/// itself.
+bool AppliedToPointee = false;
   };
   using DeclSAMapTy = llvm::SmallDenseMap;
   using UsedRefMapTy = llvm::SmallDenseMap;
@@ -511,7 +517,8 @@ class DSAStackTy {
 
   /// Adds explicit data sharing attribute to the specified declaration.
   void addDSA(const ValueDecl *D, const Expr *E, OpenMPClauseKind A,
-  DeclRefExpr *PrivateCopy = nullptr, unsigned Modifier = 0);
+  DeclRefExpr *PrivateCopy = nullptr, unsigned Modifier = 0,
+  bool AppliedToPointee = false);
 
   /// Adds additional information for the reduction items with the reduction id
   /// represented as an operator.
@@ -563,7 +570,8 @@ class DSAStackTy {
   /// match specified \a CPred predicate in any directive which matches \a 
DPred
   /// predicate.
   const DSAVarData
-  hasDSA(ValueDecl *D, const llvm::function_ref CPred,
+  hasDSA(ValueDecl *D,
+ const llvm::function_ref CPred,
  const llvm::function_ref DPred,
  bool FromParent) const;
   /// Checks if the specified variables has data-sharing attributes which
@@ -571,15 +579,16 @@ class DSAStackTy {
   /// matches \a DPred predicate.
   const DSAVarData
   hasInnermostDSA(ValueDecl *D,
-  const llvm::function_ref CPred,
+  const llvm::function_ref CPred,
   const llvm::function_ref DPred,
   bool FromParent) const;
   /// Checks if the specified variables has explicit data-sharing
   /// attributes which match specified \a CPred predicate at the specified
   /// OpenMP region.
-  bool hasExplicitDSA(const ValueDecl *D,
-  const llvm::function_ref CPred,
-  unsigned Level, bool NotLastprivate = false) const;
+  bool
+  hasExplicitDSA(const ValueDecl *D,
+ const llvm::function_ref CPred,
+ unsigned Level, bool NotLastprivate = false) const;
 
   /// Returns true if the directive at level \Level matches in the
   /// specified \a DPred predicate.
@@ -1185,6 +1194,7 @@ DSAStackTy::DSAVarData 

[PATCH] D85962: [SyntaxTree] Create annotations infrastructure and apply it in expression tests.

2020-08-18 Thread Eduardo Caldas 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 rGc8c92b54d74c: [SyntaxTree] Use Annotations based tests for 
expressions (authored by eduucaldas).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85962

Files:
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
  clang/unittests/Tooling/Syntax/TreeTestBase.cpp

Index: clang/unittests/Tooling/Syntax/TreeTestBase.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTestBase.cpp
+++ clang/unittests/Tooling/Syntax/TreeTestBase.cpp
@@ -171,7 +171,7 @@
<< "Source file has syntax errors, they were printed to the test "
   "log";
   }
-  std::string Actual = std::string(StringRef(Root->dump(*Arena)).trim());
+  auto Actual = StringRef(Root->dump(*Arena)).trim().str();
   // EXPECT_EQ shows the diff between the two strings if they are different.
   EXPECT_EQ(Tree.trim().str(), Actual);
   if (Actual != Tree.trim().str()) {
@@ -194,21 +194,29 @@
   "log";
   }
 
-  bool failed = false;
   auto AnnotatedRanges = AnnotatedCode.ranges();
-  assert(AnnotatedRanges.size() == TreeDumps.size());
-  for (auto i = 0ul; i < AnnotatedRanges.size(); i++) {
+  if (AnnotatedRanges.size() != TreeDumps.size()) {
+return ::testing::AssertionFailure()
+   << "The number of annotated ranges in the source code is different "
+  "to the number of their corresponding tree dumps.";
+  }
+  bool Failed = false;
+  for (unsigned i = 0; i < AnnotatedRanges.size(); i++) {
 auto *AnnotatedNode = nodeByRange(AnnotatedRanges[i], Root);
 assert(AnnotatedNode);
 auto AnnotatedNodeDump =
-std::string(StringRef(AnnotatedNode->dump(*Arena)).trim());
+StringRef(AnnotatedNode->dump(*Arena)).trim().str();
 // EXPECT_EQ shows the diff between the two strings if they are different.
-EXPECT_EQ(TreeDumps[i].trim().str(), AnnotatedNodeDump);
+EXPECT_EQ(TreeDumps[i].trim().str(), AnnotatedNodeDump)
+<< "Dumps diverged for the code:\n"
+<< AnnotatedCode.code().slice(AnnotatedRanges[i].Begin,
+  AnnotatedRanges[i].End);
 if (AnnotatedNodeDump != TreeDumps[i].trim().str())
-  failed = true;
+  Failed = true;
   }
-  return failed ? ::testing::AssertionFailure() : ::testing::AssertionSuccess();
+  return Failed ? ::testing::AssertionFailure() : ::testing::AssertionSuccess();
 }
+
 syntax::Node *SyntaxTreeTest::nodeByRange(llvm::Annotations::Range R,
   syntax::Node *Root) {
   ArrayRef Toks = tokens(Root);
Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -437,672 +437,355 @@
 }
 
 TEST_P(SyntaxTreeTest, UnqualifiedId_Identifier) {
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 void test(int a) {
-  a;
+  [[a]];
 }
 )cpp",
-  R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   |-SimpleDeclaration
-  |   | |-int
-  |   | `-SimpleDeclarator
-  |   |   `-a
-  |   `-)
-  `-CompoundStatement
-|-{
-|-ExpressionStatement
-| |-IdExpression
-| | `-UnqualifiedId
-| |   `-a
-| `-;
-`-}
-)txt"));
+  {R"txt(
+IdExpression
+`-UnqualifiedId
+  `-a
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, UnqualifiedId_OperatorFunctionId) {
   if (!GetParam().isCXX()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 struct X {
   friend X operator+(const X&, const X&);
 };
 void test(X x) {
-  operator+(x, x);
-}
-)cpp",
-  R"txt(
-*: TranslationUnit
-|-SimpleDeclaration
-| |-struct
-| |-X
-| |-{
-| |-UnknownDeclaration
-| | `-SimpleDeclaration
-| |   |-friend
-| |   |-X
-| |   |-SimpleDeclarator
-| |   | |-operator
-| |   | |-+
-| |   | `-ParametersAndQualifiers
-| |   |   |-(
-| |   |   |-SimpleDeclaration
-| |   |   | |-const
-| |   |   | |-X
-| |   |   | `-SimpleDeclarator
-| |   |   |   `-&
-| |   |   |-,
-| |   |   |-SimpleDeclaration
-| |   |   | |-const
-| |   |   | |-X
-| |   |   | `-SimpleDeclarator
-| |   |   |   `-&
-| |   |   `-)
-| |   `-;
-| |-}
-| `-;
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   |-SimpleDeclaration
-  |   | |-X
-  |   | `-SimpleDeclarator
-  |   |   `-x
-  |   `-)
-  `-CompoundStatement
-|-{
-|-ExpressionStatement
-| |-UnknownExpression
-| | |-IdExpression
-| | | `-UnqualifiedId
-| | |   |-operator
-| | |   `-+
-| | |-(
-| | |-IdExpression
-| | | `-UnqualifiedId
-

[clang] c8c92b5 - [SyntaxTree] Use Annotations based tests for expressions

2020-08-18 Thread Eduardo Caldas via cfe-commits

Author: Eduardo Caldas
Date: 2020-08-18T13:00:56Z
New Revision: c8c92b54d74c1b9256f9aed6ba89d66fbd1d01ae

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

LOG: [SyntaxTree] Use Annotations based tests for expressions

In this process we also create some other tests, in order to not lose
coverage when focusing on the annotated code

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

Added: 


Modified: 
clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
clang/unittests/Tooling/Syntax/TreeTestBase.cpp

Removed: 




diff  --git a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp 
b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
index 211e8b1ae901..fd858dfba91f 100644
--- a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -437,672 +437,355 @@ void test() {
 }
 
 TEST_P(SyntaxTreeTest, UnqualifiedId_Identifier) {
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 void test(int a) {
-  a;
+  [[a]];
 }
 )cpp",
-  R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   |-SimpleDeclaration
-  |   | |-int
-  |   | `-SimpleDeclarator
-  |   |   `-a
-  |   `-)
-  `-CompoundStatement
-|-{
-|-ExpressionStatement
-| |-IdExpression
-| | `-UnqualifiedId
-| |   `-a
-| `-;
-`-}
-)txt"));
+  {R"txt(
+IdExpression
+`-UnqualifiedId
+  `-a
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, UnqualifiedId_OperatorFunctionId) {
   if (!GetParam().isCXX()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 struct X {
   friend X operator+(const X&, const X&);
 };
 void test(X x) {
-  operator+(x, x);
-}
-)cpp",
-  R"txt(
-*: TranslationUnit
-|-SimpleDeclaration
-| |-struct
-| |-X
-| |-{
-| |-UnknownDeclaration
-| | `-SimpleDeclaration
-| |   |-friend
-| |   |-X
-| |   |-SimpleDeclarator
-| |   | |-operator
-| |   | |-+
-| |   | `-ParametersAndQualifiers
-| |   |   |-(
-| |   |   |-SimpleDeclaration
-| |   |   | |-const
-| |   |   | |-X
-| |   |   | `-SimpleDeclarator
-| |   |   |   `-&
-| |   |   |-,
-| |   |   |-SimpleDeclaration
-| |   |   | |-const
-| |   |   | |-X
-| |   |   | `-SimpleDeclarator
-| |   |   |   `-&
-| |   |   `-)
-| |   `-;
-| |-}
-| `-;
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   |-SimpleDeclaration
-  |   | |-X
-  |   | `-SimpleDeclarator
-  |   |   `-x
-  |   `-)
-  `-CompoundStatement
-|-{
-|-ExpressionStatement
-| |-UnknownExpression
-| | |-IdExpression
-| | | `-UnqualifiedId
-| | |   |-operator
-| | |   `-+
-| | |-(
-| | |-IdExpression
-| | | `-UnqualifiedId
-| | |   `-x
-| | |-,
-| | |-IdExpression
-| | | `-UnqualifiedId
-| | |   `-x
-| | `-)
-| `-;
-`-}
-)txt"));
+  [[operator+(x, x)]];
+}
+)cpp",
+  {R"txt(
+UnknownExpression
+|-IdExpression
+| `-UnqualifiedId
+|   |-operator
+|   `-+
+|-(
+|-IdExpression
+| `-UnqualifiedId
+|   `-x
+|-,
+|-IdExpression
+| `-UnqualifiedId
+|   `-x
+`-)
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, UnqualifiedId_ConversionFunctionId) {
   if (!GetParam().isCXX()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 struct X {
   operator int();
 };
 void test(X x) {
   // TODO: Expose `id-expression` from `MemberExpr`
-  x.operator int();
+  [[x.operator int()]];
 }
 )cpp",
-  R"txt(
-*: TranslationUnit
-|-SimpleDeclaration
-| |-struct
-| |-X
-| |-{
-| |-SimpleDeclaration
-| | |-SimpleDeclarator
-| | | |-operator
-| | | |-int
-| | | `-ParametersAndQualifiers
-| | |   |-(
-| | |   `-)
-| | `-;
-| |-}
-| `-;
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   |-SimpleDeclaration
-  |   | |-X
-  |   | `-SimpleDeclarator
-  |   |   `-x
-  |   `-)
-  `-CompoundStatement
-|-{
-|-ExpressionStatement
-| |-UnknownExpression
-| | |-UnknownExpression
-| | | |-IdExpression
-| | | | `-UnqualifiedId
-| | | |   `-x
-| | | |-.
-| | | |-operator
-| | | `-int
-| | |-(
-| | `-)
-| `-;
-`-}
-)txt"));
+  {R"txt(
+UnknownExpression
+|-UnknownExpression
+| |-IdExpression
+| | `-UnqualifiedId
+| |   `-x
+| |-.
+| |-operator
+| `-int
+|-(
+`-)
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, UnqualifiedId_LiteralOperatorId) {
   if (!GetParam().isCXX11OrLater()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 unsigned operator "" _w(char);
 void test() {
-  operator "" _w('1');
+  [[operator "" _w('1')]];
 }
 )cpp",
-  R"txt(

[clang] ab58c9e - [SyntaxTree] Implement annotation-based test infrastructure

2020-08-18 Thread Eduardo Caldas via cfe-commits

Author: Eduardo Caldas
Date: 2020-08-18T13:00:56Z
New Revision: ab58c9ee8a6e9ace3a93198496b4d85e8cb2b5a9

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

LOG: [SyntaxTree] Implement annotation-based test infrastructure

We add the method `SyntaxTreeTest::treeDumpEqualOnAnnotations`, which
allows us to compare the treeDump of only annotated code. This will reduce a
lot of noise from our `BuildTreeTest` and make them short and easier to
read.

Added: 


Modified: 
clang/unittests/Tooling/Syntax/TreeTestBase.cpp
clang/unittests/Tooling/Syntax/TreeTestBase.h

Removed: 




diff  --git a/clang/unittests/Tooling/Syntax/TreeTestBase.cpp 
b/clang/unittests/Tooling/Syntax/TreeTestBase.cpp
index 6d2efeaaa8eb..05fbac4f47e1 100644
--- a/clang/unittests/Tooling/Syntax/TreeTestBase.cpp
+++ b/clang/unittests/Tooling/Syntax/TreeTestBase.cpp
@@ -180,6 +180,35 @@ ::testing::AssertionResult 
SyntaxTreeTest::treeDumpEqual(StringRef Code,
   return ::testing::AssertionSuccess();
 }
 
+::testing::AssertionResult
+SyntaxTreeTest::treeDumpEqualOnAnnotations(StringRef CodeWithAnnotations,
+   ArrayRef TreeDumps) {
+  SCOPED_TRACE(llvm::join(GetParam().getCommandLineArgs(), " "));
+
+  auto AnnotatedCode = llvm::Annotations(CodeWithAnnotations);
+  auto *Root = buildTree(AnnotatedCode.code(), GetParam());
+
+  if (Diags->getClient()->getNumErrors() != 0) {
+return ::testing::AssertionFailure()
+   << "Source file has syntax errors, they were printed to the test "
+  "log";
+  }
+
+  bool failed = false;
+  auto AnnotatedRanges = AnnotatedCode.ranges();
+  assert(AnnotatedRanges.size() == TreeDumps.size());
+  for (auto i = 0ul; i < AnnotatedRanges.size(); i++) {
+auto *AnnotatedNode = nodeByRange(AnnotatedRanges[i], Root);
+assert(AnnotatedNode);
+auto AnnotatedNodeDump =
+std::string(StringRef(AnnotatedNode->dump(*Arena)).trim());
+// EXPECT_EQ shows the 
diff  between the two strings if they are 
diff erent.
+EXPECT_EQ(TreeDumps[i].trim().str(), AnnotatedNodeDump);
+if (AnnotatedNodeDump != TreeDumps[i].trim().str())
+  failed = true;
+  }
+  return failed ? ::testing::AssertionFailure() : 
::testing::AssertionSuccess();
+}
 syntax::Node *SyntaxTreeTest::nodeByRange(llvm::Annotations::Range R,
   syntax::Node *Root) {
   ArrayRef Toks = tokens(Root);

diff  --git a/clang/unittests/Tooling/Syntax/TreeTestBase.h 
b/clang/unittests/Tooling/Syntax/TreeTestBase.h
index bfa6ecd7909f..c282bbf45fd3 100644
--- a/clang/unittests/Tooling/Syntax/TreeTestBase.h
+++ b/clang/unittests/Tooling/Syntax/TreeTestBase.h
@@ -34,6 +34,9 @@ class SyntaxTreeTest : public ::testing::Test,
 
   ::testing::AssertionResult treeDumpEqual(StringRef Code, StringRef Tree);
 
+  ::testing::AssertionResult
+  treeDumpEqualOnAnnotations(StringRef CodeWithAnnotations,
+ ArrayRef TreeDumps);
   /// Finds the deepest node in the tree that covers exactly \p R.
   /// FIXME: implement this efficiently and move to public syntax tree API.
   syntax::Node *nodeByRange(llvm::Annotations::Range R, syntax::Node *Root);



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


[PATCH] D86137: Add ignore-unknown-options flag to clang-format.

2020-08-18 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor created this revision.
fodinabor added reviewers: bkramer, djasper, klimek.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya.
Herald added projects: clang, LLVM.
fodinabor requested review of this revision.

Currently newer clang-format options cannot be included in .clang-format files, 
if not all users can be forced to use an updated version.
This patch tries to solve this by adding an option to clang-format, enabling to 
ignore unknown (newer) options.

As this is my first LLVM patch, I'm expecting to get some things wrong and are 
happy to receive any feedback!
E.g.: I haven't found how to update the clang-format help page yet. Is it auto 
generated?
Also if you have any suggestions on whom to ask wrt review, please add them.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86137

Files:
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/tools/clang-format/ClangFormat.cpp
  llvm/include/llvm/Support/YAMLTraits.h
  llvm/lib/Support/YAMLTraits.cpp

Index: llvm/lib/Support/YAMLTraits.cpp
===
--- llvm/lib/Support/YAMLTraits.cpp
+++ llvm/lib/Support/YAMLTraits.cpp
@@ -195,6 +195,8 @@
   MapHNode *MN = dyn_cast_or_null(CurrentNode);
   if (!MN)
 return;
+  if (IgnoreUnkown)
+return;
   for (const auto  : MN->Mapping) {
 if (!is_contained(MN->ValidKeys, NN.first())) {
   setError(NN.second.get(), Twine("unknown key '") + NN.first() + "'");
@@ -428,6 +430,8 @@
   setError(CurrentNode, Message);
 }
 
+void Input::setIgnoreUnknown(bool Value) { IgnoreUnkown = Value; }
+
 bool Input::canElideEmptySequence() {
   return false;
 }
@@ -735,6 +739,8 @@
 void Output::setError(const Twine ) {
 }
 
+void Output::setIgnoreUnknown(bool Value) {}
+
 bool Output::canElideEmptySequence() {
   // Normally, with an optional key/value where the value is an empty sequence,
   // the whole key/value can be not written.  But, that produces wrong yaml
Index: llvm/include/llvm/Support/YAMLTraits.h
===
--- llvm/include/llvm/Support/YAMLTraits.h
+++ llvm/include/llvm/Support/YAMLTraits.h
@@ -789,6 +789,7 @@
   virtual NodeKind getNodeKind() = 0;
 
   virtual void setError(const Twine &) = 0;
+  virtual void setIgnoreUnknown(bool) = 0;
 
   template 
   void enumCase(T , const char* Str, const T ConstVal) {
@@ -1504,6 +1505,8 @@
   /// Returns the current node that's being parsed by the YAML Parser.
   const Node *getCurrentNode() const;
 
+  void setIgnoreUnknown(bool) override;
+
 private:
   SourceMgr   SrcMgr; // must be before Strm
   std::unique_ptr Strm;
@@ -1514,6 +1517,7 @@
   std::vector   BitValuesUsed;
   HNode *CurrentNode = nullptr;
   boolScalarMatchFound = false;
+  bool IgnoreUnkown = false;
 };
 
 ///
@@ -1561,6 +1565,7 @@
   void scalarTag(std::string &) override;
   NodeKind getNodeKind() override;
   void setError(const Twine ) override;
+  void setIgnoreUnknown(bool) override;
   bool canElideEmptySequence() override;
 
   // These are only used by operator<<. They could be private
Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -104,6 +104,11 @@
  "SortIncludes style flag"),
 cl::cat(ClangFormatCategory));
 
+static cl::opt
+IgnoreUnkownOptions("ignore-unknown-options",
+cl::desc("If set, unknown format options are ignored."),
+cl::init(false), cl::cat(ClangFormatCategory));
+
 static cl::opt
 Verbose("verbose", cl::desc("If set, shows the list of processed files"),
 cl::cat(ClangFormatCategory));
@@ -378,7 +383,8 @@
   }
 
   llvm::Expected FormatStyle =
-  getStyle(Style, AssumedFileName, FallbackStyle, Code->getBuffer());
+  getStyle(Style, AssumedFileName, FallbackStyle, Code->getBuffer(),
+   nullptr, IgnoreUnkownOptions.getValue());
   if (!FormatStyle) {
 llvm::errs() << llvm::toString(FormatStyle.takeError()) << "\n";
 return true;
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -1288,7 +1288,8 @@
   return true;
 }
 
-std::error_code parseConfiguration(StringRef Text, FormatStyle *Style) {
+std::error_code parseConfiguration(StringRef Text, FormatStyle *Style,
+   bool IgnoreUnknownOptions) {
   assert(Style);
   FormatStyle::LanguageKind Language = Style->Language;
   assert(Language != FormatStyle::LK_None);
@@ -1302,6 +1303,7 @@
   // Mapping also uses the context to get the language to find the correct
   // base style.
   Input.setContext(Style);
+  Input.setIgnoreUnknown(IgnoreUnknownOptions);
   

[PATCH] D85191: [AST] Get field size in chars rather than bits in RecordLayoutBuilder.

2020-08-18 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added a comment.

It doesn't feel like this patch got a very positive reception, but I'd still 
like to try a bit more to get it in.

Even though it's difficult to test this particular change upstream, would it 
still be acceptable to take the patch since it reverts the behavior to what it 
was previously? If there are worries that things may break in the future due to 
other changes, we do catch these things in our downstream testing and are 
fairly diligent about reporting back about them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85191

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


  1   2   >