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

2020-08-21 Thread Nikita Popov via Phabricator via cfe-commits
nikic requested changes to this revision.
nikic added a comment.
This revision now requires changes to proceed.

This change adds three PDT calculations to the standard pipeline. Please try to 
avoid the PDT calculations if PGO is not used, possibly by using LazyBPI.


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

https://reviews.llvm.org/D86156

___
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-21 Thread Di Mo via Phabricator via cfe-commits
modimo added inline comments.



Comment at: llvm/include/llvm/Transforms/Scalar/LoopPassManager.h:408
 FunctionToLoopPassAdaptor
 createFunctionToLoopPassAdaptor(LoopPassT Pass, bool UseMemorySSA = false,
+bool UseBlockFrequencyInfo = false,

@asbirlea Assuming this change matches expectations of making BFI on present 
when LICM or loop passes contain LICM I'm looking at the users of this and they 
seem to fall into 2 categories:
1. Those that specify the optional flags
2. Those that only pass in the LoopPassT

I found as I was updating with a new flag that due to C++ behavior a place that 
wasn't updated to have all 3 optional parameters will place DebugLogging into 
UseBlockFrequencyInfo which is a nasty error. I think a way around it is to 
enforce overloaded functions with either 0 additional parameters or having 
every "optional" parameter specified so it'll be a build time error for the 
previous scenario rather than a runtime issue.



Comment at: llvm/include/llvm/Transforms/Scalar/LoopPassManager.h:278
AM.getResult(F),
+   
(F),
MSSA};

asbirlea wrote:
> This should not be unconditional. See MSSA approach.
Fixed it up to resemble MSSA



Comment at: llvm/test/Transforms/LoopRotate/pr35210.ll:51
+; MSSA-NEXT: Running analysis: BlockFrequencyAnalysis on f
+; MSSA-NEXT: Running analysis: BranchProbabilityAnalysis on f
 ; MSSA-NEXT: Running analysis: InnerAnalysisManagerProxy{{.*}} on f

asbirlea wrote:
> e.g. there's no use of creating these for LoopRotate.
Changed up so LoopRotate no longer has a dependency on BFI


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

https://reviews.llvm.org/D86156

___
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-21 Thread Di Mo via Phabricator via cfe-commits
modimo updated this revision to Diff 287152.
modimo added a comment.
Herald added subscribers: lxfind, nikic.

@asbirlea Thanks for taking a look!

I updated BFI to resemble MSSA as recommended which removed the BFI calculation 
unless LICM is invoked. Also removed the spurious diffs from formatting.


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/Passes/PassBuilder.cpp
  llvm/lib/Transforms/Scalar/LICM.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/new-pm-defaults.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/opt-O2-pipeline.ll
  llvm/test/Other/opt-O3-pipeline-enable-matrix.ll
  llvm/test/Other/opt-O3-pipeline.ll
  llvm/test/Other/opt-Os-pipeline.ll
  llvm/test/Other/pass-pipelines.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/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/opt-Os-pipeline.ll
===
--- llvm/test/Other/opt-Os-pipeline.ll
+++ llvm/test/Other/opt-Os-pipeline.ll
@@ -96,9 +96,13 @@
 ; CHECK-NEXT: Scalar Evolution Analysis
 ; CHECK-NEXT: Loop Pass Manager
 ; CHECK-NEXT:   Rotate Loops
+; CHECK-NEXT: Post-Dominator Tree Construction
+; CHECK-NEXT: Branch Probability Analysis
+; CHECK-NEXT: Block Frequency Analysis
 ; CHECK-NEXT: Memory SSA
 ; CHECK-NEXT: Loop Pass Manager
 ; CHECK-NEXT:   Loop Invariant Code Motion
+; CHECK-NEXT: Loop Pass Manager
 ; CHECK-NEXT:   Unswitch loops
 ; CHECK-NEXT: Simplify the CFG
 ; CHECK-NEXT: Dominator Tree Construction
@@ -147,13 +151,17 @@
 ; CHECK-NEXT: Phi Values Analysis
 ; CHECK-NEXT: Memory Dependence Analysis
 ; CHECK-NEXT: Dead Store Elimination
+; CHECK-NEXT: Natural Loop Information
+; CHECK-NEXT: Post-Dominator Tree Construction
+; CHECK-NEXT: Branch Probability Analysis
+; CHECK-NEXT: Block Frequency Analysis
 ; CHECK-NEXT: Function Alias Analysis Results
 ; CHECK-NEXT: Memory SSA
-; CHECK-NEXT: Natural Loop Information
 ; CHECK-NEXT: Canonicalize natural loops
 ; CHECK-NEXT: LCSSA Verifier
 ; CHECK-NEXT: Loop-Closed SSA Form Pass
 ; CHECK-NEXT: Scalar Evolution Analysis
+; CHECK-NEXT: Block Frequency Analysis
 ; CHECK-NEXT: Loop Pass Manager
 ; CHECK-NEXT:   Loop Invariant Code Motion
 ; CHECK-NEXT: Post-Dominator Tree Construction
@@ -251,11 +259,15 @@
 ; CHECK-NEXT:   Lazy Block Frequency Analysis
 ; CHECK-NEXT:   Optimization Remark Emitter
 ; CHECK-NEXT:   Combine redundant instructions
+; 

[PATCH] D83500: [PowerPC][Power10] Implement custom codegen for the vec_replace_elt and vec_replace_unaligned builtins.

2020-08-21 Thread Amy Kwan via Phabricator via cfe-commits
amyk updated this revision to Diff 287142.
amyk added a comment.

Address review comments:

- Further consolidate the custom codegen of the two builtins
- Add SemaChecking for if the third argument is a constant, if the third 
argument is in range and if the second argument is the same type as the element 
type of the first argument
- Add extra test to test the semantic checks that were added


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83500

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/altivec.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-ppc-p10vector.c
  clang/test/CodeGen/builtins-ppc-vec-ins-error.c

Index: clang/test/CodeGen/builtins-ppc-vec-ins-error.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-ppc-vec-ins-error.c
@@ -0,0 +1,81 @@
+// REQUIRES: powerpc-registered-target
+
+// RUN: %clang_cc1 -target-feature +vsx -target-cpu pwr10 \
+// RUN:   -triple powerpc64le-unknown-unknown -fsyntax-only %s -verify
+// RUN: %clang_cc1 -target-feature +vsx -target-cpu pwr10 \
+// RUN:   -triple powerpc64-unknown-unknown -fsyntax-only %s -verify
+
+#include 
+
+vector signed int vsia;
+vector unsigned int vuia;
+vector signed long long vslla;
+vector unsigned long long vulla;
+vector float vfa;
+vector double vda;
+signed int sia;
+unsigned int uia;
+signed long long slla;
+unsigned long long ulla;
+float fa;
+double da;
+
+vector signed int test_vec_replace_elt_si(void) {
+  return vec_replace_elt(vsia, sia, 13); // expected-error {{argument value 13 is outside the valid range [0, 12]}}
+}
+
+vector unsigned int test_vec_replace_elt_ui(void) {
+  return vec_replace_elt(vuia, sia, 1); // expected-error {{arguments are of different types ('unsigned int' vs 'int')}}
+}
+
+vector float test_vec_replace_elt_f(void) {
+  return vec_replace_elt(vfa, fa, 20); // expected-error {{argument value 20 is outside the valid range [0, 12]}}
+}
+
+vector float test_vec_replace_elt_f_2(void) {
+  return vec_replace_elt(vfa, da, 0); // expected-error {{arguments are of different types ('float' vs 'double')}}
+}
+
+vector signed long long test_vec_replace_elt_sll(void) {
+  return vec_replace_elt(vslla, slla, 9); // expected-error {{argument value 9 is outside the valid range [0, 8]}}
+}
+
+vector unsigned long long test_vec_replace_elt_ull(void) {
+  return vec_replace_elt(vulla, vda, 0); // expected-error {{arguments are of different types ('unsigned long long' vs '__vector double' (vector of 2 'double' values))}}
+}
+
+vector unsigned long long test_vec_replace_elt_ull_2(void) {
+  return vec_replace_elt(vulla, vulla, vsia); // expected-error {{argument to '__builtin_altivec_vec_replace_elt' must be a constant integer}}
+}
+
+vector double test_vec_replace_elt_d(void) {
+  return vec_replace_elt(vda, da, 33); // expected-error {{argument value 33 is outside the valid range [0, 8]}}
+}
+
+vector unsigned char test_vec_replace_unaligned_si(void) {
+  return vec_replace_unaligned(vsia, da, 6); // expected-error {{arguments are of different types ('int' vs 'double')}}
+}
+
+vector unsigned char test_vec_replace_unaligned_ui(void) {
+  return vec_replace_unaligned(vuia, uia, 14); // expected-error {{argument value 14 is outside the valid range [0, 12]}}
+}
+
+vector unsigned char test_vec_replace_unaligned_f(void) {
+  return vec_replace_unaligned(vfa, fa, 19); // expected-error {{argument value 19 is outside the valid range [0, 12]}}
+}
+
+vector unsigned char test_vec_replace_unaligned_sll(void) {
+  return vec_replace_unaligned(vslla, fa, 0); // expected-error {{arguments are of different types ('long long' vs 'float')}}
+}
+
+vector unsigned char test_vec_replace_unaligned_ull(void) {
+  return vec_replace_unaligned(vulla, ulla, 12); // expected-error {{argument value 12 is outside the valid range [0, 8]}}
+}
+
+vector unsigned char test_vec_replace_unaligned_d(void) {
+  return vec_replace_unaligned(vda, fa, 8); // expected-error {{arguments are of different types ('double' vs 'float')}}
+}
+
+vector unsigned char test_vec_replace_unaligned_d_2(void) {
+  return vec_replace_unaligned(vda, vda, da); // expected-error {{argument to '__builtin_altivec_vec_replace_unaligned' must be a constant integer}}
+}
Index: clang/test/CodeGen/builtins-ppc-p10vector.c
===
--- clang/test/CodeGen/builtins-ppc-p10vector.c
+++ clang/test/CodeGen/builtins-ppc-p10vector.c
@@ -20,10 +20,14 @@
 vector unsigned __int128 vui128a, vui128b, vui128c;
 vector float vfa, vfb;
 vector double vda, vdb;
+signed int sia;
 unsigned int uia, uib;
 unsigned char uca;
 unsigned short usa;
+signed long long slla;
 unsigned long long ulla;
+float fa;
+double da;
 
 vector signed long long test_vec_mul_sll(void) {
   // CHECK: mul <2 x i64>
@@ -863,3 +867,123 @@
   // 

[PATCH] D86293: [analyzer] Add modeling of Eq operator in smart ptr

2020-08-21 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

This looks outright correct to me. I have random suggestions on note text here 
and there.




Comment at: clang/test/Analysis/smart-ptr-text-output.cpp:132
+  std::unique_ptr PToMove; // expected-note {{Default constructed smart 
pointer 'PToMove' is null}}
+  P = std::move(PToMove); // expected-note {{Smart pointer 'P' is null after a 
null value moved from 'PToMove'}}
+  P->foo(); // expected-warning {{Dereference of null smart pointer 'P' 
[alpha.cplusplus.SmartPtr]}}

I suggest: `Null pointer value move-assigned to 'P'`.



Comment at: clang/test/Analysis/smart-ptr-text-output.cpp:139
+  std::unique_ptr P;
+  P = std::move(PToMove); // expected-note {{Smart pointer 'PToMove' is null 
after moved and assigned to 'P'}}
+  PToMove->foo(); // expected-warning {{Dereference of null smart pointer 
'PToMove' [alpha.cplusplus.SmartPtr]}}

I suggest: `Smart pointer 'PToMove' is null; previous value moved to 'P'`. Or 
maybe instead keep the note that the move-checker currently emits?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86293

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


[PATCH] D86373: [analyzer] Add modeling for unique_ptr move constructor

2020-08-21 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

This is easier than D86293  because there's no 
old value in the freshly constructed smart pointer, right? I suspect that you 
can still re-use a lot of the implementation with D86293 
, at least partially.




Comment at: clang/test/Analysis/smart-ptr.cpp:295
+  P->foo();  // No warning.
+}

vrnithinkumar wrote:
> I was trying to test the below code.
> ```
> void foo_() {
>   std::unique_ptr PToMove;
>   std::unique_ptr&& AfterRValeRefCast = 
> std::move(functionReturnsRValueRef());
>   std::unique_ptr P(AfterRValeRefCast);
>   P->foo(); // expected-warning {{Dereference of null smart pointer 'P' 
> [alpha.cplusplus.SmartPtr]}}
> }
> ```
> 
> But passing the local RValue reference variable to move constructor is always 
> invoking the deleted copy constructor.
Yeah, you still need an explicit move over it. Implicit moves don't happen 
because it's an rvalue reference, it has more to do with the anonymity of the 
object; the compiler only auto-moves when there's no possibility for accidental 
implicit use-after-move, and in presence of a named reference to the value, 
accidental implicit use-after-move is still very much possible, so an explicit 
move is required. That's not the exact rules but that's, as far as i 
understand, the logic behind the exact rules.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86373

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


[PATCH] D81703: [Clang] Don't leave Expr::Classification fields uninitialized in default constructor

2020-08-21 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

Compiler warning should already catch this


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81703

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


[PATCH] D85998: Add clang-cl "vctoolsdir" option to specify the location of the msvc toolchain

2020-08-21 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added inline comments.



Comment at: clang/test/Driver/cl-options.c:685
 
+// vctoolsdir is handled by the driver; just check that we don't error. Pass 
-c because fakedir isn't a real toolchain path
+// RUN: %clang_cl -c -vctoolsdir fakedir -- %s 2>&1

One more thing: I would avoid long lines, and try to stay as much as possible 
within the 80 char per line limit. There's no hard rule for the tests as you 
can see in the file above, but it's a nice to have.


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

https://reviews.llvm.org/D85998

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


[PATCH] D86310: [X86] Align i128 to 16 bytes in x86-64 datalayout

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

As far as I know, there are basically three categories of things that depend on 
the alignment of a type.

1. The default alignment of load/store/alloca.  On trunk, load/store/alloca 
always have explicitly specified alignment in memory.  That said, old bitcode 
doesn't have explicit alignment in some cases, and we currently run 
UpgradeDataLayoutString() before we actually parse the IR instructions.
2. The default alignment of global variables.  Globals are allowed to have 
unspecified alignment, and the resulting alignment is implicitly computed by a 
sort of tricky algorithm.  We could look into forcing it to be computed 
explicitly, but it's a lot of work because there are a lot of places in the 
code that create globals without specifying the alignment.
3. The layout of other types: for a struct that isn't packed, LLVM implicitly 
inserts padding to ensure it's aligned.  To make this work correctly, you'd 
have to rewrite the types of every global/load/store/GEP/etc so they don't 
depend on the alignment of i128.

To autoupgrade correctly, we have to handle all three of those.

We can't just weaken the compatible datalayout check because the modules are 
actually incompatible, for the above reasons.


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

https://reviews.llvm.org/D86310

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


[PATCH] D86376: [HIP] Improve kernel launching latency

2020-08-21 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: tra, rjmccall.
yaxunl requested review of this revision.

Currently clang emits emits the following code for triple chevron kernel call 
for HIP:

  __hipPushCallConfiguration(grids, blocks, shmem, stream);
  kernel_stub();

whereas for each kernel, clang emits a kernel_stub:

  void kernel_stub() {
__hipPopCallConfiguration(, , , );
hipLaunchKernel(kernel_stub, grids, blocks, kernel_args, shmem, stream);
  }

This is really unnecessary. in host code, a kernel function is not really a 
"function"
since you cannot "call" it in the generated IR, you can only launch it through 
kernel
launching API.

This patch simplifies the generated code for kernel launching by eliminating the
call of `__hipPushCallConfiguration` and `__hipPopCallConfiguration`. For each
triple chevron, a call of `hipLaunchKernel` is directly emitted. The kernel stub
function is still emitted as an empty function, for the sole purpose of as a 
shadow
symbol to map to the device symbol in device binary so that runtime can use it
to find the device symbol.

This patch does not change AST for kernel since semantically a triple chevron
is like a function call. Keep it as a function call facilitates overloading 
resolution
and function argument type checking.

This patch only changes kernel launching codegen for HIP for the new kernel 
launching
API since we are sure there is no other side effect in 
`__hipPushCallConfiguration`
and `__hipPopCallConfiguration`.


https://reviews.llvm.org/D86376

Files:
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/test/CodeGenCUDA/kernel-call.cu
  clang/test/CodeGenCUDA/kernel-call.hip
  clang/test/lit.cfg.py

Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -25,7 +25,7 @@
 config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
 
 # suffixes: A list of file extensions to treat as test files.
-config.suffixes = ['.c', '.cpp', '.i', '.cppm', '.m', '.mm', '.cu',
+config.suffixes = ['.c', '.cpp', '.i', '.cppm', '.m', '.mm', '.cu', '.hip',
'.ll', '.cl', '.s', '.S', '.modulemap', '.test', '.rs', '.ifs']
 
 # excludes: A list of directories to exclude from the testsuite. The 'Inputs'
Index: clang/test/CodeGenCUDA/kernel-call.hip
===
--- /dev/null
+++ clang/test/CodeGenCUDA/kernel-call.hip
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -fhip-new-launch-api -triple x86_64-unknown-linux-gnu \
+// RUN:   -std=c++11 -emit-llvm %s -o - | FileCheck %s
+
+#include "Inputs/cuda.h"
+
+struct A { int a[10]; };
+
+__global__ void g1(int x) {}
+__global__ void g2(A x) {}
+__global__ void g3(A ) {}
+template __global__ void g4(F f, int *x) { *x = f(); }
+void (*pg1)(int x) = g1;
+
+// CHECK-LABEL: define{{.*}}test1
+void test1() {
+  // CHECK: call void @_ZN4dim3C1Ejjj(%struct.dim3* {{.*}}, i32 2, i32 1, i32 1)
+  // CHECK: call void @_ZN4dim3C1Ejjj(%struct.dim3* {{.*}}, i32 3, i32 1, i32 1)
+  // CHECK: call i32 @hipLaunchKernel({{.*}}@_Z17__device_stub__g1i{{.*}}, i64 0, %struct.hipStream* null)
+  g1<<<2, 3>>>(0);
+
+  // CHECK: call void @_ZN4dim3C1Ejjj(%struct.dim3* {{.*}}, i32 4, i32 5, i32 6)
+  // CHECK: call void @_ZN4dim3C1Ejjj(%struct.dim3* {{.*}}, i32 7, i32 8, i32 9)
+  // CHECK: call i32 @hipLaunchKernel({{.*}}@_Z17__device_stub__g1i{{.*}}, i64 10, {{.*}}inttoptr (i64 11
+  g1<<>>(0);
+
+  // CHECK: %[[LD:.*]] = load void (i32)*, void (i32)** @pg1
+  // CHECK: %[[PTR:.*]] = bitcast void (i32)* %[[LD]] to i8*
+  // CHECK: call i32 @hipLaunchKernel({{.*}}%[[PTR]]{{.*}}, i64 0, %struct.hipStream* null)
+  pg1<<<1, 1>>>(0);
+}
+
+// CHECK-LABEL: define{{.*}}test2
+void test2() {
+  A a;
+  // CHECK: %agg.tmp = alloca %struct.A, align 4
+  // CHECK: %kernel_args = alloca i8*, i64 1, align 16
+  // CHECK: %[[CAST:.*]] = bitcast %struct.A* %agg.tmp to i8*
+  // CHECK: %[[GEP:.*]] = getelementptr i8*, i8** %kernel_args, i32 0
+  // CHECK: store i8* %[[CAST]], i8** %[[GEP]], align 8
+  // CHECK: call i32 @hipLaunchKernel({{.*}}@_Z17__device_stub__g21A{{.*}}, i64 0, %struct.hipStream* null)
+  g2<<<1, 1>>>(a);
+}
+
+// CHECK-LABEL: define{{.*}}test3
+void test3() {
+  A a;
+  // CHECK: %a = alloca %struct.A, align 4
+  // CHECK: %kernel_arg = alloca %struct.A*, align 8
+  // CHECK: %kernel_args = alloca i8*, i64 1, align 16
+  // CHECK: store %struct.A* %a, %struct.A** %kernel_arg, align 8
+  // CHECK: %[[CAST:.*]] = bitcast %struct.A** %kernel_arg to i8*
+  // CHECK: %[[GEP:.*]] = getelementptr i8*, i8** %kernel_args, i32 0
+  // CHECK: store i8* %[[CAST]], i8** %[[GEP]], align 8
+  // CHECK: call i32 @hipLaunchKernel({{.*}}@_Z17__device_stub__g3R1A{{.*}}, i64 0, %struct.hipStream* null)
+  g3<<<1, 1>>>(a);
+}
+
+// CHECK-LABEL: define{{.*}}test4
+void test4() {
+  int x = 123;
+  int y;
+  // CHECK: %agg.tmp = alloca %class.anon, align 4
+  // CHECK: %kernel_args = alloca i8*, 

[PATCH] D85998: Add clang-cl "vctoolsdir" option to specify the location of the msvc toolchain

2020-08-21 Thread Zachary Henkel via Phabricator via cfe-commits
zahen added a comment.

We use BuildXL.  Thanks for the comments.  I'll make the requested changes and 
get a new rev posted.


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

https://reviews.llvm.org/D85998

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


[PATCH] D86218: Teach the swift calling convention about _Atomic types

2020-08-21 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86218

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


[PATCH] D85998: Add clang-cl "vctoolsdir" option to specify the location of the msvc toolchain

2020-08-21 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added subscribers: amccarth, dblaikie.
aganea added a comment.

In D85998#2231001 , @zahen wrote:

> The build system strives to be deterministic

When you say build system, you mean MSBuild? Other? For example, Fastbuild 
purposely calls `CreateProcess` with an empty environment block (not null) to 
avoid determinism issues. Is that your case? We are also using `-nostdinc` to 
avoid any compiler-generated include paths, even in cases where you need to 
repro something in a VS cmd shell.

The patch looks good otherwise, modulo the comments. + @amccarth @dblaikie for 
more opinions.




Comment at: clang/lib/Driver/ToolChains/MSVC.cpp:74
+   if (Arg *A = Args.getLastArg(options::OPT__SLASH_vctoolsdir)) {
+Path = A->getValue();
+VSLayout = MSVCToolChain::ToolsetLayout::VS2017OrNewer;

zahen wrote:
> Deliberately not validating the input.  The primary motivation is to prevent 
> unnecessary file and registry access.
I would add what you said above as a comment. It is interesting for future 
readers of this code, and avoids digging the history for intent.



Comment at: clang/test/Driver/cl-options.c:686
+// vctoolsdir is handled by the driver; just check that we don't error. Pass 
-c because fakedir isn't a real toolchain path
+// RUN: %clang_cl -c -vctoolsdir fakedir -- %s 2>&1
+

Check that we're not detecting a local installation, and that we fallback to 
the default triple 19.11, ie.
```
// RUN: %clang_cl ... -vctoolsdir "" -### | FileCheck %s --check-prefix 
VCTOOLSDIR
// VCTOOLSDIR: "-cc1" "-triple" "x86_64-pc-windows-msvc19.11.0"
```


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

https://reviews.llvm.org/D85998

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


[PATCH] D86373: [analyzer] Add modeling for unique_ptr move constructor

2020-08-21 Thread Nithin VR via Phabricator via cfe-commits
vrnithinkumar added inline comments.



Comment at: clang/test/Analysis/smart-ptr.cpp:295
+  P->foo();  // No warning.
+}

I was trying to test the below code.
```
void foo_() {
  std::unique_ptr PToMove;
  std::unique_ptr&& AfterRValeRefCast = 
std::move(functionReturnsRValueRef());
  std::unique_ptr P(AfterRValeRefCast);
  P->foo(); // expected-warning {{Dereference of null smart pointer 'P' 
[alpha.cplusplus.SmartPtr]}}
}
```

But passing the local RValue reference variable to move constructor is always 
invoking the deleted copy constructor.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86373

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


[PATCH] D86373: [analyzer] Add modeling for unique_ptr move constructor

2020-08-21 Thread Nithin VR via Phabricator via cfe-commits
vrnithinkumar created this revision.
Herald added subscribers: cfe-commits, steakhal, ASDenysPetrov, martong, 
Charusso, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, 
baloghadamsoftware, xazax.hun.
Herald added a project: clang.
vrnithinkumar requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86373

Files:
  clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.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
@@ -252,3 +252,44 @@
   P->foo(); // No warning.
   PValid->foo(); // No warning.
 }
+
+void derefMoveConstructedWithValidPtr() {
+  std::unique_ptr PToMove(new A());
+  std::unique_ptr P(std::move(PToMove));
+  P->foo(); // No warning.
+}
+
+void derefMoveConstructedWithNullPtr() {
+  std::unique_ptr PToMove;
+  std::unique_ptr P(std::move(PToMove));
+  P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+}
+
+void derefMoveConstructedWithUnknownPtr(std::unique_ptr PToMove) {
+  std::unique_ptr P(std::move(PToMove));
+  P->foo(); // No warning.
+}
+
+void derefValidPtrMovedToConstruct() {
+  std::unique_ptr PToMove(new A());
+  std::unique_ptr P(std::move(PToMove));
+  PToMove->foo(); // expected-warning {{Dereference of null smart pointer 'PToMove' [alpha.cplusplus.SmartPtr]}}
+}
+
+void derefNullPtrMovedToConstruct() {
+  std::unique_ptr PToMove;
+  std::unique_ptr P(std::move(PToMove));
+  PToMove->foo(); // expected-warning {{Dereference of null smart pointer 'PToMove' [alpha.cplusplus.SmartPtr]}}
+}
+
+void derefUnknownPtrMovedToConstruct(std::unique_ptr PToMove) {
+  std::unique_ptr P(std::move(PToMove));
+  PToMove->foo(); // expected-warning {{Dereference of null smart pointer 'PToMove' [alpha.cplusplus.SmartPtr]}}
+}
+
+std::unique_ptr &();
+
+void derefMoveConstructedWithRValueRefReturn(std::unique_ptr PToMove) {
+  std::unique_ptr P(functionReturnsRValueRef());
+  P->foo();  // No warning.
+}
Index: clang/test/Analysis/smart-ptr-text-output.cpp
===
--- clang/test/Analysis/smart-ptr-text-output.cpp
+++ clang/test/Analysis/smart-ptr-text-output.cpp
@@ -116,3 +116,32 @@
   P->foo(); // expected-warning {{Dereference of null smart pointer 'P' of type 'std::unique_ptr' [cplusplus.Move]}}
   // expected-note@-1 {{Dereference of null smart pointer 'P' of type 'std::unique_ptr'}}
 }
+
+void derefMoveConstructedWithNullPtr() {
+  std::unique_ptr PToMove; // expected-note {{Default constructed smart pointer 'PToMove' is null}}
+  std::unique_ptr P(std::move(PToMove)); // expected-note {{Smart pointer 'P' is constructed with null value moved from 'PToMove'}}
+  P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+  // expected-note@-1{{Dereference of null smart pointer 'P'}}
+}
+
+void derefValidPtrMovedToConstruct() {
+  std::unique_ptr PToMove(new A()); // expected-note {{Smart pointer 'PToMove' is constructed}}
+  // FIXME: above note should go away once we fix marking region not interested. 
+  std::unique_ptr P(std::move(PToMove)); // expected-note {{Smart pointer 'PToMove' is null after moved to construct 'P'}}
+  PToMove->foo(); // expected-warning {{Dereference of null smart pointer 'PToMove' [alpha.cplusplus.SmartPtr]}}
+  // expected-note@-1{{Dereference of null smart pointer 'PToMove'}}
+}
+
+void derefNullPtrMovedToConstruct() {
+  std::unique_ptr PToMove; // expected-note {{Default constructed smart pointer 'PToMove' is null}}
+  // FIXME: above note should go away once we fix marking region not interested. 
+  std::unique_ptr P(std::move(PToMove)); // expected-note {{Smart pointer 'PToMove' is null after moved to construct 'P'}}
+  PToMove->foo(); // expected-warning {{Dereference of null smart pointer 'PToMove' [alpha.cplusplus.SmartPtr]}}
+  // expected-note@-1{{Dereference of null smart pointer 'PToMove'}}
+}
+
+void derefUnknownPtrMovedToConstruct(std::unique_ptr PToMove) {
+  std::unique_ptr P(std::move(PToMove)); // expected-note {{Smart pointer 'PToMove' is null after moved to construct 'P'}}
+  PToMove->foo(); // expected-warning {{Dereference of null smart pointer 'PToMove' [alpha.cplusplus.SmartPtr]}}
+  // expected-note@-1{{Dereference of null smart pointer 'PToMove'}}
+}
Index: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
@@ -56,6 +56,8 @@
   void handleReset(const CallEvent , CheckerContext ) const;
   void handleRelease(const CallEvent , CheckerContext ) const;
   void handleSwap(const CallEvent , CheckerContext ) const;
+  bool 

[PATCH] D86369: [Sema][MSVC] warn at dynamic_cast when /GR- is given

2020-08-21 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added inline comments.



Comment at: clang/test/SemaCXX/ms_dynamic_cast.cpp:16
+B *b = new D1();
+auto d = dynamic_cast(b); // expected-warning{{should not use 
dynamic_cast with /GR-}}
+}

lebedev.ri wrote:
> I'm not sure it makes sense to talk about MSVC/clang-cl flags when normal 
> clang is used.
> Either the diag should only be used in MSVC compat mode,
> or it should talk about `-fno-rtti` in non-MSVC compat mode.
I am not sure either... But `-fno-rtti-data` is only used when clang-cl driver 
translate `/GR-` to `-fno-rtti-data`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86369

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


[PATCH] D84713: [DominatorTree] Simplify ChildrenGetter.

2020-08-21 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added a comment.

Done in https://reviews.llvm.org/rG7ea0ee30588,


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84713

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


[PATCH] D86369: [Sema][MSVC] warn at dynamic_cast when /GR- is given

2020-08-21 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: clang/test/SemaCXX/ms_dynamic_cast.cpp:16
+B *b = new D1();
+auto d = dynamic_cast(b); // expected-warning{{should not use 
dynamic_cast with /GR-}}
+}

I'm not sure it makes sense to talk about MSVC/clang-cl flags when normal clang 
is used.
Either the diag should only be used in MSVC compat mode,
or it should talk about `-fno-rtti` in non-MSVC compat mode.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86369

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


[PATCH] D86369: [Sema][MSVC] warn at dynamic_cast when /GR- is given

2020-08-21 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu created this revision.
zequanwu added a reviewer: hans.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
zequanwu requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86369

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaCast.cpp
  clang/test/SemaCXX/ms_dynamic_cast.cpp


Index: clang/test/SemaCXX/ms_dynamic_cast.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/ms_dynamic_cast.cpp
@@ -0,0 +1,17 @@
+// RUN:  %clang_cc1 %s -fno-rtti-data -fsyntax-only -verify
+
+class B {
+public:
+virtual ~B() = default;
+};
+
+class D1 : public B {
+public:
+~D1() = default;
+
+};
+
+void  f() {
+B *b = new D1();
+auto d = dynamic_cast(b); // expected-warning{{should not use 
dynamic_cast with /GR-}}
+}
\ No newline at end of file
Index: clang/lib/Sema/SemaCast.cpp
===
--- clang/lib/Sema/SemaCast.cpp
+++ clang/lib/Sema/SemaCast.cpp
@@ -890,6 +890,11 @@
 return;
   }
 
+  // MSVC warns when dynamic_cast is used with /GR-.
+  if (!Self.getLangOpts().RTTIData) {
+Self.Diag(OpRange.getBegin(), diag::warn_no_dynamic_cast_with_no_GR);
+  }
+
   // Done. Everything else is run-time checks.
   Kind = CK_Dynamic;
 }
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7433,6 +7433,8 @@
   "use of typeid requires -frtti">;
 def err_no_dynamic_cast_with_fno_rtti : Error<
   "use of dynamic_cast requires -frtti">;
+def warn_no_dynamic_cast_with_no_GR: Warning<
+  "should not use dynamic_cast with /GR-">;
 
 def err_cannot_form_pointer_to_member_of_reference_type : Error<
   "cannot form a pointer-to-member to member %0 of reference type %1">;


Index: clang/test/SemaCXX/ms_dynamic_cast.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/ms_dynamic_cast.cpp
@@ -0,0 +1,17 @@
+// RUN:  %clang_cc1 %s -fno-rtti-data -fsyntax-only -verify
+
+class B {
+public:
+virtual ~B() = default;
+};
+
+class D1 : public B {
+public:
+~D1() = default;
+
+};
+
+void  f() {
+B *b = new D1();
+auto d = dynamic_cast(b); // expected-warning{{should not use dynamic_cast with /GR-}}
+}
\ No newline at end of file
Index: clang/lib/Sema/SemaCast.cpp
===
--- clang/lib/Sema/SemaCast.cpp
+++ clang/lib/Sema/SemaCast.cpp
@@ -890,6 +890,11 @@
 return;
   }
 
+  // MSVC warns when dynamic_cast is used with /GR-.
+  if (!Self.getLangOpts().RTTIData) {
+Self.Diag(OpRange.getBegin(), diag::warn_no_dynamic_cast_with_no_GR);
+  }
+
   // Done. Everything else is run-time checks.
   Kind = CK_Dynamic;
 }
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7433,6 +7433,8 @@
   "use of typeid requires -frtti">;
 def err_no_dynamic_cast_with_fno_rtti : Error<
   "use of dynamic_cast requires -frtti">;
+def warn_no_dynamic_cast_with_no_GR: Warning<
+  "should not use dynamic_cast with /GR-">;
 
 def err_cannot_form_pointer_to_member_of_reference_type : Error<
   "cannot form a pointer-to-member to member %0 of reference type %1">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86310: [X86] Align i128 to 16 bytes in x86-64 datalayout

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

In D86310#2231136 , @efriedma wrote:

> I'm afraid the AutoUpgrade component of this isn't compatible with existing 
> IR without some additional work.  I'm most concerned about cases like the 
> following:
>
>   #pragma pack(8)
>   struct X { __int128 x; }; // Not a packed struct in IR because the native 
> alignment is 8
>   struct Y { long long x; struct X y; }; // 24 bytes before autoupgrade, 32 
> bytes after
>   struct Y x;
>
>
>
> --
>
> On a related note, we need to add "Fn8" to the x86 datalayout at some point.

I kind of feared that old IR was going to be a problem. Any thoughts on how to 
fix it? Do we need to visit every alloca/load/store/etc that don't have 
explicit alignment and force them to the old alignment?  Alternatively, could 
we skip the autoupgrade and weaken the compatible layout check somehow?


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

https://reviews.llvm.org/D86310

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


[PATCH] D86310: [X86] Align i128 to 16 bytes in x86-64 datalayout

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

I'm afraid the AutoUpgrade component of this isn't compatible with existing IR 
without some additional work.  I'm most concerned about cases like the 
following:

  #pragma pack(8)
  struct X { __int128 x; }; // Not a packed struct in IR because the native 
alignment is 8
  struct Y { long long x; struct X y; }; // 24 bytes before autoupgrade, 32 
bytes after
  struct Y x;



--

On a related note, we need to add "Fn8" to the x86 datalayout at some point.


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

https://reviews.llvm.org/D86310

___
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-21 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

(side note: this code review is a bit hard to follow with all the linting 
messages about naming - might be a bit more readable if it conformed to the 
naming conventions?)

In D83088#2227151 , @nhaehnle wrote:

> In D83088#2225415 , @dblaikie wrote:
>
 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?
>
> See below.
>
>>> 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.
>
> Take a look here for example: 
> https://github.com/nhaehnle/llvm-project/blob/715450fa7f968ceefaf9c3b04b47066866c97206/llvm/lib/Analysis/GenericConvergenceUtils.cpp#L499
>  -- this is obviously still fairly simple, but it's an example of printing 
> out the results of an analysis in a way that's generic over the underlying 
> CFG and SSA form.

I'm having trouble following this example - I'm not sure what the CfgPrinter 
abstraction is/why it's first-class, and why this "print" function is calling 
what look like mutation operations like "appendBlocks". I guess perhaps the 
question is - what's it printing from and what's it printing to?

Ah, I see, the "append" functions are accessors, of a sort. Returning a 
container might be more clear than using an out parameter - alternatively, a 
functor parameter (ala std::for_each) that is called for each element, that can 
then be used to populate an existing container if desired, or to do immediate 
processing without the need for an intermediate container.

Though the printer abstraction still strikes me as a bit strange - especially 
since it doesn't seem to be printing itself. This function was passed a printer 
and a stream - the printer prints to the stream (perhaps it'd make more sense 
for the printer to take the stream on construction) and the function isn't 
passed the thing to print at all - that thing is accessed from the printer. 
That seems fairly awkward to me - I'd expect a printing operation to take a 
thing to be printed and a thing to print to.

Perhaps setting aside the complexities of printing things - could you provide 
an example of code, given a CfgGraph, that walks the graph - perhaps just 
numbering the nodes/edges/etc to produce a dot graph? Showing what the code 
would look like if it were passed a GraphTraits-implementing graph, a static 
polymorphic CfgGraph, and a dynamically polymorphic GfgGraph - and also showing 
what would be fandemantally possible with the CfgGraph that wouldn't be 
possible with GraphTraits, if any such things exist (it's still unclear to me 
whether CfgGraph has abstractions that don't exist in GraphTraits (eg: could 
you write a CfgGraph over GraphTraits? or would that be impossible because 
GraphTraits is missing concepts/CfgGraph doesn't apply to all 
GraphTraits-grahs? what subset of GraphTraits graphs does CfgGraph cover?).

> A statically 

[PATCH] D85998: Add clang-cl "vctoolsdir" option to specify the location of the msvc toolchain

2020-08-21 Thread Zachary Henkel via Phabricator via cfe-commits
zahen added a comment.

The build system strives to be deterministic so all file probes need to be 
accounted for; environment variables are also problematic.  Our builds 
deliberately don't run from a Visual Studio command prompt.  In addition, we'd 
like to avoid coupling clang tools that don't perform codegen to link.exe.  We 
do use -fmsc-version= during the build.


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

https://reviews.llvm.org/D85998

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


[PATCH] D85998: Add clang-cl "vctoolsdir" option to specify the location of the msvc toolchain

2020-08-21 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

Could you please explain a little bit more what motivated this change? You can 
achieve almost the same with `env VCToolsInstallDir=F:\Your_Path\ clang-cl 
...`. You would also want to pass `-fmsc-version=...` to avoid extracting the 
version from `cl.exe`. If you're seeing many file and registry accesses, then 
`clang-cl` probably runs without a call to `vcvarsall.bat` before?


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

https://reviews.llvm.org/D85998

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


[PATCH] D82502: [PowerPC] Implement Load VSX Vector and Sign Extend and Zero Extend

2020-08-21 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai accepted this revision.
nemanjai added a comment.

LGTM aside from a couple of minor nits.




Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:13405
+  // This combine is only eligible for a BUILD_VECTOR of v1i128.
+  // Other return types are not valid for the LXVRZX replacement.
+  if (N->getValueType(0) != MVT::v1i128)

This line is redundant. Please remove it.



Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:13424
+  // Ensure that the load from the narrow width is being zero extended to i128.
+  if (!ValidLDType || (LD->getValueType(0) != MVT::i128) ||
+  (LD->getExtensionType() != ISD::ZEXTLOAD &&

The second condition was already checked on line 13604. You can omit  it here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82502

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


[clang] c0ec37e - [docs] Move the label for __builtin_shufflevector below __builtin_dump_struct so the see also link in 'vector operations' will go to the right place and have the right name.

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

Author: Craig Topper
Date: 2020-08-21T11:51:15-07:00
New Revision: c0ec37ee65d0d21fddc6194fe1cce9db4107a902

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

LOG: [docs] Move the label for __builtin_shufflevector below 
__builtin_dump_struct so the see also link in 'vector operations' will go to 
the right place and have the right name.

Added: 


Modified: 
clang/docs/LanguageExtensions.rst

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index e12bc2ce9633..518ab6385263 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -1810,8 +1810,6 @@ Query for this feature with 
``__has_builtin(__builtin_readcyclecounter)``. Note
 that even if present, its use may depend on run-time privilege or other OS
 controlled state.
 
-.. _langext-__builtin_shufflevector:
-
 ``__builtin_dump_struct``
 -
 
@@ -1858,6 +1856,8 @@ to a structure to dump the fields of, and a pointer to a 
formatted output
 function whose signature must be: ``int (*)(const char *, ...)`` and must
 support the format specifiers used by ``printf()``.
 
+.. _langext-__builtin_shufflevector:
+
 ``__builtin_shufflevector``
 ---
 



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


[PATCH] D85324: [SystemZ][z/OS] Add z/OS Target and define macros

2020-08-21 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast accepted this revision.
hubert.reinterpretcast added a comment.
This revision is now accepted and ready to land.

LGTM from my end; although @MaskRay might want another look.




Comment at: clang/lib/Basic/Targets/OSTargets.h:758
+  Builder.defineMacro("__DLL__");
+  // XOPEN_SOURCE=600 is required to build libcxx.
+  Builder.defineMacro("_XOPEN_SOURCE", "600");

Minor nit: s/XOPEN_SOURCE/_XOPEN_SOURCE/;


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85324

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


[PATCH] D83174: Teach AttachPreviousImpl to inherit MSInheritanceAttr attribute

2020-08-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D83174#2230795 , @gargvaibhav64 
wrote:

> I updated the -triple option to x86_64-pc-windows-msvc (as it was more 
> consistent with current tests). I also updated the path to Unix style in the 
> -I option.

Thank you for the fixes, I've re-landed in 
aca191cce1c4dbab28a65cfe4caa6348e698a2b3 
.


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

https://reviews.llvm.org/D83174

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


[clang] aca191c - Re-land 7a527f17776be78ec44b88e82b39afb65fc148e4 with fixes.

2020-08-21 Thread Aaron Ballman via cfe-commits

Author: Vaibhav Garg
Date: 2020-08-21T14:40:09-04:00
New Revision: aca191cce1c4dbab28a65cfe4caa6348e698a2b3

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

LOG: Re-land 7a527f17776be78ec44b88e82b39afb65fc148e4 with fixes.

The original commit was reverted in 58c305f466d1f78adb10e7295b9bc9fc192a6e09
due to broken bots. This commit corrects the triple and command line paths.

Added: 
clang/test/Modules/Inputs/inherit-attribute/a.h
clang/test/Modules/Inputs/inherit-attribute/b.h
clang/test/Modules/Inputs/inherit-attribute/c.h
clang/test/Modules/Inputs/inherit-attribute/module.modulemap
clang/test/Modules/inherit-attribute.cpp

Modified: 
clang/lib/Serialization/ASTReaderDecl.cpp

Removed: 




diff  --git a/clang/lib/Serialization/ASTReaderDecl.cpp 
b/clang/lib/Serialization/ASTReaderDecl.cpp
index d76182847e9d..c7a009d1e50d 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -281,6 +281,9 @@ namespace clang {
 static Decl *getMostRecentDeclImpl(...);
 static Decl *getMostRecentDecl(Decl *D);
 
+static void mergeInheritableAttributes(ASTReader , Decl *D,
+   Decl *Previous);
+
 template 
 static void attachPreviousDeclImpl(ASTReader ,
Redeclarable *D, Decl *Previous,
@@ -3511,6 +3514,19 @@ Decl *ASTReader::getMostRecentExistingDecl(Decl *D) {
   return ASTDeclReader::getMostRecentDecl(D->getCanonicalDecl());
 }
 
+void ASTDeclReader::mergeInheritableAttributes(ASTReader , Decl *D,
+   Decl *Previous) {
+  InheritableAttr *NewAttr = nullptr;
+  ASTContext  = Reader.getContext();
+  const auto *IA = Previous->getAttr();
+
+  if (IA && !D->hasAttr()) {
+NewAttr = cast(IA->clone(Context));
+NewAttr->setInherited(true);
+D->addAttr(NewAttr);
+  }
+}
+
 template
 void ASTDeclReader::attachPreviousDeclImpl(ASTReader ,
Redeclarable *D,
@@ -3669,6 +3685,12 @@ void ASTDeclReader::attachPreviousDecl(ASTReader 
, Decl *D,
   if (auto *TD = dyn_cast(D))
 inheritDefaultTemplateArguments(Reader.getContext(),
 cast(Previous), TD);
+
+  // If any of the declaration in the chain contains an Inheritable attribute,
+  // it needs to be added to all the declarations in the redeclarable chain.
+  // FIXME: Only the logic of merging MSInheritableAttr is present, it should
+  // be extended for all inheritable attributes.
+  mergeInheritableAttributes(Reader, D, Previous);
 }
 
 template

diff  --git a/clang/test/Modules/Inputs/inherit-attribute/a.h 
b/clang/test/Modules/Inputs/inherit-attribute/a.h
new file mode 100644
index ..04aabe9e8c61
--- /dev/null
+++ b/clang/test/Modules/Inputs/inherit-attribute/a.h
@@ -0,0 +1,10 @@
+#ifndef FOO
+#define FOO
+
+class Foo {
+public:
+  void step(int v);
+  Foo();
+};
+
+#endif

diff  --git a/clang/test/Modules/Inputs/inherit-attribute/b.h 
b/clang/test/Modules/Inputs/inherit-attribute/b.h
new file mode 100644
index ..9cd1f55b9d33
--- /dev/null
+++ b/clang/test/Modules/Inputs/inherit-attribute/b.h
@@ -0,0 +1,5 @@
+#include "a.h"
+
+void bar() {
+  ::step;
+}

diff  --git a/clang/test/Modules/Inputs/inherit-attribute/c.h 
b/clang/test/Modules/Inputs/inherit-attribute/c.h
new file mode 100644
index ..2243de1baf9a
--- /dev/null
+++ b/clang/test/Modules/Inputs/inherit-attribute/c.h
@@ -0,0 +1 @@
+#include "a.h"

diff  --git a/clang/test/Modules/Inputs/inherit-attribute/module.modulemap 
b/clang/test/Modules/Inputs/inherit-attribute/module.modulemap
new file mode 100644
index ..16481e2745dd
--- /dev/null
+++ b/clang/test/Modules/Inputs/inherit-attribute/module.modulemap
@@ -0,0 +1,3 @@
+module "b" { header "b.h" }
+
+module "c" { header "c.h" }

diff  --git a/clang/test/Modules/inherit-attribute.cpp 
b/clang/test/Modules/inherit-attribute.cpp
new file mode 100644
index ..980b30ef4975
--- /dev/null
+++ b/clang/test/Modules/inherit-attribute.cpp
@@ -0,0 +1,20 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -triple x86_64-pc-windows-msvc 
-I%S/Inputs/inherit-attribute -fmodules-cache-path=%t \
+// RUN: -fimplicit-module-maps -fmodules-local-submodule-visibility %s 
-ast-dump-all \
+// RUN: | FileCheck %s
+
+#include "b.h"
+#include "c.h"
+
+class Foo;
+
+Foo f;
+
+// CHECK:   CXXRecordDecl {{.*}} imported in b {{.*}} Foo
+// CHECK:   MSInheritanceAttr {{[^()]*$}}
+
+// CHECK:   CXXRecordDecl {{.*}} prev {{.*}} imported in c {{.*}} Foo
+// CHECK:   MSInheritanceAttr {{.*}} Inherited {{[^()]*$}}
+
+// CHECK:   CXXRecordDecl {{.*}}  col:7 referenced class Foo
+// CHECK:   MSInheritanceAttr {{.*}} Inherited 

[PATCH] D86089: [flang][driver]Add experimental flang driver and frontend with help screen

2020-08-21 Thread sameeran joshi via Phabricator via cfe-commits
sameeranjoshi requested changes to this revision.
sameeranjoshi added a comment.

Thanks for working on it.
A few review comments/questions on changes in `flang` part from the patch.




Comment at: flang/include/flang/Frontend/CompilerInstance.h:93
+
+  static clang::IntrusiveRefCntPtr createDiagnostics(
+  clang::DiagnosticOptions *Opts,

The block of comments above make sense for this function and not the currently 
mentioned one.
Please interchange/replace the comments to later declared function.
Wrong comments above could reflect in `doxygen APIs`, misleading the reader of 
code.



Comment at: flang/include/flang/FrontendTool/Utils.h:1
+
+//===--- Utils.h - Misc utilities for the flang front-end *- 
C++-*-===//

`nit:`: blank line.



Comment at: flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:35
+  if (Flang->getFrontendOpts().ShowVersion) {
+llvm::cl::PrintVersionMessage();
+return true;

With 
```
clang --version
clang version 11.0.0 (https://github.com/llvm/llvm-project.git 
1acf129bcf9a1b51e301a9fef151254ec4c7ec43)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
```
whereas with 
```
./bin/flang-new --vesion
Flang experimental driver (flang-new)
```

I see both `clang` & `flang` call
`llvm::cl::PrintVersionMessage()` internally.

Is more information need to be registered in llvm(`llvm::cl`) for flang to give 
more detailed output or will that come later once we start adding more patch 
for driver?



Comment at: flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:39
+
+  return true;
+}

The comment in header for `ExecuteCompilerInvocation` mentions,
```
/// \return - True on success.
bool ExecuteCompilerInvocation(CompilerInstance *Flang);
```

Do we need to have a `false` somewhere here?

I see 2 scenarios when `ExecuteCompilerInvocation` might fail (there could 
definitely be more) and there we need an indication of failure by returning 
`false`,
1. When there is no actual execution of compiler.
2. The compilation in not successful.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86089

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


[PATCH] D86239: [OPENMP]Fix PR47158, case 3: allow devic_typein nested declare target region.

2020-08-21 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen accepted this revision.
cchen 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/D86239/new/

https://reviews.llvm.org/D86239

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


[PATCH] D86342: Enable constexpr on ROTATELEFT/ROTATERIGHT builtin intrinsics (PR47249)

2020-08-21 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

(Same comments as for the bitreverse patch.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86342

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


[PATCH] D86339: Enable constexpr on BITREVERSE builtin intrinsics (PR47249)

2020-08-21 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Can you also add documentation to LanguageExtensions.rst? Thanks!




Comment at: clang/docs/ReleaseNotes.rst:61
+  ``__builtin_bitreverse32`` and ``__builtin_bitreverse64`` may now be used
+  within constexpr expressions.
 

There's no such thing as a "constexpr expression". The right term is "constant 
expressions".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86339

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


[PATCH] D86339: Enable constexpr on BITREVERSE builtin intrinsics (PR47249)

2020-08-21 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

This looks right to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86339

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


[PATCH] D86342: Enable constexpr on ROTATELEFT/ROTATERIGHT builtin intrinsics (PR47249)

2020-08-21 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

Its a bit of a shame that the two implementations (left/right) differ by only a 
single character, an y ideas for combining them cleanly?  I might also consider 
combining the two 'if' statements into a single one (if 
!EvalInteger(E->getArg(0)...) || !EvalInteger(E->getArg(1)...), but that is 
generally just preference.

Otherwise, LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86342

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


[PATCH] D86089: [flang][driver]Add experimental flang driver and frontend with help screen

2020-08-21 Thread Richard Barton via Phabricator via cfe-commits
richard.barton.arm added inline comments.



Comment at: flang/test/lit.cfg.py:40
+# exclude the tests for flang_new driver while there are two drivers
+if config.include_flang_new_driver_test == "OFF":
+  config.excludes = ['Inputs', 'CMakeLists.txt', 'README.txt', 'LICENSE.txt', 
'Flang-Driver']

richard.barton.arm wrote:
> I think it would be cleaner to define config.excludes unconditionally then 
> append the Flang-Driver dir if our condition passes.
I _think_ the pattern to follow to exclude tests for something you haven't 
built is to use lit features.

So you would add a feature like:
`config.available_features.add("new-driver")`

then each test that only works on the new driver would be prefixed with a 
statement:

`REQUIRES: new-driver`

This means that the tests can go in the test/Driver directory and you don't 
need to create a new directory for these tests or this hack. The additional 
benefit would be that all the existing tests for the throwaway driver can be 
re-used on the new Driver to test it. There are not many of those though and we 
are using a different driver name so they can't be shared either. Still think 
it would be a worthwhile thing to do because when looking at the test itself it 
is clear why it is not being run whereas with this hack it is hidden away.

 Sorry for not thinking this first time around.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86089

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


[PATCH] D83174: Teach AttachPreviousImpl to inherit MSInheritanceAttr attribute

2020-08-21 Thread Vaibhav Garg via Phabricator via cfe-commits
gargvaibhav64 updated this revision to Diff 287060.
gargvaibhav64 added a comment.

I updated the -triple option to x86_64-pc-windows-msvc (as it was more 
consistent with current tests). I also updated the path to Unix style in the -I 
option.


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

https://reviews.llvm.org/D83174

Files:
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/test/Modules/Inputs/inherit-attribute/a.h
  clang/test/Modules/Inputs/inherit-attribute/b.h
  clang/test/Modules/Inputs/inherit-attribute/c.h
  clang/test/Modules/Inputs/inherit-attribute/module.modulemap
  clang/test/Modules/inherit-attribute.cpp

Index: clang/test/Modules/inherit-attribute.cpp
===
--- /dev/null
+++ clang/test/Modules/inherit-attribute.cpp
@@ -0,0 +1,20 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -triple x86_64-pc-windows-msvc -I%S/Inputs/inherit-attribute -fmodules-cache-path=%t \
+// RUN: -fimplicit-module-maps -fmodules-local-submodule-visibility %s -ast-dump-all \
+// RUN: | FileCheck %s
+
+#include "b.h"
+#include "c.h"
+
+class Foo;
+
+Foo f;
+
+// CHECK:   CXXRecordDecl {{.*}} imported in b {{.*}} Foo
+// CHECK:   MSInheritanceAttr {{[^()]*$}}
+
+// CHECK:   CXXRecordDecl {{.*}} prev {{.*}} imported in c {{.*}} Foo
+// CHECK:   MSInheritanceAttr {{.*}} Inherited {{[^()]*$}}
+
+// CHECK:   CXXRecordDecl {{.*}}  col:7 referenced class Foo
+// CHECK:   MSInheritanceAttr {{.*}} Inherited {{[^()]*$}}
Index: clang/test/Modules/Inputs/inherit-attribute/module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/inherit-attribute/module.modulemap
@@ -0,0 +1,3 @@
+module "b" { header "b.h" }
+
+module "c" { header "c.h" }
Index: clang/test/Modules/Inputs/inherit-attribute/c.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/inherit-attribute/c.h
@@ -0,0 +1 @@
+#include "a.h"
Index: clang/test/Modules/Inputs/inherit-attribute/b.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/inherit-attribute/b.h
@@ -0,0 +1,5 @@
+#include "a.h"
+
+void bar() {
+  ::step;
+}
Index: clang/test/Modules/Inputs/inherit-attribute/a.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/inherit-attribute/a.h
@@ -0,0 +1,10 @@
+#ifndef FOO
+#define FOO
+
+class Foo {
+public:
+  void step(int v);
+  Foo();
+};
+
+#endif
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -281,6 +281,9 @@
 static Decl *getMostRecentDeclImpl(...);
 static Decl *getMostRecentDecl(Decl *D);
 
+static void mergeInheritableAttributes(ASTReader , Decl *D,
+   Decl *Previous);
+
 template 
 static void attachPreviousDeclImpl(ASTReader ,
Redeclarable *D, Decl *Previous,
@@ -3531,6 +3534,19 @@
   return ASTDeclReader::getMostRecentDecl(D->getCanonicalDecl());
 }
 
+void ASTDeclReader::mergeInheritableAttributes(ASTReader , Decl *D,
+   Decl *Previous) {
+  InheritableAttr *NewAttr = nullptr;
+  ASTContext  = Reader.getContext();
+  const auto *IA = Previous->getAttr();
+
+  if (IA && !D->hasAttr()) {
+NewAttr = cast(IA->clone(Context));
+NewAttr->setInherited(true);
+D->addAttr(NewAttr);
+  }
+}
+
 template
 void ASTDeclReader::attachPreviousDeclImpl(ASTReader ,
Redeclarable *D,
@@ -3689,6 +3705,12 @@
   if (auto *TD = dyn_cast(D))
 inheritDefaultTemplateArguments(Reader.getContext(),
 cast(Previous), TD);
+
+  // If any of the declaration in the chain contains an Inheritable attribute,
+  // it needs to be added to all the declarations in the redeclarable chain.
+  // FIXME: Only the logic of merging MSInheritableAttr is present, it should
+  // be extended for all inheritable attributes.
+  mergeInheritableAttributes(Reader, D, Previous);
 }
 
 template
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83174: Teach AttachPreviousImpl to inherit MSInheritanceAttr attribute

2020-08-21 Thread James Nagurne via Phabricator via cfe-commits
JamesNagurne added a comment.

In D83174#2230763 , @aaron.ballman 
wrote:

> Unfortunately, I had to revert the change as it was causing some buildbots to 
> fail. I reverted in 58c305f466d1f78adb10e7295b9bc9fc192a6e09 
> . Some 
> failures include:
>
> http://lab.llvm.org:8011/builders/clang-cmake-armv7-quick/builds/20294
> http://lab.llvm.org:8011/builders/clang-ppc64le-linux-multistage/builds/13600
>
> I'm not certain why b.h is not being found by those builders. Do you mind 
> investigating?

I suspect the failures are due to the Windows-style path in the -I option.
I recall lit being able to handle such a thing, but my memory might be a bit 
spotty on its command-line emulation capabilities.


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

https://reviews.llvm.org/D83174

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


[PATCH] D83174: Teach AttachPreviousImpl to inherit MSInheritanceAttr attribute

2020-08-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Unfortunately, I had to revert the change as it was causing some buildbots to 
fail. I reverted in 58c305f466d1f78adb10e7295b9bc9fc192a6e09 
. Some 
failures include:

http://lab.llvm.org:8011/builders/clang-cmake-armv7-quick/builds/20294
http://lab.llvm.org:8011/builders/clang-ppc64le-linux-multistage/builds/13600

I'm not certain why b.h is not being found by those builders. Do you mind 
investigating?


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

https://reviews.llvm.org/D83174

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


[clang] 58c305f - Revert "Teach AttachPreviousImpl to inherit MSInheritanceAttr attribute"

2020-08-21 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2020-08-21T12:42:10-04:00
New Revision: 58c305f466d1f78adb10e7295b9bc9fc192a6e09

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

LOG: Revert "Teach AttachPreviousImpl to inherit MSInheritanceAttr attribute"

This reverts commit 7a527f17776be78ec44b88e82b39afb65fc148e4.

It caused some buildbot failures:
http://lab.llvm.org:8011/builders/clang-ppc64le-linux-multistage/builds/13600
http://lab.llvm.org:8011/builders/clang-cmake-armv7-quick/builds/20294

Added: 


Modified: 
clang/lib/Serialization/ASTReaderDecl.cpp

Removed: 
clang/test/Modules/Inputs/inherit-attribute/a.h
clang/test/Modules/Inputs/inherit-attribute/b.h
clang/test/Modules/Inputs/inherit-attribute/c.h
clang/test/Modules/Inputs/inherit-attribute/module.modulemap
clang/test/Modules/inherit-attribute.cpp



diff  --git a/clang/lib/Serialization/ASTReaderDecl.cpp 
b/clang/lib/Serialization/ASTReaderDecl.cpp
index c7a009d1e50d..d76182847e9d 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -281,9 +281,6 @@ namespace clang {
 static Decl *getMostRecentDeclImpl(...);
 static Decl *getMostRecentDecl(Decl *D);
 
-static void mergeInheritableAttributes(ASTReader , Decl *D,
-   Decl *Previous);
-
 template 
 static void attachPreviousDeclImpl(ASTReader ,
Redeclarable *D, Decl *Previous,
@@ -3514,19 +3511,6 @@ Decl *ASTReader::getMostRecentExistingDecl(Decl *D) {
   return ASTDeclReader::getMostRecentDecl(D->getCanonicalDecl());
 }
 
-void ASTDeclReader::mergeInheritableAttributes(ASTReader , Decl *D,
-   Decl *Previous) {
-  InheritableAttr *NewAttr = nullptr;
-  ASTContext  = Reader.getContext();
-  const auto *IA = Previous->getAttr();
-
-  if (IA && !D->hasAttr()) {
-NewAttr = cast(IA->clone(Context));
-NewAttr->setInherited(true);
-D->addAttr(NewAttr);
-  }
-}
-
 template
 void ASTDeclReader::attachPreviousDeclImpl(ASTReader ,
Redeclarable *D,
@@ -3685,12 +3669,6 @@ void ASTDeclReader::attachPreviousDecl(ASTReader 
, Decl *D,
   if (auto *TD = dyn_cast(D))
 inheritDefaultTemplateArguments(Reader.getContext(),
 cast(Previous), TD);
-
-  // If any of the declaration in the chain contains an Inheritable attribute,
-  // it needs to be added to all the declarations in the redeclarable chain.
-  // FIXME: Only the logic of merging MSInheritableAttr is present, it should
-  // be extended for all inheritable attributes.
-  mergeInheritableAttributes(Reader, D, Previous);
 }
 
 template

diff  --git a/clang/test/Modules/Inputs/inherit-attribute/a.h 
b/clang/test/Modules/Inputs/inherit-attribute/a.h
deleted file mode 100644
index 04aabe9e8c61..
--- a/clang/test/Modules/Inputs/inherit-attribute/a.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef FOO
-#define FOO
-
-class Foo {
-public:
-  void step(int v);
-  Foo();
-};
-
-#endif

diff  --git a/clang/test/Modules/Inputs/inherit-attribute/b.h 
b/clang/test/Modules/Inputs/inherit-attribute/b.h
deleted file mode 100644
index 9cd1f55b9d33..
--- a/clang/test/Modules/Inputs/inherit-attribute/b.h
+++ /dev/null
@@ -1,5 +0,0 @@
-#include "a.h"
-
-void bar() {
-  ::step;
-}

diff  --git a/clang/test/Modules/Inputs/inherit-attribute/c.h 
b/clang/test/Modules/Inputs/inherit-attribute/c.h
deleted file mode 100644
index 2243de1baf9a..
--- a/clang/test/Modules/Inputs/inherit-attribute/c.h
+++ /dev/null
@@ -1 +0,0 @@
-#include "a.h"

diff  --git a/clang/test/Modules/Inputs/inherit-attribute/module.modulemap 
b/clang/test/Modules/Inputs/inherit-attribute/module.modulemap
deleted file mode 100644
index 16481e2745dd..
--- a/clang/test/Modules/Inputs/inherit-attribute/module.modulemap
+++ /dev/null
@@ -1,3 +0,0 @@
-module "b" { header "b.h" }
-
-module "c" { header "c.h" }

diff  --git a/clang/test/Modules/inherit-attribute.cpp 
b/clang/test/Modules/inherit-attribute.cpp
deleted file mode 100644
index 34aa4670365a..
--- a/clang/test/Modules/inherit-attribute.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodules -triple x86_64-pc-windows-msvc-unknown 
-I%S\Inputs\inherit-attribute -fmodules-cache-path=%t \
-// RUN: -fimplicit-module-maps -fmodules-local-submodule-visibility %s 
-ast-dump-all \
-// RUN: | FileCheck %s
-
-#include "b.h"
-#include "c.h"
-
-class Foo;
-
-Foo f;
-
-// CHECK:   CXXRecordDecl {{.*}} imported in b {{.*}} Foo
-// CHECK:   MSInheritanceAttr {{[^()]*$}}
-
-// CHECK:   CXXRecordDecl {{.*}} prev {{.*}} imported in c {{.*}} Foo
-// CHECK:   MSInheritanceAttr {{.*}} 

[PATCH] D86218: Teach the swift calling convention about _Atomic types

2020-08-21 Thread Arnold Schwaighofer via Phabricator via cfe-commits
aschwaighofer updated this revision to Diff 287055.
aschwaighofer added a comment.

Respect atomic padding.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86218

Files:
  clang/lib/CodeGen/SwiftCallingConv.cpp
  clang/test/CodeGen/64bit-swiftcall.c


Index: clang/test/CodeGen/64bit-swiftcall.c
===
--- clang/test/CodeGen/64bit-swiftcall.c
+++ clang/test/CodeGen/64bit-swiftcall.c
@@ -10,6 +10,9 @@
 #define ERROR __attribute__((swift_error_result))
 #define CONTEXT __attribute__((swift_context))
 
+// CHECK-DAG: %struct.atomic_padded = type { { %struct.packed, [7 x i8] } }
+// CHECK-DAG: %struct.packed = type <{ i64, i8 }>
+//
 // CHECK: [[STRUCT2_RESULT:@.*]] = private {{.*}} constant 
[[STRUCT2_TYPE:%.*]] { i32 0, i8 0, i8 undef, i8 0, i32 0, i32 0 }
 
 /*/
@@ -1042,3 +1045,27 @@
   // CHECK-NOT: call void @llvm.lifetime.
   take_int5(return_int5());
 }
+
+typedef struct {
+  unsigned long long a;
+  unsigned long long b;
+} double_word;
+
+typedef struct {
+  _Atomic(double_word) a;
+} atomic_double_word;
+
+// CHECK-LABEL: use_atomic(i64 %0, i64 %1)
+SWIFTCALL void use_atomic(atomic_double_word a) {}
+
+typedef struct {
+  unsigned long long a;
+  unsigned char b;
+} __attribute__((packed)) packed;
+
+typedef struct {
+  _Atomic(packed) a;
+} atomic_padded;
+
+// CHECK-LABEL: use_atomic_padded(i64 %0, i64 %1)
+SWIFTCALL void use_atomic_padded(atomic_padded a) {}
Index: clang/lib/CodeGen/SwiftCallingConv.cpp
===
--- clang/lib/CodeGen/SwiftCallingConv.cpp
+++ clang/lib/CodeGen/SwiftCallingConv.cpp
@@ -93,11 +93,24 @@
 // Just add it all as opaque.
 addOpaqueData(begin, begin + CGM.getContext().getTypeSizeInChars(type));
 
-  // Everything else is scalar and should not convert as an LLVM aggregate.
+// Atomic types.
+  } else if (const auto *atomicType = type->getAs()) {
+auto valueType = atomicType->getValueType();
+auto atomicSize = CGM.getContext().getTypeSizeInChars(atomicType);
+auto valueSize = CGM.getContext().getTypeSizeInChars(valueType);
+
+addTypedData(atomicType->getValueType(), begin);
+
+// Add atomic padding.
+auto atomicPadding = atomicSize - valueSize;
+if (atomicPadding > CharUnits::Zero())
+  addOpaqueData(begin + valueSize, begin + atomicSize);
+
+// Everything else is scalar and should not convert as an LLVM aggregate.
   } else {
 // We intentionally convert as !ForMem because we want to preserve
 // that a type was an i1.
-auto llvmType = CGM.getTypes().ConvertType(type);
+auto *llvmType = CGM.getTypes().ConvertType(type);
 addTypedData(llvmType, begin);
   }
 }


Index: clang/test/CodeGen/64bit-swiftcall.c
===
--- clang/test/CodeGen/64bit-swiftcall.c
+++ clang/test/CodeGen/64bit-swiftcall.c
@@ -10,6 +10,9 @@
 #define ERROR __attribute__((swift_error_result))
 #define CONTEXT __attribute__((swift_context))
 
+// CHECK-DAG: %struct.atomic_padded = type { { %struct.packed, [7 x i8] } }
+// CHECK-DAG: %struct.packed = type <{ i64, i8 }>
+//
 // CHECK: [[STRUCT2_RESULT:@.*]] = private {{.*}} constant [[STRUCT2_TYPE:%.*]] { i32 0, i8 0, i8 undef, i8 0, i32 0, i32 0 }
 
 /*/
@@ -1042,3 +1045,27 @@
   // CHECK-NOT: call void @llvm.lifetime.
   take_int5(return_int5());
 }
+
+typedef struct {
+  unsigned long long a;
+  unsigned long long b;
+} double_word;
+
+typedef struct {
+  _Atomic(double_word) a;
+} atomic_double_word;
+
+// CHECK-LABEL: use_atomic(i64 %0, i64 %1)
+SWIFTCALL void use_atomic(atomic_double_word a) {}
+
+typedef struct {
+  unsigned long long a;
+  unsigned char b;
+} __attribute__((packed)) packed;
+
+typedef struct {
+  _Atomic(packed) a;
+} atomic_padded;
+
+// CHECK-LABEL: use_atomic_padded(i64 %0, i64 %1)
+SWIFTCALL void use_atomic_padded(atomic_padded a) {}
Index: clang/lib/CodeGen/SwiftCallingConv.cpp
===
--- clang/lib/CodeGen/SwiftCallingConv.cpp
+++ clang/lib/CodeGen/SwiftCallingConv.cpp
@@ -93,11 +93,24 @@
 // Just add it all as opaque.
 addOpaqueData(begin, begin + CGM.getContext().getTypeSizeInChars(type));
 
-  // Everything else is scalar and should not convert as an LLVM aggregate.
+// Atomic types.
+  } else if (const auto *atomicType = type->getAs()) {
+auto valueType = atomicType->getValueType();
+auto atomicSize = CGM.getContext().getTypeSizeInChars(atomicType);
+auto valueSize = CGM.getContext().getTypeSizeInChars(valueType);
+
+addTypedData(atomicType->getValueType(), begin);
+
+// Add atomic padding.
+auto atomicPadding = atomicSize - valueSize;
+if 

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

2020-08-21 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 287053.
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] D83174: Teach AttachPreviousImpl to inherit MSInheritanceAttr attribute

2020-08-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D83174#2230616 , @gargvaibhav64 
wrote:

> In D83174#2230546 , @aaron.ballman 
> wrote:
>
>> LGTM, thank you for the fix! Do you need someone to commit on your behalf? 
>> If so, please be sure you're fine with the license agreement and let us know 
>> what name and email address you would like associated with the commit. 
>> Thanks!
>
> Hi, 
> Yes, I am fine with the license agreement.
> Name: Vaibhav Garg
> E-Mail: gargvaibha...@gmail.com
>
> Thanks a lot!

Any time, thank you again for the patch! I've commit on your behalf in 
7a527f17776be78ec44b88e82b39afb65fc148e4 
.


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

https://reviews.llvm.org/D83174

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


[clang] 7a527f1 - Teach AttachPreviousImpl to inherit MSInheritanceAttr attribute

2020-08-21 Thread Aaron Ballman via cfe-commits

Author: Vaibhav Garg
Date: 2020-08-21T12:04:43-04:00
New Revision: 7a527f17776be78ec44b88e82b39afb65fc148e4

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

LOG: Teach AttachPreviousImpl to inherit MSInheritanceAttr attribute

This commit teaches ASTDeclReader::attachPreviousDecl to successfully merge
two Decl's when one contains an inheritable attribute like the
MSInheritanceAttr. Usually, attributes that are needed to be present along the
redeclaration chain are attached during ASTReading from
ASTDeclReader::attachPreviousDecl, but no such thing is done for inheritable
attributes. Currently, only the logic for merging MSInheritanceAttr is
provided.

Added: 
clang/test/Modules/Inputs/inherit-attribute/a.h
clang/test/Modules/Inputs/inherit-attribute/b.h
clang/test/Modules/Inputs/inherit-attribute/c.h
clang/test/Modules/Inputs/inherit-attribute/module.modulemap
clang/test/Modules/inherit-attribute.cpp

Modified: 
clang/lib/Serialization/ASTReaderDecl.cpp

Removed: 




diff  --git a/clang/lib/Serialization/ASTReaderDecl.cpp 
b/clang/lib/Serialization/ASTReaderDecl.cpp
index d76182847e9d..c7a009d1e50d 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -281,6 +281,9 @@ namespace clang {
 static Decl *getMostRecentDeclImpl(...);
 static Decl *getMostRecentDecl(Decl *D);
 
+static void mergeInheritableAttributes(ASTReader , Decl *D,
+   Decl *Previous);
+
 template 
 static void attachPreviousDeclImpl(ASTReader ,
Redeclarable *D, Decl *Previous,
@@ -3511,6 +3514,19 @@ Decl *ASTReader::getMostRecentExistingDecl(Decl *D) {
   return ASTDeclReader::getMostRecentDecl(D->getCanonicalDecl());
 }
 
+void ASTDeclReader::mergeInheritableAttributes(ASTReader , Decl *D,
+   Decl *Previous) {
+  InheritableAttr *NewAttr = nullptr;
+  ASTContext  = Reader.getContext();
+  const auto *IA = Previous->getAttr();
+
+  if (IA && !D->hasAttr()) {
+NewAttr = cast(IA->clone(Context));
+NewAttr->setInherited(true);
+D->addAttr(NewAttr);
+  }
+}
+
 template
 void ASTDeclReader::attachPreviousDeclImpl(ASTReader ,
Redeclarable *D,
@@ -3669,6 +3685,12 @@ void ASTDeclReader::attachPreviousDecl(ASTReader 
, Decl *D,
   if (auto *TD = dyn_cast(D))
 inheritDefaultTemplateArguments(Reader.getContext(),
 cast(Previous), TD);
+
+  // If any of the declaration in the chain contains an Inheritable attribute,
+  // it needs to be added to all the declarations in the redeclarable chain.
+  // FIXME: Only the logic of merging MSInheritableAttr is present, it should
+  // be extended for all inheritable attributes.
+  mergeInheritableAttributes(Reader, D, Previous);
 }
 
 template

diff  --git a/clang/test/Modules/Inputs/inherit-attribute/a.h 
b/clang/test/Modules/Inputs/inherit-attribute/a.h
new file mode 100644
index ..04aabe9e8c61
--- /dev/null
+++ b/clang/test/Modules/Inputs/inherit-attribute/a.h
@@ -0,0 +1,10 @@
+#ifndef FOO
+#define FOO
+
+class Foo {
+public:
+  void step(int v);
+  Foo();
+};
+
+#endif

diff  --git a/clang/test/Modules/Inputs/inherit-attribute/b.h 
b/clang/test/Modules/Inputs/inherit-attribute/b.h
new file mode 100644
index ..9cd1f55b9d33
--- /dev/null
+++ b/clang/test/Modules/Inputs/inherit-attribute/b.h
@@ -0,0 +1,5 @@
+#include "a.h"
+
+void bar() {
+  ::step;
+}

diff  --git a/clang/test/Modules/Inputs/inherit-attribute/c.h 
b/clang/test/Modules/Inputs/inherit-attribute/c.h
new file mode 100644
index ..2243de1baf9a
--- /dev/null
+++ b/clang/test/Modules/Inputs/inherit-attribute/c.h
@@ -0,0 +1 @@
+#include "a.h"

diff  --git a/clang/test/Modules/Inputs/inherit-attribute/module.modulemap 
b/clang/test/Modules/Inputs/inherit-attribute/module.modulemap
new file mode 100644
index ..16481e2745dd
--- /dev/null
+++ b/clang/test/Modules/Inputs/inherit-attribute/module.modulemap
@@ -0,0 +1,3 @@
+module "b" { header "b.h" }
+
+module "c" { header "c.h" }

diff  --git a/clang/test/Modules/inherit-attribute.cpp 
b/clang/test/Modules/inherit-attribute.cpp
new file mode 100644
index ..34aa4670365a
--- /dev/null
+++ b/clang/test/Modules/inherit-attribute.cpp
@@ -0,0 +1,20 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -triple x86_64-pc-windows-msvc-unknown 
-I%S\Inputs\inherit-attribute -fmodules-cache-path=%t \
+// RUN: -fimplicit-module-maps -fmodules-local-submodule-visibility %s 
-ast-dump-all \
+// RUN: | FileCheck %s
+
+#include "b.h"
+#include "c.h"
+
+class Foo;
+
+Foo f;
+
+// CHECK:   CXXRecordDecl {{.*}} imported in b {{.*}} 

[PATCH] D86277: [NFC][compiler-rt] Factor out __mulv[sdt]i3 implementations to .inc file

2020-08-21 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

LGTM, but let's give others a chance to comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86277

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


[PATCH] D86289: [NFC][compiler-rt] Factor out __mulo[sdt]i3 implementations to .inc file

2020-08-21 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

LGTM, but let's give others a chance to comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86289

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


[PATCH] D86274: [Constants] Handle FNeg in getWithOperands.

2020-08-21 Thread Florian Hahn 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 rGbc72a3ab949e: [Constants] Handle FNeg in getWithOperands. 
(authored by fhahn).

Changed prior to commit:
  https://reviews.llvm.org/D86274?vs=286756=287047#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86274

Files:
  clang/test/CodeGen/constantexpr-fneg.c
  llvm/lib/IR/Constants.cpp


Index: llvm/lib/IR/Constants.cpp
===
--- llvm/lib/IR/Constants.cpp
+++ llvm/lib/IR/Constants.cpp
@@ -1441,6 +1441,8 @@
 OnlyIfReducedTy);
   case Instruction::ExtractValue:
 return ConstantExpr::getExtractValue(Ops[0], getIndices(), 
OnlyIfReducedTy);
+  case Instruction::FNeg:
+return ConstantExpr::getFNeg(Ops[0]);
   case Instruction::ShuffleVector:
 return ConstantExpr::getShuffleVector(Ops[0], Ops[1], getShuffleMask(),
   OnlyIfReducedTy);
Index: clang/test/CodeGen/constantexpr-fneg.c
===
--- /dev/null
+++ clang/test/CodeGen/constantexpr-fneg.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -emit-llvm-bc -disable-llvm-passes -o %t.bc %s
+// RUN: llvm-dis %t.bc -o - | FileCheck %s
+
+// Test case for PR45426. Make sure we do not crash while writing bitcode
+// containing a simplify-able fneg constant expression. Check that the created
+// bitcode file can be disassembled and has the constant expressions 
simplified.
+//
+// CHECK-LABEL define i32 @main()
+// CHECK:  entry:
+// CHECK-NEXT:   %retval = alloca i32
+// CHECK-NEXT:   store i32 0, i32* %retval
+// CHECK-NEXT:   [[LV:%.*]] = load float*, float** @c
+// CHECK-NEXT:   store float 1.00e+00, float* [[LV]], align 4
+// CHECK-NEXT:   ret i32 -1
+
+int a[], b;
+float *c;
+int main() {
+  return -(*c =  != a);
+}


Index: llvm/lib/IR/Constants.cpp
===
--- llvm/lib/IR/Constants.cpp
+++ llvm/lib/IR/Constants.cpp
@@ -1441,6 +1441,8 @@
 OnlyIfReducedTy);
   case Instruction::ExtractValue:
 return ConstantExpr::getExtractValue(Ops[0], getIndices(), OnlyIfReducedTy);
+  case Instruction::FNeg:
+return ConstantExpr::getFNeg(Ops[0]);
   case Instruction::ShuffleVector:
 return ConstantExpr::getShuffleVector(Ops[0], Ops[1], getShuffleMask(),
   OnlyIfReducedTy);
Index: clang/test/CodeGen/constantexpr-fneg.c
===
--- /dev/null
+++ clang/test/CodeGen/constantexpr-fneg.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -emit-llvm-bc -disable-llvm-passes -o %t.bc %s
+// RUN: llvm-dis %t.bc -o - | FileCheck %s
+
+// Test case for PR45426. Make sure we do not crash while writing bitcode
+// containing a simplify-able fneg constant expression. Check that the created
+// bitcode file can be disassembled and has the constant expressions simplified.
+//
+// CHECK-LABEL define i32 @main()
+// CHECK:  entry:
+// CHECK-NEXT:   %retval = alloca i32
+// CHECK-NEXT:   store i32 0, i32* %retval
+// CHECK-NEXT:   [[LV:%.*]] = load float*, float** @c
+// CHECK-NEXT:   store float 1.00e+00, float* [[LV]], align 4
+// CHECK-NEXT:   ret i32 -1
+
+int a[], b;
+float *c;
+int main() {
+  return -(*c =  != a);
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] bc72a3a - [Constants] Handle FNeg in getWithOperands.

2020-08-21 Thread Florian Hahn via cfe-commits

Author: Florian Hahn
Date: 2020-08-21T16:50:56+01:00
New Revision: bc72a3ab949e14b990c080985fc1e74475f1e7d2

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

LOG: [Constants] Handle FNeg in getWithOperands.

Currently ConstantExpr::getWithOperands does not handle FNeg and
subsequently treats FNeg as binary operator, leading to an assertion
failure or segmentation fault if built without assertions.

Originally I reproduced this with llvm-dis on a bitcode file, which I
unfortunately cannot share and also cannot really reduce.

But PR45426 describes the same issue and has a reproducer with Clang, so
I'll go with that.

Reviewed By: aprantl

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

Added: 
clang/test/CodeGen/constantexpr-fneg.c

Modified: 
llvm/lib/IR/Constants.cpp

Removed: 




diff  --git a/clang/test/CodeGen/constantexpr-fneg.c 
b/clang/test/CodeGen/constantexpr-fneg.c
new file mode 100644
index ..57f616437516
--- /dev/null
+++ b/clang/test/CodeGen/constantexpr-fneg.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -emit-llvm-bc -disable-llvm-passes -o %t.bc %s
+// RUN: llvm-dis %t.bc -o - | FileCheck %s
+
+// Test case for PR45426. Make sure we do not crash while writing bitcode
+// containing a simplify-able fneg constant expression. Check that the created
+// bitcode file can be disassembled and has the constant expressions 
simplified.
+//
+// CHECK-LABEL define i32 @main()
+// CHECK:  entry:
+// CHECK-NEXT:   %retval = alloca i32
+// CHECK-NEXT:   store i32 0, i32* %retval
+// CHECK-NEXT:   [[LV:%.*]] = load float*, float** @c
+// CHECK-NEXT:   store float 1.00e+00, float* [[LV]], align 4
+// CHECK-NEXT:   ret i32 -1
+
+int a[], b;
+float *c;
+int main() {
+  return -(*c =  != a);
+}

diff  --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp
index b252ef71c8ee..1cd2ced46930 100644
--- a/llvm/lib/IR/Constants.cpp
+++ b/llvm/lib/IR/Constants.cpp
@@ -1441,6 +1441,8 @@ Constant *ConstantExpr::getWithOperands(ArrayRef Ops, Type *Ty,
 OnlyIfReducedTy);
   case Instruction::ExtractValue:
 return ConstantExpr::getExtractValue(Ops[0], getIndices(), 
OnlyIfReducedTy);
+  case Instruction::FNeg:
+return ConstantExpr::getFNeg(Ops[0]);
   case Instruction::ShuffleVector:
 return ConstantExpr::getShuffleVector(Ops[0], Ops[1], getShuffleMask(),
   OnlyIfReducedTy);



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


[PATCH] D85324: [SystemZ][z/OS] Add z/OS Target and define macros

2020-08-21 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan marked 5 inline comments as done.
abhina.sreeskantharajan added inline comments.



Comment at: clang/lib/Basic/Targets/OSTargets.h:743
+Builder.defineMacro("__BFP__");
+// FIXME: __BOOL__ should be defined under strict -std=c89.
+Builder.defineMacro("__BOOL__");

hubert.reinterpretcast wrote:
> MaskRay wrote:
> > What is strict -std=c89? `!Opts.C99` ?
> The comment has a typo. The macro should //not// be defined with strict C89 
> modes.
> 
> > What is strict -std=c89? `!Opts.C99` ?
> 
> In the context of this macro, "strict C89" means `!Opts.C99` and the severity 
> of `ext_c99_feature` diagnostics is at least an error. This occurs, for 
> example, with `-std=gnu89 -Werror=c99-extensions`.
> 
Thanks, I've fixed the comment.



Comment at: clang/lib/Basic/Targets/OSTargets.h:757
+if (Opts.C99)
+  Builder.defineMacro("_ISOC99_SOURCE");
+

MaskRay wrote:
> This is strange. On other systems the user requests it.
Thanks, I've removed this macro to maintain consistency with other platforms.



Comment at: clang/lib/Basic/Targets/OSTargets.h:773
+  // type is not declared as a typedef in system headers.
+  Builder.defineMacro("__wchar_t");
+}

MaskRay wrote:
> Does it need a value?
No, this macro doesn't require a number. This macro is defined when the wchar_t 
type is available, so that the system headers do not declare it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85324

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


[PATCH] D81003: [clang] SequenceChecker: Also visit default arguments and default initializers.

2020-08-21 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

Friendly ping on this patch: this is the last change to `SequenceChecker` I had 
in mind.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81003

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


[PATCH] D84599: [Index/USRGeneration] Use NamedDecl::getDeclName() instead of NamedDecl::printName in USRGenerator::EmitDeclName

2020-08-21 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

Friendly ping on this patch; the patches depending on this patch (D84658 
 and D85033  
on Phab + others not uploaded yet) significantly improve the handling of 
unnamed entities in diagnostics.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84599

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


[PATCH] D85324: [SystemZ][z/OS] Add z/OS Target and define macros

2020-08-21 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 287043.
abhina.sreeskantharajan added a comment.

Thanks for reviewing. I've updated the comments and removed ISOC99_SOURCE 
macro. I've updated the lit test to reflect these changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85324

Files:
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/test/Preprocessor/init-zos.c


Index: clang/test/Preprocessor/init-zos.c
===
--- /dev/null
+++ clang/test/Preprocessor/init-zos.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=s390x-none-zos 
-fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix 
S390X-ZOS %s
+// RUN: %clang_cc1 -x c++ -std=gnu++14 -E -dM -ffreestanding 
-triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck 
-match-full-lines -check-prefix S390X-ZOS -check-prefix S390X-ZOS-GNUXX %s
+
+// S390X-ZOS-GNUXX:#define _EXT 1
+// S390X-ZOS:#define _LONG_LONG 1
+// S390X-ZOS-GNUXX:#define _MI_BUILTIN 1
+// S390X-ZOS:#define _OPEN_DEFAULT 1
+// S390X-ZOS:#define _UNIX03_WITHDRAWN 1
+// S390X-ZOS-GNUXX:#define _XOPEN_SOURCE 600
+// S390X-ZOS:#define __370__ 1
+// S390X-ZOS:#define __64BIT__ 1
+// S390X-ZOS:#define __BFP__ 1
+// S390X-ZOS:#define __BOOL__ 1
+// S390X-ZOS-GNUXX:#define __DLL__ 1
+// S390X-ZOS:#define __LONGNAME__ 1
+// S390X-ZOS:#define __MVS__ 1
+// S390X-ZOS:#define __THW_370__ 1
+// S390X-ZOS:#define __THW_BIG_ENDIAN__ 1
+// S390X-ZOS:#define __TOS_390__ 1
+// S390X-ZOS:#define __TOS_MVS__ 1
+// S390X-ZOS:#define __XPLINK__ 1
+// S390X-ZOS-GNUXX:#define __wchar_t 1
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -727,6 +727,55 @@
   bool defaultsToAIXPowerAlignment() const override { return true; }
 };
 
+// z/OS target
+template 
+class LLVM_LIBRARY_VISIBILITY ZOSTargetInfo : public OSTargetInfo {
+protected:
+  void getOSDefines(const LangOptions , const llvm::Triple ,
+MacroBuilder ) const override {
+// FIXME: _LONG_LONG should not be defined under -std=c89.
+Builder.defineMacro("_LONG_LONG");
+Builder.defineMacro("_OPEN_DEFAULT");
+// _UNIX03_WITHDRAWN is required to build libcxx.
+Builder.defineMacro("_UNIX03_WITHDRAWN");
+Builder.defineMacro("__370__");
+Builder.defineMacro("__BFP__");
+// FIXME: __BOOL__ should not be defined under -std=c89.
+Builder.defineMacro("__BOOL__");
+Builder.defineMacro("__LONGNAME__");
+Builder.defineMacro("__MVS__");
+Builder.defineMacro("__THW_370__");
+Builder.defineMacro("__THW_BIG_ENDIAN__");
+Builder.defineMacro("__TOS_390__");
+Builder.defineMacro("__TOS_MVS__");
+Builder.defineMacro("__XPLINK__");
+
+if (this->PointerWidth == 64)
+  Builder.defineMacro("__64BIT__");
+
+if (Opts.CPlusPlus) {
+  Builder.defineMacro("__DLL__");
+  // XOPEN_SOURCE=600 is required to build libcxx.
+  Builder.defineMacro("_XOPEN_SOURCE", "600");
+}
+
+if (Opts.GNUMode) {
+  Builder.defineMacro("_MI_BUILTIN");
+  Builder.defineMacro("_EXT");
+}
+
+if (Opts.CPlusPlus && Opts.WChar) {
+  // Macro __wchar_t is defined so that the wchar_t data
+  // type is not declared as a typedef in system headers.
+  Builder.defineMacro("__wchar_t");
+}
+  }
+
+public:
+  ZOSTargetInfo(const llvm::Triple , const TargetOptions )
+  : OSTargetInfo(Triple, Opts) {}
+};
+
 void addWindowsDefines(const llvm::Triple , const LangOptions ,
MacroBuilder );
 
Index: clang/lib/Basic/Targets.cpp
===
--- clang/lib/Basic/Targets.cpp
+++ clang/lib/Basic/Targets.cpp
@@ -450,6 +450,8 @@
 switch (os) {
 case llvm::Triple::Linux:
   return new LinuxTargetInfo(Triple, Opts);
+case llvm::Triple::ZOS:
+  return new ZOSTargetInfo(Triple, Opts);
 default:
   return new SystemZTargetInfo(Triple, Opts);
 }


Index: clang/test/Preprocessor/init-zos.c
===
--- /dev/null
+++ clang/test/Preprocessor/init-zos.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS %s
+// RUN: %clang_cc1 -x c++ -std=gnu++14 -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS -check-prefix S390X-ZOS-GNUXX %s
+
+// S390X-ZOS-GNUXX:#define _EXT 1
+// S390X-ZOS:#define _LONG_LONG 1
+// S390X-ZOS-GNUXX:#define _MI_BUILTIN 1
+// S390X-ZOS:#define _OPEN_DEFAULT 1
+// S390X-ZOS:#define _UNIX03_WITHDRAWN 1
+// S390X-ZOS-GNUXX:#define _XOPEN_SOURCE 600
+// 

[PATCH] D83174: Teach AttachPreviousImpl to inherit MSInheritanceAttr attribute

2020-08-21 Thread Vaibhav Garg via Phabricator via cfe-commits
gargvaibhav64 added a comment.

In D83174#2230546 , @aaron.ballman 
wrote:

> LGTM, thank you for the fix! Do you need someone to commit on your behalf? If 
> so, please be sure you're fine with the license agreement and let us know 
> what name and email address you would like associated with the commit. Thanks!

Hi, 
Yes, I am fine with the license agreement.
Name: Vaibhav Garg
E-Mail: gargvaibha...@gmail.com

Thanks a lot!


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

https://reviews.llvm.org/D83174

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


[PATCH] D86295: [analyzer] Reorder the layout of MemRegion and cache by hand for optimal size

2020-08-21 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

In D86295#2229712 , @NoQ wrote:

> Heh, nice! Did you try to measure the actual impact of this change on memory 
> and/or performance?

Eh, I don't really know how to bench this.
Here is how I did it in nutshell:
Added STATISTIC counters to MemRegion ctor, dtor, getAsOffset begining and the 
path of just returning the cached value.
F12722457: add-memregion-statistics.patch 

I have analyzed a faily big (50k+ LOC) TU of the llvm repository 
(`X86ISelLowering.cpp`).
I was using the following command:

  /home/myuser/git/llvm-project/build/bin/clang --analyze -Qunused-arguments 
-Xclang -analyzer-opt-analyze-headers -Xclang -analyzer-output=text -Xclang 
-analyzer-config -Xclang expand-macros=true -Xclang -analyzer-checker=core 
-Xclang -analyzer-config -Xclang 
aggressive-binary-operation-simplification=true  -x c++ 
--target=x86_64-linux-gnu -std=gnu++14 -DGTEST_HAS_RTTI=0 -D_DEBUG 
-D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
-D__STDC_LIMIT_MACROS -I/home/myuser/git/llvm-project/build/lib/Target/X86 
-I/home/myuser/git/llvm-project/llvm/lib/Target/X86 
-I/home/myuser/git/llvm-project/build/include 
-I/home/myuser/git/llvm-project/llvm/include -fPIC -fvisibility-inlines-hidden 
-Wno-unused-parameter -Wno-missing-field-initializers -pedantic -Wno-long-long 
-Wno-maybe-uninitialized -Wno-noexcept-type -Wno-comment -fdiagnostics-color 
-fPIC -fno-exceptions -fno-rtti -std=c++14 -isystem /usr/include/c++/7 -isystem 
/usr/include/x86_64-linux-gnu/c++/7 -isystem /usr/include/c++/7/backward 
-isystem /usr/local/include -isystem /usr/include/x86_64-linux-gnu -isystem 
/usr/include -Xclang -analyzer-stats 
/home/myuser/git/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp

The relevant part of the log is:

   1051489 MemRegion- The # of MemRegion objects were alive at a time 
during analysis
  48603499 MemRegion- The # of times the MemRegion::getAsOffset was 
called and the result was already cached
  49258796 MemRegion- The # of times the MemRegion::getAsOffset was 
called
   1051489 MemRegion- The # of MemRegion objects alive at the given 
moment
   1051489 MemRegion- The # of MemRegion objects created during the 
analysis



---

> I think it'd make perfect sense to keep the offset in a side map. We don't 
> compute it for all regions, and for most regions it doesn't need to be 
> computed *at all*.

It seems that at least with this configuration the `MemRegion::getAsOffset` was 
called every single time.

Please have a look at the patch file, and the results - I might messed 
something up :s


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86295

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


[PATCH] D83174: Teach AttachPreviousImpl to inherit MSInheritanceAttr attribute

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

LGTM, thank you for the fix! Do you need someone to commit on your behalf? If 
so, please be sure you're fine with the license agreement and let us know what 
name and email address you would like associated with the commit. Thanks!


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

https://reviews.llvm.org/D83174

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


[PATCH] D86345: [SyntaxTree] Use annotations in Statement tests

2020-08-21 Thread Eduardo Caldas via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1beb11c61ae4: [SyntaxTree] Use annotations in Statement 
tests (authored by eduucaldas).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86345

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
@@ -102,282 +102,196 @@
 }
 
 TEST_P(SyntaxTreeTest, If) {
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
-int main() {
-  if (1) {}
-  if (1) {} else if (0) {}
+void test() {
+  [[if (1) {}]]
+  [[if (1) {} else if (0) {}]]
 }
 )cpp",
-  R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-int
-  |-SimpleDeclarator
-  | |-main
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   `-)
+  {R"txt(
+IfStatement
+|-if
+|-(
+|-IntegerLiteralExpression
+| `-1
+|-)
+`-CompoundStatement
+  |-{
+  `-}
+  )txt",
+   R"txt(
+IfStatement
+|-if
+|-(
+|-IntegerLiteralExpression
+| `-1
+|-)
+|-CompoundStatement
+| |-{
+| `-}
+|-else
+`-IfStatement
+  |-if
+  |-(
+  |-IntegerLiteralExpression
+  | `-0
+  |-)
   `-CompoundStatement
 |-{
-|-IfStatement
-| |-if
-| |-(
-| |-IntegerLiteralExpression
-| | `-1
-| |-)
-| `-CompoundStatement
-|   |-{
-|   `-}
-|-IfStatement
-| |-if
-| |-(
-| |-IntegerLiteralExpression
-| | `-1
-| |-)
-| |-CompoundStatement
-| | |-{
-| | `-}
-| |-else
-| `-IfStatement
-|   |-if
-|   |-(
-|   |-IntegerLiteralExpression
-|   | `-0
-|   |-)
-|   `-CompoundStatement
-| |-{
-| `-}
 `-}
-)txt"));
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, For) {
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 void test() {
-  for (;;)  {}
+  [[for (;;)  {}]]
 }
 )cpp",
-  R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   `-)
-  `-CompoundStatement
-|-{
-|-ForStatement
-| |-for
-| |-(
-| |-;
-| |-;
-| |-)
-| `-CompoundStatement
-|   |-{
-|   `-}
-`-}
-)txt"));
+  {R"txt(
+ForStatement
+|-for
+|-(
+|-;
+|-;
+|-)
+`-CompoundStatement
+  |-{
+  `-}
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, RangeBasedFor) {
   if (!GetParam().isCXX11OrLater()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 void test() {
   int a[3];
-  for (int x : a)
-;
+  [[for (int x : a)
+;]]
 }
 )cpp",
-  R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   `-)
-  `-CompoundStatement
-|-{
-|-DeclarationStatement
-| |-SimpleDeclaration
-| | |-int
-| | `-SimpleDeclarator
-| |   |-a
-| |   `-ArraySubscript
-| | |-[
-| | |-IntegerLiteralExpression
-| | | `-3
-| | `-]
-| `-;
-|-RangeBasedForStatement
-| |-for
-| |-(
-| |-SimpleDeclaration
-| | |-int
-| | |-SimpleDeclarator
-| | | `-x
-| | `-:
-| |-IdExpression
-| | `-UnqualifiedId
-| |   `-a
-| |-)
-| `-EmptyStatement
-|   `-;
-`-}
-)txt"));
+  {R"txt(
+RangeBasedForStatement
+|-for
+|-(
+|-SimpleDeclaration
+| |-int
+| |-SimpleDeclarator
+| | `-x
+| `-:
+|-IdExpression
+| `-UnqualifiedId
+|   `-a
+|-)
+`-EmptyStatement
+  `-;
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, DeclarationStatement) {
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 void test() {
-  int a = 10;
+  [[int a = 10;]]
 }
 )cpp",
-  R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   `-)
-  `-CompoundStatement
-|-{
-|-DeclarationStatement
-| |-SimpleDeclaration
-| | |-int
-| | `-SimpleDeclarator
-| |   |-a
-| |   |-=
-| |   `-IntegerLiteralExpression
-| | `-10
-| `-;
-`-}
-)txt"));
+  {R"txt(
+DeclarationStatement
+|-SimpleDeclaration
+| |-int
+| `-SimpleDeclarator
+|   |-a
+|   |-=
+|   `-IntegerLiteralExpression
+| `-10
+`-;
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, Switch) {
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 void test() {
-  switch (1) {
+  [[switch (1) {
 case 0:
 default:;
-  }
+  }]]
 }
 )cpp",
-  R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   `-)
-  `-CompoundStatement
-|-{
-|-SwitchStatement
-| |-switch
-| |-(
-| |-IntegerLiteralExpression
-| | 

[clang] 1beb11c - [SyntaxTree] Use annotations in Statement tests

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

Author: Eduardo Caldas
Date: 2020-08-21T14:42:33Z
New Revision: 1beb11c61ae4b0130cb87ed56b9e010ef6a06691

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

LOG: [SyntaxTree] Use annotations in Statement tests

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

Added: 


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

Removed: 




diff  --git a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp 
b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
index d4e2684934f3..994dd68028ea 100644
--- a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -102,282 +102,196 @@ void foo(int a, int b) {}
 }
 
 TEST_P(SyntaxTreeTest, If) {
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
-int main() {
-  if (1) {}
-  if (1) {} else if (0) {}
+void test() {
+  [[if (1) {}]]
+  [[if (1) {} else if (0) {}]]
 }
 )cpp",
-  R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-int
-  |-SimpleDeclarator
-  | |-main
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   `-)
+  {R"txt(
+IfStatement
+|-if
+|-(
+|-IntegerLiteralExpression
+| `-1
+|-)
+`-CompoundStatement
+  |-{
+  `-}
+  )txt",
+   R"txt(
+IfStatement
+|-if
+|-(
+|-IntegerLiteralExpression
+| `-1
+|-)
+|-CompoundStatement
+| |-{
+| `-}
+|-else
+`-IfStatement
+  |-if
+  |-(
+  |-IntegerLiteralExpression
+  | `-0
+  |-)
   `-CompoundStatement
 |-{
-|-IfStatement
-| |-if
-| |-(
-| |-IntegerLiteralExpression
-| | `-1
-| |-)
-| `-CompoundStatement
-|   |-{
-|   `-}
-|-IfStatement
-| |-if
-| |-(
-| |-IntegerLiteralExpression
-| | `-1
-| |-)
-| |-CompoundStatement
-| | |-{
-| | `-}
-| |-else
-| `-IfStatement
-|   |-if
-|   |-(
-|   |-IntegerLiteralExpression
-|   | `-0
-|   |-)
-|   `-CompoundStatement
-| |-{
-| `-}
 `-}
-)txt"));
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, For) {
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 void test() {
-  for (;;)  {}
+  [[for (;;)  {}]]
 }
 )cpp",
-  R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   `-)
-  `-CompoundStatement
-|-{
-|-ForStatement
-| |-for
-| |-(
-| |-;
-| |-;
-| |-)
-| `-CompoundStatement
-|   |-{
-|   `-}
-`-}
-)txt"));
+  {R"txt(
+ForStatement
+|-for
+|-(
+|-;
+|-;
+|-)
+`-CompoundStatement
+  |-{
+  `-}
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, RangeBasedFor) {
   if (!GetParam().isCXX11OrLater()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 void test() {
   int a[3];
-  for (int x : a)
-;
+  [[for (int x : a)
+;]]
 }
 )cpp",
-  R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   `-)
-  `-CompoundStatement
-|-{
-|-DeclarationStatement
-| |-SimpleDeclaration
-| | |-int
-| | `-SimpleDeclarator
-| |   |-a
-| |   `-ArraySubscript
-| | |-[
-| | |-IntegerLiteralExpression
-| | | `-3
-| | `-]
-| `-;
-|-RangeBasedForStatement
-| |-for
-| |-(
-| |-SimpleDeclaration
-| | |-int
-| | |-SimpleDeclarator
-| | | `-x
-| | `-:
-| |-IdExpression
-| | `-UnqualifiedId
-| |   `-a
-| |-)
-| `-EmptyStatement
-|   `-;
-`-}
-)txt"));
+  {R"txt(
+RangeBasedForStatement
+|-for
+|-(
+|-SimpleDeclaration
+| |-int
+| |-SimpleDeclarator
+| | `-x
+| `-:
+|-IdExpression
+| `-UnqualifiedId
+|   `-a
+|-)
+`-EmptyStatement
+  `-;
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, DeclarationStatement) {
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 void test() {
-  int a = 10;
+  [[int a = 10;]]
 }
 )cpp",
-  R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   `-)
-  `-CompoundStatement
-|-{
-|-DeclarationStatement
-| |-SimpleDeclaration
-| | |-int
-| | `-SimpleDeclarator
-| |   |-a
-| |   |-=
-| |   `-IntegerLiteralExpression
-| | `-10
-| `-;
-`-}
-)txt"));
+  {R"txt(
+DeclarationStatement
+|-SimpleDeclaration
+| |-int
+| `-SimpleDeclarator
+|   |-a
+|   |-=
+|   `-IntegerLiteralExpression
+| `-10
+`-;
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, Switch) {
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 void test() {
-  switch (1) {
+  [[switch (1) {
 case 0:
 default:;
-  }
+  }]]
 }
 )cpp",
-  

[PATCH] D86277: [NFC][compiler-rt] Factor out __mulv[sdt]i3 implementations to .inc file

2020-08-21 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko added inline comments.



Comment at: compiler-rt/lib/builtins/int_mulv_impl.inc:1
-//===-- mulvdi3.c - Implement __mulvdi3 
---===//
+//===-- int_mulv_impl.inc - Implement __mulv[sdt]i3 
---===//
 //

MaskRay wrote:
> `---*- C++ -*-===//`
Thanks. It really is a C source (there are no C++ sources in the builtins 
library, as far as I know), still almost all other .inc files in this directory 
are actually marked with `-*- C -*-`, so explicitly marked this one as well.

Interestingly, `int_div_impl.inc` is the only one such file **explicitly** 
marked as C++, but it is probably a mistake.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86277

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


[PATCH] D86289: [NFC][compiler-rt] Factor out __mulo[sdt]i3 implementations to .inc file

2020-08-21 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko updated this revision to Diff 287032.
atrosinenko added a comment.

Explicitly mark .inc file as a C source like is already done for almost all 
`*_impl.inc` files.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86289

Files:
  compiler-rt/lib/builtins/int_mulo_impl.inc
  compiler-rt/lib/builtins/mulodi4.c
  compiler-rt/lib/builtins/mulosi4.c
  compiler-rt/lib/builtins/muloti4.c

Index: compiler-rt/lib/builtins/muloti4.c
===
--- compiler-rt/lib/builtins/muloti4.c
+++ compiler-rt/lib/builtins/muloti4.c
@@ -18,36 +18,11 @@
 
 // Effects: sets *overflow to 1  if a * b overflows
 
+#define fixint_t ti_int
+#include "int_mulo_impl.inc"
+
 COMPILER_RT_ABI ti_int __muloti4(ti_int a, ti_int b, int *overflow) {
-  const int N = (int)(sizeof(ti_int) * CHAR_BIT);
-  const ti_int MIN = (ti_int)1 << (N - 1);
-  const ti_int MAX = ~MIN;
-  *overflow = 0;
-  ti_int result = a * b;
-  if (a == MIN) {
-if (b != 0 && b != 1)
-  *overflow = 1;
-return result;
-  }
-  if (b == MIN) {
-if (a != 0 && a != 1)
-  *overflow = 1;
-return result;
-  }
-  ti_int sa = a >> (N - 1);
-  ti_int abs_a = (a ^ sa) - sa;
-  ti_int sb = b >> (N - 1);
-  ti_int abs_b = (b ^ sb) - sb;
-  if (abs_a < 2 || abs_b < 2)
-return result;
-  if (sa == sb) {
-if (abs_a > MAX / abs_b)
-  *overflow = 1;
-  } else {
-if (abs_a > MIN / -abs_b)
-  *overflow = 1;
-  }
-  return result;
+  return __muloXi4(a, b, overflow);
 }
 
 #endif // CRT_HAS_128BIT
Index: compiler-rt/lib/builtins/mulosi4.c
===
--- compiler-rt/lib/builtins/mulosi4.c
+++ compiler-rt/lib/builtins/mulosi4.c
@@ -10,40 +10,13 @@
 //
 //===--===//
 
-#include "int_lib.h"
+#define fixint_t si_int
+#include "int_mulo_impl.inc"
 
 // Returns: a * b
 
 // Effects: sets *overflow to 1  if a * b overflows
 
 COMPILER_RT_ABI si_int __mulosi4(si_int a, si_int b, int *overflow) {
-  const int N = (int)(sizeof(si_int) * CHAR_BIT);
-  const si_int MIN = (si_int)1 << (N - 1);
-  const si_int MAX = ~MIN;
-  *overflow = 0;
-  si_int result = a * b;
-  if (a == MIN) {
-if (b != 0 && b != 1)
-  *overflow = 1;
-return result;
-  }
-  if (b == MIN) {
-if (a != 0 && a != 1)
-  *overflow = 1;
-return result;
-  }
-  si_int sa = a >> (N - 1);
-  si_int abs_a = (a ^ sa) - sa;
-  si_int sb = b >> (N - 1);
-  si_int abs_b = (b ^ sb) - sb;
-  if (abs_a < 2 || abs_b < 2)
-return result;
-  if (sa == sb) {
-if (abs_a > MAX / abs_b)
-  *overflow = 1;
-  } else {
-if (abs_a > MIN / -abs_b)
-  *overflow = 1;
-  }
-  return result;
+  return __muloXi4(a, b, overflow);
 }
Index: compiler-rt/lib/builtins/mulodi4.c
===
--- compiler-rt/lib/builtins/mulodi4.c
+++ compiler-rt/lib/builtins/mulodi4.c
@@ -10,40 +10,13 @@
 //
 //===--===//
 
-#include "int_lib.h"
+#define fixint_t di_int
+#include "int_mulo_impl.inc"
 
 // Returns: a * b
 
 // Effects: sets *overflow to 1  if a * b overflows
 
 COMPILER_RT_ABI di_int __mulodi4(di_int a, di_int b, int *overflow) {
-  const int N = (int)(sizeof(di_int) * CHAR_BIT);
-  const di_int MIN = (di_int)1 << (N - 1);
-  const di_int MAX = ~MIN;
-  *overflow = 0;
-  di_int result = a * b;
-  if (a == MIN) {
-if (b != 0 && b != 1)
-  *overflow = 1;
-return result;
-  }
-  if (b == MIN) {
-if (a != 0 && a != 1)
-  *overflow = 1;
-return result;
-  }
-  di_int sa = a >> (N - 1);
-  di_int abs_a = (a ^ sa) - sa;
-  di_int sb = b >> (N - 1);
-  di_int abs_b = (b ^ sb) - sb;
-  if (abs_a < 2 || abs_b < 2)
-return result;
-  if (sa == sb) {
-if (abs_a > MAX / abs_b)
-  *overflow = 1;
-  } else {
-if (abs_a > MIN / -abs_b)
-  *overflow = 1;
-  }
-  return result;
+  return __muloXi4(a, b, overflow);
 }
Index: compiler-rt/lib/builtins/int_mulo_impl.inc
===
--- compiler-rt/lib/builtins/int_mulo_impl.inc
+++ compiler-rt/lib/builtins/int_mulo_impl.inc
@@ -1,4 +1,4 @@
-//===-- mulodi4.c - Implement __mulodi4 ---===//
+//===-- int_mulo_impl.inc - Implement __mulo[sdt]i3 ---*- C -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
 //
 //===--===//
 //
-// This file implements __mulodi4 for the compiler_rt library.
+// Helper used by __mulosi3, __mulodi3 and __muloti3.
 //
 //===--===//
 
@@ -16,12 +16,12 

[PATCH] D86277: [NFC][compiler-rt] Factor out __mulv[sdt]i3 implementations to .inc file

2020-08-21 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko updated this revision to Diff 287031.
atrosinenko added a comment.

Explicitly mark .inc file as a C source like is already done for almost all 
`*_impl.inc` files.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86277

Files:
  compiler-rt/lib/builtins/int_mulv_impl.inc
  compiler-rt/lib/builtins/mulvdi3.c
  compiler-rt/lib/builtins/mulvsi3.c
  compiler-rt/lib/builtins/mulvti3.c

Index: compiler-rt/lib/builtins/mulvti3.c
===
--- compiler-rt/lib/builtins/mulvti3.c
+++ compiler-rt/lib/builtins/mulvti3.c
@@ -18,34 +18,9 @@
 
 // Effects: aborts if a * b overflows
 
-COMPILER_RT_ABI ti_int __mulvti3(ti_int a, ti_int b) {
-  const int N = (int)(sizeof(ti_int) * CHAR_BIT);
-  const ti_int MIN = (ti_int)1 << (N - 1);
-  const ti_int MAX = ~MIN;
-  if (a == MIN) {
-if (b == 0 || b == 1)
-  return a * b;
-compilerrt_abort();
-  }
-  if (b == MIN) {
-if (a == 0 || a == 1)
-  return a * b;
-compilerrt_abort();
-  }
-  ti_int sa = a >> (N - 1);
-  ti_int abs_a = (a ^ sa) - sa;
-  ti_int sb = b >> (N - 1);
-  ti_int abs_b = (b ^ sb) - sb;
-  if (abs_a < 2 || abs_b < 2)
-return a * b;
-  if (sa == sb) {
-if (abs_a > MAX / abs_b)
-  compilerrt_abort();
-  } else {
-if (abs_a > MIN / -abs_b)
-  compilerrt_abort();
-  }
-  return a * b;
-}
+#define fixint_t ti_int
+#include "int_mulv_impl.inc"
+
+COMPILER_RT_ABI ti_int __mulvti3(ti_int a, ti_int b) { return __mulvXi3(a, b); }
 
 #endif // CRT_HAS_128BIT
Index: compiler-rt/lib/builtins/mulvsi3.c
===
--- compiler-rt/lib/builtins/mulvsi3.c
+++ compiler-rt/lib/builtins/mulvsi3.c
@@ -10,38 +10,11 @@
 //
 //===--===//
 
-#include "int_lib.h"
+#define fixint_t si_int
+#include "int_mulv_impl.inc"
 
 // Returns: a * b
 
 // Effects: aborts if a * b overflows
 
-COMPILER_RT_ABI si_int __mulvsi3(si_int a, si_int b) {
-  const int N = (int)(sizeof(si_int) * CHAR_BIT);
-  const si_int MIN = (si_int)1 << (N - 1);
-  const si_int MAX = ~MIN;
-  if (a == MIN) {
-if (b == 0 || b == 1)
-  return a * b;
-compilerrt_abort();
-  }
-  if (b == MIN) {
-if (a == 0 || a == 1)
-  return a * b;
-compilerrt_abort();
-  }
-  si_int sa = a >> (N - 1);
-  si_int abs_a = (a ^ sa) - sa;
-  si_int sb = b >> (N - 1);
-  si_int abs_b = (b ^ sb) - sb;
-  if (abs_a < 2 || abs_b < 2)
-return a * b;
-  if (sa == sb) {
-if (abs_a > MAX / abs_b)
-  compilerrt_abort();
-  } else {
-if (abs_a > MIN / -abs_b)
-  compilerrt_abort();
-  }
-  return a * b;
-}
+COMPILER_RT_ABI si_int __mulvsi3(si_int a, si_int b) { return __mulvXi3(a, b); }
Index: compiler-rt/lib/builtins/mulvdi3.c
===
--- compiler-rt/lib/builtins/mulvdi3.c
+++ compiler-rt/lib/builtins/mulvdi3.c
@@ -10,38 +10,11 @@
 //
 //===--===//
 
-#include "int_lib.h"
+#define fixint_t di_int
+#include "int_mulv_impl.inc"
 
 // Returns: a * b
 
 // Effects: aborts if a * b overflows
 
-COMPILER_RT_ABI di_int __mulvdi3(di_int a, di_int b) {
-  const int N = (int)(sizeof(di_int) * CHAR_BIT);
-  const di_int MIN = (di_int)1 << (N - 1);
-  const di_int MAX = ~MIN;
-  if (a == MIN) {
-if (b == 0 || b == 1)
-  return a * b;
-compilerrt_abort();
-  }
-  if (b == MIN) {
-if (a == 0 || a == 1)
-  return a * b;
-compilerrt_abort();
-  }
-  di_int sa = a >> (N - 1);
-  di_int abs_a = (a ^ sa) - sa;
-  di_int sb = b >> (N - 1);
-  di_int abs_b = (b ^ sb) - sb;
-  if (abs_a < 2 || abs_b < 2)
-return a * b;
-  if (sa == sb) {
-if (abs_a > MAX / abs_b)
-  compilerrt_abort();
-  } else {
-if (abs_a > MIN / -abs_b)
-  compilerrt_abort();
-  }
-  return a * b;
-}
+COMPILER_RT_ABI di_int __mulvdi3(di_int a, di_int b) { return __mulvXi3(a, b); }
Index: compiler-rt/lib/builtins/int_mulv_impl.inc
===
--- compiler-rt/lib/builtins/int_mulv_impl.inc
+++ compiler-rt/lib/builtins/int_mulv_impl.inc
@@ -1,4 +1,4 @@
-//===-- mulvdi3.c - Implement __mulvdi3 ---===//
+//===-- int_mulv_impl.inc - Implement __mulv[sdt]i3 ---*- C -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
 //
 //===--===//
 //
-// This file implements __mulvdi3 for the compiler_rt library.
+// Helper used by __mulvsi3, __mulvdi3 and __mulvti3.
 //
 //===--===//
 
@@ -16,10 +16,10 @@
 
 // Effects: aborts if a * b 

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

2020-08-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added reviewers: john.brawn, rsmith, erichkeane.
aaron.ballman added a comment.

Thank you for the work in progress patch as a starting point for discussion! 
I'm adding a few more reviewers who may be interested in this work.

One part of the design I'm not yet certain of is passing in the `Declarator *` 
to the various parsing functions. While I understand the idea (and appreciate 
the explanation of why you'd like this), my concern is that attributes 
appertain to more than just declarators (like declaration specifiers, types,  
and statements). Do you envision supporting all the various entities that an 
attribute can appertain to? Also, do you intend to provide the same information 
to the other spellings, like `__attribute__` or `__declspec` (because plugins 
can define custom attributes with those spellings as well)?




Comment at: clang/include/clang/Sema/ParsedAttr.h:97
+  virtual AttrHandling
+  parseAttributePayload(Parser *P, ParsedAttributes , Declarator *D,
+IdentifierInfo *AttrName, SourceLocation AttrNameLoc,

I think this should also have a parameter for the syntax used for the 
attribute, because different syntaxes may have different rules for how to parse 
the arguments to the attribute (this is one of the reasons why we have common 
attribute argument parsing as well as syntax-specific attribute argument 
parsing in `Parser`).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86169

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


[PATCH] D82657: [AST][RecoveryAST] Preserve the type by default for recovery expression.

2020-08-21 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang/test/SemaCXX/abstract.cpp:282
 
-  void foo( C& c ) {}
+  void foo( C& c ) {} // expected-note {{candidate function not viable: 
expects an l-value for 1st argument}}
 

sammccall wrote:
> the new diagnostics are correct (nice!) but this is just a bug in the test:
> see https://bugs.llvm.org/show_bug.cgi?id=12658 vs 
> https://github.com/llvm/llvm-project/commit/ea03214a5e3413cf95e388f28e4d9b9eeb30210a
> 
> To keep the test simple, I'd consider changing C& to const C& here instead.
I'd prefer to keep these as these are secondary-diagnostic improvements (so 
that we will not regress them in the future).  

I fixed these tests, and created two in `recovery-ast-type.cpp`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82657

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


[PATCH] D82657: [AST][RecoveryAST] Preserve the type by default for recovery expression.

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

update a comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82657

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CXX/temp/temp.constr/temp.constr.order/function-templates.cpp
  clang/test/SemaCXX/abstract.cpp
  clang/test/SemaCXX/decl-expr-ambiguity.cpp
  clang/test/SemaCXX/recovery-expr-type.cpp
  clang/test/SemaCXX/type-convert-construct.cpp
  clang/test/SemaTemplate/dependent-names.cpp

Index: clang/test/SemaTemplate/dependent-names.cpp
===
--- clang/test/SemaTemplate/dependent-names.cpp
+++ clang/test/SemaTemplate/dependent-names.cpp
@@ -173,7 +173,7 @@
 
 
   namespace O {
-void f(char&); // expected-note {{candidate function not viable}}
+int f(char&); // expected-note {{candidate function not viable}}
 
 template struct C {
   static const int n = f(T()); // expected-error {{no matching function}}
Index: clang/test/SemaCXX/type-convert-construct.cpp
===
--- clang/test/SemaCXX/type-convert-construct.cpp
+++ clang/test/SemaCXX/type-convert-construct.cpp
@@ -6,7 +6,7 @@
   float v1 = float(1);
   int v2 = typeof(int)(1,2); // expected-error {{excess elements in scalar initializer}}
   typedef int arr[];
-  int v3 = arr(); // expected-error {{array types cannot be value-initialized}}
+  arr(); // expected-error {{array types cannot be value-initialized}}
   typedef void fn_ty();
   fn_ty(); // expected-error {{cannot create object of function type 'fn_ty'}}
   fn_ty(0); // expected-error {{functional-style cast from 'int' to 'fn_ty'}}
Index: clang/test/SemaCXX/recovery-expr-type.cpp
===
--- clang/test/SemaCXX/recovery-expr-type.cpp
+++ clang/test/SemaCXX/recovery-expr-type.cpp
@@ -86,3 +86,22 @@
   (T(T())); // expected-error {{call to deleted constructor}}
 }
 }
+
+// verify the secondary diagnostic "no matching function" is emitted.
+namespace test7 {
+struct C {
+  C() = delete; // expected-note {{has been explicitly marked deleted}}
+};
+void f(C &); // expected-note {{candidate function not viable: expects an l-value for 1st argument}}
+void test() {
+  f(C()); // expected-error {{call to deleted constructor}} \
+ expected-error {{no matching function for call}}
+}
+}
+
+// verify the secondary diagnostic "cannot initialize" is emitted.
+namespace test8 {
+typedef int arr[];
+int v = arr(); // expected-error {{array types cannot be value-initialized}} \
+  expected-error {{cannot initialize a variable of type 'int' with an rvalue of type 'test8::arr'}}
+}
Index: clang/test/SemaCXX/decl-expr-ambiguity.cpp
===
--- clang/test/SemaCXX/decl-expr-ambiguity.cpp
+++ clang/test/SemaCXX/decl-expr-ambiguity.cpp
@@ -12,7 +12,7 @@
   T(a)->m = 7;
   int(a)++; // expected-error {{assignment to cast is illegal}}
   __extension__ int(a)++; // expected-error {{assignment to cast is illegal}}
-  __typeof(int)(a,5)<()));
-// expected-error@-1 {{call to 'f' is ambiguous}}
+// expected-error@-1 {{call to 'f' is ambiguous}} \
+   expected-error@-1 {{invalid application of 'sizeof' to an incomplete type 'void'}}
 
 template
 concept C3 = true;
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2934,8 +2934,8 @@
   // Recovery AST still heavily relies on dependent-type machinery.
   Opts.RecoveryAST =
   Args.hasFlag(OPT_frecovery_ast, OPT_fno_recovery_ast, Opts.CPlusPlus);
-  Opts.RecoveryASTType =
-  Args.hasFlag(OPT_frecovery_ast_type, OPT_fno_recovery_ast_type, false);
+  Opts.RecoveryASTType = Args.hasFlag(
+  OPT_frecovery_ast_type, OPT_fno_recovery_ast_type, Opts.CPlusPlus);
   Opts.HeinousExtensions = Args.hasArg(OPT_fheinous_gnu_extensions);
   Opts.AccessControl = !Args.hasArg(OPT_fno_access_control);
   Opts.ElideConstructors = !Args.hasArg(OPT_fno_elide_constructors);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82657: [AST][RecoveryAST] Preserve the type by default for recovery expression.

2020-08-21 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 287029.
hokein marked 2 inline comments as done.
hokein added a comment.

update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82657

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CXX/temp/temp.constr/temp.constr.order/function-templates.cpp
  clang/test/SemaCXX/abstract.cpp
  clang/test/SemaCXX/decl-expr-ambiguity.cpp
  clang/test/SemaCXX/recovery-expr-type.cpp
  clang/test/SemaCXX/type-convert-construct.cpp
  clang/test/SemaTemplate/dependent-names.cpp

Index: clang/test/SemaTemplate/dependent-names.cpp
===
--- clang/test/SemaTemplate/dependent-names.cpp
+++ clang/test/SemaTemplate/dependent-names.cpp
@@ -173,7 +173,7 @@
 
 
   namespace O {
-void f(char&); // expected-note {{candidate function not viable}}
+int f(char&); // expected-note {{candidate function not viable}}
 
 template struct C {
   static const int n = f(T()); // expected-error {{no matching function}}
Index: clang/test/SemaCXX/type-convert-construct.cpp
===
--- clang/test/SemaCXX/type-convert-construct.cpp
+++ clang/test/SemaCXX/type-convert-construct.cpp
@@ -6,7 +6,7 @@
   float v1 = float(1);
   int v2 = typeof(int)(1,2); // expected-error {{excess elements in scalar initializer}}
   typedef int arr[];
-  int v3 = arr(); // expected-error {{array types cannot be value-initialized}}
+  arr(); // expected-error {{array types cannot be value-initialized}}
   typedef void fn_ty();
   fn_ty(); // expected-error {{cannot create object of function type 'fn_ty'}}
   fn_ty(0); // expected-error {{functional-style cast from 'int' to 'fn_ty'}}
Index: clang/test/SemaCXX/recovery-expr-type.cpp
===
--- clang/test/SemaCXX/recovery-expr-type.cpp
+++ clang/test/SemaCXX/recovery-expr-type.cpp
@@ -86,3 +86,21 @@
   (T(T())); // expected-error {{call to deleted constructor}}
 }
 }
+
+// verify the secondary diagnostic "no matching function" is emitted.
+namespace test7 {
+struct C {
+  C() = delete; // expected-note {{has been explicitly marked deleted}}
+};
+void f(C&); // expected-note {{candidate function not viable: expects an l-value for 1st argument}}
+void test() {
+  f(C()); // expected-error {{call to deleted constructor}} \
+ expected-error {{no matching function for call}}
+}
+}
+
+namespace test8 {
+typedef int arr[];
+int v = arr(); // expected-error {{array types cannot be value-initialized}} \
+  expected-error {{cannot initialize a variable of type 'int' with an rvalue of type 'test8::arr'}}
+}
Index: clang/test/SemaCXX/decl-expr-ambiguity.cpp
===
--- clang/test/SemaCXX/decl-expr-ambiguity.cpp
+++ clang/test/SemaCXX/decl-expr-ambiguity.cpp
@@ -12,7 +12,7 @@
   T(a)->m = 7;
   int(a)++; // expected-error {{assignment to cast is illegal}}
   __extension__ int(a)++; // expected-error {{assignment to cast is illegal}}
-  __typeof(int)(a,5)<()));
-// expected-error@-1 {{call to 'f' is ambiguous}}
+// expected-error@-1 {{call to 'f' is ambiguous}} \
+   expected-error@-1 {{invalid application of 'sizeof' to an incomplete type 'void'}}
 
 template
 concept C3 = true;
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2934,8 +2934,8 @@
   // Recovery AST still heavily relies on dependent-type machinery.
   Opts.RecoveryAST =
   Args.hasFlag(OPT_frecovery_ast, OPT_fno_recovery_ast, Opts.CPlusPlus);
-  Opts.RecoveryASTType =
-  Args.hasFlag(OPT_frecovery_ast_type, OPT_fno_recovery_ast_type, false);
+  Opts.RecoveryASTType = Args.hasFlag(
+  OPT_frecovery_ast_type, OPT_fno_recovery_ast_type, Opts.CPlusPlus);
   Opts.HeinousExtensions = Args.hasArg(OPT_fheinous_gnu_extensions);
   Opts.AccessControl = !Args.hasArg(OPT_fno_access_control);
   Opts.ElideConstructors = !Args.hasArg(OPT_fno_elide_constructors);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D85611: Improve dynamic AST matching diagnostics for conversion errors

2020-08-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D85611#2218144 , @aaron.ballman 
wrote:

> Ping

Ping x2


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

https://reviews.llvm.org/D85611

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


[PATCH] D84013: Correctly emit dwoIDs after ASTFileSignature refactoring (D81347)

2020-08-21 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor reopened this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

Somehow this ended up failing on Fuchsia with a plain "Exit code 1", but not 
sure what's the fault. I'll revert until I figured that out.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84013

___
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-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, thank you for the fix!




Comment at: 
clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp:66
+  if (const auto *Negated = Result.Nodes.getNodeAs(Id)) {
+if (Negated->getOpcode() == UO_LNot &&
+isa(Negated->getSubExpr()))

njames93 wrote:
> aaron.ballman wrote:
> > njames93 wrote:
> > > aaron.ballman wrote:
> > > > I'd like to see this handled recursively instead so that we properly 
> > > > handle more esoteric logic (but it still shows up from time to time) 
> > > > like `!!foo`: 
> > > > https://codesearch.isocpp.org/cgi-bin/cgi_ppsearch?q=%21%21=Search
> > > > 
> > > > This is a case where I don't think the simplification should happen -- 
> > > > e.g., the code is usually subtly incorrect when converted to remove the 
> > > > `!!`. It's less clear to me whether the same is true for something like 
> > > > `!!!` being converted to `!`, but that's not a case I'm really worried 
> > > > about either.
> > > As this is only looking for boolean literals that shouldn't matter
> > > `!!true` is identical to `true`.
> > > I get putting `!!` in front of expressions that aren't boolean has an 
> > > effect, but we aren't looking for that in this case.
> > Oh, derp, I saw "SimplifyBooleanExprCheck" and assumed it was simplifying 
> > arbitrary boolean expressions, not just literals. I am now far less worried 
> > about supporting this case, it's up to you if you want to do the extra 
> > work. Thank you for clarifying and sorry for my think-o!
> Personally I don't think the extra complexity is worth it. Usages of `!true`, 
> I expect are rather low but likely show up in a few places, however I doubt 
> anyone would use `!!true`. 
Agreed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86176

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


[clang] c1dd5df - Revert "Correctly emit dwoIDs after ASTFileSignature refactoring (D81347)"

2020-08-21 Thread Raphael Isemann via cfe-commits

Author: Raphael Isemann
Date: 2020-08-21T16:08:37+02:00
New Revision: c1dd5df4255cd870e96a59e73163b22d85fbaba3

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

LOG: Revert "Correctly emit dwoIDs after ASTFileSignature refactoring (D81347)"

This reverts commit a4c3ed42ba5625af54254584d762ebf96cc06942.

The test is curiously failing with a plain exit code 1 on Fuchsia.

Added: 


Modified: 
clang/include/clang/Basic/Module.h
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
clang/test/Modules/Inputs/module.map

Removed: 
clang/test/Modules/Inputs/DebugDwoId.h
clang/test/Modules/ModuleDebugInfoDwoId.cpp



diff  --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index ac33c7573f35..94dd21537966 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -62,15 +62,6 @@ struct ASTFileSignature : std::array {
 
   explicit operator bool() const { return *this != BaseT({{0}}); }
 
-  /// Returns the value truncated to the size of an uint64_t.
-  uint64_t truncatedValue() const {
-uint64_t Value = 0;
-static_assert(sizeof(*this) >= sizeof(uint64_t), "No need to truncate.");
-for (unsigned I = 0; I < sizeof(uint64_t); ++I)
-  Value |= static_cast((*this)[I]) << (I * 8);
-return Value;
-  }
-
   static ASTFileSignature create(StringRef Bytes) {
 return create(Bytes.bytes_begin(), Bytes.bytes_end());
   }

diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index e3442ecd4bd5..2faf944d07d1 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2545,11 +2545,12 @@ llvm::DIModule 
*CGDebugInfo::getOrCreateModuleRef(ASTSourceDescriptor Mod,
 // We use the lower 64 bits for debug info.
 
 uint64_t Signature = 0;
-if (const auto  = Mod.getSignature())
-  Signature = ModSig.truncatedValue();
-else
+if (const auto  = Mod.getSignature()) {
+  for (unsigned I = 0; I != sizeof(Signature); ++I)
+Signature |= (uint64_t)ModSig[I] << (I * 8);
+} else {
   Signature = ~1ULL;
-
+}
 llvm::DIBuilder DIB(CGM.getModule());
 SmallString<0> PCM;
 if (!llvm::sys::path::is_absolute(Mod.getASTFile()))

diff  --git a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp 
b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
index 04bd6680e31c..0c7e5f4598f8 100644
--- a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
+++ b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
@@ -250,10 +250,10 @@ class PCHContainerGenerator : public ASTConsumer {
 // PCH files don't have a signature field in the control block,
 // but LLVM detects DWO CUs by looking for a non-zero DWO id.
 // We use the lower 64 bits for debug info.
-
 uint64_t Signature =
-Buffer->Signature ? Buffer->Signature.truncatedValue() : ~1ULL;
-
+Buffer->Signature
+? (uint64_t)Buffer->Signature[1] << 32 | Buffer->Signature[0]
+: ~1ULL;
 Builder->getModuleDebugInfo()->setDwoId(Signature);
 
 // Finalize the Builder.

diff  --git a/clang/test/Modules/Inputs/DebugDwoId.h 
b/clang/test/Modules/Inputs/DebugDwoId.h
deleted file mode 100644
index 242e4c7f5116..
--- a/clang/test/Modules/Inputs/DebugDwoId.h
+++ /dev/null
@@ -1,4 +0,0 @@
-#ifndef DEBUG_DWO_ID_H
-#define DEBUG_DWO_ID_H
-struct Dummy {};
-#endif

diff  --git a/clang/test/Modules/Inputs/module.map 
b/clang/test/Modules/Inputs/module.map
index e7cb4b27bc08..ed220e667f05 100644
--- a/clang/test/Modules/Inputs/module.map
+++ b/clang/test/Modules/Inputs/module.map
@@ -357,10 +357,6 @@ module DebugObjCImport {
   }
 }
 
-module DebugDwoId {
-  header "DebugDwoId.h"
-}
-
 module ImportNameInDir {
   header "ImportNameInDir.h"
   export *

diff  --git a/clang/test/Modules/ModuleDebugInfoDwoId.cpp 
b/clang/test/Modules/ModuleDebugInfoDwoId.cpp
deleted file mode 100644
index 566db048df84..
--- a/clang/test/Modules/ModuleDebugInfoDwoId.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-// Tests that dwoIds in modules match the dwoIDs in the main file.
-
-// RUN: rm -rf %t.cache
-// RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++ -std=c++11 
-debugger-tuning=lldb -debug-info-kind=limited -fmodules -fmodule-format=obj 
-dwarf-ext-refs -fimplicit-module-maps -fmodules-cache-path=%t.cache %s -I 
%S/Inputs -emit-llvm -o %t.ll -mllvm -debug-only=pchcontainer &> %t.mod-out
-// RUN: cat %t.ll %t.mod-out | FileCheck %s
-// RUN: cat %t.ll | FileCheck --check-prefix=CHECK-REALIDS %s
-// RUN: cat %t.mod-out | FileCheck --check-prefix=CHECK-REALIDS %s
-
-@import DebugDwoId;
-
-Dummy d;
-
-// Find the emitted dwoID for DebugInfoId and compare it against the 

[PATCH] D85716: [AST][RecoveryExpr] Fix a bogus unused diagnostic when the type is preserved.

2020-08-21 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 287025.
hokein marked an inline comment as done.
hokein added a comment.

simplify the testcase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85716

Files:
  clang/lib/AST/Expr.cpp
  clang/test/SemaCXX/recovery-expr-type.cpp


Index: clang/test/SemaCXX/recovery-expr-type.cpp
===
--- clang/test/SemaCXX/recovery-expr-type.cpp
+++ clang/test/SemaCXX/recovery-expr-type.cpp
@@ -75,3 +75,14 @@
   template U& f(); // expected-error {{pack expansion 
used as argument for non-pack parameter of alias template}}
   double  = f(); // expected-error {{no matching function}}
 }
+
+namespace test6 {
+struct T {
+  T() = delete; // expected-note {{has been explicitly marked deleted here}}
+};
+
+void func() {
+  // verify that no -Wunused-value diagnostic.
+  (T(T())); // expected-error {{call to deleted constructor}}
+}
+}
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -2658,6 +2658,8 @@
 // Otherwise, the result of the cast is unused.
 if (CE->getCastKind() == CK_ConstructorConversion)
   return CE->getSubExpr()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
+if (CE->getCastKind() == CK_Dependent)
+  return false;
 
 WarnE = this;
 if (const CXXFunctionalCastExpr *CXXCE =


Index: clang/test/SemaCXX/recovery-expr-type.cpp
===
--- clang/test/SemaCXX/recovery-expr-type.cpp
+++ clang/test/SemaCXX/recovery-expr-type.cpp
@@ -75,3 +75,14 @@
   template U& f(); // expected-error {{pack expansion used as argument for non-pack parameter of alias template}}
   double  = f(); // expected-error {{no matching function}}
 }
+
+namespace test6 {
+struct T {
+  T() = delete; // expected-note {{has been explicitly marked deleted here}}
+};
+
+void func() {
+  // verify that no -Wunused-value diagnostic.
+  (T(T())); // expected-error {{call to deleted constructor}}
+}
+}
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -2658,6 +2658,8 @@
 // Otherwise, the result of the cast is unused.
 if (CE->getCastKind() == CK_ConstructorConversion)
   return CE->getSubExpr()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
+if (CE->getCastKind() == CK_Dependent)
+  return false;
 
 WarnE = this;
 if (const CXXFunctionalCastExpr *CXXCE =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D85716: [AST][RecoveryExpr] Fix a bogus unused diagnostic when the type is preserved.

2020-08-21 Thread Haojian 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 rG466590192b42: [AST][RecoveryExpr] Fix a bogus unused 
diagnostic when the type is preserved. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85716

Files:
  clang/lib/AST/Expr.cpp
  clang/test/SemaCXX/recovery-expr-type.cpp


Index: clang/test/SemaCXX/recovery-expr-type.cpp
===
--- clang/test/SemaCXX/recovery-expr-type.cpp
+++ clang/test/SemaCXX/recovery-expr-type.cpp
@@ -75,3 +75,14 @@
   template U& f(); // expected-error {{pack expansion 
used as argument for non-pack parameter of alias template}}
   double  = f(); // expected-error {{no matching function}}
 }
+
+namespace test6 {
+struct T {
+  T() = delete; // expected-note {{has been explicitly marked deleted here}}
+};
+
+void func() {
+  // verify that no -Wunused-value diagnostic.
+  (T(T())); // expected-error {{call to deleted constructor}}
+}
+}
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -2658,6 +2658,8 @@
 // Otherwise, the result of the cast is unused.
 if (CE->getCastKind() == CK_ConstructorConversion)
   return CE->getSubExpr()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
+if (CE->getCastKind() == CK_Dependent)
+  return false;
 
 WarnE = this;
 if (const CXXFunctionalCastExpr *CXXCE =


Index: clang/test/SemaCXX/recovery-expr-type.cpp
===
--- clang/test/SemaCXX/recovery-expr-type.cpp
+++ clang/test/SemaCXX/recovery-expr-type.cpp
@@ -75,3 +75,14 @@
   template U& f(); // expected-error {{pack expansion used as argument for non-pack parameter of alias template}}
   double  = f(); // expected-error {{no matching function}}
 }
+
+namespace test6 {
+struct T {
+  T() = delete; // expected-note {{has been explicitly marked deleted here}}
+};
+
+void func() {
+  // verify that no -Wunused-value diagnostic.
+  (T(T())); // expected-error {{call to deleted constructor}}
+}
+}
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -2658,6 +2658,8 @@
 // Otherwise, the result of the cast is unused.
 if (CE->getCastKind() == CK_ConstructorConversion)
   return CE->getSubExpr()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
+if (CE->getCastKind() == CK_Dependent)
+  return false;
 
 WarnE = this;
 if (const CXXFunctionalCastExpr *CXXCE =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 4665901 - [AST][RecoveryExpr] Fix a bogus unused diagnostic when the type is preserved.

2020-08-21 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-08-21T15:48:59+02:00
New Revision: 466590192b4202ceb294eb82f881193d013dc90c

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

LOG: [AST][RecoveryExpr] Fix a bogus unused diagnostic when the type is 
preserved.

Reviewed By: sammccall

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

Added: 


Modified: 
clang/lib/AST/Expr.cpp
clang/test/SemaCXX/recovery-expr-type.cpp

Removed: 




diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index e3e5e9dbdc62..8efd6837c541 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -2658,6 +2658,8 @@ bool Expr::isUnusedResultAWarning(const Expr *, 
SourceLocation ,
 // Otherwise, the result of the cast is unused.
 if (CE->getCastKind() == CK_ConstructorConversion)
   return CE->getSubExpr()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
+if (CE->getCastKind() == CK_Dependent)
+  return false;
 
 WarnE = this;
 if (const CXXFunctionalCastExpr *CXXCE =

diff  --git a/clang/test/SemaCXX/recovery-expr-type.cpp 
b/clang/test/SemaCXX/recovery-expr-type.cpp
index 2ce47f2f8efc..7fad61e53df8 100644
--- a/clang/test/SemaCXX/recovery-expr-type.cpp
+++ b/clang/test/SemaCXX/recovery-expr-type.cpp
@@ -75,3 +75,14 @@ namespace test5 {
   template U& f(); // expected-error {{pack expansion 
used as argument for non-pack parameter of alias template}}
   double  = f(); // expected-error {{no matching function}}
 }
+
+namespace test6 {
+struct T {
+  T() = delete; // expected-note {{has been explicitly marked deleted here}}
+};
+
+void func() {
+  // verify that no -Wunused-value diagnostic.
+  (T(T())); // expected-error {{call to deleted constructor}}
+}
+}



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


[PATCH] D83660: [analyzer] Fix a crash for dereferencing an empty llvm::Optional variable in SMTConstraintManager.h.

2020-08-21 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

It seems that this patch is stuck.
How can I reproduce the crash? @OikawaKirie

The closest I could come up with was:

  void clang_analyzer_eval(int);
  void clang_analyzer_printState();
  
  void foo(int a, int b) {
if (a > 5)
  return;
if (b < 4)
  return;
if (a <= b)
  return;
  
clang_analyzer_printState();
clang_analyzer_eval(a == 5); // expected-warning{{TRUE}}
clang_analyzer_eval(b == 4); // expected-warning{{TRUE}}
(void)a;
(void)b;
  }

But it still not crash. Any idea?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83660

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


[PATCH] D84013: Correctly emit dwoIDs after ASTFileSignature refactoring (D81347)

2020-08-21 Thread Raphael Isemann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa4c3ed42ba56: Correctly emit dwoIDs after ASTFileSignature 
refactoring (D81347) (authored by teemperor).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84013

Files:
  clang/include/clang/Basic/Module.h
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
  clang/test/Modules/Inputs/DebugDwoId.h
  clang/test/Modules/Inputs/module.map
  clang/test/Modules/ModuleDebugInfoDwoId.cpp

Index: clang/test/Modules/ModuleDebugInfoDwoId.cpp
===
--- /dev/null
+++ clang/test/Modules/ModuleDebugInfoDwoId.cpp
@@ -0,0 +1,20 @@
+// Tests that dwoIds in modules match the dwoIDs in the main file.
+
+// RUN: rm -rf %t.cache
+// RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++ -std=c++11 -debugger-tuning=lldb -debug-info-kind=limited -fmodules -fmodule-format=obj -dwarf-ext-refs -fimplicit-module-maps -fmodules-cache-path=%t.cache %s -I %S/Inputs -emit-llvm -o %t.ll -mllvm -debug-only=pchcontainer &> %t.mod-out
+// RUN: cat %t.ll %t.mod-out | FileCheck %s
+// RUN: cat %t.ll | FileCheck --check-prefix=CHECK-REALIDS %s
+// RUN: cat %t.mod-out | FileCheck --check-prefix=CHECK-REALIDS %s
+
+@import DebugDwoId;
+
+Dummy d;
+
+// Find the emitted dwoID for DebugInfoId and compare it against the one in the PCM.
+// CHECK: DebugDwoId-{{[A-Z0-9]+}}.pcm
+// CHECK-SAME: dwoId: [[DWOID:[0-9]+]]
+// CHECK: dwoId: [[DWOID]]
+// CHECK-NEXT: !DIFile(filename: "DebugDwoId"
+
+// Make sure the dwo IDs are real IDs and not fallback values (~1ULL).
+// CHECK-REALIDS-NOT: dwoId: 18446744073709551615
Index: clang/test/Modules/Inputs/module.map
===
--- clang/test/Modules/Inputs/module.map
+++ clang/test/Modules/Inputs/module.map
@@ -357,6 +357,10 @@
   }
 }
 
+module DebugDwoId {
+  header "DebugDwoId.h"
+}
+
 module ImportNameInDir {
   header "ImportNameInDir.h"
   export *
Index: clang/test/Modules/Inputs/DebugDwoId.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/DebugDwoId.h
@@ -0,0 +1,4 @@
+#ifndef DEBUG_DWO_ID_H
+#define DEBUG_DWO_ID_H
+struct Dummy {};
+#endif
Index: clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
===
--- clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
+++ clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
@@ -250,10 +250,10 @@
 // PCH files don't have a signature field in the control block,
 // but LLVM detects DWO CUs by looking for a non-zero DWO id.
 // We use the lower 64 bits for debug info.
+
 uint64_t Signature =
-Buffer->Signature
-? (uint64_t)Buffer->Signature[1] << 32 | Buffer->Signature[0]
-: ~1ULL;
+Buffer->Signature ? Buffer->Signature.truncatedValue() : ~1ULL;
+
 Builder->getModuleDebugInfo()->setDwoId(Signature);
 
 // Finalize the Builder.
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2545,12 +2545,11 @@
 // We use the lower 64 bits for debug info.
 
 uint64_t Signature = 0;
-if (const auto  = Mod.getSignature()) {
-  for (unsigned I = 0; I != sizeof(Signature); ++I)
-Signature |= (uint64_t)ModSig[I] << (I * 8);
-} else {
+if (const auto  = Mod.getSignature())
+  Signature = ModSig.truncatedValue();
+else
   Signature = ~1ULL;
-}
+
 llvm::DIBuilder DIB(CGM.getModule());
 SmallString<0> PCM;
 if (!llvm::sys::path::is_absolute(Mod.getASTFile()))
Index: clang/include/clang/Basic/Module.h
===
--- clang/include/clang/Basic/Module.h
+++ clang/include/clang/Basic/Module.h
@@ -62,6 +62,15 @@
 
   explicit operator bool() const { return *this != BaseT({{0}}); }
 
+  /// Returns the value truncated to the size of an uint64_t.
+  uint64_t truncatedValue() const {
+uint64_t Value = 0;
+static_assert(sizeof(*this) >= sizeof(uint64_t), "No need to truncate.");
+for (unsigned I = 0; I < sizeof(uint64_t); ++I)
+  Value |= static_cast((*this)[I]) << (I * 8);
+return Value;
+  }
+
   static ASTFileSignature create(StringRef Bytes) {
 return create(Bytes.bytes_begin(), Bytes.bytes_end());
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] a4c3ed4 - Correctly emit dwoIDs after ASTFileSignature refactoring (D81347)

2020-08-21 Thread Raphael Isemann via cfe-commits

Author: Raphael Isemann
Date: 2020-08-21T15:05:02+02:00
New Revision: a4c3ed42ba5625af54254584d762ebf96cc06942

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

LOG: Correctly emit dwoIDs after ASTFileSignature refactoring (D81347)

D81347 changes the ASTFileSignature to be an array of 20 uint8_t instead of 5
uint32_t. However, it didn't update the code in ObjectFilePCHContainerOperations
that creates the dwoID in the module from the ASTFileSignature
(`Buffer->Signature` being the array subclass that is now `std::array` instead of `std::array`).

```
  uint64_t Signature = [..] (uint64_t)Buffer->Signature[1] << 32 | 
Buffer->Signature[0]
```

This code works with the old ASTFileSignature (where two uint32_t are enough to
fill the uint64_t), but after the patch this only took two bytes from the
ASTFileSignature and only partly filled the Signature uint64_t.

This caused that the dwoID in the module ref and the dwoID in the actual module
no longer match (which in turns causes that LLDB keeps warning about the dwoID's
not matching when debugging -gmodules-compiled binaries).

This patch just unifies the logic for turning the ASTFileSignature into an
uint64_t which makes the dwoID match again (and should prevent issues like that
in the future).

Reviewed By: aprantl, dang

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

Added: 
clang/test/Modules/Inputs/DebugDwoId.h
clang/test/Modules/ModuleDebugInfoDwoId.cpp

Modified: 
clang/include/clang/Basic/Module.h
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
clang/test/Modules/Inputs/module.map

Removed: 




diff  --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index 94dd21537966..ac33c7573f35 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -62,6 +62,15 @@ struct ASTFileSignature : std::array {
 
   explicit operator bool() const { return *this != BaseT({{0}}); }
 
+  /// Returns the value truncated to the size of an uint64_t.
+  uint64_t truncatedValue() const {
+uint64_t Value = 0;
+static_assert(sizeof(*this) >= sizeof(uint64_t), "No need to truncate.");
+for (unsigned I = 0; I < sizeof(uint64_t); ++I)
+  Value |= static_cast((*this)[I]) << (I * 8);
+return Value;
+  }
+
   static ASTFileSignature create(StringRef Bytes) {
 return create(Bytes.bytes_begin(), Bytes.bytes_end());
   }

diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 2faf944d07d1..e3442ecd4bd5 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2545,12 +2545,11 @@ llvm::DIModule 
*CGDebugInfo::getOrCreateModuleRef(ASTSourceDescriptor Mod,
 // We use the lower 64 bits for debug info.
 
 uint64_t Signature = 0;
-if (const auto  = Mod.getSignature()) {
-  for (unsigned I = 0; I != sizeof(Signature); ++I)
-Signature |= (uint64_t)ModSig[I] << (I * 8);
-} else {
+if (const auto  = Mod.getSignature())
+  Signature = ModSig.truncatedValue();
+else
   Signature = ~1ULL;
-}
+
 llvm::DIBuilder DIB(CGM.getModule());
 SmallString<0> PCM;
 if (!llvm::sys::path::is_absolute(Mod.getASTFile()))

diff  --git a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp 
b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
index 0c7e5f4598f8..04bd6680e31c 100644
--- a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
+++ b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
@@ -250,10 +250,10 @@ class PCHContainerGenerator : public ASTConsumer {
 // PCH files don't have a signature field in the control block,
 // but LLVM detects DWO CUs by looking for a non-zero DWO id.
 // We use the lower 64 bits for debug info.
+
 uint64_t Signature =
-Buffer->Signature
-? (uint64_t)Buffer->Signature[1] << 32 | Buffer->Signature[0]
-: ~1ULL;
+Buffer->Signature ? Buffer->Signature.truncatedValue() : ~1ULL;
+
 Builder->getModuleDebugInfo()->setDwoId(Signature);
 
 // Finalize the Builder.

diff  --git a/clang/test/Modules/Inputs/DebugDwoId.h 
b/clang/test/Modules/Inputs/DebugDwoId.h
new file mode 100644
index ..242e4c7f5116
--- /dev/null
+++ b/clang/test/Modules/Inputs/DebugDwoId.h
@@ -0,0 +1,4 @@
+#ifndef DEBUG_DWO_ID_H
+#define DEBUG_DWO_ID_H
+struct Dummy {};
+#endif

diff  --git a/clang/test/Modules/Inputs/module.map 
b/clang/test/Modules/Inputs/module.map
index ed220e667f05..e7cb4b27bc08 100644
--- a/clang/test/Modules/Inputs/module.map
+++ b/clang/test/Modules/Inputs/module.map
@@ -357,6 +357,10 @@ module DebugObjCImport {
   }
 }
 
+module DebugDwoId {
+  header "DebugDwoId.h"
+}
+
 module ImportNameInDir {
   

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

2020-08-21 Thread Paul Walker via Phabricator via cfe-commits
paulwalker-arm added inline comments.



Comment at: llvm/include/llvm/Support/TypeSize.h:56
 
+  friend bool operator>(const ElementCount , const ElementCount ) {
+assert(LHS.Scalable == RHS.Scalable &&

david-arm wrote:
> ctetreau wrote:
> > fpetrogalli wrote:
> > > I think that @ctetreau is right on 
> > > https://reviews.llvm.org/D85794#inline-793909. We should not overload a 
> > > comparison operator on this class because the set it represent it cannot 
> > > be ordered.
> > > 
> > > Chris suggests an approach of writing a static function that can be used 
> > > as a comparison operator,  so that we can make it explicit of what kind 
> > > of comparison we  are doing. 
> > In C++, it's common to overload the comparison operators for the purposes 
> > of being able to std::sort and use ordered sets. Normally, I would be OK 
> > with such usages. However, since `ElementCount` is basically a numeric 
> > type, and they only have a partial ordering, I think this is dangerous. I'm 
> > concerned that this will result in more bugs whereby somebody didn't 
> > remember that vectors can be scalable.
> > 
> > I don't have a strong opinion what the comparator function should be 
> > called, but I strongly prefer that it not be a comparison operator.
> Hi @ctetreau, yeah I understand. The reason I chose to use operators was 
> simply to be consistent with what we have already in TypeSize. Also, we have 
> existing "==" and "!=" operators in ElementCount too, although these are 
> essentially testing that two ElementCounts are identically the same or not, 
> i.e. for 2 given polynomials (a + bx) and (c + dx) we're essentially asking 
> if both a==c and b==d.
> 
> If I introduce a new comparison function, I'll probably keep the asserts in 
> for now, but in general we can do better than simply asserting if something 
> is scalable or not. For example, we know that (vscale * 4) is definitely >= 4 
> because vscale is at least 1. I'm just not sure if we have that need yet.
I think we should treat the non-equality comparison functions more like 
floating point.  What we don't want is somebody writing !GreaterThan when they 
actually mean LessThan.

Perhaps we should name the functions accordingly (i.e. ogt for 
OrderedAndGreaterThan).  We will also need matching less than functions since I 
can see those being useful when analysing constant insert/extract element 
indices which stand a good chance to be a known comparison (with 0 being the 
most common index).



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


[PATCH] D86345: [SyntaxTree] Use annotations in Statement tests

2020-08-21 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas added a reviewer: gribozavr2.
eduucaldas added a comment.

Sorry for doing this after asking for review.

I think it might be interesting landing this patch before : 
https://reviews.llvm.org/D85330


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86345

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


[PATCH] D86345: [SyntaxTree] Use annotations in Statement tests

2020-08-21 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/D86345

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
@@ -102,282 +102,196 @@
 }
 
 TEST_P(SyntaxTreeTest, If) {
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
-int main() {
-  if (1) {}
-  if (1) {} else if (0) {}
+void test() {
+  [[if (1) {}]]
+  [[if (1) {} else if (0) {}]]
 }
 )cpp",
-  R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-int
-  |-SimpleDeclarator
-  | |-main
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   `-)
+  {R"txt(
+IfStatement
+|-if
+|-(
+|-IntegerLiteralExpression
+| `-1
+|-)
+`-CompoundStatement
+  |-{
+  `-}
+  )txt",
+   R"txt(
+IfStatement
+|-if
+|-(
+|-IntegerLiteralExpression
+| `-1
+|-)
+|-CompoundStatement
+| |-{
+| `-}
+|-else
+`-IfStatement
+  |-if
+  |-(
+  |-IntegerLiteralExpression
+  | `-0
+  |-)
   `-CompoundStatement
 |-{
-|-IfStatement
-| |-if
-| |-(
-| |-IntegerLiteralExpression
-| | `-1
-| |-)
-| `-CompoundStatement
-|   |-{
-|   `-}
-|-IfStatement
-| |-if
-| |-(
-| |-IntegerLiteralExpression
-| | `-1
-| |-)
-| |-CompoundStatement
-| | |-{
-| | `-}
-| |-else
-| `-IfStatement
-|   |-if
-|   |-(
-|   |-IntegerLiteralExpression
-|   | `-0
-|   |-)
-|   `-CompoundStatement
-| |-{
-| `-}
 `-}
-)txt"));
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, For) {
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 void test() {
-  for (;;)  {}
+  [[for (;;)  {}]]
 }
 )cpp",
-  R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   `-)
-  `-CompoundStatement
-|-{
-|-ForStatement
-| |-for
-| |-(
-| |-;
-| |-;
-| |-)
-| `-CompoundStatement
-|   |-{
-|   `-}
-`-}
-)txt"));
+  {R"txt(
+ForStatement
+|-for
+|-(
+|-;
+|-;
+|-)
+`-CompoundStatement
+  |-{
+  `-}
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, RangeBasedFor) {
   if (!GetParam().isCXX11OrLater()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 void test() {
   int a[3];
-  for (int x : a)
-;
+  [[for (int x : a)
+;]]
 }
 )cpp",
-  R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   `-)
-  `-CompoundStatement
-|-{
-|-DeclarationStatement
-| |-SimpleDeclaration
-| | |-int
-| | `-SimpleDeclarator
-| |   |-a
-| |   `-ArraySubscript
-| | |-[
-| | |-IntegerLiteralExpression
-| | | `-3
-| | `-]
-| `-;
-|-RangeBasedForStatement
-| |-for
-| |-(
-| |-SimpleDeclaration
-| | |-int
-| | |-SimpleDeclarator
-| | | `-x
-| | `-:
-| |-IdExpression
-| | `-UnqualifiedId
-| |   `-a
-| |-)
-| `-EmptyStatement
-|   `-;
-`-}
-)txt"));
+  {R"txt(
+RangeBasedForStatement
+|-for
+|-(
+|-SimpleDeclaration
+| |-int
+| |-SimpleDeclarator
+| | `-x
+| `-:
+|-IdExpression
+| `-UnqualifiedId
+|   `-a
+|-)
+`-EmptyStatement
+  `-;
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, DeclarationStatement) {
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 void test() {
-  int a = 10;
+  [[int a = 10;]]
 }
 )cpp",
-  R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   `-)
-  `-CompoundStatement
-|-{
-|-DeclarationStatement
-| |-SimpleDeclaration
-| | |-int
-| | `-SimpleDeclarator
-| |   |-a
-| |   |-=
-| |   `-IntegerLiteralExpression
-| | `-10
-| `-;
-`-}
-)txt"));
+  {R"txt(
+DeclarationStatement
+|-SimpleDeclaration
+| |-int
+| `-SimpleDeclarator
+|   |-a
+|   |-=
+|   `-IntegerLiteralExpression
+| `-10
+`-;
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, Switch) {
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
 void test() {
-  switch (1) {
+  [[switch (1) {
 case 0:
 default:;
-  }
+  }]]
 }
 )cpp",
-  R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   `-)
-  `-CompoundStatement
-|-{
-|-SwitchStatement
-| |-switch
-| |-(
-| |-IntegerLiteralExpression
-| | `-1
-| |-)
-| `-CompoundStatement
-|   |-{
-|   |-CaseStatement
-|   | 

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

2020-08-21 Thread David Sherwood via Phabricator via cfe-commits
david-arm updated this revision to Diff 287003.

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

https://reviews.llvm.org/D86065

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  llvm/include/llvm/Analysis/VectorUtils.h
  llvm/include/llvm/CodeGen/ValueTypes.h
  llvm/include/llvm/IR/DataLayout.h
  llvm/include/llvm/IR/DerivedTypes.h
  llvm/include/llvm/IR/Instructions.h
  llvm/include/llvm/Support/MachineValueType.h
  llvm/include/llvm/Support/TypeSize.h
  llvm/lib/Analysis/InstructionSimplify.cpp
  llvm/lib/Analysis/VFABIDemangling.cpp
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/TargetLoweringBase.cpp
  llvm/lib/CodeGen/ValueTypes.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/ConstantFold.cpp
  llvm/lib/IR/Constants.cpp
  llvm/lib/IR/DataLayout.cpp
  llvm/lib/IR/Function.cpp
  llvm/lib/IR/IRBuilder.cpp
  llvm/lib/IR/Instructions.cpp
  llvm/lib/IR/IntrinsicInst.cpp
  llvm/lib/IR/Type.cpp
  llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
  llvm/lib/Transforms/Utils/FunctionComparator.cpp
  llvm/unittests/CodeGen/ScalableVectorMVTsTest.cpp
  llvm/unittests/IR/VectorTypesTest.cpp

Index: llvm/unittests/IR/VectorTypesTest.cpp
===
--- llvm/unittests/IR/VectorTypesTest.cpp
+++ llvm/unittests/IR/VectorTypesTest.cpp
@@ -119,8 +119,8 @@
   EXPECT_EQ(ConvTy->getElementType()->getScalarSizeInBits(), 64U);
 
   EltCnt = V8Int64Ty->getElementCount();
-  EXPECT_EQ(EltCnt.Min, 8U);
-  ASSERT_FALSE(EltCnt.Scalable);
+  EXPECT_EQ(EltCnt.getKnownMinValue(), 8U);
+  ASSERT_FALSE(EltCnt.isScalable());
 }
 
 TEST(VectorTypesTest, Scalable) {
@@ -215,8 +215,8 @@
   EXPECT_EQ(ConvTy->getElementType()->getScalarSizeInBits(), 64U);
 
   EltCnt = ScV8Int64Ty->getElementCount();
-  EXPECT_EQ(EltCnt.Min, 8U);
-  ASSERT_TRUE(EltCnt.Scalable);
+  EXPECT_EQ(EltCnt.getKnownMinValue(), 8U);
+  ASSERT_TRUE(EltCnt.isScalable());
 }
 
 TEST(VectorTypesTest, BaseVectorType) {
@@ -250,7 +250,7 @@
 // test I == J
 VectorType *VI = VTys[I];
 ElementCount ECI = VI->getElementCount();
-EXPECT_EQ(isa(VI), ECI.Scalable);
+EXPECT_EQ(isa(VI), ECI.isScalable());
 
 for (size_t J = I + 1, JEnd = VTys.size(); J < JEnd; ++J) {
   // test I < J
Index: llvm/unittests/CodeGen/ScalableVectorMVTsTest.cpp
===
--- llvm/unittests/CodeGen/ScalableVectorMVTsTest.cpp
+++ llvm/unittests/CodeGen/ScalableVectorMVTsTest.cpp
@@ -71,8 +71,8 @@
 
   // Check fields inside llvm::ElementCount
   EltCnt = Vnx4i32.getVectorElementCount();
-  EXPECT_EQ(EltCnt.Min, 4U);
-  ASSERT_TRUE(EltCnt.Scalable);
+  EXPECT_EQ(EltCnt.getKnownMinValue(), 4U);
+  ASSERT_TRUE(EltCnt.isScalable());
 
   // Check that fixed-length vector types aren't scalable.
   EVT V8i32 = EVT::getVectorVT(Ctx, MVT::i32, 8);
@@ -82,8 +82,8 @@
 
   // Check that llvm::ElementCount works for fixed-length types.
   EltCnt = V8i32.getVectorElementCount();
-  EXPECT_EQ(EltCnt.Min, 8U);
-  ASSERT_FALSE(EltCnt.Scalable);
+  EXPECT_EQ(EltCnt.getKnownMinValue(), 8U);
+  ASSERT_FALSE(EltCnt.isScalable());
 }
 
 TEST(ScalableVectorMVTsTest, IRToVTTranslation) {
Index: llvm/lib/Transforms/Utils/FunctionComparator.cpp
===
--- llvm/lib/Transforms/Utils/FunctionComparator.cpp
+++ llvm/lib/Transforms/Utils/FunctionComparator.cpp
@@ -488,12 +488,13 @@
   case Type::ScalableVectorTyID: {
 auto *STyL = cast(TyL);
 auto *STyR = cast(TyR);
-if (STyL->getElementCount().Scalable != STyR->getElementCount().Scalable)
-  return cmpNumbers(STyL->getElementCount().Scalable,
-STyR->getElementCount().Scalable);
-if (STyL->getElementCount().Min != STyR->getElementCount().Min)
-  return cmpNumbers(STyL->getElementCount().Min,
-STyR->getElementCount().Min);
+if (STyL->getElementCount().isScalable() !=
+STyR->getElementCount().isScalable())
+  return cmpNumbers(STyL->getElementCount().isScalable(),
+STyR->getElementCount().isScalable());
+if (STyL->getElementCount() != STyR->getElementCount())
+  return cmpNumbers(STyL->getElementCount().getKnownMinValue(),
+STyR->getElementCount().getKnownMinValue());
 return cmpTypes(STyL->getElementType(), STyR->getElementType());
   }
   }
Index: llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
===
--- llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
@@ 

[PATCH] D86342: Enable constexpr on ROTATELEFT/ROTATERIGHT builtin intrinsics (PR47249)

2020-08-21 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon created this revision.
RKSimon added reviewers: rsmith, craig.topper, spatel.
Herald added a project: clang.
RKSimon requested review of this revision.

This enables us to use the __builtin_rotateleft / __builtin_rotateright 
8/16/32/64 intrinsics inside constexpr code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86342

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/AST/ExprConstant.cpp
  clang/test/Sema/constant-builtins-2.c


Index: clang/test/Sema/constant-builtins-2.c
===
--- clang/test/Sema/constant-builtins-2.c
+++ clang/test/Sema/constant-builtins-2.c
@@ -169,6 +169,16 @@
 char parity9[__builtin_parityl(1L << (BITSIZE(long) - 1)) == 1 ? 1 : -1];
 char parity10[__builtin_parityll(1LL << (BITSIZE(long long) - 1)) == 1 ? 1 : 
-1];
 
+char rotateleft1[__builtin_rotateleft8(0x01, 5) == 0x20 ? 1 : -1];
+char rotateleft2[__builtin_rotateleft16(0x3210, 11) == 0x8190 ? 1 : -1];
+char rotateleft2[__builtin_rotateleft32(0x76543210, 22) == 0x841D950C ? 1 : 
-1];
+char rotateleft2[__builtin_rotateleft64(0xFEDCBA9876543210ULL, 55) == 
0x87F6E5D4C3B2A19ULL ? 1 : -1];
+
+char rotateright1[__builtin_rotateright8(0x01, 5) == 0x08 ? 1 : -1];
+char rotateright2[__builtin_rotateright16(0x3210, 11) == 0x4206 ? 1 : -1];
+char rotateright2[__builtin_rotateright32(0x76543210, 22) == 0x50C841D9 ? 1 : 
-1];
+char rotateright2[__builtin_rotateright64(0xFEDCBA9876543210ULL, 55) == 
0xB97530ECA86421FDULL ? 1 : -1];
+
 char ffs1[__builtin_ffs(0) == 0 ? 1 : -1];
 char ffs2[__builtin_ffs(1) == 1 ? 1 : -1];
 char ffs3[__builtin_ffs(0xfbe71) == 1 ? 1 : -1];
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -11347,6 +11347,32 @@
 return Success(Val.countPopulation(), E);
   }
 
+  case Builtin::BI__builtin_rotateleft8:
+  case Builtin::BI__builtin_rotateleft16:
+  case Builtin::BI__builtin_rotateleft32:
+  case Builtin::BI__builtin_rotateleft64: {
+APSInt Val, Amt;
+if (!EvaluateInteger(E->getArg(0), Val, Info))
+  return false;
+if (!EvaluateInteger(E->getArg(1), Amt, Info))
+  return false;
+
+return Success(Val.rotl(Amt.urem(Val.getBitWidth())), E);
+  }
+
+  case Builtin::BI__builtin_rotateright8:
+  case Builtin::BI__builtin_rotateright16:
+  case Builtin::BI__builtin_rotateright32:
+  case Builtin::BI__builtin_rotateright64: {
+APSInt Val, Amt;
+if (!EvaluateInteger(E->getArg(0), Val, Info))
+  return false;
+if (!EvaluateInteger(E->getArg(1), Amt, Info))
+  return false;
+
+return Success(Val.rotr(Amt.urem(Val.getBitWidth())), E);
+  }
+
   case Builtin::BIstrlen:
   case Builtin::BIwcslen:
 // A call to strlen is not a constant expression.
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -56,7 +56,13 @@
 Non-comprehensive list of changes in this release
 -
 
-- ...
+- The builtin intrinsics ``__builtin_rotateleft8``, ``__builtin_rotateleft16``,
+  ``__builtin_rotateleft32`` and ``__builtin_rotateleft64`` may now be used
+  within constexpr expressions.
+
+- The builtin intrinsics ``__builtin_rotateright8``, 
``__builtin_rotateright16``,
+  ``__builtin_rotateright32`` and ``__builtin_rotateright64`` may now be used
+  within constexpr expressions.
 
 New Compiler Flags
 --


Index: clang/test/Sema/constant-builtins-2.c
===
--- clang/test/Sema/constant-builtins-2.c
+++ clang/test/Sema/constant-builtins-2.c
@@ -169,6 +169,16 @@
 char parity9[__builtin_parityl(1L << (BITSIZE(long) - 1)) == 1 ? 1 : -1];
 char parity10[__builtin_parityll(1LL << (BITSIZE(long long) - 1)) == 1 ? 1 : -1];
 
+char rotateleft1[__builtin_rotateleft8(0x01, 5) == 0x20 ? 1 : -1];
+char rotateleft2[__builtin_rotateleft16(0x3210, 11) == 0x8190 ? 1 : -1];
+char rotateleft2[__builtin_rotateleft32(0x76543210, 22) == 0x841D950C ? 1 : -1];
+char rotateleft2[__builtin_rotateleft64(0xFEDCBA9876543210ULL, 55) == 0x87F6E5D4C3B2A19ULL ? 1 : -1];
+
+char rotateright1[__builtin_rotateright8(0x01, 5) == 0x08 ? 1 : -1];
+char rotateright2[__builtin_rotateright16(0x3210, 11) == 0x4206 ? 1 : -1];
+char rotateright2[__builtin_rotateright32(0x76543210, 22) == 0x50C841D9 ? 1 : -1];
+char rotateright2[__builtin_rotateright64(0xFEDCBA9876543210ULL, 55) == 0xB97530ECA86421FDULL ? 1 : -1];
+
 char ffs1[__builtin_ffs(0) == 0 ? 1 : -1];
 char ffs2[__builtin_ffs(1) == 1 ? 1 : -1];
 char ffs3[__builtin_ffs(0xfbe71) == 1 ? 1 : -1];
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -11347,6 +11347,32 @@
 return 

[PATCH] D83174: Teach AttachPreviousImpl to inherit MSInheritanceAttr attribute

2020-08-21 Thread Vaibhav Garg via Phabricator via cfe-commits
gargvaibhav64 updated this revision to Diff 287004.
gargvaibhav64 marked an inline comment as done.
gargvaibhav64 added a comment.

Updated the regex to be less-greedy.


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

https://reviews.llvm.org/D83174

Files:
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/test/Modules/Inputs/inherit-attribute/a.h
  clang/test/Modules/Inputs/inherit-attribute/b.h
  clang/test/Modules/Inputs/inherit-attribute/c.h
  clang/test/Modules/Inputs/inherit-attribute/module.modulemap
  clang/test/Modules/inherit-attribute.cpp

Index: clang/test/Modules/inherit-attribute.cpp
===
--- /dev/null
+++ clang/test/Modules/inherit-attribute.cpp
@@ -0,0 +1,20 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -triple x86_64-pc-windows-msvc-unknown -I%S\Inputs\inherit-attribute -fmodules-cache-path=%t \
+// RUN: -fimplicit-module-maps -fmodules-local-submodule-visibility %s -ast-dump-all \
+// RUN: | FileCheck %s
+
+#include "b.h"
+#include "c.h"
+
+class Foo;
+
+Foo f;
+
+// CHECK:   CXXRecordDecl {{.*}} imported in b {{.*}} Foo
+// CHECK:   MSInheritanceAttr {{[^()]*$}}
+
+// CHECK:   CXXRecordDecl {{.*}} prev {{.*}} imported in c {{.*}} Foo
+// CHECK:   MSInheritanceAttr {{.*}} Inherited {{[^()]*$}}
+
+// CHECK:   CXXRecordDecl {{.*}}  col:7 referenced class Foo
+// CHECK:   MSInheritanceAttr {{.*}} Inherited {{[^()]*$}}
Index: clang/test/Modules/Inputs/inherit-attribute/module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/inherit-attribute/module.modulemap
@@ -0,0 +1,3 @@
+module "b" { header "b.h" }
+
+module "c" { header "c.h" }
Index: clang/test/Modules/Inputs/inherit-attribute/c.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/inherit-attribute/c.h
@@ -0,0 +1 @@
+#include "a.h"
Index: clang/test/Modules/Inputs/inherit-attribute/b.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/inherit-attribute/b.h
@@ -0,0 +1,5 @@
+#include "a.h"
+
+void bar() {
+  ::step;
+}
Index: clang/test/Modules/Inputs/inherit-attribute/a.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/inherit-attribute/a.h
@@ -0,0 +1,10 @@
+#ifndef FOO
+#define FOO
+
+class Foo {
+public:
+  void step(int v);
+  Foo();
+};
+
+#endif
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -281,6 +281,9 @@
 static Decl *getMostRecentDeclImpl(...);
 static Decl *getMostRecentDecl(Decl *D);
 
+static void mergeInheritableAttributes(ASTReader , Decl *D,
+   Decl *Previous);
+
 template 
 static void attachPreviousDeclImpl(ASTReader ,
Redeclarable *D, Decl *Previous,
@@ -3531,6 +3534,19 @@
   return ASTDeclReader::getMostRecentDecl(D->getCanonicalDecl());
 }
 
+void ASTDeclReader::mergeInheritableAttributes(ASTReader , Decl *D,
+   Decl *Previous) {
+  InheritableAttr *NewAttr = nullptr;
+  ASTContext  = Reader.getContext();
+  const auto *IA = Previous->getAttr();
+
+  if (IA && !D->hasAttr()) {
+NewAttr = cast(IA->clone(Context));
+NewAttr->setInherited(true);
+D->addAttr(NewAttr);
+  }
+}
+
 template
 void ASTDeclReader::attachPreviousDeclImpl(ASTReader ,
Redeclarable *D,
@@ -3689,6 +3705,12 @@
   if (auto *TD = dyn_cast(D))
 inheritDefaultTemplateArguments(Reader.getContext(),
 cast(Previous), TD);
+
+  // If any of the declaration in the chain contains an Inheritable attribute,
+  // it needs to be added to all the declarations in the redeclarable chain.
+  // FIXME: Only the logic of merging MSInheritableAttr is present, it should
+  // be extended for all inheritable attributes.
+  mergeInheritableAttributes(Reader, D, Previous);
 }
 
 template
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80791: [AArch64] Generate .note.gnu.property based on module flags.

2020-08-21 Thread Momchil Velikov via Phabricator via cfe-commits
chill added a comment.

In D85649  I suggested a different version of 
module flags, which is a bit nicer to use, e.g. one can say just

  getModuleFlag("sign-return-address-with-bkey") != nullptr

instead of a) checking for the flag presence, b) getting its value and c) 
comparing it to a set of strings, which is
way too verbose.

Thus, the set of module flags are essentially booleans:

- "sign-return-address" when PAC-RET is enabled; it establishes the defaults of 
signing non-leaf functions with the A key
- "sign-return-address-all", modifies the default, established by 
"sign-return-address" to signing all functions, including ones that do not 
spill LR
- "sign-return-address-with-bkey", modifies the default, established by 
"sign-return-address" to signing with the B key.

These are not ABI, so if, in the future, if we do need a set of values, we can 
easily change it.


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

https://reviews.llvm.org/D80791

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


[PATCH] D85753: [clangd] Discard diagnostics from another SourceManager.

2020-08-21 Thread Adam Czachorowski via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb4889353207a: [clangd] Discard diagnostics from another 
SourceManager. (authored by adamcz).

Changed prior to commit:
  https://reviews.llvm.org/D85753?vs=285961=287000#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85753

Files:
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/Diagnostics.h
  clang-tools-extra/clangd/unittests/ModulesTests.cpp

Index: clang-tools-extra/clangd/unittests/ModulesTests.cpp
===
--- clang-tools-extra/clangd/unittests/ModulesTests.cpp
+++ clang-tools-extra/clangd/unittests/ModulesTests.cpp
@@ -64,6 +64,34 @@
   EXPECT_TRUE(TU.build().getDiagnostics().empty());
 }
 
+TEST(Modules, Diagnostic) {
+  // Produce a diagnostic while building an implicit module. Use
+  // -fmodules-strict-decluse, but any non-silenced diagnostic will do.
+  TestTU TU = TestTU::withCode(R"cpp(
+/*error-ok*/
+#include "modular.h"
+
+void bar() {}
+)cpp");
+  TU.OverlayRealFileSystemForModules = true;
+  TU.ExtraArgs.push_back("-fmodule-map-file=" + testPath("m.modulemap"));
+  TU.ExtraArgs.push_back("-fmodules");
+  TU.ExtraArgs.push_back("-fimplicit-modules");
+  TU.ExtraArgs.push_back("-fmodules-strict-decluse");
+  TU.AdditionalFiles["modular.h"] = R"cpp(
+#include "non-modular.h"
+  )cpp";
+  TU.AdditionalFiles["non-modular.h"] = "";
+  TU.AdditionalFiles["m.modulemap"] = R"modulemap(
+module M {
+  header "modular.h"
+}
+)modulemap";
+
+  // Test that we do not crash.
+  TU.build();
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/Diagnostics.h
===
--- clang-tools-extra/clangd/Diagnostics.h
+++ clang-tools-extra/clangd/Diagnostics.h
@@ -122,7 +122,8 @@
   // The ClangTidyContext populates Source and Name for clang-tidy diagnostics.
   std::vector take(const clang::tidy::ClangTidyContext *Tidy = nullptr);
 
-  void BeginSourceFile(const LangOptions , const Preprocessor *) override;
+  void BeginSourceFile(const LangOptions ,
+   const Preprocessor *PP) override;
   void EndSourceFile() override;
   void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
 const clang::Diagnostic ) override;
@@ -148,6 +149,7 @@
   llvm::Optional LastDiag;
   llvm::Optional LastDiagLoc; // Valid only when LastDiag is set.
   bool LastDiagOriginallyError = false;  // Valid only when LastDiag is set.
+  SourceManager *OrigSrcMgr = nullptr;
 
   llvm::DenseSet> IncludedErrorLocations;
   bool LastPrimaryDiagnosticWasSuppressed = false;
Index: clang-tools-extra/clangd/Diagnostics.cpp
===
--- clang-tools-extra/clangd/Diagnostics.cpp
+++ clang-tools-extra/clangd/Diagnostics.cpp
@@ -518,13 +518,17 @@
 }
 
 void StoreDiags::BeginSourceFile(const LangOptions ,
- const Preprocessor *) {
+ const Preprocessor *PP) {
   LangOpts = Opts;
+  if (PP) {
+OrigSrcMgr = >getSourceManager();
+  }
 }
 
 void StoreDiags::EndSourceFile() {
   flushLastDiag();
   LangOpts = None;
+  OrigSrcMgr = nullptr;
 }
 
 /// Sanitizes a piece for presenting it in a synthesized fix message. Ensures
@@ -560,6 +564,16 @@
 
 void StoreDiags::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
   const clang::Diagnostic ) {
+  // If the diagnostic was generated for a different SourceManager, skip it.
+  // This happens when a module is imported and needs to be implicitly built.
+  // The compilation of that module will use the same StoreDiags, but different
+  // SourceManager.
+  if (OrigSrcMgr && Info.hasSourceManager() &&
+  OrigSrcMgr != ()) {
+IgnoreDiagnostics::log(DiagLevel, Info);
+return;
+  }
+
   DiagnosticConsumer::HandleDiagnostic(DiagLevel, Info);
   bool OriginallyError =
   Info.getDiags()->getDiagnosticIDs()->isDefaultMappingAsError(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] b488935 - [clangd] Discard diagnostics from another SourceManager.

2020-08-21 Thread Adam Czachorowski via cfe-commits

Author: Adam Czachorowski
Date: 2020-08-21T13:11:21+02:00
New Revision: b4889353207aefd6f2641cef0301f78838c5b52e

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

LOG: [clangd] Discard diagnostics from another SourceManager.

This can happen when building implicit modules, as demonstrated in test.
The CompilerInstance uses the same StoredDiags, but different
SourceManager. This used to crash clangd when it tried to relocate the
diagnostic to the main file, which, according to SourceManager from the
diagnostic, is a fake  file.

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

Added: 


Modified: 
clang-tools-extra/clangd/Diagnostics.cpp
clang-tools-extra/clangd/Diagnostics.h
clang-tools-extra/clangd/unittests/ModulesTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Diagnostics.cpp 
b/clang-tools-extra/clangd/Diagnostics.cpp
index 674fa0dbf9ec..afa72f9d4051 100644
--- a/clang-tools-extra/clangd/Diagnostics.cpp
+++ b/clang-tools-extra/clangd/Diagnostics.cpp
@@ -518,13 +518,17 @@ std::vector StoreDiags::take(const 
clang::tidy::ClangTidyContext *Tidy) {
 }
 
 void StoreDiags::BeginSourceFile(const LangOptions ,
- const Preprocessor *) {
+ const Preprocessor *PP) {
   LangOpts = Opts;
+  if (PP) {
+OrigSrcMgr = >getSourceManager();
+  }
 }
 
 void StoreDiags::EndSourceFile() {
   flushLastDiag();
   LangOpts = None;
+  OrigSrcMgr = nullptr;
 }
 
 /// Sanitizes a piece for presenting it in a synthesized fix message. Ensures
@@ -560,6 +564,16 @@ static void fillNonLocationData(DiagnosticsEngine::Level 
DiagLevel,
 
 void StoreDiags::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
   const clang::Diagnostic ) {
+  // If the diagnostic was generated for a 
diff erent SourceManager, skip it.
+  // This happens when a module is imported and needs to be implicitly built.
+  // The compilation of that module will use the same StoreDiags, but 
diff erent
+  // SourceManager.
+  if (OrigSrcMgr && Info.hasSourceManager() &&
+  OrigSrcMgr != ()) {
+IgnoreDiagnostics::log(DiagLevel, Info);
+return;
+  }
+
   DiagnosticConsumer::HandleDiagnostic(DiagLevel, Info);
   bool OriginallyError =
   Info.getDiags()->getDiagnosticIDs()->isDefaultMappingAsError(

diff  --git a/clang-tools-extra/clangd/Diagnostics.h 
b/clang-tools-extra/clangd/Diagnostics.h
index 58f69287f256..4a00abfc450f 100644
--- a/clang-tools-extra/clangd/Diagnostics.h
+++ b/clang-tools-extra/clangd/Diagnostics.h
@@ -122,7 +122,8 @@ class StoreDiags : public DiagnosticConsumer {
   // The ClangTidyContext populates Source and Name for clang-tidy diagnostics.
   std::vector take(const clang::tidy::ClangTidyContext *Tidy = nullptr);
 
-  void BeginSourceFile(const LangOptions , const Preprocessor *) override;
+  void BeginSourceFile(const LangOptions ,
+   const Preprocessor *PP) override;
   void EndSourceFile() override;
   void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
 const clang::Diagnostic ) override;
@@ -148,6 +149,7 @@ class StoreDiags : public DiagnosticConsumer {
   llvm::Optional LastDiag;
   llvm::Optional LastDiagLoc; // Valid only when LastDiag is 
set.
   bool LastDiagOriginallyError = false;  // Valid only when LastDiag is 
set.
+  SourceManager *OrigSrcMgr = nullptr;
 
   llvm::DenseSet> IncludedErrorLocations;
   bool LastPrimaryDiagnosticWasSuppressed = false;

diff  --git a/clang-tools-extra/clangd/unittests/ModulesTests.cpp 
b/clang-tools-extra/clangd/unittests/ModulesTests.cpp
index a10b9e897a48..83d6b28d6dfc 100644
--- a/clang-tools-extra/clangd/unittests/ModulesTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ModulesTests.cpp
@@ -64,6 +64,34 @@ TEST(Modules, PreambleBuildVisibility) {
   EXPECT_TRUE(TU.build().getDiagnostics().empty());
 }
 
+TEST(Modules, Diagnostic) {
+  // Produce a diagnostic while building an implicit module. Use
+  // -fmodules-strict-decluse, but any non-silenced diagnostic will do.
+  TestTU TU = TestTU::withCode(R"cpp(
+/*error-ok*/
+#include "modular.h"
+
+void bar() {}
+)cpp");
+  TU.OverlayRealFileSystemForModules = true;
+  TU.ExtraArgs.push_back("-fmodule-map-file=" + testPath("m.modulemap"));
+  TU.ExtraArgs.push_back("-fmodules");
+  TU.ExtraArgs.push_back("-fimplicit-modules");
+  TU.ExtraArgs.push_back("-fmodules-strict-decluse");
+  TU.AdditionalFiles["modular.h"] = R"cpp(
+#include "non-modular.h"
+  )cpp";
+  TU.AdditionalFiles["non-modular.h"] = "";
+  TU.AdditionalFiles["m.modulemap"] = R"modulemap(
+module M {
+  header "modular.h"
+}
+)modulemap";
+
+  // Test that we do not crash.
+  TU.build();
+}
+
 } // namespace
 } // namespace 

[PATCH] D82657: [AST][RecoveryAST] Preserve the type by default for recovery expression.

2020-08-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

New diagnostics are really good :-)




Comment at: clang/test/SemaCXX/abstract.cpp:282
 
-  void foo( C& c ) {}
+  void foo( C& c ) {} // expected-note {{candidate function not viable: 
expects an l-value for 1st argument}}
 

the new diagnostics are correct (nice!) but this is just a bug in the test:
see https://bugs.llvm.org/show_bug.cgi?id=12658 vs 
https://github.com/llvm/llvm-project/commit/ea03214a5e3413cf95e388f28e4d9b9eeb30210a

To keep the test simple, I'd consider changing C& to const C& here instead.



Comment at: clang/test/SemaCXX/type-convert-construct.cpp:9
   typedef int arr[];
-  int v3 = arr(); // expected-error {{array types cannot be value-initialized}}
+  int v3 = arr(); // expected-error {{array types cannot be 
value-initialized}} \
+ expected-error {{cannot initialize a variable of type 
'int' with an rvalue of type 'arr'}}

again, `arr v3 = arr();` is almost certainly intended


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82657

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


[PATCH] D86339: Enable constexpr on BITREVERSE builtin intrinsics (PR47249)

2020-08-21 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon created this revision.
RKSimon added reviewers: rsmith, craig.topper, spatel.
Herald added a project: clang.
RKSimon requested review of this revision.

This enables us to use the __builtin_bitreverse 8/16/32/64 intrinsics inside 
constexpr code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86339

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/AST/ExprConstant.cpp
  clang/test/Sema/constant-builtins-2.c


Index: clang/test/Sema/constant-builtins-2.c
===
--- clang/test/Sema/constant-builtins-2.c
+++ clang/test/Sema/constant-builtins-2.c
@@ -169,6 +169,11 @@
 char parity9[__builtin_parityl(1L << (BITSIZE(long) - 1)) == 1 ? 1 : -1];
 char parity10[__builtin_parityll(1LL << (BITSIZE(long long) - 1)) == 1 ? 1 : 
-1];
 
+char bitreverse1[__builtin_bitreverse8(0x01) == 0x80 ? 1 : -1];
+char bitreverse2[__builtin_bitreverse16(0x3C48) == 0x123C ? 1 : -1];
+char bitreverse3[__builtin_bitreverse32(0x12345678) == 0x1E6A2C48 ? 1 : -1];
+char bitreverse4[__builtin_bitreverse64(0x0123456789ABCDEFULL) == 
0xF7B3D591E6A2C480 ? 1 : -1];
+
 char ffs1[__builtin_ffs(0) == 0 ? 1 : -1];
 char ffs2[__builtin_ffs(1) == 1 ? 1 : -1];
 char ffs3[__builtin_ffs(0xfbe71) == 1 ? 1 : -1];
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -11180,6 +11180,17 @@
 return Success(AlignedVal, E);
   }
 
+  case Builtin::BI__builtin_bitreverse8:
+  case Builtin::BI__builtin_bitreverse16:
+  case Builtin::BI__builtin_bitreverse32:
+  case Builtin::BI__builtin_bitreverse64: {
+APSInt Val;
+if (!EvaluateInteger(E->getArg(0), Val, Info))
+  return false;
+
+return Success(Val.reverseBits(), E);
+  }
+
   case Builtin::BI__builtin_bswap16:
   case Builtin::BI__builtin_bswap32:
   case Builtin::BI__builtin_bswap64: {
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -56,7 +56,9 @@
 Non-comprehensive list of changes in this release
 -
 
-- ...
+- The builtin intrinsics ``__builtin_bitreverse8``, ``__builtin_bitreverse``,
+  ``__builtin_bitreverse32`` and ``__builtin_bitreverse64`` may now be used
+  within constexpr expressions.
 
 New Compiler Flags
 --


Index: clang/test/Sema/constant-builtins-2.c
===
--- clang/test/Sema/constant-builtins-2.c
+++ clang/test/Sema/constant-builtins-2.c
@@ -169,6 +169,11 @@
 char parity9[__builtin_parityl(1L << (BITSIZE(long) - 1)) == 1 ? 1 : -1];
 char parity10[__builtin_parityll(1LL << (BITSIZE(long long) - 1)) == 1 ? 1 : -1];
 
+char bitreverse1[__builtin_bitreverse8(0x01) == 0x80 ? 1 : -1];
+char bitreverse2[__builtin_bitreverse16(0x3C48) == 0x123C ? 1 : -1];
+char bitreverse3[__builtin_bitreverse32(0x12345678) == 0x1E6A2C48 ? 1 : -1];
+char bitreverse4[__builtin_bitreverse64(0x0123456789ABCDEFULL) == 0xF7B3D591E6A2C480 ? 1 : -1];
+
 char ffs1[__builtin_ffs(0) == 0 ? 1 : -1];
 char ffs2[__builtin_ffs(1) == 1 ? 1 : -1];
 char ffs3[__builtin_ffs(0xfbe71) == 1 ? 1 : -1];
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -11180,6 +11180,17 @@
 return Success(AlignedVal, E);
   }
 
+  case Builtin::BI__builtin_bitreverse8:
+  case Builtin::BI__builtin_bitreverse16:
+  case Builtin::BI__builtin_bitreverse32:
+  case Builtin::BI__builtin_bitreverse64: {
+APSInt Val;
+if (!EvaluateInteger(E->getArg(0), Val, Info))
+  return false;
+
+return Success(Val.reverseBits(), E);
+  }
+
   case Builtin::BI__builtin_bswap16:
   case Builtin::BI__builtin_bswap32:
   case Builtin::BI__builtin_bswap64: {
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -56,7 +56,9 @@
 Non-comprehensive list of changes in this release
 -
 
-- ...
+- The builtin intrinsics ``__builtin_bitreverse8``, ``__builtin_bitreverse``,
+  ``__builtin_bitreverse32`` and ``__builtin_bitreverse64`` may now be used
+  within constexpr expressions.
 
 New Compiler Flags
 --
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D85716: [AST][RecoveryExpr] Fix a bogus unused diagnostic when the type is preserved.

2020-08-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/test/SemaCXX/recovery-expr-type.cpp:80
+namespace test6 {
+struct Base {
+private:

nit: can the testcase be simplified?
Isn't `struct T { T() = delete; };` enough (with no inheritance)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85716

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


[PATCH] D85635: [clangd] Compute the inactive code range for semantic highlighting.

2020-08-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

I think the code could be a bit clearer, but up to you. The tests are good so 
feel free to submit any version you're happy with.




Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:242
+});
+NonConflicting.push_back(
+{HighlightingKind::InactiveCode,

Hmm, the role of `NonConflicting` is pretty confusing here: it has an invariant 
preserved as we construct it, then we violate it by dumping a bunch of ranges 
into it, then try to restore it.
And the correctness of the restoring seems to rely on some pretty subtle facts 
(that the inactive region always fully contains and is sorted *before* the 
regions it overlaps).

What about:
```
// Merge token stream with "inactive line" markers.
vector WithInactiveLines;
auto It = NonConflicting.begin();
for (Range  : Ranges) {
  for (int Line : R) {
// Copy tokens before the inactive line
for (; It != NonConflicting.end() && It->position.begin.line < Line)
  WithInactiveLines.push_back(std::move(*It));
// Add a token for the inactive line itself.
WithInactiveLines.push_back(createInactiveLineToken(MainCode, Line));
// Skip any other tokens on the inactive line
while (It != NonConflicting.end() && It->position.begin.line == Line)
  ++It;
  }
}
// Copy tokens after the last inactive line
for (; It != NonOverlapping.end(); ++It)
  WithInactiveLines.push_back(std::move(*It));
```

The only real assumption here is "a token is associated with a line", which is 
pretty fundamental anyway.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85635

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


[clang] 9ffc412 - [X86] Enable constexpr on BITSCAN intrinsics (PR31446)

2020-08-21 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-08-21T11:44:20+01:00
New Revision: 9ffc412e1afba9e4853c94669d26c9ba0707096c

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

LOG: [X86] Enable constexpr on BITSCAN intrinsics (PR31446)

This enables constexpr BSF/BSR intrinsics defined in ia32intrin.h

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Headers/ia32intrin.h
clang/test/CodeGen/bitscan-builtins.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index f19edfe6cfcd..6ea9a1499ed3 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -160,6 +160,12 @@ X86 Support in Clang
   ``_popcnt64``, ``__popcntd`` and ``__popcntq``  may now be used within
   constexpr expressions.
 
+- The x86 intrinsics ``_bit_scan_forward``, ``__bsfd`` and ``__bsfq`` may now
+  be used within constexpr expressions.
+
+- The x86 intrinsics ``_bit_scan_reverse``, ``__bsrd`` and ``__bsrq`` may now
+  be used within constexpr expressions.
+
 - The x86 intrinsics ``__bswap``, ``__bswapd``, ``__bswap64`` and ``__bswapq``
   may now be used within constexpr expressions.
 

diff  --git a/clang/lib/Headers/ia32intrin.h b/clang/lib/Headers/ia32intrin.h
index 88f031056f2d..a86ef868c3ce 100644
--- a/clang/lib/Headers/ia32intrin.h
+++ b/clang/lib/Headers/ia32intrin.h
@@ -36,7 +36,7 @@
  * A 32-bit integer operand.
  *  \returns A 32-bit integer containing the bit number.
  */
-static __inline__ int __DEFAULT_FN_ATTRS
+static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR
 __bsfd(int __A) {
   return __builtin_ctz(__A);
 }
@@ -53,7 +53,7 @@ __bsfd(int __A) {
  * A 32-bit integer operand.
  *  \returns A 32-bit integer containing the bit number.
  */
-static __inline__ int __DEFAULT_FN_ATTRS
+static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR
 __bsrd(int __A) {
   return 31 - __builtin_clz(__A);
 }
@@ -95,7 +95,7 @@ _bswap(int __A) {
  * A 64-bit integer operand.
  *  \returns A 32-bit integer containing the bit number.
  */
-static __inline__ int __DEFAULT_FN_ATTRS
+static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR
 __bsfq(long long __A) {
   return __builtin_ctzll(__A);
 }
@@ -112,7 +112,7 @@ __bsfq(long long __A) {
  * A 64-bit integer operand.
  *  \returns A 32-bit integer containing the bit number.
  */
-static __inline__ int __DEFAULT_FN_ATTRS
+static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR
 __bsrq(long long __A) {
   return 63 - __builtin_clzll(__A);
 }

diff  --git a/clang/test/CodeGen/bitscan-builtins.c 
b/clang/test/CodeGen/bitscan-builtins.c
index 176d829127b8..2fcebf477846 100644
--- a/clang/test/CodeGen/bitscan-builtins.c
+++ b/clang/test/CodeGen/bitscan-builtins.c
@@ -1,47 +1,74 @@
-// RUN: %clang_cc1 -ffreestanding -triple x86_64-unknown-unknown -emit-llvm -o 
- %s | FileCheck %s
+// RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-unknown-unknown 
-emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECKC
+// RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s 
-triple=x86_64-unknown-unknown -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK,CHECKCPP
+
 
 // PR33722
-// RUN: %clang_cc1 -ffreestanding -triple x86_64-unknown-unknown 
-fms-extensions -fms-compatibility-version=19.00 -emit-llvm -o - %s | FileCheck 
%s
+// RUN: %clang_cc1 -x c -ffreestanding %s -triple x86_64-unknown-unknown 
-fms-extensions -fms-compatibility-version=19.00 -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK,CHECKC
+// RUN: %clang_cc1 -x c++ -ffreestanding %s -triple x86_64-unknown-unknown 
-fms-extensions -fms-compatibility-version=19.00 -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK,CHECKCPP
 
 #include 
 
 int test_bit_scan_forward(int a) {
   return _bit_scan_forward(a);
-// CHECK: @test_bit_scan_forward
+// CHECKC-LABEL: @test_bit_scan_forward
 // CHECK: %[[call:.*]] = call i32 @llvm.cttz.i32(i32 %{{.*}}, i1 true)
 // CHECK: ret i32 %[[call]]
 }
 
 int test_bit_scan_reverse(int a) {
   return _bit_scan_reverse(a);
+// CHECKC-LABEL: @test_bit_scan_reverse
 // CHECK:  %[[call:.*]] = call i32 @llvm.ctlz.i32(i32 %{{.*}}, i1 true)
 // CHECK:  %[[sub:.*]] = sub nsw i32 31, %[[call]]
 // CHECK: ret i32 %[[sub]]
 }
 
 int test__bsfd(int X) {
-// CHECK: @test__bsfd
+// CHECKC-LABEL: @test__bsfd
 // CHECK: %[[call:.*]] = call i32 @llvm.cttz.i32(i32 %{{.*}}, i1 true)
   return __bsfd(X);
 }
 
 int test__bsfq(long long X) {
-// CHECK: @test__bsfq
+// CHECKC-LABEL: @test__bsfq
 // CHECK: %[[call:.*]] = call i64 @llvm.cttz.i64(i64 %{{.*}}, i1 true)
   return __bsfq(X);
 }
 
 int test__bsrd(int X) {
-// CHECK: @test__bsrd
+// CHECKC-LABEL: @test__bsrd
 // CHECK:  %[[call:.*]] = call i32 @llvm.ctlz.i32(i32 %{{.*}}, i1 true)
 // CHECK:  %[[sub:.*]] = sub nsw i32 31, %[[call]]
   return __bsrd(X);
 }
 
 int test__bsrq(long 

[PATCH] D85330: [SyntaxTree] Extend the syntax tree dump

2020-08-21 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added inline comments.



Comment at: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp:107-110
 int main() {
   if (1) {}
   if (1) {} else if (0) {}
 }

eduucaldas wrote:
> I just noticed that we didn't yet use annotations on statement tests. 
> I think that might help a bit, should I do a quick patch for adding those?
Yes,  that's a good idea!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85330

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


[PATCH] D85330: [SyntaxTree] Extend the syntax tree dump

2020-08-21 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

Output format LGTM!




Comment at: clang/lib/Tooling/Syntax/Tree.cpp:160
+  assert(N);
+  if (auto *L = llvm::dyn_cast(N)) {
+OS << "'";





Comment at: clang/lib/Tooling/Syntax/Tree.cpp:169
 
-  auto *T = cast(N);
-  OS << T->kind() << "\n";
+  auto *T = llvm::cast(N);
+  OS << T->kind();





Comment at: clang/lib/Tooling/Syntax/Tree.cpp:205
   traverse(this, [&](const syntax::Node *N) {
-auto *L = dyn_cast(N);
-if (!L)
-  return;
-::dumpTokens(OS, *L->token(), A.sourceManager());
-OS << " ";
+if (auto *L = llvm::dyn_cast(N)) {
+  dumpLeaf(OS, L, SM);




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85330

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


[PATCH] D85330: [SyntaxTree] Extend the syntax tree dump

2020-08-21 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas added inline comments.



Comment at: clang/lib/Tooling/Syntax/Tree.cpp:158
   if (!Marks.empty())
 OS << Marks << ": ";
 

gribozavr2 wrote:
> Maybe the marks should be moved after the primary identifier of the node, 
> WDYT? That would be more consistent with AST dump: first the node kind, then 
> all its info.
I agree 



Comment at: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp:107-110
 int main() {
   if (1) {}
   if (1) {} else if (0) {}
 }

I just noticed that we didn't yet use annotations on statement tests. 
I think that might help a bit, should I do a quick patch for adding those?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85330

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


[PATCH] D85330: [SyntaxTree] Extend the syntax tree dump

2020-08-21 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 286983.
eduucaldas added a comment.

Adapt Statement tests to new testing infrastructure


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85330

Files:
  clang/include/clang/Tooling/Syntax/Tree.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Tree.cpp
  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";
   }
-  auto Actual = StringRef(Root->dump(*Arena)).trim().str();
+  auto Actual = StringRef(Root->dump(Arena->sourceManager())).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()) {
@@ -205,7 +205,7 @@
 auto *AnnotatedNode = nodeByRange(AnnotatedRanges[i], Root);
 assert(AnnotatedNode);
 auto AnnotatedNodeDump =
-StringRef(AnnotatedNode->dump(*Arena)).trim().str();
+StringRef(AnnotatedNode->dump(Arena->sourceManager())).trim().str();
 // EXPECT_EQ shows the diff between the two strings if they are different.
 EXPECT_EQ(TreeDumps[i].trim().str(), AnnotatedNodeDump)
 << "Dumps diverged for the code:\n"
Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -24,27 +24,27 @@
 void foo() {}
 )cpp",
   R"txt(
-*: TranslationUnit
+TranslationUnit Detached
 |-SimpleDeclaration
-| |-int
-| |-SimpleDeclarator
-| | |-main
+| |-'int'
+| |-SimpleDeclarator SimpleDeclaration_declarator
+| | |-'main'
 | | `-ParametersAndQualifiers
-| |   |-(
-| |   `-)
+| |   |-'(' OpenParen
+| |   `-')' CloseParen
 | `-CompoundStatement
-|   |-{
-|   `-}
+|   |-'{' OpenParen
+|   `-'}' CloseParen
 `-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-foo
+  |-'void'
+  |-SimpleDeclarator SimpleDeclaration_declarator
+  | |-'foo'
   | `-ParametersAndQualifiers
-  |   |-(
-  |   `-)
+  |   |-'(' OpenParen
+  |   `-')' CloseParen
   `-CompoundStatement
-|-{
-`-}
+|-'{' OpenParen
+`-'}' CloseParen
 )txt"));
 }
 
@@ -55,20 +55,20 @@
 int b = 42;
 )cpp",
   R"txt(
-*: TranslationUnit
+TranslationUnit Detached
 |-SimpleDeclaration
-| |-int
-| |-SimpleDeclarator
-| | `-a
-| `-;
+| |-'int'
+| |-SimpleDeclarator SimpleDeclaration_declarator
+| | `-'a'
+| `-';'
 `-SimpleDeclaration
-  |-int
-  |-SimpleDeclarator
-  | |-b
-  | |-=
+  |-'int'
+  |-SimpleDeclarator SimpleDeclaration_declarator
+  | |-'b'
+  | |-'='
   | `-IntegerLiteralExpression
-  |   `-42
-  `-;
+  |   `-'42' LiteralToken
+  `-';'
 )txt"));
 }
 
@@ -78,26 +78,26 @@
 void foo(int a, int b) {}
 )cpp",
   R"txt(
-*: TranslationUnit
+TranslationUnit Detached
 `-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-foo
+  |-'void'
+  |-SimpleDeclarator SimpleDeclaration_declarator
+  | |-'foo'
   | `-ParametersAndQualifiers
-  |   |-(
-  |   |-SimpleDeclaration
-  |   | |-int
-  |   | `-SimpleDeclarator
-  |   |   `-a
-  |   |-,
-  |   |-SimpleDeclaration
-  |   | |-int
-  |   | `-SimpleDeclarator
-  |   |   `-b
-  |   `-)
+  |   |-'(' OpenParen
+  |   |-SimpleDeclaration ParametersAndQualifiers_parameter
+  |   | |-'int'
+  |   | `-SimpleDeclarator SimpleDeclaration_declarator
+  |   |   `-'a'
+  |   |-','
+  |   |-SimpleDeclaration ParametersAndQualifiers_parameter
+  |   | |-'int'
+  |   | `-SimpleDeclarator SimpleDeclaration_declarator
+  |   |   `-'b'
+  |   `-')' CloseParen
   `-CompoundStatement
-|-{
-`-}
+|-'{' OpenParen
+`-'}' CloseParen
 )txt"));
 }
 
@@ -110,45 +110,45 @@
 }
 )cpp",
   R"txt(
-*: TranslationUnit
+TranslationUnit Detached
 `-SimpleDeclaration
-  |-int
-  |-SimpleDeclarator
-  | |-main
+  |-'int'
+  |-SimpleDeclarator SimpleDeclaration_declarator
+  | |-'main'
   | `-ParametersAndQualifiers
-  |   |-(
-  |   `-)
+  |   |-'(' OpenParen
+  |   `-')' CloseParen
   `-CompoundStatement
-|-{
-|-IfStatement
-| |-if
-| |-(
+|-'{' OpenParen
+|-IfStatement CompoundStatement_statement
+| |-'if' IntroducerKeyword
+| |-'('
 | |-IntegerLiteralExpression
-| | `-1
-| |-)
-| `-CompoundStatement
-|   |-{
-|   `-}
-|-IfStatement
-| |-if
-| |-(
+| | `-'1' LiteralToken
+| |-')'
+| `-CompoundStatement IfStatement_thenStatement
+|   |-'{' OpenParen
+|   `-'}' CloseParen
+|-IfStatement CompoundStatement_statement
+| |-'if' IntroducerKeyword
+| |-'('
 | 

[PATCH] D86334: [analyzer] Remove redundant output errs

2020-08-21 Thread Yang Fan via Phabricator via cfe-commits
nullptr.cpp added a comment.

I don't have commit access, can you help commit it?

In D86334#2230032 , @xazax.hun wrote:

> LGTM, thanks!




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86334

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


[clang] c8e6bf0 - [X86] Enable constexpr on BSWAP intrinsics (PR31446)

2020-08-21 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-08-21T10:55:15+01:00
New Revision: c8e6bf0a65fdbda7a611e8047e2a644777f15b24

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

LOG: [X86] Enable constexpr on BSWAP intrinsics (PR31446)

This enables constexpr BSWAP intrinsics defined in ia32intrin.h

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Headers/ia32intrin.h
clang/test/CodeGen/x86-bswap.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 0c864d8b4d14..f19edfe6cfcd 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -160,6 +160,9 @@ X86 Support in Clang
   ``_popcnt64``, ``__popcntd`` and ``__popcntq``  may now be used within
   constexpr expressions.
 
+- The x86 intrinsics ``__bswap``, ``__bswapd``, ``__bswap64`` and ``__bswapq``
+  may now be used within constexpr expressions.
+
 Internal API Changes
 
 

diff  --git a/clang/lib/Headers/ia32intrin.h b/clang/lib/Headers/ia32intrin.h
index bed75e18c4f6..88f031056f2d 100644
--- a/clang/lib/Headers/ia32intrin.h
+++ b/clang/lib/Headers/ia32intrin.h
@@ -69,12 +69,12 @@ __bsrd(int __A) {
  * A 32-bit integer operand.
  *  \returns A 32-bit integer containing the swapped bytes.
  */
-static __inline__ int __DEFAULT_FN_ATTRS
+static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR
 __bswapd(int __A) {
   return __builtin_bswap32(__A);
 }
 
-static __inline__ int __DEFAULT_FN_ATTRS
+static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR
 _bswap(int __A) {
   return __builtin_bswap32(__A);
 }
@@ -128,7 +128,7 @@ __bsrq(long long __A) {
  * A 64-bit integer operand.
  *  \returns A 64-bit integer containing the swapped bytes.
  */
-static __inline__ long long __DEFAULT_FN_ATTRS
+static __inline__ long long __DEFAULT_FN_ATTRS_CONSTEXPR
 __bswapq(long long __A) {
   return __builtin_bswap64(__A);
 }

diff  --git a/clang/test/CodeGen/x86-bswap.c b/clang/test/CodeGen/x86-bswap.c
index adf8b7846a02..e952e4f5b127 100644
--- a/clang/test/CodeGen/x86-bswap.c
+++ b/clang/test/CodeGen/x86-bswap.c
@@ -1,29 +1,45 @@
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -emit-llvm -o 
- | FileCheck %s
+// RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-apple-darwin 
-emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECKC
+// RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s 
-triple=x86_64-apple-darwin -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK,CHECKCPP
 
 #include 
 
 int test__bswapd(int X) {
-// CHECK-LABEL: @test__bswapd
+// CHECKC-LABEL: @test__bswapd
 // CHECK: call i32 @llvm.bswap.i32
   return __bswapd(X);
 }
 
 int test_bswap(int X) {
-// CHECK-LABEL: @test_bswap
+// CHECKC-LABEL: @test_bswap
 // CHECK: call i32 @llvm.bswap.i32
   return _bswap(X);
 }
 
 long test__bswapq(long long X) {
-// CHECK-LABEL: @test__bswapq
+// CHECKC-LABEL: @test__bswapq
 // CHECK: call i64 @llvm.bswap.i64
   return __bswapq(X);
 }
 
 long test_bswap64(long long X) {
-// CHECK-LABEL: @test_bswap64
+// CHECKC-LABEL: @test_bswap64
 // CHECK: call i64 @llvm.bswap.i64
   return _bswap64(X);
 }
 
+// Test constexpr handling.
+#if defined(__cplusplus) && (__cplusplus >= 201103L)
 
+char bswapd_0[__bswapd(0x) == 0x ? 1 : -1];
+char bswapd_1[__bswapd(0x01020304) == 0x04030201 ? 1 : -1];
+
+char bswap_0[_bswap(0x) == 0x ? 1 : -1];
+char bswap_1[_bswap(0x10203040) == 0x40302010 ? 1 : -1];
+
+char bswapq_0[__bswapq(0xULL) == 0x ? 1 : -1];
+char bswapq_1[__bswapq(0x0102030405060708ULL) == 0x0807060504030201 ? 1 : -1];
+
+char bswap64_0[_bswap64(0xULL) == 0x ? 1 : -1];
+char bswap64_1[_bswap64(0x1020304050607080ULL) == 0x8070605040302010 ? 1 : -1];
+
+#endif



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


[PATCH] D81083: [Clang] Allow "vector_size" applied to Booleans

2020-08-21 Thread Simon Moll via Phabricator via cfe-commits
simoll added a comment.

In D81083#2227760 , @rsandifo-arm 
wrote:

> I'm not qualified to review the CodeGen stuff (or accept the patch, obvs. 
> :-)) but FWIW, here are some comments on the doc and Sema side.

Thanks for your comments! Maybe you know people who could review the CodeGen 
side of this..?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81083

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


[clang] c6863a4 - [X86] Enable constexpr on POPCNT intrinsics (PR31446)

2020-08-21 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-08-21T10:20:37+01:00
New Revision: c6863a4ab8b96ba4b878cb2da7e101bc6bcfaeef

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

LOG: [X86] Enable constexpr on POPCNT intrinsics (PR31446)

Followup to D86229, this enables constexpr on the alternative (which fallback 
to generic code) POPCNT intrinsics defined in ia32intrin.h

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Headers/ia32intrin.h
clang/test/CodeGen/popcnt-builtins.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index f97e95a55c0e..0c864d8b4d14 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -156,8 +156,9 @@ CUDA Support in Clang
 X86 Support in Clang
 
 
-- The x86 intrinsics ``_mm_popcnt_u32`` and ``_mm_popcnt_u64`` may now be used
-  within constexpr expressions.
+- The x86 intrinsics ``_mm_popcnt_u32``, ``_mm_popcnt_u64``, ``_popcnt32``,
+  ``_popcnt64``, ``__popcntd`` and ``__popcntq``  may now be used within
+  constexpr expressions.
 
 Internal API Changes
 

diff  --git a/clang/lib/Headers/ia32intrin.h b/clang/lib/Headers/ia32intrin.h
index b4812517b2ea..bed75e18c4f6 100644
--- a/clang/lib/Headers/ia32intrin.h
+++ b/clang/lib/Headers/ia32intrin.h
@@ -18,6 +18,12 @@
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
 #define __DEFAULT_FN_ATTRS_SSE42 __attribute__((__always_inline__, 
__nodebug__, __target__("sse4.2")))
 
+#if defined(__cplusplus) && (__cplusplus >= 201103L)
+#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS constexpr
+#else
+#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS
+#endif
+
 /** Find the first set bit starting from the lsb. Result is undefined if
  *  input is 0.
  *
@@ -142,7 +148,7 @@ __bswapq(long long __A) {
  *  \returns A 32-bit integer containing the number of bits with value 1 in the
  * source operand.
  */
-static __inline__ int __DEFAULT_FN_ATTRS
+static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR
 __popcntd(unsigned int __A)
 {
   return __builtin_popcount(__A);
@@ -163,7 +169,7 @@ __popcntd(unsigned int __A)
  *  \returns A 64-bit integer containing the number of bits with value 1 in the
  * source operand.
  */
-static __inline__ long long __DEFAULT_FN_ATTRS
+static __inline__ long long __DEFAULT_FN_ATTRS_CONSTEXPR
 __popcntq(unsigned long long __A)
 {
   return __builtin_popcountll(__A);
@@ -435,5 +441,6 @@ __rorq(unsigned long long __X, int __C) {
 
 #undef __DEFAULT_FN_ATTRS
 #undef __DEFAULT_FN_ATTRS_SSE42
+#undef __DEFAULT_FN_ATTRS_CONSTEXPR
 
 #endif /* __IA32INTRIN_H */

diff  --git a/clang/test/CodeGen/popcnt-builtins.c 
b/clang/test/CodeGen/popcnt-builtins.c
index 40b786275e93..e59ffaa031a6 100644
--- a/clang/test/CodeGen/popcnt-builtins.c
+++ b/clang/test/CodeGen/popcnt-builtins.c
@@ -46,10 +46,24 @@ long long test__popcntq(unsigned long long __X) {
 #if defined(__POPCNT__)
 char ctpop32_0[_mm_popcnt_u32(0x) == 0 ? 1 : -1];
 char ctpop32_1[_mm_popcnt_u32(0x00F0) == 4 ? 1 : -1];
+#endif
+
+char popcnt32_0[_popcnt32(0x) == 0 ? 1 : -1];
+char popcnt32_1[_popcnt32(0x10F0) == 5 ? 1 : -1];
+
+char popcntd_0[__popcntd(0x) == 0 ? 1 : -1];
+char popcntd_1[__popcntd(0x00F000F0) == 8 ? 1 : -1];
 
 #ifdef __x86_64__
+#if defined(__POPCNT__)
 char ctpop64_0[_mm_popcnt_u64(0xULL) == 0 ? 1 : -1];
 char ctpop64_1[_mm_popcnt_u64(0xF001ULL) == 5 ? 1 : -1];
 #endif
+
+char popcnt64_0[_popcnt64(0xULL) == 0 ? 1 : -1];
+char popcnt64_1[_popcnt64(0xF0F1ULL) == 9 ? 1 : -1];
+
+char popcntq_0[__popcntq(0xULL) == 0 ? 1 : -1];
+char popcntq_1[__popcntq(0xF131ULL) == 8 ? 1 : -1];
 #endif
 #endif



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


[PATCH] D86334: [analyzer] Remove redundant output errs

2020-08-21 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86334

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


[PATCH] D41179: [Sema] Diagnose template specializations with C linkage

2020-08-21 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki abandoned this revision.
miyuki added a comment.

Abandoning in favour of:

commit a64883431369f28f3fac311c496a4dfad480058f 

Author: Richard Smith 
Date:   Wed Jul 29 16:49:05 2020 -0700

  PR46729: Reject explicit and partial specializations with C linkage.


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

https://reviews.llvm.org/D41179

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


[PATCH] D81083: [Clang] Allow "vector_size" applied to Booleans

2020-08-21 Thread Simon Moll via Phabricator via cfe-commits
simoll updated this revision to Diff 286971.
simoll edited the summary of this revision.
simoll added a comment.

- Rebased.
- Allow comparisons on boolean vectors.
- Restored result type for vector comparisons on other types.
- Added operator, alignment and constexpr tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81083

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/AST/Type.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/AST/ast-print-vector-size-bool.c
  clang/test/CodeGen/debug-info-vector-bool.c
  clang/test/CodeGen/vector-alignment.c
  clang/test/SemaCXX/constexpr-vectors.cpp
  clang/test/SemaCXX/vector-bool.cpp
  clang/test/SemaCXX/vector-conditional.cpp
  clang/test/SemaCXX/vector.cpp

Index: clang/test/SemaCXX/vector.cpp
===
--- clang/test/SemaCXX/vector.cpp
+++ clang/test/SemaCXX/vector.cpp
@@ -331,8 +331,7 @@
 typedef __attribute__((ext_vector_type(4))) int vi4;
 const int _to_vec_element = vi4(1).x;
 
-// PR12649
-typedef bool bad __attribute__((__vector_size__(16)));  // expected-error {{invalid vector element type 'bool'}}
+typedef bool good __attribute__((__vector_size__(16)));
 
 namespace Templates {
 template 
@@ -350,9 +349,7 @@
 void Init() {
   const TemplateVectorType::type Works = {};
   const TemplateVectorType::type Works2 = {};
-  // expected-error@#1 {{invalid vector element type 'bool'}}
-  // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
-  const TemplateVectorType::type NoBool = {};
+  const TemplateVectorType::type BoolWorks = {};
   // expected-error@#1 {{invalid vector element type 'int __attribute__((ext_vector_type(4)))' (vector of 4 'int' values)}}
   // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
   const TemplateVectorType::type NoComplex = {};
Index: clang/test/SemaCXX/vector-conditional.cpp
===
--- clang/test/SemaCXX/vector-conditional.cpp
+++ clang/test/SemaCXX/vector-conditional.cpp
@@ -13,6 +13,7 @@
 using FourFloats = float __attribute__((__vector_size__(16)));
 using TwoDoubles = double __attribute__((__vector_size__(16)));
 using FourDoubles = double __attribute__((__vector_size__(32)));
+using EightBools = bool __attribute__((__vector_size__(2)));
 
 FourShorts four_shorts;
 TwoInts two_ints;
@@ -25,6 +26,8 @@
 FourFloats four_floats;
 TwoDoubles two_doubles;
 FourDoubles four_doubles;
+EightBools eight_bools;
+EightBools other_eight_bools;
 
 enum E {};
 enum class SE {};
@@ -95,6 +98,9 @@
   (void)(four_ints ? four_uints : 3.0f);
   (void)(four_ints ? four_ints : 3.0f);
 
+  // Allow conditional select on bool vectors.
+  (void)(eight_bools ? eight_bools : other_eight_bools);
+
   // When there is a vector and a scalar, conversions must be legal.
   (void)(four_ints ? four_floats : 3); // should work, ints can convert to floats.
   (void)(four_ints ? four_uints : e);  // expected-error {{cannot convert between scalar type 'E' and vector type 'FourUInts'}}
@@ -163,10 +169,10 @@
 void Templates() {
   dependent_cond(two_ints);
   dependent_operand(two_floats);
-  // expected-error@159 {{vector operands to the vector conditional must be the same type ('__attribute__((__vector_size__(4 * sizeof(unsigned int unsigned int' (vector of 4 'unsigned int' values) and '__attribute__((__vector_size__(4 * sizeof(double double' (vector of 4 'double' values))}}}
+  // expected-error@165 {{vector operands to the vector conditional must be the same type ('__attribute__((__vector_size__(4 * sizeof(unsigned int unsigned int' (vector of 4 'unsigned int' values) and '__attribute__((__vector_size__(4 * sizeof(double double' (vector of 4 'double' values))}}}
   all_dependent(four_ints, four_uints, four_doubles); // expected-note {{in instantiation of}}
 
-  // expected-error@159 {{vector operands to the vector conditional must be the same type ('__attribute__((__vector_size__(4 * sizeof(unsigned int unsigned int' (vector of 4 'unsigned int' values) and '__attribute__((__vector_size__(2 * sizeof(unsigned int unsigned int' (vector of 2 'unsigned int' values))}}}
+  // expected-error@165 {{vector operands to the vector conditional must be the same type ('__attribute__((__vector_size__(4 * sizeof(unsigned int unsigned int' (vector of 4 'unsigned int' values) and '__attribute__((__vector_size__(2 * sizeof(unsigned int unsigned int' 

[clang] 33bb80b - [X86] ia32intrin.h - pull out common attributes into defines. NFCI.

2020-08-21 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-08-21T10:03:28+01:00
New Revision: 33bb80bc7a6e67be90cf9b5e8d0f679e5e3acbaf

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

LOG: [X86] ia32intrin.h - pull out common attributes into defines. NFCI.

Matches what we do in most other x86 headers

Added: 


Modified: 
clang/lib/Headers/ia32intrin.h

Removed: 




diff  --git a/clang/lib/Headers/ia32intrin.h b/clang/lib/Headers/ia32intrin.h
index 79b7f0655cf0..b4812517b2ea 100644
--- a/clang/lib/Headers/ia32intrin.h
+++ b/clang/lib/Headers/ia32intrin.h
@@ -14,6 +14,10 @@
 #ifndef __IA32INTRIN_H
 #define __IA32INTRIN_H
 
+/* Define the default attributes for the functions in this file. */
+#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
+#define __DEFAULT_FN_ATTRS_SSE42 __attribute__((__always_inline__, 
__nodebug__, __target__("sse4.2")))
+
 /** Find the first set bit starting from the lsb. Result is undefined if
  *  input is 0.
  *
@@ -26,7 +30,7 @@
  * A 32-bit integer operand.
  *  \returns A 32-bit integer containing the bit number.
  */
-static __inline__ int __attribute__((__always_inline__, __nodebug__))
+static __inline__ int __DEFAULT_FN_ATTRS
 __bsfd(int __A) {
   return __builtin_ctz(__A);
 }
@@ -43,7 +47,7 @@ __bsfd(int __A) {
  * A 32-bit integer operand.
  *  \returns A 32-bit integer containing the bit number.
  */
-static __inline__ int __attribute__((__always_inline__, __nodebug__))
+static __inline__ int __DEFAULT_FN_ATTRS
 __bsrd(int __A) {
   return 31 - __builtin_clz(__A);
 }
@@ -59,12 +63,12 @@ __bsrd(int __A) {
  * A 32-bit integer operand.
  *  \returns A 32-bit integer containing the swapped bytes.
  */
-static __inline__ int __attribute__((__always_inline__, __nodebug__))
+static __inline__ int __DEFAULT_FN_ATTRS
 __bswapd(int __A) {
   return __builtin_bswap32(__A);
 }
 
-static __inline__ int __attribute__((__always_inline__, __nodebug__))
+static __inline__ int __DEFAULT_FN_ATTRS
 _bswap(int __A) {
   return __builtin_bswap32(__A);
 }
@@ -85,7 +89,7 @@ _bswap(int __A) {
  * A 64-bit integer operand.
  *  \returns A 32-bit integer containing the bit number.
  */
-static __inline__ int __attribute__((__always_inline__, __nodebug__))
+static __inline__ int __DEFAULT_FN_ATTRS
 __bsfq(long long __A) {
   return __builtin_ctzll(__A);
 }
@@ -102,7 +106,7 @@ __bsfq(long long __A) {
  * A 64-bit integer operand.
  *  \returns A 32-bit integer containing the bit number.
  */
-static __inline__ int __attribute__((__always_inline__, __nodebug__))
+static __inline__ int __DEFAULT_FN_ATTRS
 __bsrq(long long __A) {
   return 63 - __builtin_clzll(__A);
 }
@@ -118,7 +122,7 @@ __bsrq(long long __A) {
  * A 64-bit integer operand.
  *  \returns A 64-bit integer containing the swapped bytes.
  */
-static __inline__ long long __attribute__((__always_inline__, __nodebug__))
+static __inline__ long long __DEFAULT_FN_ATTRS
 __bswapq(long long __A) {
   return __builtin_bswap64(__A);
 }
@@ -138,7 +142,7 @@ __bswapq(long long __A) {
  *  \returns A 32-bit integer containing the number of bits with value 1 in the
  * source operand.
  */
-static __inline__ int __attribute__((__always_inline__, __nodebug__))
+static __inline__ int __DEFAULT_FN_ATTRS
 __popcntd(unsigned int __A)
 {
   return __builtin_popcount(__A);
@@ -159,7 +163,7 @@ __popcntd(unsigned int __A)
  *  \returns A 64-bit integer containing the number of bits with value 1 in the
  * source operand.
  */
-static __inline__ long long __attribute__((__always_inline__, __nodebug__))
+static __inline__ long long __DEFAULT_FN_ATTRS
 __popcntq(unsigned long long __A)
 {
   return __builtin_popcountll(__A);
@@ -169,26 +173,26 @@ __popcntq(unsigned long long __A)
 #endif /* __x86_64__ */
 
 #ifdef __x86_64__
-static __inline__ unsigned long long __attribute__((__always_inline__, 
__nodebug__))
+static __inline__ unsigned long long __DEFAULT_FN_ATTRS
 __readeflags(void)
 {
   return __builtin_ia32_readeflags_u64();
 }
 
-static __inline__ void __attribute__((__always_inline__, __nodebug__))
+static __inline__ void __DEFAULT_FN_ATTRS
 __writeeflags(unsigned long long __f)
 {
   __builtin_ia32_writeeflags_u64(__f);
 }
 
 #else /* !__x86_64__ */
-static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
+static __inline__ unsigned int __DEFAULT_FN_ATTRS
 __readeflags(void)
 {
   return __builtin_ia32_readeflags_u32();
 }
 
-static __inline__ void __attribute__((__always_inline__, __nodebug__))
+static __inline__ void __DEFAULT_FN_ATTRS
 __writeeflags(unsigned int __f)
 {
   __builtin_ia32_writeeflags_u32(__f);
@@ -278,7 +282,7 @@ _castu64_f64(unsigned long long __A) {
  *  \returns The result of adding operand \a __C to the CRC-32C checksum of
  * operand \a __D.

  1   2   >