[PATCH] D80462: Fix floating point math function attributes definition.

2020-05-28 Thread Michele Scandale via Phabricator via cfe-commits
michele.scandale updated this revision to Diff 267122.
michele.scandale added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80462

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGen/fp-function-attrs.cpp

Index: clang/test/CodeGen/fp-function-attrs.cpp
===
--- /dev/null
+++ clang/test/CodeGen/fp-function-attrs.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -ffast-math -ffp-contract=fast -emit-llvm -o - %s | FileCheck %s
+
+float test_default(float a, float b, float c) {
+  float tmp = a;
+  tmp += b;
+  tmp += c;
+  return tmp;
+}
+
+// CHECK: define float @_Z12test_defaultfff(float %a, float %b, float %c) [[FAST_ATTRS:#[0-9]+]]
+// CHECK: fadd fast float {{%.+}}, {{%.+}}
+// CHECK: fadd fast float {{%.+}}, {{%.+}}
+
+float test_precise_on_pragma(float a, float b, float c) {
+  float tmp = a;
+  {
+#pragma float_control(precise, on)
+tmp += b;
+  }
+  tmp += c;
+  return tmp;
+}
+
+// CHECK: define float @_Z22test_precise_on_pragmafff(float %a, float %b, float %c) [[PRECISE_ATTRS:#[0-9]+]]
+// CHECK: fadd float {{%.+}}, {{%.+}}
+// CHECK: fadd fast float {{%.+}}, {{%.+}}
+
+float test_reassociate_off_pragma(float a, float b, float c) {
+  float tmp = a;
+  {
+#pragma clang fp reassociate(off)
+tmp += b;
+  }
+  tmp += c;
+  return tmp;
+}
+
+// CHECK: define float @_Z27test_reassociate_off_pragmafff(float %a, float %b, float %c) [[NOREASSOC_ATTRS:#[0-9]+]]
+// CHECK: fadd nnan ninf nsz arcp contract afn float {{%.+}}, {{%.+}}
+// CHECK: fadd fast float {{%.+}}, {{%.+}}
+
+// CHECK: attributes [[FAST_ATTRS]] = { {{.*}}"no-infs-fp-math"="true" {{.*}}"no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" {{.*}}"unsafe-fp-math"="true"{{.*}} }
+// CHECK: attributes [[PRECISE_ATTRS]] = { {{.*}}"no-infs-fp-math"="false" {{.*}}"no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" {{.*}}"unsafe-fp-math"="false"{{.*}} }
+// CHECK: attributes [[NOREASSOC_ATTRS]] = { {{.*}}"no-infs-fp-math"="true" {{.*}}"no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" {{.*}}"unsafe-fp-math"="false"{{.*}} }
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -678,6 +678,20 @@
 return DominatingValue::save(*this, value);
   }
 
+  class CGFPOptionsRAII : public CGBuilderTy::FastMathFlagGuard {
+  public:
+CGFPOptionsRAII(CodeGenFunction , FPOptions FPFeatures);
+~CGFPOptionsRAII() = default;
+  };
+
+  /// State for the floating point function attributes. At the end of the
+  /// codegen of a function they will have the strictest configuration required
+  /// by the statements in the function itself.
+  bool FnAttrNoInfsFPMath;
+  bool FnAttrNoNaNsFPMath;
+  bool FnAttrNoSignedZerosFPMath;
+  bool FnAttrUnsafeFPMath;
+
 public:
   /// ObjCEHValueStack - Stack of Objective-C exception values, used for
   /// rethrows.
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -73,6 +73,11 @@
 
   SetFastMathFlags(FPOptions(CGM.getLangOpts()));
   SetFPModel();
+
+  FnAttrNoInfsFPMath = CGM.getLangOpts().NoHonorInfs;
+  FnAttrNoNaNsFPMath = CGM.getLangOpts().NoHonorNaNs;
+  FnAttrNoSignedZerosFPMath = CGM.getLangOpts().NoSignedZero;
+  FnAttrUnsafeFPMath = CGM.getLangOpts().UnsafeFPMath;
 }
 
 CodeGenFunction::~CodeGenFunction() {
@@ -132,6 +137,32 @@
   Builder.setFastMathFlags(FMF);
 }
 
+CodeGenFunction::CGFPOptionsRAII::CGFPOptionsRAII(CodeGenFunction ,
+  FPOptions FPFeatures)
+: CGBuilderTy::FastMathFlagGuard(CGF.Builder) {
+  auto NewRoundingBehavior = FPFeatures.getRoundingMode();
+  CGF.Builder.setDefaultConstrainedRounding(NewRoundingBehavior);
+  auto NewExceptionBehavior =
+  ToConstrainedExceptMD(FPFeatures.getExceptionMode());
+  CGF.Builder.setDefaultConstrainedExcept(NewExceptionBehavior);
+
+  CGF.SetFastMathFlags(FPFeatures);
+
+  assert((CGF.CurFuncDecl == nullptr || CGF.Builder.getIsFPConstrained() ||
+  isa(CGF.CurFuncDecl) ||
+  isa(CGF.CurFuncDecl) ||
+  (NewExceptionBehavior == llvm::fp::ebIgnore &&
+   NewRoundingBehavior == llvm::RoundingMode::NearestTiesToEven)) &&
+ "FPConstrained should be enabled on entire function");
+
+  CGF.FnAttrNoInfsFPMath &= FPFeatures.noHonorInfs();
+  CGF.FnAttrNoNaNsFPMath &= FPFeatures.noHonorNaNs();
+  CGF.FnAttrNoSignedZerosFPMath &= FPFeatures.noSignedZeros();
+  CGF.FnAttrUnsafeFPMath &=
+  

[PATCH] D80315: Fix CC1 command line options mapping into fast-math flags.

2020-05-28 Thread Michele Scandale via Phabricator via cfe-commits
michele.scandale updated this revision to Diff 267121.
michele.scandale added a comment.

Rebase + `-ffast-math` change the default contraction mode to fast.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80315

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/builtins-nvptx-ptx60.cu
  clang/test/CodeGen/complex-math.c
  clang/test/CodeGen/fast-math.c
  clang/test/CodeGen/fp-options-to-fast-math-flags.c
  clang/test/CodeGen/fpconstrained.c
  clang/test/CodeGen/fpconstrained.cpp
  clang/test/CodeGen/libcalls.c
  clang/test/CodeGenCUDA/builtins-amdgcn.cu
  clang/test/CodeGenCUDA/library-builtin.cu
  clang/test/CodeGenOpenCL/relaxed-fpmath.cl

Index: clang/test/CodeGenOpenCL/relaxed-fpmath.cl
===
--- clang/test/CodeGenOpenCL/relaxed-fpmath.cl
+++ clang/test/CodeGenOpenCL/relaxed-fpmath.cl
@@ -11,7 +11,7 @@
   // NORMAL: fdiv float
   // FAST: fdiv fast float
   // FINITE: fdiv nnan ninf float
-  // UNSAFE: fdiv nnan nsz float
+  // UNSAFE: fdiv reassoc nsz arcp afn float
   // MAD: fdiv float
   // NOSIGNED: fdiv nsz float
   return a / b;
@@ -38,7 +38,7 @@
 
 // UNSAFE: "less-precise-fpmad"="true"
 // UNSAFE: "no-infs-fp-math"="false"
-// UNSAFE: "no-nans-fp-math"="true"
+// UNSAFE: "no-nans-fp-math"="false"
 // UNSAFE: "no-signed-zeros-fp-math"="true"
 // UNSAFE: "unsafe-fp-math"="true"
 
Index: clang/test/CodeGenCUDA/library-builtin.cu
===
--- clang/test/CodeGenCUDA/library-builtin.cu
+++ clang/test/CodeGenCUDA/library-builtin.cu
@@ -10,7 +10,7 @@
 
 // logf() should be calling itself recursively as we don't have any standard
 // library on device side.
-// DEVICE: call float @logf(float
+// DEVICE: call contract float @logf(float
 extern "C" __attribute__((device)) float logf(float __x) { return logf(__x); }
 
 // NOTE: this case is to illustrate the expected differences in behavior between
@@ -18,5 +18,5 @@
 // library.
 //
 // Host is assumed to have standard library, so logf() calls LLVM intrinsic.
-// HOST: call float @llvm.log.f32(float
+// HOST: call contract float @llvm.log.f32(float
 extern "C" float logf(float __x) { return logf(__x); }
Index: clang/test/CodeGenCUDA/builtins-amdgcn.cu
===
--- clang/test/CodeGenCUDA/builtins-amdgcn.cu
+++ clang/test/CodeGenCUDA/builtins-amdgcn.cu
@@ -10,7 +10,7 @@
 }
 
 // CHECK-LABEL: @_Z12test_ds_fmaxf(
-// CHECK: call float @llvm.amdgcn.ds.fmax(float addrspace(3)* @_ZZ12test_ds_fmaxfE6shared, float %{{[^,]*}}, i32 0, i32 0, i1 false)
+// CHECK: call contract float @llvm.amdgcn.ds.fmax(float addrspace(3)* @_ZZ12test_ds_fmaxfE6shared, float %{{[^,]*}}, i32 0, i32 0, i1 false)
 __global__
 void test_ds_fmax(float src) {
   __shared__ float shared;
Index: clang/test/CodeGen/libcalls.c
===
--- clang/test/CodeGen/libcalls.c
+++ clang/test/CodeGen/libcalls.c
@@ -8,17 +8,17 @@
 void test_sqrt(float a0, double a1, long double a2) {
   // CHECK-YES: call float @sqrtf
   // CHECK-NO: call float @llvm.sqrt.f32(float
-  // CHECK-FAST: call float @llvm.sqrt.f32(float
+  // CHECK-FAST: call reassoc nsz arcp afn float @llvm.sqrt.f32(float
   float l0 = sqrtf(a0);
 
   // CHECK-YES: call double @sqrt
   // CHECK-NO: call double @llvm.sqrt.f64(double
-  // CHECK-FAST: call double @llvm.sqrt.f64(double
+  // CHECK-FAST: call reassoc nsz arcp afn double @llvm.sqrt.f64(double
   double l1 = sqrt(a1);
 
   // CHECK-YES: call x86_fp80 @sqrtl
   // CHECK-NO: call x86_fp80 @llvm.sqrt.f80(x86_fp80
-  // CHECK-FAST: call x86_fp80 @llvm.sqrt.f80(x86_fp80
+  // CHECK-FAST: call reassoc nsz arcp afn x86_fp80 @llvm.sqrt.f80(x86_fp80
   long double l2 = sqrtl(a2);
 }
 
Index: clang/test/CodeGen/fpconstrained.cpp
===
--- clang/test/CodeGen/fpconstrained.cpp
+++ clang/test/CodeGen/fpconstrained.cpp
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -x c++ -ftrapping-math -fexceptions -fcxx-exceptions -frounding-math -ffp-exception-behavior=strict -emit-llvm -o - %s | FileCheck %s -check-prefix=FPMODELSTRICT
 // RUN: %clang_cc1 -x c++ -ffp-contract=fast -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s -check-prefix=PRECISE
 // RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -ffp-contract=fast -emit-llvm -o - %s | FileCheck %s -check-prefix=FAST
-// RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s -check-prefix=FASTNOCONTRACT
+// RUN: 

[PATCH] D80315: Fix CC1 command line options mapping into fast-math flags.

2020-05-28 Thread Michele Scandale via Phabricator via cfe-commits
michele.scandale added a comment.

In D80315#2061164 , @rjmccall wrote:

> In D80315#2059160 , 
> @michele.scandale wrote:
>
> > In D80315#2058914 , @rjmccall 
> > wrote:
> >
> > > In D80315#2058735 , 
> > > @michele.scandale wrote:
> > >
> > > > In D80315#2058549 , @rjmccall 
> > > > wrote:
> > > >
> > > > > The code cleanups all seems reasonable.  The actual changes in 
> > > > > code-generation changes are because we were failing to set these 
> > > > > reliably?
> > > >
> > > >
> > > > Most of them yes.
> > > >
> > > > In the CUDA test we there is now `contract` because we honor the 
> > > > default contraction mode that for CUDA is set to fast.
> > >
> > >
> > > Right, and we weren't honoring that mode before?
> >
> >
> > Not in the setup of base fast-math flags inside `CodeGenFunction`. However 
> > when emitting code for expression with `FPOptions` stored in the AST nodes 
> > then `contract` was set correctly.
>
>
> Okay, that seems justifiable.
>
> >>> In `clang/test/CodeGen/complex-math.c` I've added `-ffp-contract=fast` to 
> >>> the command line option because `-ffast-math` at the CC1 level does not 
> >>> change the default contraction mode.
> >> 
> >> Oh, I see, makes sense.  So there was inconsistent treatment of the 
> >> options, where one thing observed it but others didn't, and that's been 
> >> fixed now.
> > 
> > Do you think we should handle `-ffast-math` as `-cl-fast-relaxed-math`, 
> > i.e. it implies the default contraction mode being "fast"?
>
> I'm actually surprised it doesn't.  I can't imagine why someone enabling fast 
> math would want contraction to be disabled.


Just to be clear the clang driver does the right thing.
If you run `clang -ffast-math` the CC1 invocation has both `-ffast-math` and 
`-ffp-contract=fast` (and other options as well)

Here specifically I'm just considering the behavior of `clang -cc1 -ffast-math`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80315



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


[PATCH] D80770: [diagtool] Install diagtool when LLVM_INSTALL_TOOLCHAIN_ONLY is ON.

2020-05-28 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

Thanks, Volodymyr!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80770



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


[PATCH] D80723: [PowerPC] Convert vec_splats functions to macros

2020-05-28 Thread Qing Shan Zhang via Phabricator via cfe-commits
steven.zhang added inline comments.



Comment at: clang/lib/Headers/altivec.h:13670
+  )
+#elif defined(__VSX__)
+#define vec_splats(N) \

vddvss wrote:
> steven.zhang wrote:
> > I am not sure if this is by intention. It is not semantics the same with 
> > this change. Before the change, if VSX is off, and POWER8_VECTOR && 
> > __powerpc64__ is on, vector signed/unsigned long long, signed/unsigned 
> > __int128 is not a valid candidate of vec_splats. But with this patch, they 
> > are.
> No intention to change semantics. But AFICT, we throw an error if 
> POWER8_VECTOR is on and VSX is off: 
> https://github.com/llvm/llvm-project/blob/master/clang/lib/Basic/Targets/PPC.cpp#L222
Hmm, we are making assumption that, POWER8_VECTOR enables the VSX, and it is 
true. Thank you for pointing out this.



Comment at: clang/test/CodeGen/pr44276.c:3
+// REQUIRES: powerpc-registered-target
+// RUN: %clang -S -emit-llvm -target powerpc64-unknown-unknown -mcpu=pwr8 %s 
-o - | FileCheck %s
+

The assembly output is not your test point. How about doing it as this:
```
// RUN: %clang_cc1 -S -emit-llvm -triple powerpc64-unknown-unknown -target-cpu 
pwr8 %s
// expected-no-diagnostics
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80723



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


[PATCH] D80242: [Clang] implement -fno-eliminate-unused-debug-types

2020-05-28 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:5369
 if (ES->hasExternalDefinitions(D) == ExternalASTSource::EK_Never)
-  DebugInfo->completeUnusedClass(cast(*D));
+  DebugInfo->completeUnusedClass(*CRD);
 }

nickdesaulniers wrote:
> The difference between using `DebugInfo` vs `getModuleDebugInfo` in this 
> method is *killing* me.  Same with `return` vs `break`.
Feel free to send separate patches to clean these things up.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:5317
 /// EmitTopLevelDecl - Emit code for a single top level declaration.
 void CodeGenModule::EmitTopLevelDecl(Decl *D) {
   // Ignore dependent declarations.

Since this is only for top-level decls, have you checked this works for types 
inside namespaces, local types in functions (well, that one might not be 
supported by GCC - so probably good to test/compare GCC's behavior here too), 
etc?



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:5365-5369
+  if (getCodeGenOpts().DebugUnusedTypes && CRD->hasDefinition())
+DebugInfo->completeUnusedClass(*CRD);
+  else if (auto *ES = D->getASTContext().getExternalSource())
 if (ES->hasExternalDefinitions(D) == ExternalASTSource::EK_Never)
+  DebugInfo->completeUnusedClass(*CRD);

Perhaps this could be modified to use the same general purpose utility like the 
other type emissions (as speculated in another comment "EmitUnusedType" or the 
like)



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:5565
+if (CGDebugInfo *DI = getModuleDebugInfo())
+  if (getCodeGenOpts().DebugUnusedTypes) {
+QualType QT = getContext().getTypedefType(cast(D));

Rather than testing DebugUnusedType for every call - might be best to add a 
"EmitUnusedType" function that tests the flag and does the emission? (same way 
EmitExplicitCastType already checks for a certain level of debug info before 
emitting)



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:768
   Opts.DebugFwdTemplateParams = Args.hasArg(OPT_debug_forward_template_params);
+  Opts.DebugUnusedTypes = Args.hasArg(OPT_eliminate_unused_debug_types_fno);
   Opts.EmbedSource = Args.hasArg(OPT_gembed_source);

Could this be rolled into the debug-info-kind? (a kind beyond "standalone")


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80242



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


[PATCH] D80225: [Driver] Recognize -fuse-ld={bfd, gold, lld} but don't prepend "ld." or "ld64." for other values

2020-05-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

@theraven Are you ok with this change? You seem to have a use case not using 
ld.bfd, ld.gold or ld.lld . This change will require you to adapt.

In D80225#2049466 , @jyknight wrote:

> It's worrying to me that there number of places in LLVM that at the exact 
> argument value of "-fuse-ld=". E.g. in the windows and PS4 toolchains. We 
> already claim to support arbitrary values and full paths, but if you specify 
> "-fuse-ld=/path/to/lld-link" on Windows today, you end up with different 
> behavior than "-fuse-ld=lld" (which gets translated to searching for an 
> "lld-link" binary, but also triggers other conditions).
>
> That's not a reason to not make this particular change, but if conditionals 
> on the flavor of linker are going to be used, that seems like perhaps a 
> reason why we should not accept arbitrary values at all?


This is indeed unfortunate, but I can see the reasons people customize linker 
options for different linkers. An arbitrary value is a bit convenient when 
people want to compare behavior differences between different versions of a 
linker. As a linker developer I do this a lot. Some ClangBuiltLinux folks do 
this. (In addition, an absolute path can sometimes give extra confidence that a 
particular executable is picked -> `-fuse-ld=lld` may pick one from PATH if 
`ld.lld` does not sit beside `clang`.) Now @keith also expresses interest in 
such a feature. I think it is really difficult for us to drop it now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80225



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


[PATCH] D80771: [MTE] Convert StackSafety into analysisThis lets us to remove !stack-safe metadata andbetter controll when to perform StackSafetyanalysis.

2020-05-28 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka created this revision.
vitalybuka added a reviewer: eugenis.
Herald added subscribers: llvm-commits, cfe-commits, dexonsmith, steven_wu, 
hiraditya.
Herald added projects: clang, LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80771

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/Driver/memtag.c
  clang/test/Driver/memtag_lto.c
  llvm/include/llvm/Analysis/StackSafetyAnalysis.h
  llvm/lib/Analysis/StackSafetyAnalysis.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Target/AArch64/AArch64.h
  llvm/lib/Target/AArch64/AArch64StackTagging.cpp
  llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
  llvm/test/Analysis/StackSafetyAnalysis/ipa-attr.ll
  llvm/test/CodeGen/AArch64/O3-pipeline.ll
  llvm/test/CodeGen/AArch64/stack-tagging.ll

Index: llvm/test/CodeGen/AArch64/stack-tagging.ll
===
--- llvm/test/CodeGen/AArch64/stack-tagging.ll
+++ llvm/test/CodeGen/AArch64/stack-tagging.ll
@@ -1,4 +1,5 @@
-; RUN: opt < %s -stack-tagging -S -o - | FileCheck %s
+; RUN: opt < %s -stack-tagging -S -o - | FileCheck %s --check-prefixes=CHECK,SSI
+; RUN: opt < %s -stack-tagging -stack-tagging-use-stack-safety=0 -S -o - | FileCheck %s --check-prefixes=CHECK,NOSSI
 
 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
 target triple = "aarch64--linux-android"
@@ -8,6 +9,11 @@
 declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture)
 declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture)
 
+define dso_local void @noUse32(i32*) sanitize_memtag {
+entry:
+  ret void
+}
+
 define void @OneVar() sanitize_memtag {
 entry:
   %x = alloca i32, align 4
@@ -33,7 +39,7 @@
   %x1 = alloca i32, align 4
   %x2 = alloca i8, align 4
   %x3 = alloca i32, i32 11, align 4
-  %x4 = alloca i32, align 4, !stack-safe !0
+  %x4 = alloca i32, align 4
   call void @use32(i32* %x1)
   call void @use8(i8* %x2)
   call void @use32(i32* %x3)
@@ -50,9 +56,12 @@
 ; CHECK:  alloca { [11 x i32], [4 x i8] }, align 16
 ; CHECK:  call { [11 x i32], [4 x i8] }* @llvm.aarch64.tagp.{{.*}}({ [11 x i32], [4 x i8] }* {{.*}}, i64 2)
 ; CHECK:  call void @llvm.aarch64.settag(i8* {{.*}}, i64 48)
-; CHECK:  alloca i32, align 4
-; CHECK-NOT: @llvm.aarch64.tagp
-; CHECK-NOT: @llvm.aarch64.settag
+; SSI:alloca i32, align 4
+; NOSSI:  alloca { i32, [12 x i8] }, align 16
+; NOSSI: @llvm.aarch64.tagp.
+; NOSSI: call void @llvm.aarch64.settag(i8* {{.*}}, i64 16)
+; SSI-NOT: @llvm.aarch64.tagp
+; SSI-NOT: @llvm.aarch64.settag
 
 ; CHECK:  call void @use32(
 ; CHECK:  call void @use8(
@@ -61,6 +70,7 @@
 ; CHECK:  call void @llvm.aarch64.settag(i8* {{.*}}, i64 16)
 ; CHECK:  call void @llvm.aarch64.settag(i8* {{.*}}, i64 16)
 ; CHECK:  call void @llvm.aarch64.settag(i8* {{.*}}, i64 48)
+; NOSSI:  call void @llvm.aarch64.settag(i8* {{.*}}, i64 16)
 ; CHECK-NEXT:  ret void
 
 
@@ -161,12 +171,15 @@
 another_bb:
   call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %cz)
   store i32 7, i32* %z
+  call void @noUse32(i32* %z)
   call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %cz)
   call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %cz)
   store i32 7, i32* %z
   call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %cz)
   call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %cxcy)
   store i32 8, i32* %xy
+  call void @noUse32(i32* %x)
+  call void @noUse32(i32* %y)
   call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %cxcy)
   ret void
 }
@@ -179,15 +192,18 @@
 ; CHECK: alloca { i32, [12 x i8] }, align 16
 ; CHECK: call { i32, [12 x i8] }* @llvm.aarch64.tagp
 ; CHECK: call void @llvm.aarch64.settag(
-; CHECK: alloca { i32, [12 x i8] }, align 16
-; CHECK: call { i32, [12 x i8] }* @llvm.aarch64.tagp
-; CHECK: call void @llvm.aarch64.settag(
+; SSI: alloca i32, align 4
+; NOSSI: alloca { i32, [12 x i8] }, align 16
+; NOSSI: call { i32, [12 x i8] }* @llvm.aarch64.tagp
+; NOSSI: call void @llvm.aarch64.settag(
 ; CHECK: store i32
+; CHECK: call void @noUse32(i32*
 ; CHECK: store i32
 ; CHECK: store i32
+; CHECK: call void @noUse32(i32*
 ; CHECK: call void @llvm.aarch64.settag(
 ; CHECK: call void @llvm.aarch64.settag(
-; CHECK: call void @llvm.aarch64.settag(
+; NOSSI: call void @llvm.aarch64.settag(
 ; CHECK: ret void
 
 !0 = !{}
\ No newline at end of file
Index: llvm/test/CodeGen/AArch64/O3-pipeline.ll
===
--- llvm/test/CodeGen/AArch64/O3-pipeline.ll
+++ llvm/test/CodeGen/AArch64/O3-pipeline.ll
@@ -66,6 +66,14 @@
 ; CHECK-NEXT:   Interleaved Load Combine Pass
 ; CHECK-NEXT:   Dominator Tree Construction
 ; CHECK-NEXT:   Interleaved Access Pass
+; CHECK-NEXT: Stack Safety Analysis
+; CHECK-NEXT:   FunctionPass Manager
+; CHECK-NEXT: Dominator Tree Construction
+; CHECK-NEXT: Natural Loop Information
+; CHECK-NEXT: Scalar Evolution Analysis
+; CHECK-NEXT: Stack Safety Local Analysis
+; CHECK-NEXT: FunctionPass Manager

[PATCH] D80770: [diagtool] Install diagtool when LLVM_INSTALL_TOOLCHAIN_ONLY is ON.

2020-05-28 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai created this revision.
vsapsai added reviewers: JDevlieghere, steven_wu.
Herald added subscribers: ributzka, dexonsmith, jkorous, mgorny.
Herald added a project: clang.

Not sure about other platforms but `install-xcode-toolchain` was already
including diagtool in the toolchain. This change makes it possible to
install diagtool during Apple's 2-stage build.

Instead of dropping `if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)` conditional
I've switched to `add_clang_tool` which handles install targets. Also a
few other clang tools like clang-format, clang-scan-deps are using this
macro, so it is good to be consistent.

rdar://problem/15386909


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80770

Files:
  clang/tools/diagtool/CMakeLists.txt


Index: clang/tools/diagtool/CMakeLists.txt
===
--- clang/tools/diagtool/CMakeLists.txt
+++ clang/tools/diagtool/CMakeLists.txt
@@ -2,7 +2,7 @@
   Support
   )
 
-add_clang_executable(diagtool
+add_clang_tool(diagtool
   diagtool_main.cpp
   DiagTool.cpp
   DiagnosticNames.cpp
@@ -17,15 +17,3 @@
   clangBasic
   clangFrontend
   )
-
-if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
-  install(TARGETS diagtool
-COMPONENT diagtool
-RUNTIME DESTINATION bin)
-
-  if (NOT LLVM_ENABLE_IDE)
-add_llvm_install_targets(install-diagtool
-  DEPENDS diagtool
-  COMPONENT diagtool)
-  endif()
-endif()


Index: clang/tools/diagtool/CMakeLists.txt
===
--- clang/tools/diagtool/CMakeLists.txt
+++ clang/tools/diagtool/CMakeLists.txt
@@ -2,7 +2,7 @@
   Support
   )
 
-add_clang_executable(diagtool
+add_clang_tool(diagtool
   diagtool_main.cpp
   DiagTool.cpp
   DiagnosticNames.cpp
@@ -17,15 +17,3 @@
   clangBasic
   clangFrontend
   )
-
-if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
-  install(TARGETS diagtool
-COMPONENT diagtool
-RUNTIME DESTINATION bin)
-
-  if (NOT LLVM_ENABLE_IDE)
-add_llvm_install_targets(install-diagtool
-  DEPENDS diagtool
-  COMPONENT diagtool)
-  endif()
-endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80412: Summary: [Lexer] Fix invalid suffix diagnostic for fixed-point literals

2020-05-28 Thread Arthi via Phabricator via cfe-commits
nagart added a comment.

@leonardchan  Thank you :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80412



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


[PATCH] D80222: Replace Clang's createRuntimeFunction with the definitions in OMPKinds.def

2020-05-28 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D80222#2061810 , @jdoerfert wrote:

> LGTM. Thanks for taking this one, it was more complex than I thought but it 
> is a really nice step in the right direction. I'll commit it for you soon if 
> you don't have access yet. Feel free to get access though.


Thanks, I don't have access yet. I'll get on that soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80222



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


[PATCH] D80692: Run Coverage pass before other *San passes under new pass manager, round 2

2020-05-28 Thread Arthur Eubanks via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1285e8bcac2c: Run Coverage pass before other *San passes 
under new pass manager, round 2 (authored by aeubanks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80692

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/sancov-new-pm.c
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/tools/opt/NewPMDriver.cpp

Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -194,7 +194,7 @@
 });
   if (tryParsePipelineText(PB, OptimizerLastEPPipeline))
 PB.registerOptimizerLastEPCallback(
-[, VerifyEachPass, DebugLogging](FunctionPassManager ,
+[, VerifyEachPass, DebugLogging](ModulePassManager ,
 PassBuilder::OptimizationLevel) {
   ExitOnError Err("Unable to parse OptimizerLastEP pipeline: ");
   Err(PB.parsePassPipeline(PM, OptimizerLastEPPipeline, VerifyEachPass,
Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -1073,12 +1073,12 @@
   if (PTO.Coroutines)
 OptimizePM.addPass(CoroCleanupPass());
 
-  for (auto  : OptimizerLastEPCallbacks)
-C(OptimizePM, Level);
-
   // Add the core optimizing pipeline.
   MPM.addPass(createModuleToFunctionPassAdaptor(std::move(OptimizePM)));
 
+  for (auto  : OptimizerLastEPCallbacks)
+C(MPM, Level);
+
   if (PTO.CallGraphProfile)
 MPM.addPass(CGProfilePass());
 
Index: llvm/include/llvm/Passes/PassBuilder.h
===
--- llvm/include/llvm/Passes/PassBuilder.h
+++ llvm/include/llvm/Passes/PassBuilder.h
@@ -600,7 +600,7 @@
   /// is not triggered at O0. Extensions to the O0 pipeline should append their
   /// passes to the end of the overall pipeline.
   void registerOptimizerLastEPCallback(
-  const std::function ) {
+  const std::function ) {
 OptimizerLastEPCallbacks.push_back(C);
   }
 
@@ -728,7 +728,7 @@
   CGSCCOptimizerLateEPCallbacks;
   SmallVector, 2>
   VectorizerStartEPCallbacks;
-  SmallVector, 2>
+  SmallVector, 2>
   OptimizerLastEPCallbacks;
   // Module callbacks
   SmallVector, 2>
Index: clang/test/CodeGen/sancov-new-pm.c
===
--- clang/test/CodeGen/sancov-new-pm.c
+++ clang/test/CodeGen/sancov-new-pm.c
@@ -1,10 +1,6 @@
 // Test that SanitizerCoverage works under the new pass manager.
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=fuzzer %s -fexperimental-new-pass-manager -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-O0
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=fuzzer %s -fexperimental-new-pass-manager -O2 -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-O2
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=fuzzer %s -fexperimental-new-pass-manager -flto -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-O0
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=fuzzer %s -fexperimental-new-pass-manager -flto -O2 -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-O2
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=fuzzer %s -fexperimental-new-pass-manager -flto=thin -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-O0
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=fuzzer %s -fexperimental-new-pass-manager -flto=thin -O2 -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-O2,CHECK-O2-THINLTO
 
 extern void *memcpy(void *, const void *, unsigned long);
 extern int printf(const char *restrict, ...);
@@ -29,10 +25,10 @@
 // CHECK-O0-DAG: declare void @__sanitizer_cov_trace_cmp2(i16 zeroext, i16 zeroext)
 // CHECK-O0-DAG: declare void @__sanitizer_cov_trace_cmp4(i32 zeroext, i32 zeroext)
 // CHECK-O0-DAG: declare void @__sanitizer_cov_trace_cmp8(i64, i64)
-// CHECK-O2-THINLTO-NOT: declare void @__sanitizer_cov_trace_const_cmp1(i8 zeroext, i8 zeroext)
+// CHECK-O2-NOT: declare void @__sanitizer_cov_trace_const_cmp1(i8 zeroext, i8 zeroext)
 // CHECK-O0-DAG: declare void @__sanitizer_cov_trace_const_cmp2(i16 zeroext, i16 zeroext)
 // CHECK-O0-DAG: declare void @__sanitizer_cov_trace_const_cmp4(i32 zeroext, i32 zeroext)
-// CHECK-O2-THINLTO-NOT: declare void @__sanitizer_cov_trace_const_cmp8(i64, i64)
+// CHECK-O2-NOT: declare void @__sanitizer_cov_trace_const_cmp8(i64, i64)
 // CHECK-O0-DAG: declare void @__sanitizer_cov_trace_div4(i32 zeroext)
 // CHECK-O0-DAG: declare void @__sanitizer_cov_trace_div8(i64)
 // CHECK-O0-DAG: declare void @__sanitizer_cov_trace_gep(i64)
Index: clang/lib/CodeGen/BackendUtil.cpp

[clang] 1285e8b - Run Coverage pass before other *San passes under new pass manager, round 2

2020-05-28 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2020-05-28T17:04:47-07:00
New Revision: 1285e8bcac2c54ddd924ffb813b2b187467ac2a6

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

LOG: Run Coverage pass before other *San passes under new pass manager, round 2

Summary:
This was attempted once before in https://reviews.llvm.org/D79698, but
was reverted due to the coverage pass running in the wrong part of the
pipeline. This commit puts it in the same place as the other sanitizers.

This changes PassBuilder.OptimizerLastEPCallbacks to work on a
ModulePassManager instead of a FunctionPassManager. That is because
SanitizerCoverage cannot (easily) be split into a module pass and a
function pass like some of the other sanitizers since in its current
implementation it conditionally inserts module constructors based on
whether or not it successfully modified functions.

This fixes compiler-rt/test/msan/coverage-levels.cpp under the new pass
manager (last check-msan test).

Currently sanitizers + LTO don't work together under the new pass
manager, so I removed tests that checked that this combination works for
sancov.

Subscribers: hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp
clang/test/CodeGen/sancov-new-pm.c
llvm/include/llvm/Passes/PassBuilder.h
llvm/lib/Passes/PassBuilder.cpp
llvm/tools/opt/NewPMDriver.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index e746aef1a62f..dd5016333920 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -32,6 +32,7 @@
 #include "llvm/IR/LegacyPassManager.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/ModuleSummaryIndex.h"
+#include "llvm/IR/PassManager.h"
 #include "llvm/IR/Verifier.h"
 #include "llvm/LTO/LTOBackend.h"
 #include "llvm/MC/MCAsmInfo.h"
@@ -1001,6 +1002,15 @@ static void addSanitizersAtO0(ModulePassManager ,
   const Triple ,
   const LangOptions ,
   const CodeGenOptions ) {
+  if (CodeGenOpts.SanitizeCoverageType ||
+  CodeGenOpts.SanitizeCoverageIndirectCalls ||
+  CodeGenOpts.SanitizeCoverageTraceCmp) {
+auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
+MPM.addPass(ModuleSanitizerCoveragePass(
+SancovOpts, CodeGenOpts.SanitizeCoverageWhitelistFiles,
+CodeGenOpts.SanitizeCoverageBlacklistFiles));
+  }
+
   auto ASanPass = [&](SanitizerMask Mask, bool CompileKernel) {
 MPM.addPass(RequireAnalysisPass());
 bool Recover = CodeGenOpts.SanitizeRecover.has(Mask);
@@ -1249,6 +1259,20 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
 [](FunctionPassManager , PassBuilder::OptimizationLevel Level) 
{
   FPM.addPass(BoundsCheckingPass());
 });
+
+  if (CodeGenOpts.SanitizeCoverageType ||
+  CodeGenOpts.SanitizeCoverageIndirectCalls ||
+  CodeGenOpts.SanitizeCoverageTraceCmp) {
+PB.registerOptimizerLastEPCallback(
+[this](ModulePassManager ,
+   PassBuilder::OptimizationLevel Level) {
+  auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
+  MPM.addPass(ModuleSanitizerCoveragePass(
+  SancovOpts, CodeGenOpts.SanitizeCoverageWhitelistFiles,
+  CodeGenOpts.SanitizeCoverageBlacklistFiles));
+});
+  }
+
   if (LangOpts.Sanitize.has(SanitizerKind::Memory)) {
 int TrackOrigins = CodeGenOpts.SanitizeMemoryTrackOrigins;
 bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::Memory);
@@ -1257,17 +1281,19 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
   MPM.addPass(MemorySanitizerPass({TrackOrigins, Recover, false}));
 });
 PB.registerOptimizerLastEPCallback(
-[TrackOrigins, Recover](FunctionPassManager ,
+[TrackOrigins, Recover](ModulePassManager ,
 PassBuilder::OptimizationLevel Level) {
-  FPM.addPass(MemorySanitizerPass({TrackOrigins, Recover, false}));
+  MPM.addPass(createModuleToFunctionPassAdaptor(
+  MemorySanitizerPass({TrackOrigins, Recover, false})));
 });
   }
   if (LangOpts.Sanitize.has(SanitizerKind::Thread)) {
 PB.registerPipelineStartEPCallback(
 [](ModulePassManager ) { MPM.addPass(ThreadSanitizerPass()); 
});
 PB.registerOptimizerLastEPCallback(
-[](FunctionPassManager , PassBuilder::OptimizationLevel Level) 
{
-  FPM.addPass(ThreadSanitizerPass());
+

[PATCH] D80692: Run Coverage pass before other *San passes under new pass manager, round 2

2020-05-28 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 267087.
aeubanks added a comment.

Update some CHECKs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80692

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/sancov-new-pm.c
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/tools/opt/NewPMDriver.cpp

Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -194,7 +194,7 @@
 });
   if (tryParsePipelineText(PB, OptimizerLastEPPipeline))
 PB.registerOptimizerLastEPCallback(
-[, VerifyEachPass, DebugLogging](FunctionPassManager ,
+[, VerifyEachPass, DebugLogging](ModulePassManager ,
 PassBuilder::OptimizationLevel) {
   ExitOnError Err("Unable to parse OptimizerLastEP pipeline: ");
   Err(PB.parsePassPipeline(PM, OptimizerLastEPPipeline, VerifyEachPass,
Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -1073,12 +1073,12 @@
   if (PTO.Coroutines)
 OptimizePM.addPass(CoroCleanupPass());
 
-  for (auto  : OptimizerLastEPCallbacks)
-C(OptimizePM, Level);
-
   // Add the core optimizing pipeline.
   MPM.addPass(createModuleToFunctionPassAdaptor(std::move(OptimizePM)));
 
+  for (auto  : OptimizerLastEPCallbacks)
+C(MPM, Level);
+
   if (PTO.CallGraphProfile)
 MPM.addPass(CGProfilePass());
 
Index: llvm/include/llvm/Passes/PassBuilder.h
===
--- llvm/include/llvm/Passes/PassBuilder.h
+++ llvm/include/llvm/Passes/PassBuilder.h
@@ -600,7 +600,7 @@
   /// is not triggered at O0. Extensions to the O0 pipeline should append their
   /// passes to the end of the overall pipeline.
   void registerOptimizerLastEPCallback(
-  const std::function ) {
+  const std::function ) {
 OptimizerLastEPCallbacks.push_back(C);
   }
 
@@ -728,7 +728,7 @@
   CGSCCOptimizerLateEPCallbacks;
   SmallVector, 2>
   VectorizerStartEPCallbacks;
-  SmallVector, 2>
+  SmallVector, 2>
   OptimizerLastEPCallbacks;
   // Module callbacks
   SmallVector, 2>
Index: clang/test/CodeGen/sancov-new-pm.c
===
--- clang/test/CodeGen/sancov-new-pm.c
+++ clang/test/CodeGen/sancov-new-pm.c
@@ -1,10 +1,6 @@
 // Test that SanitizerCoverage works under the new pass manager.
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=fuzzer %s -fexperimental-new-pass-manager -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-O0
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=fuzzer %s -fexperimental-new-pass-manager -O2 -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-O2
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=fuzzer %s -fexperimental-new-pass-manager -flto -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-O0
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=fuzzer %s -fexperimental-new-pass-manager -flto -O2 -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-O2
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=fuzzer %s -fexperimental-new-pass-manager -flto=thin -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-O0
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=fuzzer %s -fexperimental-new-pass-manager -flto=thin -O2 -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-O2,CHECK-O2-THINLTO
 
 extern void *memcpy(void *, const void *, unsigned long);
 extern int printf(const char *restrict, ...);
@@ -29,10 +25,10 @@
 // CHECK-O0-DAG: declare void @__sanitizer_cov_trace_cmp2(i16 zeroext, i16 zeroext)
 // CHECK-O0-DAG: declare void @__sanitizer_cov_trace_cmp4(i32 zeroext, i32 zeroext)
 // CHECK-O0-DAG: declare void @__sanitizer_cov_trace_cmp8(i64, i64)
-// CHECK-O2-THINLTO-NOT: declare void @__sanitizer_cov_trace_const_cmp1(i8 zeroext, i8 zeroext)
+// CHECK-O2-NOT: declare void @__sanitizer_cov_trace_const_cmp1(i8 zeroext, i8 zeroext)
 // CHECK-O0-DAG: declare void @__sanitizer_cov_trace_const_cmp2(i16 zeroext, i16 zeroext)
 // CHECK-O0-DAG: declare void @__sanitizer_cov_trace_const_cmp4(i32 zeroext, i32 zeroext)
-// CHECK-O2-THINLTO-NOT: declare void @__sanitizer_cov_trace_const_cmp8(i64, i64)
+// CHECK-O2-NOT: declare void @__sanitizer_cov_trace_const_cmp8(i64, i64)
 // CHECK-O0-DAG: declare void @__sanitizer_cov_trace_div4(i32 zeroext)
 // CHECK-O0-DAG: declare void @__sanitizer_cov_trace_div8(i64)
 // CHECK-O0-DAG: declare void @__sanitizer_cov_trace_gep(i64)
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -32,6 +32,7 @@
 

[PATCH] D80660: clang: Add support for relative linker paths with -fuse-ld

2020-05-28 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.

The new test failure appears unrelated to my changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80660



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


[PATCH] D80222: Replace Clang's createRuntimeFunction with the definitions in OMPKinds.def

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

LGTM. Thanks for taking this one, it was more complex than I thought but it is 
a really nice step in the right direction. I'll commit it for you soon if you 
don't have access yet. Feel free to get access though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80222



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


[PATCH] D80692: Run Coverage pass before other *San passes under new pass manager, round 2

2020-05-28 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan accepted this revision.
leonardchan added a comment.

In D80692#2061739 , @aeubanks wrote:

> I foolishly submitted without running check-all, and it turns out this broke 
> a test under check-clang.
>  Looks like https://reviews.llvm.org/D62888 added tests in sancov-new-pm.c to 
> make sure that sancov + LTO work together, but they won't after this change 
> since the (Thin)LTO pipeline doesn't run things under 
> `registerOptimizerLastEPCallback()`. So I deleted those tests. Other 
> sanitizers don't work under LTO right now (at least for non-O0) because of 
> the same thing. Does this make sense?


Makes sense. Could you also remove any CHECK lines for RUNs that were removed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80692



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


[PATCH] D80692: Run Coverage pass before other *San passes under new pass manager, round 2

2020-05-28 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 267073.
aeubanks added a comment.

I foolishly submitted without running check-all, and it turns out this broke a 
test under check-clang.
Looks like https://reviews.llvm.org/D62888 added tests in sancov-new-pm.c to 
make sure that sancov + LTO work together, but they won't after this change 
since the (Thin)LTO pipeline doesn't run things under 
`registerOptimizerLastEPCallback()`. So I deleted those tests. Other sanitizers 
don't work under LTO right now (at least for non-O0) because of the same thing. 
Does this make sense?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80692

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/sancov-new-pm.c
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/tools/opt/NewPMDriver.cpp

Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -194,7 +194,7 @@
 });
   if (tryParsePipelineText(PB, OptimizerLastEPPipeline))
 PB.registerOptimizerLastEPCallback(
-[, VerifyEachPass, DebugLogging](FunctionPassManager ,
+[, VerifyEachPass, DebugLogging](ModulePassManager ,
 PassBuilder::OptimizationLevel) {
   ExitOnError Err("Unable to parse OptimizerLastEP pipeline: ");
   Err(PB.parsePassPipeline(PM, OptimizerLastEPPipeline, VerifyEachPass,
Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -1073,12 +1073,12 @@
   if (PTO.Coroutines)
 OptimizePM.addPass(CoroCleanupPass());
 
-  for (auto  : OptimizerLastEPCallbacks)
-C(OptimizePM, Level);
-
   // Add the core optimizing pipeline.
   MPM.addPass(createModuleToFunctionPassAdaptor(std::move(OptimizePM)));
 
+  for (auto  : OptimizerLastEPCallbacks)
+C(MPM, Level);
+
   if (PTO.CallGraphProfile)
 MPM.addPass(CGProfilePass());
 
Index: llvm/include/llvm/Passes/PassBuilder.h
===
--- llvm/include/llvm/Passes/PassBuilder.h
+++ llvm/include/llvm/Passes/PassBuilder.h
@@ -600,7 +600,7 @@
   /// is not triggered at O0. Extensions to the O0 pipeline should append their
   /// passes to the end of the overall pipeline.
   void registerOptimizerLastEPCallback(
-  const std::function ) {
+  const std::function ) {
 OptimizerLastEPCallbacks.push_back(C);
   }
 
@@ -728,7 +728,7 @@
   CGSCCOptimizerLateEPCallbacks;
   SmallVector, 2>
   VectorizerStartEPCallbacks;
-  SmallVector, 2>
+  SmallVector, 2>
   OptimizerLastEPCallbacks;
   // Module callbacks
   SmallVector, 2>
Index: clang/test/CodeGen/sancov-new-pm.c
===
--- clang/test/CodeGen/sancov-new-pm.c
+++ clang/test/CodeGen/sancov-new-pm.c
@@ -1,10 +1,6 @@
 // Test that SanitizerCoverage works under the new pass manager.
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=fuzzer %s -fexperimental-new-pass-manager -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-O0
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=fuzzer %s -fexperimental-new-pass-manager -O2 -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-O2
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=fuzzer %s -fexperimental-new-pass-manager -flto -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-O0
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=fuzzer %s -fexperimental-new-pass-manager -flto -O2 -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-O2
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=fuzzer %s -fexperimental-new-pass-manager -flto=thin -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-O0
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=fuzzer %s -fexperimental-new-pass-manager -flto=thin -O2 -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-O2,CHECK-O2-THINLTO
 
 extern void *memcpy(void *, const void *, unsigned long);
 extern int printf(const char *restrict, ...);
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -32,6 +32,7 @@
 #include "llvm/IR/LegacyPassManager.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/ModuleSummaryIndex.h"
+#include "llvm/IR/PassManager.h"
 #include "llvm/IR/Verifier.h"
 #include "llvm/LTO/LTOBackend.h"
 #include "llvm/MC/MCAsmInfo.h"
@@ -1001,6 +1002,15 @@
   const Triple ,
   const LangOptions ,
   const CodeGenOptions ) {
+  if (CodeGenOpts.SanitizeCoverageType ||
+  

[PATCH] D80660: clang: Add support for relative linker paths with -fuse-ld

2020-05-28 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.

Thanks I moved them to the bottom and I believe I fixed them on windows!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80660



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


[PATCH] D80660: clang: Add support for relative linker paths with -fuse-ld

2020-05-28 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 267069.
keith added a comment.

Update tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80660

Files:
  clang/lib/Driver/ToolChain.cpp
  clang/test/Driver/fuse-ld.c


Index: clang/test/Driver/fuse-ld.c
===
--- clang/test/Driver/fuse-ld.c
+++ clang/test/Driver/fuse-ld.c
@@ -4,7 +4,6 @@
 // RUN:   | FileCheck %s --check-prefix=CHECK-ABSOLUTE-LD
 // CHECK-ABSOLUTE-LD: /usr/local/bin/or1k-linux-ld
 
-
 // RUN: %clang %s -### \
 // RUN: -target x86_64-unknown-freebsd 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-FREEBSD-LD
@@ -94,3 +93,18 @@
 // RUN:   | FileCheck %s --check-prefix CHECK-WINDOWS-MSVC-BFD
 // CHECK-WINDOWS-MSVC-BFD: "{{.*}}ld.bfd"
 // CHECK-WINDOWS-MSVC-BFD-SAME: "-o"
+
+// RUN: %clang %s -### \
+// RUN: -target x86_64-unknown-linux \
+// RUN: -working-directory "%S/Inputs" \
+// RUN: -fuse-ld=fuse_ld_windows/ld.foo.exe 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-RELATIVE-WORKDIR-LD
+// CHECK-RELATIVE-WORKDIR-LD-NOT: error: invalid linker name
+// CHECK-RELATIVE-WORKDIR-LD: 
test{{/|\\+}}Driver{{/|\\+}}Inputs/fuse_ld_windows/ld.foo.exe
+
+// RUN: cd "%S" && %clang %s -### \
+// RUN: -target x86_64-unknown-linux \
+// RUN: -fuse-ld=Inputs/fuse_ld_windows/ld.foo.exe 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-RELATIVE-LD
+// CHECK-RELATIVE-LD-NOT: error: invalid linker name
+// CHECK-RELATIVE-LD: 
test{{/|\\+}}Driver{{/|\\+}}Inputs/fuse_ld_windows/ld.foo.exe
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -554,6 +554,18 @@
 std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
 if (llvm::sys::fs::can_execute(LinkerPath))
   return LinkerPath;
+
+const Arg *WorkingDir = Args.getLastArg(options::OPT_working_directory);
+SmallString<128> ResolvedPath(UseLinker);
+if (WorkingDir) {
+  sys::fs::make_absolute(WorkingDir->getValue(), ResolvedPath);
+  if (llvm::sys::fs::can_execute(ResolvedPath))
+return std::string(ResolvedPath);
+}
+
+if (!sys::fs::make_absolute(ResolvedPath) &&
+llvm::sys::fs::can_execute(ResolvedPath))
+  return std::string(ResolvedPath);
   }
 
   if (A)


Index: clang/test/Driver/fuse-ld.c
===
--- clang/test/Driver/fuse-ld.c
+++ clang/test/Driver/fuse-ld.c
@@ -4,7 +4,6 @@
 // RUN:   | FileCheck %s --check-prefix=CHECK-ABSOLUTE-LD
 // CHECK-ABSOLUTE-LD: /usr/local/bin/or1k-linux-ld
 
-
 // RUN: %clang %s -### \
 // RUN: -target x86_64-unknown-freebsd 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-FREEBSD-LD
@@ -94,3 +93,18 @@
 // RUN:   | FileCheck %s --check-prefix CHECK-WINDOWS-MSVC-BFD
 // CHECK-WINDOWS-MSVC-BFD: "{{.*}}ld.bfd"
 // CHECK-WINDOWS-MSVC-BFD-SAME: "-o"
+
+// RUN: %clang %s -### \
+// RUN: -target x86_64-unknown-linux \
+// RUN: -working-directory "%S/Inputs" \
+// RUN: -fuse-ld=fuse_ld_windows/ld.foo.exe 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-RELATIVE-WORKDIR-LD
+// CHECK-RELATIVE-WORKDIR-LD-NOT: error: invalid linker name
+// CHECK-RELATIVE-WORKDIR-LD: test{{/|\\+}}Driver{{/|\\+}}Inputs/fuse_ld_windows/ld.foo.exe
+
+// RUN: cd "%S" && %clang %s -### \
+// RUN: -target x86_64-unknown-linux \
+// RUN: -fuse-ld=Inputs/fuse_ld_windows/ld.foo.exe 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-RELATIVE-LD
+// CHECK-RELATIVE-LD-NOT: error: invalid linker name
+// CHECK-RELATIVE-LD: test{{/|\\+}}Driver{{/|\\+}}Inputs/fuse_ld_windows/ld.foo.exe
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -554,6 +554,18 @@
 std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
 if (llvm::sys::fs::can_execute(LinkerPath))
   return LinkerPath;
+
+const Arg *WorkingDir = Args.getLastArg(options::OPT_working_directory);
+SmallString<128> ResolvedPath(UseLinker);
+if (WorkingDir) {
+  sys::fs::make_absolute(WorkingDir->getValue(), ResolvedPath);
+  if (llvm::sys::fs::can_execute(ResolvedPath))
+return std::string(ResolvedPath);
+}
+
+if (!sys::fs::make_absolute(ResolvedPath) &&
+llvm::sys::fs::can_execute(ResolvedPath))
+  return std::string(ResolvedPath);
   }
 
   if (A)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 0dfb43d - Fix handling of default arguments in __attribute__((enable_if)).

2020-05-28 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-05-28T15:35:22-07:00
New Revision: 0dfb43deb6d5511a8ea69eeb7373a212ebd6c9c1

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

LOG: Fix handling of default arguments in __attribute__((enable_if)).

We didn't properly build default argument expressions previously -- we
failed to build the wrapper CXXDefaultArgExpr node, which meant that
std::source_location misbehaved, and we didn't perform default argument
instantiation when necessary, which meant that dependent default
arguments in function templates didn't work at all.

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaOverload.cpp
clang/test/SemaCXX/enable_if.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index e63f65e2580c..dc7ee2ddd0b8 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -3371,7 +3371,8 @@ class Sema final {
 
   /// Check the enable_if expressions on the given function. Returns the first
   /// failing attribute, or NULL if they were all successful.
-  EnableIfAttr *CheckEnableIf(FunctionDecl *Function, ArrayRef Args,
+  EnableIfAttr *CheckEnableIf(FunctionDecl *Function, SourceLocation CallLoc,
+  ArrayRef Args,
   bool MissingImplicitThis = false);
 
   /// Find the failed Boolean condition within a given Boolean

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 261e69b44052..4063289711cc 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -6060,7 +6060,8 @@ static void checkDirectCallValidity(Sema , const Expr 
*Fn,
   if (Callee->getMinRequiredArguments() > ArgExprs.size())
 return;
 
-  if (const EnableIfAttr *Attr = S.CheckEnableIf(Callee, ArgExprs, true)) {
+  if (const EnableIfAttr *Attr =
+  S.CheckEnableIf(Callee, Fn->getBeginLoc(), ArgExprs, true)) {
 S.Diag(Fn->getBeginLoc(),
isa(Callee)
? diag::err_ovl_no_viable_member_function_in_call

diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 1b00b2b18572..ad75529debdb 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -6356,7 +6356,8 @@ void Sema::AddOverloadCandidate(
 }
   }
 
-  if (EnableIfAttr *FailedAttr = CheckEnableIf(Function, Args)) {
+  if (EnableIfAttr *FailedAttr =
+  CheckEnableIf(Function, CandidateSet.getLocation(), Args)) {
 Candidate.Viable = false;
 Candidate.FailureKind = ovl_fail_enable_if;
 Candidate.DeductionFailure.Data = FailedAttr;
@@ -6462,11 +6463,10 @@ Sema::SelectBestMethod(Selector Sel, MultiExprArg Args, 
bool IsInstance,
   return nullptr;
 }
 
-static bool
-convertArgsForAvailabilityChecks(Sema , FunctionDecl *Function, Expr 
*ThisArg,
- ArrayRef Args, Sema::SFINAETrap ,
- bool MissingImplicitThis, Expr 
*,
- SmallVectorImpl ) {
+static bool convertArgsForAvailabilityChecks(
+Sema , FunctionDecl *Function, Expr *ThisArg, SourceLocation CallLoc,
+ArrayRef Args, Sema::SFINAETrap , bool MissingImplicitThis,
+Expr *, SmallVectorImpl ) {
   if (ThisArg) {
 CXXMethodDecl *Method = cast(Function);
 assert(!isa(Method) &&
@@ -6511,17 +6511,7 @@ convertArgsForAvailabilityChecks(Sema , FunctionDecl 
*Function, Expr *ThisArg,
   if (!Function->isVariadic() && Args.size() < Function->getNumParams()) {
 for (unsigned i = Args.size(), e = Function->getNumParams(); i != e; ++i) {
   ParmVarDecl *P = Function->getParamDecl(i);
-  Expr *DefArg = P->hasUninstantiatedDefaultArg()
- ? P->getUninstantiatedDefaultArg()
- : P->getDefaultArg();
-  // This can only happen in code completion, i.e. when PartialOverloading
-  // is true.
-  if (!DefArg)
-return false;
-  ExprResult R =
-  S.PerformCopyInitialization(InitializedEntity::InitializeParameter(
-  S.Context, 
Function->getParamDecl(i)),
-  SourceLocation(), DefArg);
+  ExprResult R = S.BuildCXXDefaultArgExpr(CallLoc, Function, P);
   if (R.isInvalid())
 return false;
   ConvertedArgs.push_back(R.get());
@@ -6533,7 +6523,9 @@ convertArgsForAvailabilityChecks(Sema , FunctionDecl 
*Function, Expr *ThisArg,
   return true;
 }
 
-EnableIfAttr *Sema::CheckEnableIf(FunctionDecl *Function, ArrayRef 
Args,
+EnableIfAttr *Sema::CheckEnableIf(FunctionDecl *Function,
+  SourceLocation CallLoc,
+  ArrayRef Args,

[PATCH] D76793: [Matrix] Implement + and - operators for MatrixType.

2020-05-28 Thread Florian Hahn via Phabricator via cfe-commits
fhahn updated this revision to Diff 267061.
fhahn marked 7 inline comments as done.
fhahn added a comment.

Updated tests to use more targeted checks, fix typo and rebased on top of 
master (so this change can be applied before D76791 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76793

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CodeGen/matrix-type-operators.c
  clang/test/CodeGenCXX/matrix-type-operators.cpp
  clang/test/Sema/matrix-type-operators.c
  clang/test/SemaCXX/matrix-type-operators.cpp
  llvm/include/llvm/IR/MatrixBuilder.h

Index: llvm/include/llvm/IR/MatrixBuilder.h
===
--- llvm/include/llvm/IR/MatrixBuilder.h
+++ llvm/include/llvm/IR/MatrixBuilder.h
@@ -127,6 +127,16 @@
   /// Add matrixes \p LHS and \p RHS. Support both integer and floating point
   /// matrixes.
   Value *CreateAdd(Value *LHS, Value *RHS) {
+assert(LHS->getType()->isVectorTy() || RHS->getType()->isVectorTy());
+if (LHS->getType()->isVectorTy() && !RHS->getType()->isVectorTy())
+  RHS = B.CreateVectorSplat(
+  cast(LHS->getType())->getNumElements(), RHS,
+  "scalar.splat");
+else if (!LHS->getType()->isVectorTy() && RHS->getType()->isVectorTy())
+  LHS = B.CreateVectorSplat(
+  cast(RHS->getType())->getNumElements(), LHS,
+  "scalar.splat");
+
 return cast(LHS->getType())
->getElementType()
->isFloatingPointTy()
@@ -137,6 +147,16 @@
   /// Subtract matrixes \p LHS and \p RHS. Support both integer and floating
   /// point matrixes.
   Value *CreateSub(Value *LHS, Value *RHS) {
+assert(LHS->getType()->isVectorTy() || RHS->getType()->isVectorTy());
+if (LHS->getType()->isVectorTy() && !RHS->getType()->isVectorTy())
+  RHS = B.CreateVectorSplat(
+  cast(LHS->getType())->getNumElements(), RHS,
+  "scalar.splat");
+else if (!LHS->getType()->isVectorTy() && RHS->getType()->isVectorTy())
+  LHS = B.CreateVectorSplat(
+  cast(RHS->getType())->getNumElements(), LHS,
+  "scalar.splat");
+
 return cast(LHS->getType())
->getElementType()
->isFloatingPointTy()
Index: clang/test/SemaCXX/matrix-type-operators.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/matrix-type-operators.cpp
@@ -0,0 +1,93 @@
+// RUN: %clang_cc1 %s -fenable-matrix -pedantic -std=c++11 -verify -triple=x86_64-apple-darwin9
+
+typedef float sx5x10_t __attribute__((matrix_type(5, 10)));
+
+template 
+struct MyMatrix {
+  using matrix_t = EltTy __attribute__((matrix_type(Rows, Columns)));
+
+  matrix_t value;
+};
+
+template 
+typename MyMatrix::matrix_t add(MyMatrix , MyMatrix ) {
+  char *v1 = A.value + B.value;
+  // expected-error@-1 {{cannot initialize a variable of type 'char *' with an rvalue of type 'MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(2, 2)))')}}
+  // expected-error@-2 {{invalid operands to binary expression ('MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(3, 3)))') and 'MyMatrix::matrix_t' (aka 'float __attribute__((matrix_type(2, 2)))'))}}
+  // expected-error@-3 {{invalid operands to binary expression ('MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(2, 2)))') and 'MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(3, 3)))'))}}
+
+  return A.value + B.value;
+  // expected-error@-1 {{invalid operands to binary expression ('MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(3, 3)))') and 'MyMatrix::matrix_t' (aka 'float __attribute__((matrix_type(2, 2)))'))}}
+  // expected-error@-2 {{invalid operands to binary expression ('MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(2, 2)))') and 'MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(3, 3)))'))}}
+}
+
+void test_add_template(unsigned *Ptr1, float *Ptr2) {
+  MyMatrix Mat1;
+  MyMatrix Mat2;
+  MyMatrix Mat3;
+  Mat1.value = *((decltype(Mat1)::matrix_t *)Ptr1);
+  unsigned v1 = add(Mat1, Mat1);
+  // expected-error@-1 {{cannot initialize a variable of type 'unsigned int' with an rvalue of type 'typename MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(2, 2)))')}}
+  // expected-note@-2 {{in instantiation of function template specialization 'add' requested here}}
+
+  Mat1.value = add(Mat1, Mat2);
+  // expected-note@-1 {{in instantiation of function template specialization 'add' requested here}}
+
+  Mat1.value = add(Mat2, Mat3);
+  // expected-note@-1 {{in instantiation of function template specialization 'add' requested here}}
+}
+
+template 
+typename MyMatrix::matrix_t subtract(MyMatrix 

[PATCH] D76793: [Matrix] Implement + and - operators for MatrixType.

2020-05-28 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:12112
+return InvalidOperands(Loc, OriginalLHS, OriginalRHS);
+  }
+

rjmccall wrote:
> You need to not actually apply this conversion to the LHS if this is a 
> compound assignment.  You can handle that in a follow-up patch, I think, 
> since this patch isn't doing those yet.
I am planning on adding support for compound assignment as follow-on patch and 
include the change there.



Comment at: clang/test/CodeGenCXX/matrix-type-operators.cpp:374
+  // CHECK-NEXT:%1 = bitcast [90 x double]* %value to <90 x double>*
+  // CHECK-NEXT:%2 = load <90 x double>, <90 x double>* %1, align 8
+  // CHECK-NEXT:%call = call double 
@_ZN14DoubleWrapper1cvdEv(%struct.DoubleWrapper1* %w1)

rjmccall wrote:
> Please don't test for exact value numbers; it makes updating the test really 
> painful for relatively minor IR changes.  Use FileCheck variables instead.
> 
> More generally, can you make these tests a little more targeted instead of 
> testing the entire function body?  You might find it easier to do so if you 
> do a single operation per function.
I've split up the tests more and updated the check lines to only check the bits 
relevant for the operator (loading operands, computation, storing result). The 
general matrix-type tests should cover checking loading the correct value. Was 
that what you had in mind?



Comment at: clang/test/SemaCXX/matrix-type-operators.cpp:188
+// expected-note@-3 {{candidate function}}
+// expected-note@-4 {{candidate function}}
+return {};

rjmccall wrote:
> `expected-note` can take a repeat count
Ah that's great, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76793



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


[PATCH] D80753: [clang-tidy] remove duplicate fixes of alias checkers

2020-05-28 Thread Daniel via Phabricator via cfe-commits
Daniel599 updated this revision to Diff 267058.
Daniel599 marked an inline comment as not done.

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

https://reviews.llvm.org/D80753

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
  
clang-tools-extra/test/clang-tidy/infrastructure/duplicate-fixes-of-alias-checkers.cpp

Index: clang-tools-extra/test/clang-tidy/infrastructure/duplicate-fixes-of-alias-checkers.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/infrastructure/duplicate-fixes-of-alias-checkers.cpp
@@ -0,0 +1,52 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-member-init,hicpp-member-init,modernize-use-emplace,hicpp-use-emplace %t
+
+namespace std {
+template 
+class initializer_list {
+public:
+  initializer_list() noexcept {}
+};
+
+template 
+class vector {
+public:
+  vector() = default;
+  vector(initializer_list) {}
+
+  void push_back(const T &) {}
+  void push_back(T &&) {}
+
+  template 
+  void emplace_back(Args &&... args){};
+  ~vector();
+};
+} // namespace std
+
+class Foo {
+public:
+  Foo() : _num1(0)
+  // CHECK-MESSAGES: warning: constructor does not initialize these fields: _num2 [cppcoreguidelines-pro-type-member-init]
+  // CHECK-MESSAGES: warning: constructor does not initialize these fields: _num2 [hicpp-member-init]
+  // CHECK-MESSAGES: note: this fix will not be applied because an alias checker has already provided it, see 'cppcoreguidelines-pro-type-member-init'
+  {
+_num1 = 10;
+  }
+
+  int use_the_members() const {
+return _num1 + _num2;
+  }
+
+private:
+  int _num1;
+  int _num2;
+  // CHECK-FIXES: _num2{};
+};
+
+int should_use_emplace(std::vector ) {
+  v.push_back(Foo());
+  // CHECK-FIXES: v.emplace_back();
+  // CHECK-MESSAGES: warning: use emplace_back instead of push_back [hicpp-use-emplace]
+  // CHECK-MESSAGES: warning: use emplace_back instead of push_back [modernize-use-emplace]
+  // CHECK-MESSAGES: note: this fix will not be applied because an alias checker has already provided it, see 'hicpp-use-emplace'
+}
+
Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -246,6 +246,7 @@
 private:
   void finalizeLastError();
   void removeIncompatibleErrors();
+  void removeDuplicatedFixesOfAliasCheckers();
 
   /// Returns the \c HeaderFilter constructed for the options set in the
   /// context.
Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -634,6 +634,8 @@
 std::tuple Priority;
   };
 
+  removeDuplicatedFixesOfAliasCheckers();
+
   // Compute error sizes.
   std::vector Sizes;
   std::vector<
@@ -728,3 +730,36 @@
 removeIncompatibleErrors();
   return std::move(Errors);
 }
+
+namespace {
+struct LessClangTidyErrorWithoutDiagnosticName {
+  bool operator()(const ClangTidyError *LHS, const ClangTidyError *RHS) const {
+const tooling::DiagnosticMessage  = LHS->Message;
+const tooling::DiagnosticMessage  = RHS->Message;
+
+return std::tie(M1.FilePath, M1.FileOffset, M1.Message) <
+   std::tie(M2.FilePath, M2.FileOffset, M2.Message);
+  }
+};
+} // end anonymous namespace
+
+void ClangTidyDiagnosticConsumer::removeDuplicatedFixesOfAliasCheckers() {
+  using UniqueErrorSet =
+  std::set;
+  UniqueErrorSet UniqueErrors;
+  for (auto  : Errors) {
+std::pair Inserted =
+UniqueErrors.insert();
+
+// If we already have an error like this, just with the different
+// DiagnosticName, remove its Fix since we don't need same fix twice
+if (!Inserted.second && !Error.Message.Fix.empty()) {
+  Error.Message.Fix.clear();
+  std::string FixAlreadyExists =
+  "this fix will not be applied because an alias checker has already "
+  "provided it, see '" +
+  (*Inserted.first)->DiagnosticName + "'";
+  Error.Notes.emplace_back(std::move(FixAlreadyExists));
+}
+  }
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80753: [clang-tidy] remove duplicate fixes of alias checkers

2020-05-28 Thread Daniel via Phabricator via cfe-commits
Daniel599 marked 4 inline comments as done.
Daniel599 added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/infrastructure/duplicate-fixes-of-alias-checkers.cpp:3
+
+#include 
+namespace std {

Eugene.Zelenko wrote:
> cstdio. Please also separate with newline.
I wanted to use cstdio but the test fails with 'file not found', don't know if 
it's specific on my host, anyway I`ll remove this include (and the printf)


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

https://reviews.llvm.org/D80753



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


[PATCH] D80153: [AST] Mangle LambdaContextDecl for top level decl

2020-05-28 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 267057.
zequanwu added a comment.

Don't mangle `ParmVarDecl`.


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

https://reviews.llvm.org/D80153

Files:
  clang/lib/AST/MicrosoftMangle.cpp
  clang/test/CodeGenCXX/mangle-ms-cxx17.cpp


Index: clang/test/CodeGenCXX/mangle-ms-cxx17.cpp
===
--- clang/test/CodeGenCXX/mangle-ms-cxx17.cpp
+++ clang/test/CodeGenCXX/mangle-ms-cxx17.cpp
@@ -19,3 +19,11 @@
 
 // CHECK-DAG: "?$S4@@3US@@B"
 const auto [x2, y2] = f();
+
+// CHECK-DAG: "?i1@@3V@0@B"
+inline const auto i1 = [](auto x) { return 0; };
+// CHECK-DAG: "?i2@@3V@0@B"
+inline const auto i2 = [](auto x) { return 1; };
+// CHECK-DAG: "??$?RH@@i1@@QBE?A?@@H@Z"
+// CHECK-DAG: "??$?RH@@i2@@QBE?A?@@H@Z"
+int g() {return i1(1) + i2(1); }
Index: clang/lib/AST/MicrosoftMangle.cpp
===
--- clang/lib/AST/MicrosoftMangle.cpp
+++ clang/lib/AST/MicrosoftMangle.cpp
@@ -947,12 +947,12 @@
 
   mangleSourceName(Name);
 
-  // If the context of a closure type is an initializer for a class
-  // member (static or nonstatic), it is encoded in a qualified name.
+  // If the context is a variable or a class member and not a 
parameter,
+  // it is encoded in a qualified name.
   if (LambdaManglingNumber && LambdaContextDecl) {
 if ((isa(LambdaContextDecl) ||
  isa(LambdaContextDecl)) &&
-LambdaContextDecl->getDeclContext()->isRecord()) {
+!isa(LambdaContextDecl)) {
   mangleUnqualifiedName(cast(LambdaContextDecl));
 }
   }


Index: clang/test/CodeGenCXX/mangle-ms-cxx17.cpp
===
--- clang/test/CodeGenCXX/mangle-ms-cxx17.cpp
+++ clang/test/CodeGenCXX/mangle-ms-cxx17.cpp
@@ -19,3 +19,11 @@
 
 // CHECK-DAG: "?$S4@@3US@@B"
 const auto [x2, y2] = f();
+
+// CHECK-DAG: "?i1@@3V@0@B"
+inline const auto i1 = [](auto x) { return 0; };
+// CHECK-DAG: "?i2@@3V@0@B"
+inline const auto i2 = [](auto x) { return 1; };
+// CHECK-DAG: "??$?RH@@i1@@QBE?A?@@H@Z"
+// CHECK-DAG: "??$?RH@@i2@@QBE?A?@@H@Z"
+int g() {return i1(1) + i2(1); }
Index: clang/lib/AST/MicrosoftMangle.cpp
===
--- clang/lib/AST/MicrosoftMangle.cpp
+++ clang/lib/AST/MicrosoftMangle.cpp
@@ -947,12 +947,12 @@
 
   mangleSourceName(Name);
 
-  // If the context of a closure type is an initializer for a class
-  // member (static or nonstatic), it is encoded in a qualified name.
+  // If the context is a variable or a class member and not a parameter,
+  // it is encoded in a qualified name.
   if (LambdaManglingNumber && LambdaContextDecl) {
 if ((isa(LambdaContextDecl) ||
  isa(LambdaContextDecl)) &&
-LambdaContextDecl->getDeclContext()->isRecord()) {
+!isa(LambdaContextDecl)) {
   mangleUnqualifiedName(cast(LambdaContextDecl));
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80753: [clang-tidy] remove duplicate fixes of alias checkers

2020-05-28 Thread Daniel via Phabricator via cfe-commits
Daniel599 updated this revision to Diff 267056.
Daniel599 marked an inline comment as done.

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

https://reviews.llvm.org/D80753

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
  
clang-tools-extra/test/clang-tidy/infrastructure/duplicate-fixes-of-alias-checkers.cpp

Index: clang-tools-extra/test/clang-tidy/infrastructure/duplicate-fixes-of-alias-checkers.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/infrastructure/duplicate-fixes-of-alias-checkers.cpp
@@ -0,0 +1,51 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-member-init,hicpp-member-init,modernize-use-emplace,hicpp-use-emplace %t
+
+namespace std {
+template 
+class initializer_list {
+public:
+  initializer_list() noexcept {}
+};
+
+template 
+class vector {
+public:
+  vector() = default;
+  vector(initializer_list) {}
+
+  void push_back(const T &) {}
+  void push_back(T &&) {}
+
+  template 
+  void emplace_back(Args &&... args){};
+  ~vector();
+};
+} // namespace std
+
+class Foo {
+public:
+  Foo() : _num1(0)
+  // CHECK-MESSAGES: warning: constructor does not initialize these fields: _num2 [cppcoreguidelines-pro-type-member-init]
+  // CHECK-MESSAGES: warning: constructor does not initialize these fields: _num2 [hicpp-member-init]
+  // CHECK-MESSAGES: note: this fix will not be applied because an alias checker has already provided it, see 'cppcoreguidelines-pro-type-member-init'
+  {
+_num1 = 10;
+  }
+
+  int use_the_members() const {
+return _num1 + _num2;
+  }
+
+private:
+  int _num1;
+  int _num2;
+  // CHECK-FIXES: _num2{};
+};
+
+int should_use_emplace(std::vector ) {
+  v.push_back(Foo());
+  // CHECK-FIXES: v.emplace_back();
+  // CHECK-MESSAGES: warning: use emplace_back instead of push_back [hicpp-use-emplace]
+  // CHECK-MESSAGES: warning: use emplace_back instead of push_back [modernize-use-emplace]
+  // CHECK-MESSAGES: note: this fix will not be applied because an alias checker has already provided it, see 'hicpp-use-emplace'
+}
Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -246,6 +246,7 @@
 private:
   void finalizeLastError();
   void removeIncompatibleErrors();
+  void removeDuplicatedFixesOfAliasCheckers();
 
   /// Returns the \c HeaderFilter constructed for the options set in the
   /// context.
Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -634,6 +634,8 @@
 std::tuple Priority;
   };
 
+  removeDuplicatedFixesOfAliasCheckers();
+
   // Compute error sizes.
   std::vector Sizes;
   std::vector<
@@ -728,3 +730,36 @@
 removeIncompatibleErrors();
   return std::move(Errors);
 }
+
+namespace {
+struct LessClangTidyErrorWithoutDiagnosticName {
+  bool operator()(const ClangTidyError *LHS, const ClangTidyError *RHS) const {
+const tooling::DiagnosticMessage  = LHS->Message;
+const tooling::DiagnosticMessage  = RHS->Message;
+
+return std::tie(M1.FilePath, M1.FileOffset, M1.Message) <
+   std::tie(M2.FilePath, M2.FileOffset, M2.Message);
+  }
+};
+} // end anonymous namespace
+
+void ClangTidyDiagnosticConsumer::removeDuplicatedFixesOfAliasCheckers() {
+  using UniqueErrorSet =
+  std::set;
+  UniqueErrorSet UniqueErrors;
+  for (auto  : Errors) {
+std::pair Inserted =
+UniqueErrors.insert();
+
+// If we already have an error like this, just with the different
+// DiagnosticName, remove its Fix since we don't need same fix twice
+if (!Inserted.second && !Error.Message.Fix.empty()) {
+  Error.Message.Fix.clear();
+  std::string FixAlreadyExists =
+  "this fix will not be applied because an alias checker has already "
+  "provided it, see '" +
+  (*Inserted.first)->DiagnosticName + "'";
+  Error.Notes.emplace_back(std::move(FixAlreadyExists));
+}
+  }
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80757: [PowerPC] Add clang option -m[no-]pcrel

2020-05-28 Thread Victor Huang via Phabricator via cfe-commits
NeHuang accepted this revision as: NeHuang.
NeHuang added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80757



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


[PATCH] D79995: [clang] [MinGW] Fix libunwind extension

2020-05-28 Thread Mateusz Mikuła via Phabricator via cfe-commits
mati865 added a comment.

No worries.
Mateusz Mikuła 


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

https://reviews.llvm.org/D79995



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


[PATCH] D80753: [clang-tidy] remove duplicate fixes of alias checkers

2020-05-28 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

It may be worth verifying that the fix-its are identical too, multiple versions 
of a check could be running with differing options resulting in different 
fix-its generated, in that case we should let clang-tidy disable any 
conflicting fixes for us.
Side note would it not be nicer to just group the diagnostics into one, 
thinking either of these ways

  CHECK-MESSAGES: warning: use emplace_back instead of push_back 
[hicpp-use-emplace, modernize-use-emplace]
  CHECK-MESSAGES: warning: use emplace_back instead of push_back 
[hicpp-use-emplace] [modernize-use-emplace]

This would result in cleaner diagnostics emitted and remove the need for that 
note.




Comment at: 
clang-tools-extra/test/clang-tidy/infrastructure/duplicate-fixes-of-alias-checkers.cpp:53
+}
\ No newline at end of file


Eugene.Zelenko wrote:
> Please add newline.
New line


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

https://reviews.llvm.org/D80753



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


[PATCH] D80627: [clang-format] Create a python documentation tool to generate a summary of the clang-format status for the whole of the LLVM project

2020-05-28 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius requested changes to this revision.
curdeius added a comment.
This revision now requires changes to proceed.

First of all, very nice idea. :)
Second, could you please make sure that the script is compatible with Python 3?
Also, in order to clean up a bit the generation of the RST (to avoid the 
repetition of all this `output.write()` stuff), you can use multiline strings 
`"""`, or in general, take inspiration from e.g. 
https://github.com/llvm/llvm-project/blob/master/libcxx/utils/generate_feature_test_macro_components.py#L720.
Lastly, it would be nice to add last update date somewhere.


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

https://reviews.llvm.org/D80627



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


[PATCH] D80692: Run Coverage pass before other *San passes under new pass manager, round 2

2020-05-28 Thread Arthur Eubanks via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG922fa2fce38b: Run Coverage pass before other *San passes 
under new pass manager, round 2 (authored by aeubanks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80692

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/tools/opt/NewPMDriver.cpp

Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -194,7 +194,7 @@
 });
   if (tryParsePipelineText(PB, OptimizerLastEPPipeline))
 PB.registerOptimizerLastEPCallback(
-[, VerifyEachPass, DebugLogging](FunctionPassManager ,
+[, VerifyEachPass, DebugLogging](ModulePassManager ,
 PassBuilder::OptimizationLevel) {
   ExitOnError Err("Unable to parse OptimizerLastEP pipeline: ");
   Err(PB.parsePassPipeline(PM, OptimizerLastEPPipeline, VerifyEachPass,
Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -1073,12 +1073,12 @@
   if (PTO.Coroutines)
 OptimizePM.addPass(CoroCleanupPass());
 
-  for (auto  : OptimizerLastEPCallbacks)
-C(OptimizePM, Level);
-
   // Add the core optimizing pipeline.
   MPM.addPass(createModuleToFunctionPassAdaptor(std::move(OptimizePM)));
 
+  for (auto  : OptimizerLastEPCallbacks)
+C(MPM, Level);
+
   if (PTO.CallGraphProfile)
 MPM.addPass(CGProfilePass());
 
Index: llvm/include/llvm/Passes/PassBuilder.h
===
--- llvm/include/llvm/Passes/PassBuilder.h
+++ llvm/include/llvm/Passes/PassBuilder.h
@@ -600,7 +600,7 @@
   /// is not triggered at O0. Extensions to the O0 pipeline should append their
   /// passes to the end of the overall pipeline.
   void registerOptimizerLastEPCallback(
-  const std::function ) {
+  const std::function ) {
 OptimizerLastEPCallbacks.push_back(C);
   }
 
@@ -728,7 +728,7 @@
   CGSCCOptimizerLateEPCallbacks;
   SmallVector, 2>
   VectorizerStartEPCallbacks;
-  SmallVector, 2>
+  SmallVector, 2>
   OptimizerLastEPCallbacks;
   // Module callbacks
   SmallVector, 2>
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -32,6 +32,7 @@
 #include "llvm/IR/LegacyPassManager.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/ModuleSummaryIndex.h"
+#include "llvm/IR/PassManager.h"
 #include "llvm/IR/Verifier.h"
 #include "llvm/LTO/LTOBackend.h"
 #include "llvm/MC/MCAsmInfo.h"
@@ -1001,6 +1002,15 @@
   const Triple ,
   const LangOptions ,
   const CodeGenOptions ) {
+  if (CodeGenOpts.SanitizeCoverageType ||
+  CodeGenOpts.SanitizeCoverageIndirectCalls ||
+  CodeGenOpts.SanitizeCoverageTraceCmp) {
+auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
+MPM.addPass(ModuleSanitizerCoveragePass(
+SancovOpts, CodeGenOpts.SanitizeCoverageWhitelistFiles,
+CodeGenOpts.SanitizeCoverageBlacklistFiles));
+  }
+
   auto ASanPass = [&](SanitizerMask Mask, bool CompileKernel) {
 MPM.addPass(RequireAnalysisPass());
 bool Recover = CodeGenOpts.SanitizeRecover.has(Mask);
@@ -1249,6 +1259,20 @@
 [](FunctionPassManager , PassBuilder::OptimizationLevel Level) {
   FPM.addPass(BoundsCheckingPass());
 });
+
+  if (CodeGenOpts.SanitizeCoverageType ||
+  CodeGenOpts.SanitizeCoverageIndirectCalls ||
+  CodeGenOpts.SanitizeCoverageTraceCmp) {
+PB.registerOptimizerLastEPCallback(
+[this](ModulePassManager ,
+   PassBuilder::OptimizationLevel Level) {
+  auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
+  MPM.addPass(ModuleSanitizerCoveragePass(
+  SancovOpts, CodeGenOpts.SanitizeCoverageWhitelistFiles,
+  CodeGenOpts.SanitizeCoverageBlacklistFiles));
+});
+  }
+
   if (LangOpts.Sanitize.has(SanitizerKind::Memory)) {
 int TrackOrigins = CodeGenOpts.SanitizeMemoryTrackOrigins;
 bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::Memory);
@@ -1257,17 +1281,19 @@
   MPM.addPass(MemorySanitizerPass({TrackOrigins, Recover, false}));
 });
 PB.registerOptimizerLastEPCallback(
-[TrackOrigins, Recover](FunctionPassManager ,
+[TrackOrigins, Recover](ModulePassManager ,
 PassBuilder::OptimizationLevel Level) {
-  

[PATCH] D79995: [clang] [MinGW] Fix libunwind extension

2020-05-28 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo accepted this revision.
mstorsjo added a comment.
This revision is now accepted and ready to land.

LGTM now - thanks! What's your preferred git author line for this project? I 
can probably push it tomorrow.


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

https://reviews.llvm.org/D79995



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


[clang] e3fb844 - Revert "Run Coverage pass before other *San passes under new pass manager, round 2"

2020-05-28 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2020-05-28T14:38:05-07:00
New Revision: e3fb8446f2ec3953348f3c773004cf2aa28a8c04

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

LOG: Revert "Run Coverage pass before other *San passes under new pass manager, 
round 2"

This reverts commit 922fa2fce38b0bd97921b91ff1cdc57f18d3569c.

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp
llvm/include/llvm/Passes/PassBuilder.h
llvm/lib/Passes/PassBuilder.cpp
llvm/tools/opt/NewPMDriver.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index dd5016333920..e746aef1a62f 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -32,7 +32,6 @@
 #include "llvm/IR/LegacyPassManager.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/ModuleSummaryIndex.h"
-#include "llvm/IR/PassManager.h"
 #include "llvm/IR/Verifier.h"
 #include "llvm/LTO/LTOBackend.h"
 #include "llvm/MC/MCAsmInfo.h"
@@ -1002,15 +1001,6 @@ static void addSanitizersAtO0(ModulePassManager ,
   const Triple ,
   const LangOptions ,
   const CodeGenOptions ) {
-  if (CodeGenOpts.SanitizeCoverageType ||
-  CodeGenOpts.SanitizeCoverageIndirectCalls ||
-  CodeGenOpts.SanitizeCoverageTraceCmp) {
-auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
-MPM.addPass(ModuleSanitizerCoveragePass(
-SancovOpts, CodeGenOpts.SanitizeCoverageWhitelistFiles,
-CodeGenOpts.SanitizeCoverageBlacklistFiles));
-  }
-
   auto ASanPass = [&](SanitizerMask Mask, bool CompileKernel) {
 MPM.addPass(RequireAnalysisPass());
 bool Recover = CodeGenOpts.SanitizeRecover.has(Mask);
@@ -1259,20 +1249,6 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
 [](FunctionPassManager , PassBuilder::OptimizationLevel Level) 
{
   FPM.addPass(BoundsCheckingPass());
 });
-
-  if (CodeGenOpts.SanitizeCoverageType ||
-  CodeGenOpts.SanitizeCoverageIndirectCalls ||
-  CodeGenOpts.SanitizeCoverageTraceCmp) {
-PB.registerOptimizerLastEPCallback(
-[this](ModulePassManager ,
-   PassBuilder::OptimizationLevel Level) {
-  auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
-  MPM.addPass(ModuleSanitizerCoveragePass(
-  SancovOpts, CodeGenOpts.SanitizeCoverageWhitelistFiles,
-  CodeGenOpts.SanitizeCoverageBlacklistFiles));
-});
-  }
-
   if (LangOpts.Sanitize.has(SanitizerKind::Memory)) {
 int TrackOrigins = CodeGenOpts.SanitizeMemoryTrackOrigins;
 bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::Memory);
@@ -1281,19 +1257,17 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
   MPM.addPass(MemorySanitizerPass({TrackOrigins, Recover, false}));
 });
 PB.registerOptimizerLastEPCallback(
-[TrackOrigins, Recover](ModulePassManager ,
+[TrackOrigins, Recover](FunctionPassManager ,
 PassBuilder::OptimizationLevel Level) {
-  MPM.addPass(createModuleToFunctionPassAdaptor(
-  MemorySanitizerPass({TrackOrigins, Recover, false})));
+  FPM.addPass(MemorySanitizerPass({TrackOrigins, Recover, false}));
 });
   }
   if (LangOpts.Sanitize.has(SanitizerKind::Thread)) {
 PB.registerPipelineStartEPCallback(
 [](ModulePassManager ) { MPM.addPass(ThreadSanitizerPass()); 
});
 PB.registerOptimizerLastEPCallback(
-[](ModulePassManager , PassBuilder::OptimizationLevel Level) {
-  MPM.addPass(
-  createModuleToFunctionPassAdaptor(ThreadSanitizerPass()));
+[](FunctionPassManager , PassBuilder::OptimizationLevel Level) 
{
+  FPM.addPass(ThreadSanitizerPass());
 });
   }
   if (LangOpts.Sanitize.has(SanitizerKind::Address)) {
@@ -1304,11 +1278,10 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
 bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::Address);
 bool UseAfterScope = CodeGenOpts.SanitizeAddressUseAfterScope;
 PB.registerOptimizerLastEPCallback(
-[Recover, UseAfterScope](ModulePassManager ,
+[Recover, UseAfterScope](FunctionPassManager ,
  PassBuilder::OptimizationLevel Level) {
-  MPM.addPass(
-  createModuleToFunctionPassAdaptor(AddressSanitizerPass(
-  /*CompileKernel=*/false, Recover, UseAfterScope)));
+  FPM.addPass(AddressSanitizerPass(
+  

[clang] 922fa2f - Run Coverage pass before other *San passes under new pass manager, round 2

2020-05-28 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2020-05-28T14:25:23-07:00
New Revision: 922fa2fce38b0bd97921b91ff1cdc57f18d3569c

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

LOG: Run Coverage pass before other *San passes under new pass manager, round 2

Summary:
This was attempted once before in https://reviews.llvm.org/D79698, but
was reverted due to the coverage pass running in the wrong part of the
pipeline. This commit puts it in the same place as the other sanitizers.

This changes PassBuilder.OptimizerLastEPCallbacks to work on a
ModulePassManager instead of a FunctionPassManager. That is because
SanitizerCoverage cannot (easily) be split into a module pass and a
function pass like some of the other sanitizers since in its current
implementation it conditionally inserts module constructors based on
whether or not it successfully modified functions.

This fixes compiler-rt/test/msan/coverage-levels.cpp under the new pass
manager (last check-msan test).

Subscribers: hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp
llvm/include/llvm/Passes/PassBuilder.h
llvm/lib/Passes/PassBuilder.cpp
llvm/tools/opt/NewPMDriver.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index e746aef1a62f..dd5016333920 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -32,6 +32,7 @@
 #include "llvm/IR/LegacyPassManager.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/ModuleSummaryIndex.h"
+#include "llvm/IR/PassManager.h"
 #include "llvm/IR/Verifier.h"
 #include "llvm/LTO/LTOBackend.h"
 #include "llvm/MC/MCAsmInfo.h"
@@ -1001,6 +1002,15 @@ static void addSanitizersAtO0(ModulePassManager ,
   const Triple ,
   const LangOptions ,
   const CodeGenOptions ) {
+  if (CodeGenOpts.SanitizeCoverageType ||
+  CodeGenOpts.SanitizeCoverageIndirectCalls ||
+  CodeGenOpts.SanitizeCoverageTraceCmp) {
+auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
+MPM.addPass(ModuleSanitizerCoveragePass(
+SancovOpts, CodeGenOpts.SanitizeCoverageWhitelistFiles,
+CodeGenOpts.SanitizeCoverageBlacklistFiles));
+  }
+
   auto ASanPass = [&](SanitizerMask Mask, bool CompileKernel) {
 MPM.addPass(RequireAnalysisPass());
 bool Recover = CodeGenOpts.SanitizeRecover.has(Mask);
@@ -1249,6 +1259,20 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
 [](FunctionPassManager , PassBuilder::OptimizationLevel Level) 
{
   FPM.addPass(BoundsCheckingPass());
 });
+
+  if (CodeGenOpts.SanitizeCoverageType ||
+  CodeGenOpts.SanitizeCoverageIndirectCalls ||
+  CodeGenOpts.SanitizeCoverageTraceCmp) {
+PB.registerOptimizerLastEPCallback(
+[this](ModulePassManager ,
+   PassBuilder::OptimizationLevel Level) {
+  auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
+  MPM.addPass(ModuleSanitizerCoveragePass(
+  SancovOpts, CodeGenOpts.SanitizeCoverageWhitelistFiles,
+  CodeGenOpts.SanitizeCoverageBlacklistFiles));
+});
+  }
+
   if (LangOpts.Sanitize.has(SanitizerKind::Memory)) {
 int TrackOrigins = CodeGenOpts.SanitizeMemoryTrackOrigins;
 bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::Memory);
@@ -1257,17 +1281,19 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
   MPM.addPass(MemorySanitizerPass({TrackOrigins, Recover, false}));
 });
 PB.registerOptimizerLastEPCallback(
-[TrackOrigins, Recover](FunctionPassManager ,
+[TrackOrigins, Recover](ModulePassManager ,
 PassBuilder::OptimizationLevel Level) {
-  FPM.addPass(MemorySanitizerPass({TrackOrigins, Recover, false}));
+  MPM.addPass(createModuleToFunctionPassAdaptor(
+  MemorySanitizerPass({TrackOrigins, Recover, false})));
 });
   }
   if (LangOpts.Sanitize.has(SanitizerKind::Thread)) {
 PB.registerPipelineStartEPCallback(
 [](ModulePassManager ) { MPM.addPass(ThreadSanitizerPass()); 
});
 PB.registerOptimizerLastEPCallback(
-[](FunctionPassManager , PassBuilder::OptimizationLevel Level) 
{
-  FPM.addPass(ThreadSanitizerPass());
+[](ModulePassManager , PassBuilder::OptimizationLevel Level) {
+  MPM.addPass(
+  createModuleToFunctionPassAdaptor(ThreadSanitizerPass()));
 });
   }
   

[PATCH] D80757: [PowerPC] Add clang option -m[no-]pcrel

2020-05-28 Thread Ahsan Saghir via Phabricator via cfe-commits
saghir accepted this revision.
saghir added a comment.
This revision is now accepted and ready to land.

Other than the nit, this looks good to me.




Comment at: clang/test/Driver/ppc-pcrel.cpp:1
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -mcpu=pwr10 -mpcrel 
-o %t.o 2>&1 | FileCheck -check-prefix=CHECK-PCREL %s
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -mcpu=pwr10 
-mno-pcrel -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOPCREL %s

nit: would the first two checks be better off in 
`clang/test/Driver/ppc-features.cpp`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80757



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


[PATCH] D79995: [clang] [MinGW] Fix libunwind extension

2020-05-28 Thread Mateusz Mikuła via Phabricator via cfe-commits
mati865 updated this revision to Diff 267036.

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

https://reviews.llvm.org/D79995

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/compiler-rt-unwind.c


Index: clang/test/Driver/compiler-rt-unwind.c
===
--- clang/test/Driver/compiler-rt-unwind.c
+++ clang/test/Driver/compiler-rt-unwind.c
@@ -48,3 +48,26 @@
 // RUN: --gcc-toolchain="" \
 // RUN: FileCheck --input-file=%t.err 
--check-prefix=RTLIB-GCC-UNWINDLIB-COMPILER_RT %s
 // RTLIB-GCC-UNWINDLIB-COMPILER_RT: "{{[.|\\\n]*}}--rtlib=libgcc requires 
--unwindlib=libgcc"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-w64-mingw32 -rtlib=compiler-rt 
--unwindlib=libunwind \
+// RUN: -shared-libgcc \
+// RUN: --gcc-toolchain="" \
+// RUN:   | FileCheck 
--check-prefix=MINGW-RTLIB-COMPILER-RT-SHARED-UNWINDLIB-COMPILER-RT %s
+// MINGW-RTLIB-COMPILER-RT-SHARED-UNWINDLIB-COMPILER-RT: 
"{{.*}}libclang_rt.builtins-x86_64.a"
+// MINGW-RTLIB-COMPILER-RT-SHARED-UNWINDLIB-COMPILER-RT: 
"{{.*}}l:libunwind.dll.a"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-w64-mingw32 -rtlib=compiler-rt 
--unwindlib=libunwind \
+// RUN: -static-libgcc \
+// RUN: --gcc-toolchain="" \
+// RUN:   | FileCheck 
--check-prefix=MINGW-RTLIB-COMPILER-RT-STATIC-UNWINDLIB-COMPILER-RT %s
+// MINGW-RTLIB-COMPILER-RT-STATIC-UNWINDLIB-COMPILER-RT: 
"{{.*}}libclang_rt.builtins-x86_64.a"
+// MINGW-RTLIB-COMPILER-RT-STATIC-UNWINDLIB-COMPILER-RT: "{{.*}}l:libunwind.a"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-w64-mingw32 -rtlib=compiler-rt 
--unwindlib=libunwind \
+// RUN: --gcc-toolchain="" \
+// RUN:   | FileCheck 
--check-prefix=MINGW-RTLIB-COMPILER-RT-UNWINDLIB-COMPILER-RT %s
+// MINGW-RTLIB-COMPILER-RT-UNWINDLIB-COMPILER-RT: 
"{{.*}}libclang_rt.builtins-x86_64.a"
+// MINGW-RTLIB-COMPILER-RT-UNWINDLIB-COMPILER-RT: "{{.*}}lunwind"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1234,7 +1234,14 @@
   case ToolChain::UNW_CompilerRT:
 if (LGT == LibGccType::StaticLibGcc)
   CmdArgs.push_back("-l:libunwind.a");
-else
+else if (TC.getTriple().isOSCygMing()) {
+  if (LGT == LibGccType::SharedLibGcc)
+CmdArgs.push_back("-l:libunwind.dll.a");
+  else
+// Let the linker choose between libunwind.dll.a and libunwind.a
+// depending on what's available, and depending on the -static flag
+CmdArgs.push_back("-lunwind");
+} else
   CmdArgs.push_back("-l:libunwind.so");
 break;
   }


Index: clang/test/Driver/compiler-rt-unwind.c
===
--- clang/test/Driver/compiler-rt-unwind.c
+++ clang/test/Driver/compiler-rt-unwind.c
@@ -48,3 +48,26 @@
 // RUN: --gcc-toolchain="" \
 // RUN: FileCheck --input-file=%t.err --check-prefix=RTLIB-GCC-UNWINDLIB-COMPILER_RT %s
 // RTLIB-GCC-UNWINDLIB-COMPILER_RT: "{{[.|\\\n]*}}--rtlib=libgcc requires --unwindlib=libgcc"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-w64-mingw32 -rtlib=compiler-rt --unwindlib=libunwind \
+// RUN: -shared-libgcc \
+// RUN: --gcc-toolchain="" \
+// RUN:   | FileCheck --check-prefix=MINGW-RTLIB-COMPILER-RT-SHARED-UNWINDLIB-COMPILER-RT %s
+// MINGW-RTLIB-COMPILER-RT-SHARED-UNWINDLIB-COMPILER-RT: "{{.*}}libclang_rt.builtins-x86_64.a"
+// MINGW-RTLIB-COMPILER-RT-SHARED-UNWINDLIB-COMPILER-RT: "{{.*}}l:libunwind.dll.a"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-w64-mingw32 -rtlib=compiler-rt --unwindlib=libunwind \
+// RUN: -static-libgcc \
+// RUN: --gcc-toolchain="" \
+// RUN:   | FileCheck --check-prefix=MINGW-RTLIB-COMPILER-RT-STATIC-UNWINDLIB-COMPILER-RT %s
+// MINGW-RTLIB-COMPILER-RT-STATIC-UNWINDLIB-COMPILER-RT: "{{.*}}libclang_rt.builtins-x86_64.a"
+// MINGW-RTLIB-COMPILER-RT-STATIC-UNWINDLIB-COMPILER-RT: "{{.*}}l:libunwind.a"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-w64-mingw32 -rtlib=compiler-rt --unwindlib=libunwind \
+// RUN: --gcc-toolchain="" \
+// RUN:   | FileCheck --check-prefix=MINGW-RTLIB-COMPILER-RT-UNWINDLIB-COMPILER-RT %s
+// MINGW-RTLIB-COMPILER-RT-UNWINDLIB-COMPILER-RT: "{{.*}}libclang_rt.builtins-x86_64.a"
+// MINGW-RTLIB-COMPILER-RT-UNWINDLIB-COMPILER-RT: "{{.*}}lunwind"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1234,7 +1234,14 @@
   case ToolChain::UNW_CompilerRT:
 if (LGT == 

[PATCH] D79995: [clang] [MinGW] Fix libunwind extension

2020-05-28 Thread Mateusz Mikuła via Phabricator via cfe-commits
mati865 updated this revision to Diff 267034.
mati865 added a comment.

Added test.


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

https://reviews.llvm.org/D79995

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/compiler-rt-unwind.c


Index: clang/test/Driver/compiler-rt-unwind.c
===
--- clang/test/Driver/compiler-rt-unwind.c
+++ clang/test/Driver/compiler-rt-unwind.c
@@ -48,3 +48,26 @@
 // RUN: --gcc-toolchain="" \
 // RUN: FileCheck --input-file=%t.err 
--check-prefix=RTLIB-GCC-UNWINDLIB-COMPILER_RT %s
 // RTLIB-GCC-UNWINDLIB-COMPILER_RT: "{{[.|\\\n]*}}--rtlib=libgcc requires 
--unwindlib=libgcc"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-w64-mingw32 -rtlib=compiler-rt 
--unwindlib=libunwind \
+// RUN: -shared-libgcc \
+// RUN: --gcc-toolchain="" \
+// RUN:   | FileCheck --check-prefix=RTLIB-COMPILER-RT-SHARED-UNWINDLIB-MINGW 
%s
+// RTLIB-COMPILER-RT-SHARED-UNWINDLIB-MINGW: 
"{{.*}}libclang_rt.builtins-x86_64.a"
+// RTLIB-COMPILER-RT-SHARED-UNWINDLIB-MINGW: "{{.*}}l:libunwind.dll.a"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-w64-mingw32 -rtlib=compiler-rt 
--unwindlib=libunwind \
+// RUN: -static-libgcc \
+// RUN: --gcc-toolchain="" \
+// RUN:   | FileCheck --check-prefix=RTLIB-COMPILER-RT-STATIC-UNWINDLIB-MINGW 
%s
+// RTLIB-COMPILER-RT-STATIC-UNWINDLIB-MINGW: 
"{{.*}}libclang_rt.builtins-x86_64.a"
+// RTLIB-COMPILER-RT-STATIC-UNWINDLIB-MINGW: "{{.*}}l:libunwind.a"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-w64-mingw32 -rtlib=compiler-rt 
--unwindlib=libunwind \
+// RUN: --gcc-toolchain="" \
+// RUN:   | FileCheck --check-prefix=RTLIB-COMPILER-RT-UNWINDLIB-MINGW %s
+// RTLIB-COMPILER-RT-UNWINDLIB-MINGW: "{{.*}}libclang_rt.builtins-x86_64.a"
+// RTLIB-COMPILER-RT-UNWINDLIB-MINGW: "{{.*}}lunwind"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1234,7 +1234,14 @@
   case ToolChain::UNW_CompilerRT:
 if (LGT == LibGccType::StaticLibGcc)
   CmdArgs.push_back("-l:libunwind.a");
-else
+else if (TC.getTriple().isOSCygMing()) {
+  if (LGT == LibGccType::SharedLibGcc)
+CmdArgs.push_back("-l:libunwind.dll.a");
+  else
+// Let the linker choose between libunwind.dll.a and libunwind.a
+// depending on what's available, and depending on the -static flag
+CmdArgs.push_back("-lunwind");
+} else
   CmdArgs.push_back("-l:libunwind.so");
 break;
   }


Index: clang/test/Driver/compiler-rt-unwind.c
===
--- clang/test/Driver/compiler-rt-unwind.c
+++ clang/test/Driver/compiler-rt-unwind.c
@@ -48,3 +48,26 @@
 // RUN: --gcc-toolchain="" \
 // RUN: FileCheck --input-file=%t.err --check-prefix=RTLIB-GCC-UNWINDLIB-COMPILER_RT %s
 // RTLIB-GCC-UNWINDLIB-COMPILER_RT: "{{[.|\\\n]*}}--rtlib=libgcc requires --unwindlib=libgcc"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-w64-mingw32 -rtlib=compiler-rt --unwindlib=libunwind \
+// RUN: -shared-libgcc \
+// RUN: --gcc-toolchain="" \
+// RUN:   | FileCheck --check-prefix=RTLIB-COMPILER-RT-SHARED-UNWINDLIB-MINGW %s
+// RTLIB-COMPILER-RT-SHARED-UNWINDLIB-MINGW: "{{.*}}libclang_rt.builtins-x86_64.a"
+// RTLIB-COMPILER-RT-SHARED-UNWINDLIB-MINGW: "{{.*}}l:libunwind.dll.a"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-w64-mingw32 -rtlib=compiler-rt --unwindlib=libunwind \
+// RUN: -static-libgcc \
+// RUN: --gcc-toolchain="" \
+// RUN:   | FileCheck --check-prefix=RTLIB-COMPILER-RT-STATIC-UNWINDLIB-MINGW %s
+// RTLIB-COMPILER-RT-STATIC-UNWINDLIB-MINGW: "{{.*}}libclang_rt.builtins-x86_64.a"
+// RTLIB-COMPILER-RT-STATIC-UNWINDLIB-MINGW: "{{.*}}l:libunwind.a"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-w64-mingw32 -rtlib=compiler-rt --unwindlib=libunwind \
+// RUN: --gcc-toolchain="" \
+// RUN:   | FileCheck --check-prefix=RTLIB-COMPILER-RT-UNWINDLIB-MINGW %s
+// RTLIB-COMPILER-RT-UNWINDLIB-MINGW: "{{.*}}libclang_rt.builtins-x86_64.a"
+// RTLIB-COMPILER-RT-UNWINDLIB-MINGW: "{{.*}}lunwind"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1234,7 +1234,14 @@
   case ToolChain::UNW_CompilerRT:
 if (LGT == LibGccType::StaticLibGcc)
   CmdArgs.push_back("-l:libunwind.a");
-else
+else if (TC.getTriple().isOSCygMing()) {
+  if (LGT == LibGccType::SharedLibGcc)
+

[PATCH] D80374: [Clang] Enable KF and KC mode for [_Complex] __float128

2020-05-28 Thread Nemanja Ivanovic via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
nemanjai marked an inline comment as done.
Closed by commit rG9021ce9576e4: [Clang] Enable KF and KC mode for [_Complex] 
__float128 (authored by nemanjai).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80374

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Sema/attr-mode.c

Index: clang/test/Sema/attr-mode.c
===
--- clang/test/Sema/attr-mode.c
+++ clang/test/Sema/attr-mode.c
@@ -4,6 +4,8 @@
 // RUN:   -verify %s
 // RUN: %clang_cc1 -triple powerpc64-pc-linux-gnu -DTEST_64BIT_PPC64 -fsyntax-only \
 // RUN:   -verify %s
+// RUN: %clang_cc1 -triple powerpc64-pc-linux-gnu -DTEST_F128_PPC64 -fsyntax-only \
+// RUN:   -verify -target-feature +float128 %s
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnux32 -DTEST_64BIT_X86 -fsyntax-only \
 // RUN:   -verify %s
 // RUN: %clang_cc1 -triple mips-linux-gnu -DTEST_MIPS_32 -fsyntax-only \
@@ -90,6 +92,15 @@
 void f_ft128_complex_arg(_Complex long double *x);
 void test_TFtype(f128ibm *a) { f_ft128_arg (a); }
 void test_TCtype(c128ibm *a) { f_ft128_complex_arg (a); }
+#elif TEST_F128_PPC64
+typedef int invalid_7 __attribute((mode(KF))); // expected-error{{type of machine mode does not match type of base type}}
+typedef int invalid_8 __attribute((mode(KI))); // expected-error{{unknown machine mode}}
+typedef _Complex float cf128 __attribute__((mode(KC)));
+typedef float f128 __attribute__((mode(KF)));
+void f_f128_arg(__float128 *x);
+void f_f128_complex_arg(_Complex __float128 *x);
+void test_KFtype(f128 *a) { f_f128_arg(a); }
+void test_KCtype(cf128 *a) { f_f128_complex_arg(a); }
 #elif TEST_MIPS_32
 typedef unsigned int gcc_unwind_word __attribute__((mode(unwind_word)));
 int foo[sizeof(gcc_unwind_word) == 4 ? 1 : -1];
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -3942,7 +3942,8 @@
 /// parseModeAttrArg - Parses attribute mode string and returns parsed type
 /// attribute.
 static void parseModeAttrArg(Sema , StringRef Str, unsigned ,
- bool , bool ) {
+ bool , bool ,
+ bool ) {
   IntegerMode = true;
   ComplexMode = false;
   switch (Str.size()) {
@@ -3963,7 +3964,12 @@
 case 'X':
   DestWidth = 96;
   break;
+case 'K': // KFmode - IEEE quad precision (__float128)
+  ExplicitIEEE = true;
+  DestWidth = Str[1] == 'I' ? 0 : 128;
+  break;
 case 'T':
+  ExplicitIEEE = false;
   DestWidth = 128;
   break;
 }
@@ -4024,6 +4030,7 @@
   unsigned DestWidth = 0;
   bool IntegerMode = true;
   bool ComplexMode = false;
+  bool ExplicitIEEE = false;
   llvm::APInt VectorSize(64, 0);
   if (Str.size() >= 4 && Str[0] == 'V') {
 // Minimal length of vector mode is 4: 'V' + NUMBER(>=1) + TYPE(>=2).
@@ -4036,7 +4043,7 @@
 !Str.substr(1, VectorStringLength).getAsInteger(10, VectorSize) &&
 VectorSize.isPowerOf2()) {
   parseModeAttrArg(*this, Str.substr(VectorStringLength + 1), DestWidth,
-   IntegerMode, ComplexMode);
+   IntegerMode, ComplexMode, ExplicitIEEE);
   // Avoid duplicate warning from template instantiation.
   if (!InInstantiation)
 Diag(AttrLoc, diag::warn_vector_mode_deprecated);
@@ -4046,7 +4053,8 @@
   }
 
   if (!VectorSize)
-parseModeAttrArg(*this, Str, DestWidth, IntegerMode, ComplexMode);
+parseModeAttrArg(*this, Str, DestWidth, IntegerMode, ComplexMode,
+ ExplicitIEEE);
 
   // FIXME: Sync this with InitializePredefinedMacros; we need to match int8_t
   // and friends, at least with glibc.
@@ -4112,7 +4120,7 @@
 NewElemTy = Context.getIntTypeForBitwidth(DestWidth,
   OldElemTy->isSignedIntegerType());
   else
-NewElemTy = Context.getRealTypeForBitwidth(DestWidth);
+NewElemTy = Context.getRealTypeForBitwidth(DestWidth, ExplicitIEEE);
 
   if (NewElemTy.isNull()) {
 Diag(AttrLoc, diag::err_machine_mode) << 1 /*Unsupported*/ << Name;
Index: clang/lib/Basic/TargetInfo.cpp
===
--- clang/lib/Basic/TargetInfo.cpp
+++ clang/lib/Basic/TargetInfo.cpp
@@ -265,7 +265,8 @@
   return NoInt;
 }
 
-TargetInfo::RealType TargetInfo::getRealTypeByWidth(unsigned BitWidth) const {
+TargetInfo::RealType TargetInfo::getRealTypeByWidth(unsigned BitWidth,
+bool ExplicitIEEE) const {
   if (getFloatWidth() == BitWidth)
 return Float;
   if (getDoubleWidth() == BitWidth)
@@ 

[PATCH] D75414: [clangd] Resolve driver symlinks, and look up unknown relative drivers in PATH.

2020-05-28 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/support/Threading.h:134
 
+// Memoize is a cache to store and reuse computation results based on a key.
+//

nit: triple slashes?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75414



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


[PATCH] D80574: [ExtVector] Support ExtVectorType conditional operator

2020-05-28 Thread Min-Yih Hsu via Phabricator via cfe-commits
myhsu updated this revision to Diff 267027.

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

https://reviews.llvm.org/D80574

Files:
  clang/docs/LanguageExtensions.rst
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/ext_vector_comparisons.c

Index: clang/test/Sema/ext_vector_comparisons.c
===
--- clang/test/Sema/ext_vector_comparisons.c
+++ clang/test/Sema/ext_vector_comparisons.c
@@ -28,3 +28,19 @@
   return vec > vec;  // no-warning
   return vec >= vec; // no-warning
 }
+
+static int4 test3() {
+  int4 i0, i1;
+
+  return i0 > i1 ? i0 : i1; // no-error
+  return i0 ? i0 : i1;  // no-error
+}
+
+static float4 test4() {
+  float4 f0, f1;
+
+  // This would actually generate implicit casting warning
+  // under Weverything flag but we don't really care here
+  return f0 > f1 ? f0 : f1; // no-error
+  return f0 ? f0 : f1;  // expected-error {{arithmetic or pointer type is required}}
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -7480,6 +7480,13 @@
   // C99 6.5.15p2
   if (CondTy->isScalarType()) return false;
 
+  // Only ext vector is allowed
+  if (const auto *VecCondTy = Cond->getType()->getAs()) {
+QualType EleTy = VecCondTy->getElementType();
+if (EleTy->isIntegerType())
+  return false;
+  }
+
   S.Diag(QuestionLoc, diag::err_typecheck_cond_expect_scalar)
 << CondTy << Cond->getSourceRange();
   return true;
@@ -7958,10 +7965,21 @@
 
   // Now check the two expressions.
   if (LHS.get()->getType()->isVectorType() ||
-  RHS.get()->getType()->isVectorType())
-return CheckVectorOperands(LHS, RHS, QuestionLoc, /*isCompAssign*/false,
-   /*AllowBothBool*/true,
-   /*AllowBoolConversions*/false);
+  RHS.get()->getType()->isVectorType()) {
+QualType VecResTy = CheckVectorOperands(LHS, RHS, QuestionLoc,
+/*isCompAssign*/ false,
+/*AllowBothBool*/ true,
+/*AllowBoolConversions*/ false);
+// If the condition is ext vector, we're imposing OpenCL's rule wrt
+// condition and result type.
+QualType CondTy = Cond.get()->getType();
+if (CondTy->isExtVectorType()) {
+  if (VecResTy.isNull() ||
+  checkVectorResult(*this, CondTy, VecResTy, QuestionLoc))
+return QualType();
+}
+return VecResTy;
+  }
 
   QualType ResTy =
   UsualArithmeticConversions(LHS, RHS, QuestionLoc, ACK_Conditional);
Index: clang/lib/CodeGen/CGExprScalar.cpp
===
--- clang/lib/CodeGen/CGExprScalar.cpp
+++ clang/lib/CodeGen/CGExprScalar.cpp
@@ -4431,8 +4431,8 @@
 
   // OpenCL: If the condition is a vector, we can treat this condition like
   // the select function.
-  if (CGF.getLangOpts().OpenCL
-  && condExpr->getType()->isVectorType()) {
+  if ((CGF.getLangOpts().OpenCL && condExpr->getType()->isVectorType()) ||
+  condExpr->getType()->isExtVectorType()) {
 CGF.incrementProfileCounter(E);
 
 llvm::Value *CondV = CGF.EmitScalarExpr(condExpr);
Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -478,7 +478,7 @@
 !, &&, ||yes --yes [#]_--
 ==, !=, >, <, >=, <= yes yes   yes --
 =yes yes   yes yes
-:? [#]_  yes --yes --
+?: [#]_  yes --yes --
 sizeof   yes yes   yes yes
 C-style cast yes yes   yes no
 reinterpret_cast yes noyes no
@@ -489,9 +489,11 @@
 See also :ref:`langext-__builtin_shufflevector`, :ref:`langext-__builtin_convertvector`.
 
 .. [#] unary operator ! is not implemented, however && and || are.
-.. [#] While OpenCL and GCC vectors both implement the comparison operator(?:) as a
-  'select', they operate somewhat differently. OpenCL selects based on signedness of
-  the condition operands, but GCC vectors use normal bool conversions (that is, != 0).
+.. [#] ternary operator(?:) has different behaviors depending on condition
+  operand's vector type. If the condition is a GNU vector (i.e. __vector_size__),
+  it's only available in C++ and uses normal bool conversions (that is, != 0).
+  If it's an extension (OpenCL) vector, it's only available in C and OpenCL C.
+  And it selects base on signedness of the condition operands (OpenCL v1.1 s6.3.i).
 
 Matrix Types
 

[PATCH] D80753: [clang-tidy] remove duplicate fixes of alias checkers

2020-05-28 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:750
+  for (auto  : Errors) {
+auto Inserted = UniqueErrors.insert();
+

Please don't use auto when type is not spelled in same statement or not 
iterator.



Comment at: 
clang-tools-extra/test/clang-tidy/infrastructure/duplicate-fixes-of-alias-checkers.cpp:3
+
+#include 
+namespace std {

cstdio. Please also separate with newline.



Comment at: 
clang-tools-extra/test/clang-tidy/infrastructure/duplicate-fixes-of-alias-checkers.cpp:53
+}
\ No newline at end of file


Please add newline.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80753



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


[PATCH] D80758: [PowerPC] Add -m[no-]power10-vector clang and llvm option

2020-05-28 Thread Ahsan Saghir via Phabricator via cfe-commits
saghir created this revision.
saghir added reviewers: hfinkel, nemanjai, lei, power-llvm-team, amyk.
saghir added projects: LLVM, clang.
Herald added subscribers: llvm-commits, cfe-commits, shchenz, hiraditya.
jsji added a reviewer: PowerPC.
jsji added a project: PowerPC.

This patch adds command line option for enabling power10-vector support.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80758

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/test/Driver/ppc-dependent-options.cpp
  clang/test/Driver/ppc-features.cpp
  llvm/lib/Target/PowerPC/PPC.td
  llvm/lib/Target/PowerPC/PPCSubtarget.cpp
  llvm/lib/Target/PowerPC/PPCSubtarget.h

Index: llvm/lib/Target/PowerPC/PPCSubtarget.h
===
--- llvm/lib/Target/PowerPC/PPCSubtarget.h
+++ llvm/lib/Target/PowerPC/PPCSubtarget.h
@@ -105,6 +105,8 @@
   bool HasP8Crypto;
   bool HasP9Vector;
   bool HasP9Altivec;
+  bool HasP10Vector;
+  bool HasP10Altivec;
   bool HasPrefixInstrs;
   bool HasPCRelativeMemops;
   bool HasFCPSGN;
@@ -262,6 +264,8 @@
   bool hasP8Crypto() const { return HasP8Crypto; }
   bool hasP9Vector() const { return HasP9Vector; }
   bool hasP9Altivec() const { return HasP9Altivec; }
+  bool hasP10Vector() const { return HasP10Vector; }
+  bool hasP10Altivec() const { return HasP10Altivec; }
   bool hasPrefixInstrs() const { return HasPrefixInstrs; }
   bool hasPCRelativeMemops() const { return HasPCRelativeMemops; }
   bool hasMFOCRF() const { return HasMFOCRF; }
Index: llvm/lib/Target/PowerPC/PPCSubtarget.cpp
===
--- llvm/lib/Target/PowerPC/PPCSubtarget.cpp
+++ llvm/lib/Target/PowerPC/PPCSubtarget.cpp
@@ -78,6 +78,8 @@
   HasP8Crypto = false;
   HasP9Vector = false;
   HasP9Altivec = false;
+  HasP10Vector = false;
+  HasP10Altivec = false;
   HasPrefixInstrs = false;
   HasPCRelativeMemops = false;
   HasFCPSGN = false;
Index: llvm/lib/Target/PowerPC/PPC.td
===
--- llvm/lib/Target/PowerPC/PPC.td
+++ llvm/lib/Target/PowerPC/PPC.td
@@ -216,6 +216,15 @@
 "Enable POWER9 vector instructions",
 [FeatureISA3_0, FeatureP8Vector,
  FeatureP9Altivec]>;
+def FeatureP10Altivec : SubtargetFeature<"power10-altivec", "HasP10Altivec",
+ "true",
+ "Enable POWER10 Altivec instructions",
+ [FeatureISA3_1, FeatureP9Altivec]>;
+def FeatureP10Vector  : SubtargetFeature<"power10-vector", "HasP10Vector",
+ "true",
+ "Enable POWER10 vector instructions",
+ [FeatureISA3_1, FeatureP9Vector,
+ FeatureP10Altivec]>;
 // A separate feature for this even though it is equivalent to P9Vector
 // because this is a feature of the implementation rather than the architecture
 // and may go away with future CPU's.
@@ -337,7 +346,7 @@
   // still exist with the exception of those we know are Power9 specific.
   list P10AdditionalFeatures =
 [DirectivePwr10, FeatureISA3_1, FeaturePrefixInstrs,
- FeaturePCRelativeMemops];
+ FeaturePCRelativeMemops, FeatureP10Altivec, FeatureP10Vector];
   list P10SpecificFeatures = [];
   list P10InheritableFeatures =
 !listconcat(P9InheritableFeatures, P10AdditionalFeatures);
Index: clang/test/Driver/ppc-features.cpp
===
--- clang/test/Driver/ppc-features.cpp
+++ clang/test/Driver/ppc-features.cpp
@@ -150,6 +150,12 @@
 // RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-power8-vector -mpower8-vector -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-P8VECTOR %s
 // CHECK-P8VECTOR: "-target-feature" "+power8-vector"
 
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-power10-vector -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOP10VECTOR %s
+// CHECK-NOP10VECTOR: "-target-feature" "-power10-vector"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-power10-vector -mpower10-vector -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-P10VECTOR %s
+// CHECK-P10VECTOR: "-target-feature" "+power10-vector"
+
 // RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-crbits -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOCRBITS %s
 // CHECK-NOCRBITS: "-target-feature" "-crbits"
 
Index: clang/test/Driver/ppc-dependent-options.cpp
===
--- clang/test/Driver/ppc-dependent-options.cpp
+++ clang/test/Driver/ppc-dependent-options.cpp
@@ -58,6 +58,14 @@
 // RUN: -mcpu=power9 -std=c++11 -mno-vsx -mfloat128 -mpower9-vector 

[clang] 9021ce9 - [Clang] Enable KF and KC mode for [_Complex] __float128

2020-05-28 Thread Nemanja Ivanovic via cfe-commits

Author: Nemanja Ivanovic
Date: 2020-05-28T15:48:15-05:00
New Revision: 9021ce9576e438ae5a6fdb574327d30ea6b67fa8

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

LOG: [Clang] Enable KF and KC mode for [_Complex] __float128

The headers provided with recent GNU toolchains for PPC have code that includes
typedefs such as:

typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__KC__)))

This patch allows clang to compile programs that contain
#include 

with -mfloat128 which it currently fails to compile.

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

Differential revision: https://reviews.llvm.org/D80374

Added: 


Modified: 
clang/include/clang/AST/ASTContext.h
clang/include/clang/Basic/TargetInfo.h
clang/lib/AST/ASTContext.cpp
clang/lib/Basic/TargetInfo.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/Sema/attr-mode.c

Removed: 




diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 509ada3c9696..a5bb9a34c2fb 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -657,7 +657,7 @@ class ASTContext : public RefCountedBase {
   /// getRealTypeForBitwidth -
   /// sets floating point QualTy according to specified bitwidth.
   /// Returns empty type if there is no appropriate target types.
-  QualType getRealTypeForBitwidth(unsigned DestWidth) const;
+  QualType getRealTypeForBitwidth(unsigned DestWidth, bool ExplicitIEEE) const;
 
   bool AtomicUsesUnsupportedLibcall(const AtomicExpr *E) const;
 

diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 910a4d6846aa..0a5379225caf 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -368,8 +368,13 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   virtual IntType getLeastIntTypeByWidth(unsigned BitWidth,
  bool IsSigned) const;
 
-  /// Return floating point type with specified width.
-  RealType getRealTypeByWidth(unsigned BitWidth) const;
+  /// Return floating point type with specified width. On PPC, there are
+  /// three possible types for 128-bit floating point: "PPC double-double",
+  /// IEEE 754R quad precision, and "long double" (which under the covers
+  /// is represented as one of those two). At this time, there is no support
+  /// for an explicit "PPC double-double" type (i.e. __ibm128) so we only
+  /// need to 
diff erentiate between "long double" and IEEE quad precision.
+  RealType getRealTypeByWidth(unsigned BitWidth, bool ExplicitIEEE) const;
 
   /// Return the alignment (in bits) of the specified integer type enum.
   ///

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index c457a5537168..bfb6014027f4 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -10644,8 +10644,10 @@ QualType ASTContext::getIntTypeForBitwidth(unsigned 
DestWidth,
 /// getRealTypeForBitwidth -
 /// sets floating point QualTy according to specified bitwidth.
 /// Returns empty type if there is no appropriate target types.
-QualType ASTContext::getRealTypeForBitwidth(unsigned DestWidth) const {
-  TargetInfo::RealType Ty = getTargetInfo().getRealTypeByWidth(DestWidth);
+QualType ASTContext::getRealTypeForBitwidth(unsigned DestWidth,
+bool ExplicitIEEE) const {
+  TargetInfo::RealType Ty =
+  getTargetInfo().getRealTypeByWidth(DestWidth, ExplicitIEEE);
   switch (Ty) {
   case TargetInfo::Float:
 return FloatTy;

diff  --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index 2f1e044bb106..a3c8da5885b8 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -265,7 +265,8 @@ TargetInfo::IntType 
TargetInfo::getLeastIntTypeByWidth(unsigned BitWidth,
   return NoInt;
 }
 
-TargetInfo::RealType TargetInfo::getRealTypeByWidth(unsigned BitWidth) const {
+TargetInfo::RealType TargetInfo::getRealTypeByWidth(unsigned BitWidth,
+bool ExplicitIEEE) const {
   if (getFloatWidth() == BitWidth)
 return Float;
   if (getDoubleWidth() == BitWidth)
@@ -277,6 +278,10 @@ TargetInfo::RealType 
TargetInfo::getRealTypeByWidth(unsigned BitWidth) const {
   return LongDouble;
 break;
   case 128:
+// The caller explicitly asked for an IEEE compliant type but we still
+// have to check if the target supports it.
+if (ExplicitIEEE)
+  return hasFloat128Type() ? Float128 : NoFloat;
 if (() == ::APFloat::PPCDoubleDouble() ||
 () == ::APFloat::IEEEquad())
   return LongDouble;

diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 

[PATCH] D80757: [PowerPC] Add clang option -m[no-]pcrel

2020-05-28 Thread Lei Huang via Phabricator via cfe-commits
lei created this revision.
lei added reviewers: stefanp, nemanjai, hfinkel, power-llvm-team.
Herald added subscribers: shchenz, wuzish.
Herald added a project: clang.

Add user-facing front end option to turn off pc-relative memops.
This will be compatible with gcc.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80757

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/test/Driver/ppc-pcrel.cpp


Index: clang/test/Driver/ppc-pcrel.cpp
===
--- /dev/null
+++ clang/test/Driver/ppc-pcrel.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -mcpu=pwr10 -mpcrel 
-o %t.o 2>&1 | FileCheck -check-prefix=CHECK-PCREL %s
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -mcpu=pwr10 
-mno-pcrel -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOPCREL %s
+// CHECK-NOPCREL: "-target-feature" "-pcrel"
+// CHECK-PCREL: "-target-feature" "+pcrel"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu -mcpu=pwr10 -emit-llvm -S 
%s -o - | grep "attributes.*+pcrelative-memops"
+// RUN: %clang -target powerpc64-unknown-linux-gnu -mcpu=pwr10 -mpcrel 
-emit-llvm -S %s -o - | grep "attributes.*+pcrelative-memops"
+// RUN: %clang -target powerpc64-unknown-linux-gnu -mcpu=pwr10 -mno-pcrel 
-emit-llvm -S %s -o - | grep "attributes.*\-pcrelative-memops"
+
+int main(int argc, char *argv[]) {
+  return 0;
+}
Index: clang/lib/Basic/Targets/PPC.h
===
--- clang/lib/Basic/Targets/PPC.h
+++ clang/lib/Basic/Targets/PPC.h
@@ -69,6 +69,7 @@
   bool HasExtDiv = false;
   bool HasP9Vector = false;
   bool HasSPE = false;
+  bool HasPCRelativeMemops = false;
 
 protected:
   std::string ABI;
Index: clang/lib/Basic/Targets/PPC.cpp
===
--- clang/lib/Basic/Targets/PPC.cpp
+++ clang/lib/Basic/Targets/PPC.cpp
@@ -54,6 +54,8 @@
   HasFloat128 = true;
 } else if (Feature == "+power9-vector") {
   HasP9Vector = true;
+} else if (Feature == "+pcrelative-memops") {
+  HasPCRelativeMemops = true;
 } else if (Feature == "+spe") {
   HasSPE = true;
   LongDoubleWidth = LongDoubleAlign = 64;
@@ -346,6 +348,7 @@
 void PPCTargetInfo::addP10SpecificFeatures(
 llvm::StringMap ) const {
   Features["htm"] = false; // HTM was removed for P10.
+  Features["pcrelative-memops"] = true;
   return;
 }
 
@@ -369,6 +372,7 @@
   .Case("extdiv", HasExtDiv)
   .Case("float128", HasFloat128)
   .Case("power9-vector", HasP9Vector)
+  .Case("pcrelative-memops", HasPCRelativeMemops)
   .Case("spe", HasSPE)
   .Default(false);
 }
@@ -389,7 +393,10 @@
   Features["vsx"] = Features["altivec"] = true;
 if (Name == "power9-vector")
   Features["power8-vector"] = true;
-Features[Name] = true;
+if (Name == "pcrel")
+  Features["pcrelative-memops"] = true;
+else
+  Features[Name] = true;
   } else {
 // If we're disabling altivec or vsx go ahead and disable all of the vsx
 // features.
@@ -398,7 +405,10 @@
   Features["float128"] = Features["power9-vector"] = false;
 if (Name == "power8-vector")
   Features["power9-vector"] = false;
-Features[Name] = false;
+if (Name == "pcrel")
+  Features["pcrelative-memops"] = false;
+else
+  Features[Name] = false;
   }
 }
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2470,6 +2470,8 @@
 def fno_altivec : Flag<["-"], "fno-altivec">, Group, 
Flags<[DriverOption]>;
 def maltivec : Flag<["-"], "maltivec">, Group;
 def mno_altivec : Flag<["-"], "mno-altivec">, Group;
+def mpcrel: Flag<["-"], "mpcrel">, Group;
+def mno_pcrel: Flag<["-"], "mno-pcrel">, Group;
 def mspe : Flag<["-"], "mspe">, Group;
 def mno_spe : Flag<["-"], "mno-spe">, Group;
 def mvsx : Flag<["-"], "mvsx">, Group;


Index: clang/test/Driver/ppc-pcrel.cpp
===
--- /dev/null
+++ clang/test/Driver/ppc-pcrel.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -mcpu=pwr10 -mpcrel -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-PCREL %s
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -mcpu=pwr10 -mno-pcrel -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOPCREL %s
+// CHECK-NOPCREL: "-target-feature" "-pcrel"
+// CHECK-PCREL: "-target-feature" "+pcrel"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu -mcpu=pwr10 -emit-llvm -S %s -o - | grep "attributes.*+pcrelative-memops"
+// RUN: %clang -target powerpc64-unknown-linux-gnu -mcpu=pwr10 -mpcrel -emit-llvm -S %s -o - | grep "attributes.*+pcrelative-memops"
+// RUN: %clang -target powerpc64-unknown-linux-gnu -mcpu=pwr10 -mno-pcrel -emit-llvm -S %s -o 

[PATCH] D80574: [ExtVector] Support ExtVectorType conditional operator

2020-05-28 Thread Min-Yih Hsu via Phabricator via cfe-commits
myhsu marked 2 inline comments as done.
myhsu added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:7484
+  // Only ext vector is allowed
+  if (const auto *VecCondTy = Cond->getType()->getAs()) {
+QualType EleTy = VecCondTy->getElementType();

Anastasia wrote:
> Why do you need this change? I believe OpenCL makes the same restriction.
I'm not quite sure what restriction you're referring here. If you're saying 
OpenCL only allow ext_vector_type on condition operand, I don't think that's 
the case since on line 7956 ~ 7957 of Sema/SemaExpr.cpp :

```
if (getLangOpts().OpenCL && Cond.get()->getType()->isVectorType())
return OpenCLCheckVectorConditional(*this, Cond, LHS, RHS, QuestionLoc);
```
`isVectorType()` will be true for both GNU vector and ext_vector_type.

Regarding why i add the change here rather than merging with OpenCL's flow 
(which is related to another comments below), OpenCL's flow diverge into line 
7957, as shown above, pretty early in the entire checking flow. And 
`OpenCLCheckVectorConditional` do other additional works. Most notably, 
promoting all scalar operands into vector if condition is a vector. I'm not 
sure if we should bring this feature to ext_vector



Comment at: clang/lib/Sema/SemaExpr.cpp:7975
+// condition and result type.
+QualType CondTy = Cond.get()->getType();
+if (CondTy->isExtVectorType()) {

Anastasia wrote:
> Do you know where it is done for OpenCL? I think we should try to share the 
> same code...
It's inside `OpenCLCheckVectorConditional` function. As I mentioned in earlier 
comment, as long as we agree to bring every OpenCL features/rules regarding 
conditional vectors to ext_vector_type, I'm happy to reuse 
`OpenCLCheckVectorConditional`


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

https://reviews.llvm.org/D80574



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


[PATCH] D80574: [ExtVector] Support ExtVectorType conditional operator

2020-05-28 Thread Min-Yih Hsu via Phabricator via cfe-commits
myhsu updated this revision to Diff 267024.
myhsu added a comment.

Fix document section


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

https://reviews.llvm.org/D80574

Files:
  clang/docs/LanguageExtensions.rst
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/ext_vector_comparisons.c

Index: clang/test/Sema/ext_vector_comparisons.c
===
--- clang/test/Sema/ext_vector_comparisons.c
+++ clang/test/Sema/ext_vector_comparisons.c
@@ -28,3 +28,19 @@
   return vec > vec;  // no-warning
   return vec >= vec; // no-warning
 }
+
+static int4 test3() {
+  int4 i0, i1;
+
+  return i0 > i1 ? i0 : i1; // no-error
+  return i0 ? i0 : i1;  // no-error
+}
+
+static float4 test4() {
+  float4 f0, f1;
+
+  // This would actually generate implicit casting warning
+  // under Weverything flag but we don't really care here
+  return f0 > f1 ? f0 : f1; // no-error
+  return f0 ? f0 : f1;  // expected-error {{arithmetic or pointer type is required}}
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -7480,6 +7480,13 @@
   // C99 6.5.15p2
   if (CondTy->isScalarType()) return false;
 
+  // Only ext vector is allowed
+  if (const auto *VecCondTy = Cond->getType()->getAs()) {
+QualType EleTy = VecCondTy->getElementType();
+if (EleTy->isIntegerType())
+  return false;
+  }
+
   S.Diag(QuestionLoc, diag::err_typecheck_cond_expect_scalar)
 << CondTy << Cond->getSourceRange();
   return true;
@@ -7958,10 +7965,21 @@
 
   // Now check the two expressions.
   if (LHS.get()->getType()->isVectorType() ||
-  RHS.get()->getType()->isVectorType())
-return CheckVectorOperands(LHS, RHS, QuestionLoc, /*isCompAssign*/false,
-   /*AllowBothBool*/true,
-   /*AllowBoolConversions*/false);
+  RHS.get()->getType()->isVectorType()) {
+QualType VecResTy = CheckVectorOperands(LHS, RHS, QuestionLoc,
+/*isCompAssign*/ false,
+/*AllowBothBool*/ true,
+/*AllowBoolConversions*/ false);
+// If the condition is ext vector, we're imposing OpenCL's rule wrt
+// condition and result type.
+QualType CondTy = Cond.get()->getType();
+if (CondTy->isExtVectorType()) {
+  if (VecResTy.isNull() ||
+  checkVectorResult(*this, CondTy, VecResTy, QuestionLoc))
+return QualType();
+}
+return VecResTy;
+  }
 
   QualType ResTy =
   UsualArithmeticConversions(LHS, RHS, QuestionLoc, ACK_Conditional);
Index: clang/lib/CodeGen/CGExprScalar.cpp
===
--- clang/lib/CodeGen/CGExprScalar.cpp
+++ clang/lib/CodeGen/CGExprScalar.cpp
@@ -4431,8 +4431,8 @@
 
   // OpenCL: If the condition is a vector, we can treat this condition like
   // the select function.
-  if (CGF.getLangOpts().OpenCL
-  && condExpr->getType()->isVectorType()) {
+  if ((CGF.getLangOpts().OpenCL && condExpr->getType()->isVectorType()) ||
+  condExpr->getType()->isExtVectorType()) {
 CGF.incrementProfileCounter(E);
 
 llvm::Value *CondV = CGF.EmitScalarExpr(condExpr);
Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -478,7 +478,7 @@
 !, &&, ||yes --yes [#]_--
 ==, !=, >, <, >=, <= yes yes   yes --
 =yes yes   yes yes
-:? [#]_  yes --yes --
+?: [#]_  yes --yes --
 sizeof   yes yes   yes yes
 C-style cast yes yes   yes no
 reinterpret_cast yes noyes no
@@ -489,9 +489,11 @@
 See also :ref:`langext-__builtin_shufflevector`, :ref:`langext-__builtin_convertvector`.
 
 .. [#] unary operator ! is not implemented, however && and || are.
-.. [#] While OpenCL and GCC vectors both implement the comparison operator(?:) as a
-  'select', they operate somewhat differently. OpenCL selects based on signedness of
-  the condition operands, but GCC vectors use normal bool conversions (that is, != 0).
+.. [#] ternary operator(?:) has different behaviors depending on condition
+  operand's vector type. If the condition is a GNU vector (i.e. __vector_size__),
+  it's only available in C++ and uses normal bool conversions (that is, != 0).
+  If it's an extension (OpenCL) vector, it's only available in C and OpenCL C.
+  And it selects base on signedness of the condition operands.
 
 Matrix Types
 

[PATCH] D79117: [clang] [Darwin] Add reverse mappings for aarch64/aarch64_32 to darwin arch names

2020-05-28 Thread Eric Christopher via Phabricator via cfe-commits
echristo accepted this revision.
echristo added a comment.
This revision is now accepted and ready to land.

This seems ok to me. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79117



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


[PATCH] D80531: [clang-tidy]: Added modernize-replace-disallow-copy-and-assign-macro

2020-05-28 Thread Konrad Wilhelm Kleine via Phabricator via cfe-commits
kwk updated this revision to Diff 267021.
kwk marked 9 inline comments as done.
kwk added a comment.

- Don't store SourceManager but get it from Preprocessor
- Use getName instead of getNameStart
- Remove FIXME
- change warning message
- doxygen: \a -> \p
- Make MacroName private and add getter


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80531

Files:
  clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
  clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
  
clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.cpp
  
clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/modernize-replace-disallow-copy-and-assign-macro.rst
  
clang-tools-extra/test/clang-tidy/checkers/modernize-replace-disallow-copy-and-assign-macro.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize-replace-disallow-copy-and-assign-macro.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-replace-disallow-copy-and-assign-macro.cpp
@@ -0,0 +1,79 @@
+// RUN: %check_clang_tidy -format-style=LLVM -check-suffix=DEFAULT %s \
+// RUN:   modernize-replace-disallow-copy-and-assign-macro %t
+
+// RUN: %check_clang_tidy -format-style=LLVM -check-suffix=DIFFERENT-NAME %s \
+// RUN:  modernize-replace-disallow-copy-and-assign-macro %t \
+// RUN:  -config="{CheckOptions: [ \
+// RUN:   {key: modernize-replace-disallow-copy-and-assign-macro.MacroName, \
+// RUN:value: MY_MACRO_NAME}]}"
+
+// RUN: %check_clang_tidy -format-style=LLVM -check-suffix=FINALIZE %s \
+// RUN:  modernize-replace-disallow-copy-and-assign-macro %t \
+// RUN:  -config="{CheckOptions: [ \
+// RUN:   {key: modernize-replace-disallow-copy-and-assign-macro.MacroName, \
+// RUN:value: DISALLOW_COPY_AND_ASSIGN_FINALIZE}]}"
+
+// RUN: clang-tidy %s -checks="-*,modernize-replace-disallow-copy-and-assign-macro" \
+// RUN:   -config="{CheckOptions: [ \
+// RUN:{key: modernize-replace-disallow-copy-and-assign-macro.MacroName, \
+// RUN: value: DISALLOW_COPY_AND_ASSIGN_MORE_AGUMENTS}]}" | count 0
+
+// RUN: clang-tidy %s -checks="-*,modernize-replace-disallow-copy-and-assign-macro" \
+// RUN:   -config="{CheckOptions: [ \
+// RUN:{key: modernize-replace-disallow-copy-and-assign-macro.MacroName, \
+// RUN: value: DISALLOW_COPY_AND_ASSIGN_NEEDS_PREEXPANSION}]}" | count 0
+
+// Note: the last two tests expect no diagnostics, but FileCheck cannot handle
+// that, hence the use of | count 0.
+
+#define DISALLOW_COPY_AND_ASSIGN(TypeName)
+
+class TestClass1 {
+private:
+  DISALLOW_COPY_AND_ASSIGN(TestClass1);
+};
+// CHECK-MESSAGES-DEFAULT: :[[@LINE-2]]:3: warning: prefer deleting copy constructor and assignment operator over using macro 'DISALLOW_COPY_AND_ASSIGN' [modernize-replace-disallow-copy-and-assign-macro]
+// CHECK-FIXES-DEFAULT:  {{^}}  TestClass1(const TestClass1 &) = delete;{{$}}
+// CHECK-FIXES-DEFAULT-NEXT: {{^}}  const TestClass1 =(const TestClass1 &) = delete;{{$}}
+
+#define MY_MACRO_NAME(TypeName)
+
+class TestClass2 {
+private:
+  MY_MACRO_NAME(TestClass2);
+};
+// CHECK-MESSAGES-DIFFERENT-NAME: :[[@LINE-2]]:3: warning: prefer deleting copy constructor and assignment operator over using macro 'MY_MACRO_NAME' [modernize-replace-disallow-copy-and-assign-macro]
+// CHECK-FIXES-DIFFERENT-NAME:  {{^}}  TestClass2(const TestClass2 &) = delete;{{$}}
+// CHECK-FIXES-DIFFERENT-NAME-NEXT: {{^}}  const TestClass2 =(const TestClass2 &) = delete;{{$}}
+
+#define DISALLOW_COPY_AND_ASSIGN_FINALIZE(TypeName) \
+  TypeName(const TypeName &) = delete;  \
+  const TypeName =(const TypeName &) = delete;
+
+class TestClass3 {
+private:
+  // Notice, that the macro allows to be used without a semicolon because the
+  // macro definition already contains one above. Therefore our replacement must
+  // contain a semicolon at the end.
+  DISALLOW_COPY_AND_ASSIGN_FINALIZE(TestClass3)
+};
+// CHECK-MESSAGES-FINALIZE: :[[@LINE-2]]:3: warning: prefer deleting copy constructor and assignment operator over using macro 'DISALLOW_COPY_AND_ASSIGN_FINALIZE' [modernize-replace-disallow-copy-and-assign-macro]
+// CHECK-FIXES-FINALIZE:  {{^}}  TestClass3(const TestClass3 &) = delete;{{$}}
+// CHECK-FIXES-FINALIZE-NEXT: {{^}}  const TestClass3 =(const TestClass3 &) = delete;{{$}}
+
+#define DISALLOW_COPY_AND_ASSIGN_MORE_AGUMENTS(A, B)
+
+class TestClass4 {
+private:
+  DISALLOW_COPY_AND_ASSIGN_MORE_AGUMENTS(TestClass4, TestClass4);
+};
+// CHECK-MESSAGES-MORE-ARGUMENTS-NOT: warning: prefer deleting copy constructor and assignment operator over using macro 'DISALLOW_COPY_AND_ASSIGN_MORE_AGUMENTS'
+
+#define DISALLOW_COPY_AND_ASSIGN_NEEDS_PREEXPANSION(A)
+#define TESTCLASS 

[PATCH] D80590: [WIP][OPENMP] Fix assertion error for using alignas with OpenMP directive

2020-05-28 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Investigated the bug. Seems to me, the bug is not related to OpenMP. The 
following code crashes the compiler too:

  struct FOO
  {
static const int vec_align_bytes = 32;
  
void foo()
{
  alignas(vec_align_bytes) double a;
  ;
}
  
  };

Seems to me, the bug is in `Actions.ClassifyName` which does not clean up the 
list of the possibly odr-used decls. Or in the code, which tries to parse the 
align argument `Parser::ParseAlignArgument`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80590



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


[PATCH] D80531: [clang-tidy]: Added modernize-replace-disallow-copy-and-assign-macro

2020-05-28 Thread Konrad Wilhelm Kleine via Phabricator via cfe-commits
kwk added a comment.

@njames93 I've addressed all your comments and hope the patch is good to land 
now :)




Comment at: 
clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.cpp:25
+  const SourceManager )
+  : Check(Check), PP(PP), SM(SM) {}
+

njames93 wrote:
> nit: You don't need to store a reference to the `SourceManager` as the 
> `Preprocessor` holds a reference to it.
@njames93 thank you for letting me know. I passed it along because the 
´ClangTidyCheck::registerPPCallbacks` that I override actually accepts both, 
`SourceManager` and the `PP`:

```
lang=c++
virtual void registerPPCallbacks(const SourceManager , Preprocessor *PP,
   Preprocessor *ModuleExpanderPP) {}
```

Other checks like `MakeSmartPtrCheck`, `PassByValueCheck` also do this similar 
to mine. 

Anyway, I've changed the code to your liking. 



Comment at: 
clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.h:52
+
+  const std::string MacroName;
+};

njames93 wrote:
> Make this private with a get function and I'll be happy. 
Done. But since the variable is `const` having it public shouldn't allow a 
caller do anything but read the macro name. But I understand that convention is 
king ;)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80531



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


[PATCH] D80712: [SVE] Add checks for no warnings in SVE tests

2020-05-28 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

I guess we could do this as a temporary measure, if you think it's useful; 
eventually, of course, the codepath to print the warning will go away.

Since you checked this, how many tests do still print warnings?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80712



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


[PATCH] D80692: Run Coverage pass before other *San passes under new pass manager, round 2

2020-05-28 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

In D80692#2061219 , @leonardchan wrote:

> Would be worthwhile to write a small test that asserts Sancov runs before the 
> other sanitizers under the new PM?
>
> Aside from this, LGTM.


Asserting that sancov runs before other sanitizers seems like overspecification 
to me. Really all we want to know is that something like msan + sancov work 
together, and there are tests for that which we are fixing with this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80692



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


[PATCH] D77942: [Preamble] Invalidate preamble when missing headers become present.

2020-05-28 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

LGTM, thanks! Let's build more preambles !


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77942



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


[clang] 2f430f7 - [StackSafety] Remove SetMetadata parameter

2020-05-28 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2020-05-28T13:32:57-07:00
New Revision: 2f430f7a51693c9d5c648179f2341b541be44000

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

LOG: [StackSafety] Remove SetMetadata parameter

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp
llvm/include/llvm/Analysis/StackSafetyAnalysis.h
llvm/lib/Analysis/StackSafetyAnalysis.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 33627f3a6733..e746aef1a62f 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -353,7 +353,7 @@ static void addDataFlowSanitizerPass(const 
PassManagerBuilder ,
 
 static void addMemTagOptimizationPasses(const PassManagerBuilder ,
 legacy::PassManagerBase ) {
-  PM.add(createStackSafetyGlobalInfoWrapperPass(/*SetMetadata=*/true));
+  PM.add(createStackSafetyGlobalInfoWrapperPass());
 }
 
 static TargetLibraryInfoImpl *createTLII(llvm::Triple ,

diff  --git a/llvm/include/llvm/Analysis/StackSafetyAnalysis.h 
b/llvm/include/llvm/Analysis/StackSafetyAnalysis.h
index df7ccac5b4b9..b5589611c8e2 100644
--- a/llvm/include/llvm/Analysis/StackSafetyAnalysis.h
+++ b/llvm/include/llvm/Analysis/StackSafetyAnalysis.h
@@ -126,12 +126,11 @@ class StackSafetyGlobalAnnotatorPass
 /// (legacy pass manager).
 class StackSafetyGlobalInfoWrapperPass : public ModulePass {
   StackSafetyGlobalInfo SSGI;
-  bool SetMetadata;
 
 public:
   static char ID;
 
-  StackSafetyGlobalInfoWrapperPass(bool SetMetadata = false);
+  StackSafetyGlobalInfoWrapperPass();
 
   const StackSafetyGlobalInfo () const { return SSGI; }
 
@@ -141,7 +140,7 @@ class StackSafetyGlobalInfoWrapperPass : public ModulePass {
   bool runOnModule(Module ) override;
 };
 
-ModulePass *createStackSafetyGlobalInfoWrapperPass(bool SetMetadata);
+ModulePass *createStackSafetyGlobalInfoWrapperPass();
 
 } // end namespace llvm
 

diff  --git a/llvm/lib/Analysis/StackSafetyAnalysis.cpp 
b/llvm/lib/Analysis/StackSafetyAnalysis.cpp
index 6eeffe6066df..e969639973a4 100644
--- a/llvm/lib/Analysis/StackSafetyAnalysis.cpp
+++ b/llvm/lib/Analysis/StackSafetyAnalysis.cpp
@@ -712,9 +712,8 @@ StackSafetyGlobalAnnotatorPass::run(Module , 
ModuleAnalysisManager ) {
 
 char StackSafetyGlobalInfoWrapperPass::ID = 0;
 
-StackSafetyGlobalInfoWrapperPass::StackSafetyGlobalInfoWrapperPass(
-bool SetMetadata)
-: ModulePass(ID), SetMetadata(SetMetadata) {
+StackSafetyGlobalInfoWrapperPass::StackSafetyGlobalInfoWrapperPass()
+: ModulePass(ID) {
   initializeStackSafetyGlobalInfoWrapperPassPass(
   *PassRegistry::getPassRegistry());
 }
@@ -738,11 +737,11 @@ bool StackSafetyGlobalInfoWrapperPass::runOnModule(Module 
) {
 .Info;
   });
   SSGI = SSDFA.run();
-  return SetMetadata ? SSGI.setMetadata(M) : false;
+  return SSGI.setMetadata(M);
 }
 
-ModulePass *llvm::createStackSafetyGlobalInfoWrapperPass(bool SetMetadata) {
-  return new StackSafetyGlobalInfoWrapperPass(SetMetadata);
+ModulePass *llvm::createStackSafetyGlobalInfoWrapperPass() {
+  return new StackSafetyGlobalInfoWrapperPass();
 }
 
 static const char LocalPassArg[] = "stack-safety-local";



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


[PATCH] D43002: Emit S_OBJNAME symbol in CodeView

2020-05-28 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

First question:

Since split dwarf has to do some similar things can we not use the same 
support? This seems to be a lot of changes for this.

Second question:

and if we can't use the same support can we make split dwarf use this? Having 
two separate methods for passing everything around is a bit painful.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D43002



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


[PATCH] D43002: Emit S_OBJNAME symbol in CodeView

2020-05-28 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea updated this revision to Diff 266989.
aganea added a comment.
Herald added subscribers: cfe-commits, steven_wu, aheejin, arichardson, sbc100, 
emaste.
Herald added a reviewer: espindola.
Herald added a project: clang.

I'm taking over this patch, as discussed offline with Zachary.

I've re-implemented the patch to use the target/final file name of the .OBJ, as 
suggested.

The bulk of the changes is mostly to pass around the file name, down to the 
back end.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D43002

Files:
  clang/include/clang/CodeGen/BackendUtil.h
  clang/include/clang/Frontend/CompilerInstance.h
  clang/include/clang/Frontend/FrontendActions.h
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
  clang/lib/Frontend/PrecompiledPreamble.cpp
  clang/lib/Frontend/Rewrite/FrontendActions.cpp
  clang/tools/driver/cc1_main.cpp
  lld/COFF/LTO.cpp
  lld/COFF/LTO.h
  lld/ELF/LTO.cpp
  lld/wasm/LTO.cpp
  llvm/include/llvm/LTO/LTO.h
  llvm/include/llvm/MC/MCTargetOptions.h
  llvm/include/llvm/Support/ToolOutputFile.h
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h
  llvm/lib/LTO/Caching.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/test/DebugInfo/COFF/globals.ll
  llvm/test/DebugInfo/COFF/multifunction.ll
  llvm/test/DebugInfo/COFF/pr28747.ll
  llvm/test/DebugInfo/COFF/simple.ll
  llvm/test/DebugInfo/COFF/vframe-fpo.ll
  llvm/test/MC/AArch64/coff-debug.ll
  llvm/test/MC/ARM/coff-debugging-secrel.ll
  llvm/test/MC/COFF/cv-compiler-info.ll
  llvm/tools/llc/llc.cpp
  llvm/tools/llvm-lto2/llvm-lto2.cpp

Index: llvm/tools/llvm-lto2/llvm-lto2.cpp
===
--- llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -352,7 +352,7 @@
 std::error_code EC;
 auto S = std::make_unique(Path, EC, sys::fs::OF_None);
 check(EC, Path);
-return std::make_unique(std::move(S));
+return std::make_unique(std::move(S), Path);
   };
 
   auto AddBuffer = [&](size_t Task, std::unique_ptr MB) {
Index: llvm/tools/llc/llc.cpp
===
--- llvm/tools/llc/llc.cpp
+++ llvm/tools/llc/llc.cpp
@@ -530,6 +530,9 @@
   GetOutputStream(TheTarget->getName(), TheTriple.getOS(), argv[0]);
   if (!Out) return 1;
 
+  // Ensure the filename is passed down to CodeViewDebug.
+  Target->Options.MCOptions.OutputPathName = Out->outputFilename();
+
   std::unique_ptr DwoOut;
   if (!SplitDwarfOutputFile.empty()) {
 std::error_code EC;
Index: llvm/test/MC/COFF/cv-compiler-info.ll
===
--- llvm/test/MC/COFF/cv-compiler-info.ll
+++ llvm/test/MC/COFF/cv-compiler-info.ll
@@ -1,4 +1,5 @@
-; RUN: llc -mtriple i686-pc-windows-msvc < %s | FileCheck %s
+; RUN: llc -mtriple i686-pc-windows-msvc < %s | FileCheck %s --check-prefixes=CHECK,STDOUT
+; RUN: llc -mtriple i686-pc-windows-msvc < %s -o %t | FileCheck %s --input-file=%t --check-prefixes=CHECK,FILE
 ; ModuleID = 'D:\src\scopes\foo.cpp'
 source_filename = "D:\5Csrc\5Cscopes\5Cfoo.cpp"
 target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
@@ -20,19 +21,23 @@
 ; One .debug$S section should contain an S_COMPILE3 record that identifies the
 ; source language and the version of the compiler based on the DICompileUnit.
 ; CHECK: 	.section	.debug$S,"dr"
+; CHECK:.short  4353# Record kind: S_OBJNAME
+; CHECK-NEXT:   .long   0   # Signature
+; STDOUT-NEXT:  .byte   0   # Object name
+; FILE-NEXT:.asciz	"{{.*}}{{|/}}cv-compiler-info.ll.tmp" # Object name
 ; CHECK: 		.short	4412  # Record kind: S_COMPILE3
-; CHECK: 		.long	1   # Flags and language
-; CHECK: 		.short	7 # CPUType
-; CHECK: 		.short	4 # Frontend version
-; CHECK: 		.short	0
-; CHECK: 		.short	0
-; CHECK: 		.short	0
-; CHECK: 		.short	[[BACKEND_VERSION:[0-9]+]]  # Backend version
-; CHECK: 		.short	0
-; CHECK: 		.short	0
-; CHECK: 		.short	0
-; CHECK: 		.asciz	"clang version 4.0.0 "  # Null-terminated compiler version string
-; CHECK-NOT: .short	4412  # Record kind: S_COMPILE3
+; CHECK-NEXT:   .long	1   # Flags and language
+; CHECK-NEXT: 	.short	7 # CPUType
+; CHECK-NEXT: 	.short	4 # Frontend version
+; CHECK-NEXT: 	.short	0
+; CHECK-NEXT: 	.short	0
+; CHECK-NEXT: 	.short	0
+; CHECK-NEXT: 	.short	[[BACKEND_VERSION:[0-9]+]]  # Backend version
+; CHECK-NEXT: 	.short	0
+; CHECK-NEXT: 	.short	0
+; CHECK-NEXT: 	.short	0
+; CHECK-NEXT: 	.asciz	"clang 

[PATCH] D80603: add isAtPosition narrowing matcher for parmVarDecl

2020-05-28 Thread Vy Nguyen via Phabricator via cfe-commits
oontvoo closed this revision.
oontvoo added a comment.

Thanks, all!
Committed 
https://github.com/llvm/llvm-project/commit/51401a676c036f2bd4e6b4b38f3538615799de40


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80603



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


[PATCH] D80603: add isAtPosition narrowing matcher for parmVarDecl

2020-05-28 Thread Vy Nguyen via Phabricator via cfe-commits
oontvoo updated this revision to Diff 267008.
oontvoo added a comment.

Move matcher to near forEachArgumentWithParam


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80603

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -2643,6 +2643,45 @@
   parmVarDecl(hasDefaultArgument(;
 }
 
+TEST(IsAtPosition, Basic) {
+  EXPECT_TRUE(matches("void x(int a, int b) {}", parmVarDecl(isAtPosition(1;
+  EXPECT_TRUE(matches("void x(int a, int b) {}", parmVarDecl(isAtPosition(0;
+  EXPECT_TRUE(matches("void x(int a, int b) {}", parmVarDecl(isAtPosition(1;
+  EXPECT_TRUE(notMatches("void x(int val) {}", parmVarDecl(isAtPosition(1;
+}
+
+TEST(IsAtPosition, FunctionDecl) {
+  EXPECT_TRUE(matches("void x(int a);", parmVarDecl(isAtPosition(0;
+  EXPECT_TRUE(matches("void x(int a, int b);", parmVarDecl(isAtPosition(0;
+  EXPECT_TRUE(matches("void x(int a, int b);", parmVarDecl(isAtPosition(1;
+  EXPECT_TRUE(notMatches("void x(int val);", parmVarDecl(isAtPosition(1;
+}
+
+TEST(IsAtPosition, Lambda) {
+  EXPECT_TRUE(
+  matches("void x() { [](int a) {};  }", parmVarDecl(isAtPosition(0;
+  EXPECT_TRUE(matches("void x() { [](int a, int b) {}; }",
+  parmVarDecl(isAtPosition(0;
+  EXPECT_TRUE(matches("void x() { [](int a, int b) {}; }",
+  parmVarDecl(isAtPosition(1;
+  EXPECT_TRUE(
+  notMatches("void x() { [](int val) {}; }", parmVarDecl(isAtPosition(1;
+}
+
+TEST(IsAtPosition, BlockDecl) {
+  EXPECT_TRUE(matchesObjC(
+  "void func()  { void (^my_block)(int arg) = ^void(int arg) {}; } ",
+  parmVarDecl(isAtPosition(0;
+
+  EXPECT_TRUE(matchesObjC("void func()  { void (^my_block)(int x, int y) = "
+  "^void(int x, int y) {}; } ",
+  parmVarDecl(isAtPosition(1;
+
+  EXPECT_TRUE(notMatchesObjC(
+  "void func()  { void (^my_block)(int arg) = ^void(int arg) {}; } ",
+  parmVarDecl(isAtPosition(1;
+}
+
 TEST(IsArray, Basic) {
   EXPECT_TRUE(matches("struct MyClass {}; MyClass *p1 = new MyClass[10];",
   cxxNewExpr(isArray(;
Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -219,6 +219,7 @@
   REGISTER_MATCHER(floatLiteral);
   REGISTER_MATCHER(forEach);
   REGISTER_MATCHER(forEachArgumentWithParam);
+  REGISTER_MATCHER(isAtPosition);
   REGISTER_MATCHER(forEachConstructorInitializer);
   REGISTER_MATCHER(forEachDescendant);
   REGISTER_MATCHER(forEachOverridden);
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -4257,6 +4257,34 @@
   return Matched;
 }
 
+/// Matches the ParmVarDecl nodes that are at the N'th position in the parameter
+/// list. The parameter list could be that of either a block, function, or
+/// objc-method.
+///
+///
+/// Given
+///
+/// \code
+/// void f(int a, int b, int c) {
+/// }
+/// \endcode
+///
+/// ``parmVarDecl(isAtPosition(0))`` matches ``int a``.
+///
+/// ``parmVarDecl(isAtPosition(1))`` matches ``int b``.
+AST_MATCHER_P(clang::ParmVarDecl, isAtPosition, unsigned, N) {
+  const clang::DeclContext *Context = Node.getParentFunctionOrMethod();
+
+  if (const auto *Decl = dyn_cast_or_null(Context))
+return N < Decl->param_size() && Decl->getParamDecl(N) == 
+  if (const auto *Decl = dyn_cast_or_null(Context))
+return N < Decl->param_size() && Decl->getParamDecl(N) == 
+  if (const auto *Decl = dyn_cast_or_null(Context))
+return N < Decl->param_size() && Decl->getParamDecl(N) == 
+
+  return false;
+}
+
 /// Matches any parameter of a function or an ObjC method declaration or a
 /// block.
 ///
Index: clang/docs/LibASTMatchersReference.html
===
--- clang/docs/LibASTMatchersReference.html
+++ clang/docs/LibASTMatchersReference.html
@@ -4671,6 +4671,23 @@
 Usable as: Matcherhttps://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html;>FunctionDecl, Matcherhttps://clang.llvm.org/doxygen/classclang_1_1VarDecl.html;>VarDecl, Matcherhttps://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html;>CXXRecordDecl
 
 
+
+Matcherclang::ParmVarDeclisAtPositionunsigned N
+Matches the ParmVarDecl nodes that 

[PATCH] D80323: [SVE] Eliminate calls to default-false VectorType::get() from Clang

2020-05-28 Thread Christopher Tetreault via Phabricator via cfe-commits
ctetreau updated this revision to Diff 267002.
ctetreau added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80323

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/SwiftCallingConv.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/utils/TableGen/MveEmitter.cpp

Index: clang/utils/TableGen/MveEmitter.cpp
===
--- clang/utils/TableGen/MveEmitter.cpp
+++ clang/utils/TableGen/MveEmitter.cpp
@@ -300,7 +300,7 @@
 return Element->cNameBase() + "x" + utostr(Lanes);
   }
   std::string llvmName() const override {
-return "llvm::VectorType::get(" + Element->llvmName() + ", " +
+return "llvm::FixedVectorType::get(" + Element->llvmName() + ", " +
utostr(Lanes) + ")";
   }
 
@@ -354,7 +354,7 @@
 // explanation.
 unsigned ModifiedLanes = (Lanes == 2 ? 4 : Lanes);
 
-return "llvm::VectorType::get(Builder.getInt1Ty(), " +
+return "llvm::FixedVectorType::get(Builder.getInt1Ty(), " +
utostr(ModifiedLanes) + ")";
   }
 
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -1478,8 +1478,8 @@
   // registers and we need to make sure to pick a type the LLVM
   // backend will like.
   if (Size == 128)
-return ABIArgInfo::getDirect(llvm::VectorType::get(
-  llvm::Type::getInt64Ty(getVMContext()), 2));
+return ABIArgInfo::getDirect(llvm::FixedVectorType::get(
+llvm::Type::getInt64Ty(getVMContext()), 2));
 
   // Always return in register if it fits in a general purpose
   // register, or if it is 64 bits and has a single element.
@@ -3122,8 +3122,8 @@
 cast(IRType)->getElementType()->isIntegerTy(128)) {
   // Use a vXi64 vector.
   uint64_t Size = getContext().getTypeSize(Ty);
-  return llvm::VectorType::get(llvm::Type::getInt64Ty(getVMContext()),
-   Size / 64);
+  return llvm::FixedVectorType::get(llvm::Type::getInt64Ty(getVMContext()),
+Size / 64);
 }
 
 return IRType;
@@ -3138,8 +3138,8 @@
 
 
   // Return a LLVM IR vector type based on the size of 'Ty'.
-  return llvm::VectorType::get(llvm::Type::getDoubleTy(getVMContext()),
-   Size / 64);
+  return llvm::FixedVectorType::get(llvm::Type::getDoubleTy(getVMContext()),
+Size / 64);
 }
 
 /// BitsContainNoUserData - Return true if the specified [start,end) bit range
@@ -3273,7 +3273,8 @@
   // case.
   if (ContainsFloatAtOffset(IRType, IROffset, getDataLayout()) &&
   ContainsFloatAtOffset(IRType, IROffset+4, getDataLayout()))
-return llvm::VectorType::get(llvm::Type::getFloatTy(getVMContext()), 2);
+return llvm::FixedVectorType::get(llvm::Type::getFloatTy(getVMContext()),
+  2);
 
   return llvm::Type::getDoubleTy(getVMContext());
 }
@@ -4140,8 +4141,8 @@
 
   // Mingw64 GCC returns i128 in XMM0. Coerce to v2i64 to handle that.
   // Clang matches them for compatibility.
-  return ABIArgInfo::getDirect(
-  llvm::VectorType::get(llvm::Type::getInt64Ty(getVMContext()), 2));
+  return ABIArgInfo::getDirect(llvm::FixedVectorType::get(
+  llvm::Type::getInt64Ty(getVMContext()), 2));
 
 default:
   break;
@@ -5478,13 +5479,13 @@
   return ABIArgInfo::getDirect(ResType);
 }
 if (Size == 64) {
-  llvm::Type *ResType =
-  llvm::VectorType::get(llvm::Type::getInt32Ty(getVMContext()), 2);
+  auto *ResType =
+  llvm::FixedVectorType::get(llvm::Type::getInt32Ty(getVMContext()), 2);
   return ABIArgInfo::getDirect(ResType);
 }
 if (Size == 128) {
-  llvm::Type *ResType =
-  llvm::VectorType::get(llvm::Type::getInt32Ty(getVMContext()), 4);
+  auto *ResType =
+  llvm::FixedVectorType::get(llvm::Type::getInt32Ty(getVMContext()), 4);
   return ABIArgInfo::getDirect(ResType);
 }
 return getNaturalAlignIndirect(Ty, /*ByVal=*/false);
@@ -6209,7 +6210,7 @@
 return ABIArgInfo::getDirect(ResType);
   }
   if (Size == 64 || Size == 128) {
-llvm::Type *ResType = llvm::VectorType::get(
+auto *ResType = llvm::FixedVectorType::get(
 llvm::Type::getInt32Ty(getVMContext()), Size / 32);
 return ABIArgInfo::getDirect(ResType);
   }
@@ -6225,7 +6226,7 @@
 // FP16 vectors should be converted to integer vectors
 if (!getTarget().hasLegalHalfType() && containsAnyFP16Vectors(Ty)) {
   uint64_t Size = getContext().getTypeSize(VT);
-  llvm::Type *NewVecTy = llvm::VectorType::get(
+  auto *NewVecTy = 

[PATCH] D80692: Run Coverage pass before other *San passes under new pass manager, round 2

2020-05-28 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan accepted this revision.
leonardchan added a comment.
This revision is now accepted and ready to land.

Would be worthwhile to write a small test that asserts Sancov runs before the 
other sanitizers under the new PM?

Aside from this, LGTM.




Comment at: llvm/include/llvm/Passes/PassBuilder.h:597-598
   ///
   /// This extension point allows adding optimizations at the very end of the
   /// function optimization pipeline. A key difference between this and the
   /// legacy PassManager's OptimizerLast callback is that this extension point

aeubanks wrote:
> leonardchan wrote:
> > Will need to change the wording on this if this doesn't handle function 
> > passes anymore.
> This doesn't say that `registerOptimizerLastEPCallback()` handles function 
> passes, it says it handles passes that will run right after all the default 
> function optimization passes. I believe that's still true. The passes were 
> previously added at the end of `OptimizePM`, now they're added right after 
> `OptimizePM`, which is the same thing.
Ah I see. You're right. I misread.



Comment at: llvm/lib/Passes/PassBuilder.cpp:1078
 
+  for (auto  : OptimizerLastEPCallbacks)
+C(MPM, Level);

aeubanks wrote:
> leonardchan wrote:
> > Would it be better to add another `SmallVector` and `register*Calback()` 
> > for modules in in `PassBuilder` that we could loop through here instead of 
> > changing how these extension points work?
> > 
> > I imagine it would still be meaningful in the future to be able to add 
> > function passes at the end of the function optimization pipeline.
> You can still add function passes via `createModuleToFunctionPassAdaptor()`, 
> which is what I've done here for the existing usages. Given that the number 
> of calls to `registerOptimizerLastEPCallback()` is small, I don't see a huge 
> benefit to create a both a vector of module passes and function passes that 
> run at the same place. If in the future we end up calling 
> `registerOptimizerLastEPCallback()` with lots of function passes we can 
> revisit this but for now it seems unnecessary.
> 
> This change doesn't change the ordering of any passes aside from sanitizer 
> coverage (I believe), all usages of `registerOptimizerLastEPCallback()` will 
> still end up putting the passes in the same place in the pipeline.
I see. Makes sense.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80692



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


[PATCH] D80603: add isAtPosition narrowing matcher for parmVarDecl

2020-05-28 Thread Vy Nguyen via Phabricator via cfe-commits
oontvoo added a comment.

In D80603#2061131 , @aaron.ballman 
wrote:

> In D80603#2059122 , @gribozavr2 
> wrote:
>
> > In D80603#2058019 , @aaron.ballman 
> > wrote:
> >
> > > I'm sorry if I'm being dense, but `hasParameter`  traverses to the 
> > > `ParmVarDecl`, so I'm not certain I understand why this new matcher is 
> > > needed as a public matcher. It seems like you can already accomplish this 
> > > without adding a second API to do effectively the same thing: 
> > > `functionDecl(hasParameter(0, parmVarDecl().bind("param")))`, can't you?
> >
> >
> > It is syntax sugar, true. Note that the proposed matcher is a narrowing 
> > matcher for `parmVarDecl()`, while your suggestion is a narrowing matcher 
> > for `functionDecl()`, so it is not an entirely apples-to-apples comparison. 
> > Think about use cases like: `declRefExpr(to(parmVarDecl(at(...`. To 
> > rewrite that with `hasParameter()`, we have to use `hasAncestor` to find 
> > the `functionDecl` first, and then compare the AST node pointers. So while 
> > it is possible to express this proposed operation today, it requires a 
> > complex matcher for such a conceptually simple operation.
>
>
> Thank you, that clarifies the need nicely for me!
>
> Is there a reason we want to support blocks but not lambdas?


Yes, the implementation does support lambdas

> Also, you need to update Registry.cpp to add this to the list of dynamic 
> matchers.

Done


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80603



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


[PATCH] D80603: add isAtPosition narrowing matcher for parmVarDecl

2020-05-28 Thread Vy Nguyen via Phabricator via cfe-commits
oontvoo updated this revision to Diff 266999.
oontvoo added a comment.

Updated Registry


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80603

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -2643,6 +2643,45 @@
   parmVarDecl(hasDefaultArgument(;
 }
 
+TEST(IsAtPosition, Basic) {
+  EXPECT_TRUE(matches("void x(int a, int b) {}", parmVarDecl(isAtPosition(1;
+  EXPECT_TRUE(matches("void x(int a, int b) {}", parmVarDecl(isAtPosition(0;
+  EXPECT_TRUE(matches("void x(int a, int b) {}", parmVarDecl(isAtPosition(1;
+  EXPECT_TRUE(notMatches("void x(int val) {}", parmVarDecl(isAtPosition(1;
+}
+
+TEST(IsAtPosition, FunctionDecl) {
+  EXPECT_TRUE(matches("void x(int a);", parmVarDecl(isAtPosition(0;
+  EXPECT_TRUE(matches("void x(int a, int b);", parmVarDecl(isAtPosition(0;
+  EXPECT_TRUE(matches("void x(int a, int b);", parmVarDecl(isAtPosition(1;
+  EXPECT_TRUE(notMatches("void x(int val);", parmVarDecl(isAtPosition(1;
+}
+
+TEST(IsAtPosition, Lambda) {
+  EXPECT_TRUE(
+  matches("void x() { [](int a) {};  }", parmVarDecl(isAtPosition(0;
+  EXPECT_TRUE(matches("void x() { [](int a, int b) {}; }",
+  parmVarDecl(isAtPosition(0;
+  EXPECT_TRUE(matches("void x() { [](int a, int b) {}; }",
+  parmVarDecl(isAtPosition(1;
+  EXPECT_TRUE(
+  notMatches("void x() { [](int val) {}; }", parmVarDecl(isAtPosition(1;
+}
+
+TEST(IsAtPosition, BlockDecl) {
+  EXPECT_TRUE(matchesObjC(
+  "void func()  { void (^my_block)(int arg) = ^void(int arg) {}; } ",
+  parmVarDecl(isAtPosition(0;
+
+  EXPECT_TRUE(matchesObjC("void func()  { void (^my_block)(int x, int y) = "
+  "^void(int x, int y) {}; } ",
+  parmVarDecl(isAtPosition(1;
+
+  EXPECT_TRUE(notMatchesObjC(
+  "void func()  { void (^my_block)(int arg) = ^void(int arg) {}; } ",
+  parmVarDecl(isAtPosition(1;
+}
+
 TEST(IsArray, Basic) {
   EXPECT_TRUE(matches("struct MyClass {}; MyClass *p1 = new MyClass[10];",
   cxxNewExpr(isArray(;
Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -261,6 +261,7 @@
   REGISTER_MATCHER(hasCastKind);
   REGISTER_MATCHER(hasCondition);
   REGISTER_MATCHER(hasConditionVariableStatement);
+  REGISTER_MATCHER(isAtPosition);
   REGISTER_MATCHER(hasDecayedType);
   REGISTER_MATCHER(hasDeclContext);
   REGISTER_MATCHER(hasDeclaration);
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -4615,6 +4615,34 @@
  InnerMatcher.matches(*DeclarationStatement, Finder, Builder);
 }
 
+/// Matches the ParmVarDecl nodes that are at the N'th position in the parameter
+/// list. The parameter list could be that of either a block, function, or
+/// objc-method.
+///
+///
+/// Given
+///
+/// \code
+/// void f(int a, int b, int c) {
+/// }
+/// \endcode
+///
+/// ``parmVarDecl(isAtPosition(0))`` matches ``int a``.
+///
+/// ``parmVarDecl(isAtPosition(1))`` matches ``int b``.
+AST_MATCHER_P(clang::ParmVarDecl, isAtPosition, unsigned, N) {
+  const clang::DeclContext *Context = Node.getParentFunctionOrMethod();
+
+  if (const auto *Decl = dyn_cast_or_null(Context))
+return N < Decl->param_size() && Decl->getParamDecl(N) == 
+  if (const auto *Decl = dyn_cast_or_null(Context))
+return N < Decl->param_size() && Decl->getParamDecl(N) == 
+  if (const auto *Decl = dyn_cast_or_null(Context))
+return N < Decl->param_size() && Decl->getParamDecl(N) == 
+
+  return false;
+}
+
 /// Matches the index expression of an array subscript expression.
 ///
 /// Given
Index: clang/docs/LibASTMatchersReference.html
===
--- clang/docs/LibASTMatchersReference.html
+++ clang/docs/LibASTMatchersReference.html
@@ -4671,6 +4671,23 @@
 Usable as: Matcherhttps://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html;>FunctionDecl, Matcherhttps://clang.llvm.org/doxygen/classclang_1_1VarDecl.html;>VarDecl, Matcherhttps://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html;>CXXRecordDecl
 
 
+
+Matcherclang::ParmVarDeclisAtPositionunsigned N
+Matches the ParmVarDecl nodes that 

[PATCH] D80603: add isAtPosition narrowing matcher for parmVarDecl

2020-05-28 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

> Also, you need to update Registry.cpp to add this to the list of dynamic 
> matchers.

Good point. @oontvoo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80603



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


[PATCH] D80315: Fix CC1 command line options mapping into fast-math flags.

2020-05-28 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D80315#2059160 , @michele.scandale 
wrote:

> In D80315#2058914 , @rjmccall wrote:
>
> > In D80315#2058735 , 
> > @michele.scandale wrote:
> >
> > > In D80315#2058549 , @rjmccall 
> > > wrote:
> > >
> > > > The code cleanups all seems reasonable.  The actual changes in 
> > > > code-generation changes are because we were failing to set these 
> > > > reliably?
> > >
> > >
> > > Most of them yes.
> > >
> > > In the CUDA test we there is now `contract` because we honor the default 
> > > contraction mode that for CUDA is set to fast.
> >
> >
> > Right, and we weren't honoring that mode before?
>
>
> Not in the setup of base fast-math flags inside `CodeGenFunction`. However 
> when emitting code for expression with `FPOptions` stored in the AST nodes 
> then `contract` was set correctly.


Okay, that seems justifiable.

>>> In `clang/test/CodeGen/complex-math.c` I've added `-ffp-contract=fast` to 
>>> the command line option because `-ffast-math` at the CC1 level does not 
>>> change the default contraction mode.
>> 
>> Oh, I see, makes sense.  So there was inconsistent treatment of the options, 
>> where one thing observed it but others didn't, and that's been fixed now.
> 
> Do you think we should handle `-ffast-math` as `-cl-fast-relaxed-math`, i.e. 
> it implies the default contraction mode being "fast"?

I'm actually surprised it doesn't.  I can't imagine why someone enabling fast 
math would want contraction to be disabled.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80315



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


[PATCH] D80603: add isAtPosition narrowing matcher for parmVarDecl

2020-05-28 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

> Is there a reason we want to support blocks but not lambdas?

Lambdas are supported (see tests). Lambdas generate classes with regular 
function decls, so there's no surprise there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80603



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


[clang] 51401a6 - add isAtPosition narrowing matcher for parmVarDecl

2020-05-28 Thread Vy Nguyen via cfe-commits

Author: Vy Nguyen
Date: 2020-05-28T16:04:41-04:00
New Revision: 51401a676c036f2bd4e6b4b38f3538615799de40

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

LOG: add isAtPosition narrowing matcher for parmVarDecl

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

Added: 


Modified: 
clang/docs/LibASTMatchersReference.html
clang/include/clang/ASTMatchers/ASTMatchers.h
clang/lib/ASTMatchers/Dynamic/Registry.cpp
clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Removed: 




diff  --git a/clang/docs/LibASTMatchersReference.html 
b/clang/docs/LibASTMatchersReference.html
index f57352389e4c..9db6795eb5fa 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -4671,6 +4671,23 @@ Narrowing Matchers
 Usable as: Matcherhttps://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html;>FunctionDecl,
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1VarDecl.html;>VarDecl,
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html;>CXXRecordDecl
 
 
+
+Matcherclang::ParmVarDeclisAtPositionunsigned N
+Matches the 
ParmVarDecl nodes that are at the N'th position in the parameter
+list. The parameter list could be that of either a block, function, or
+objc-method.
+
+
+Given
+
+void f(int a, int b, int c) {
+}
+
+``parmVarDecl(isAtPosition(0))`` matches ``int a``.
+
+``parmVarDecl(isAtPosition(1))`` matches ``int b``.
+
+
 
 
 

diff  --git a/clang/include/clang/ASTMatchers/ASTMatchers.h 
b/clang/include/clang/ASTMatchers/ASTMatchers.h
index a750747c9aa3..a3747faa139c 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -4257,6 +4257,34 @@ AST_POLYMORPHIC_MATCHER_P2(forEachArgumentWithParam,
   return Matched;
 }
 
+/// Matches the ParmVarDecl nodes that are at the N'th position in the 
parameter
+/// list. The parameter list could be that of either a block, function, or
+/// objc-method.
+///
+///
+/// Given
+///
+/// \code
+/// void f(int a, int b, int c) {
+/// }
+/// \endcode
+///
+/// ``parmVarDecl(isAtPosition(0))`` matches ``int a``.
+///
+/// ``parmVarDecl(isAtPosition(1))`` matches ``int b``.
+AST_MATCHER_P(clang::ParmVarDecl, isAtPosition, unsigned, N) {
+  const clang::DeclContext *Context = Node.getParentFunctionOrMethod();
+
+  if (const auto *Decl = dyn_cast_or_null(Context))
+return N < Decl->param_size() && Decl->getParamDecl(N) == 
+  if (const auto *Decl = dyn_cast_or_null(Context))
+return N < Decl->param_size() && Decl->getParamDecl(N) == 
+  if (const auto *Decl = dyn_cast_or_null(Context))
+return N < Decl->param_size() && Decl->getParamDecl(N) == 
+
+  return false;
+}
+
 /// Matches any parameter of a function or an ObjC method declaration or a
 /// block.
 ///

diff  --git a/clang/lib/ASTMatchers/Dynamic/Registry.cpp 
b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
index 0a7d09e55c88..14d9bbb3e52d 100644
--- a/clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -219,6 +219,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(floatLiteral);
   REGISTER_MATCHER(forEach);
   REGISTER_MATCHER(forEachArgumentWithParam);
+  REGISTER_MATCHER(isAtPosition);
   REGISTER_MATCHER(forEachConstructorInitializer);
   REGISTER_MATCHER(forEachDescendant);
   REGISTER_MATCHER(forEachOverridden);

diff  --git a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
index a7d58528c0fb..929188abf6ac 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -2643,6 +2643,45 @@ TEST(HasDefaultArgument, Basic) {
   parmVarDecl(hasDefaultArgument(;
 }
 
+TEST(IsAtPosition, Basic) {
+  EXPECT_TRUE(matches("void x(int a, int b) {}", 
parmVarDecl(isAtPosition(1;
+  EXPECT_TRUE(matches("void x(int a, int b) {}", 
parmVarDecl(isAtPosition(0;
+  EXPECT_TRUE(matches("void x(int a, int b) {}", 
parmVarDecl(isAtPosition(1;
+  EXPECT_TRUE(notMatches("void x(int val) {}", parmVarDecl(isAtPosition(1;
+}
+
+TEST(IsAtPosition, FunctionDecl) {
+  EXPECT_TRUE(matches("void x(int a);", parmVarDecl(isAtPosition(0;
+  EXPECT_TRUE(matches("void x(int a, int b);", parmVarDecl(isAtPosition(0;
+  EXPECT_TRUE(matches("void x(int a, int b);", parmVarDecl(isAtPosition(1;
+  EXPECT_TRUE(notMatches("void x(int val);", parmVarDecl(isAtPosition(1;
+}
+
+TEST(IsAtPosition, Lambda) {
+  EXPECT_TRUE(
+  matches("void x() { [](int a) {};  }", parmVarDecl(isAtPosition(0;
+  EXPECT_TRUE(matches("void x() { [](int a, int b) {}; }",
+  parmVarDecl(isAtPosition(0;
+  EXPECT_TRUE(matches("void x() { [](int a, 

[PATCH] D80731: Improve test infrastructure in SyntaxTree

2020-05-28 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGeca41919d28b: Improve test infrastructure in SyntaxTree 
(authored by eduucaldas, committed by gribozavr).

Changed prior to commit:
  https://reviews.llvm.org/D80731?vs=266898=266993#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80731

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

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -15,6 +15,7 @@
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/FrontendAction.h"
+#include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "clang/Tooling/Syntax/BuildTree.h"
@@ -97,8 +98,12 @@
 
 constexpr const char *FileName = "./input.cpp";
 FS->addFile(FileName, time_t(), llvm::MemoryBuffer::getMemBufferCopy(""));
+
 if (!Diags->getClient())
-  Diags->setClient(new IgnoringDiagConsumer);
+  Diags->setClient(new TextDiagnosticPrinter(llvm::errs(), DiagOpts.get()));
+Diags->setSeverityForGroup(diag::Flavor::WarningOrError, "unused-value",
+   diag::Severity::Ignored, SourceLocation());
+
 // Prepare to run a compiler.
 std::vector Args = {
 "syntax-test", "-target",   Target.c_str(),
@@ -117,7 +122,11 @@
 
 syntax::TranslationUnit *Root = nullptr;
 BuildSyntaxTreeAction Recorder(Root, this->Arena);
-if (!Compiler.ExecuteAction(Recorder)) {
+
+// Action could not be executed but the frontend didn't identify any errors
+// in the code ==> problem in setting up the action.
+if (!Compiler.ExecuteAction(Recorder) &&
+Diags->getClient()->getNumErrors() == 0) {
   ADD_FAILURE() << "failed to run the frontend";
   std::abort();
 }
@@ -143,6 +152,8 @@
 continue;
   }
   auto *Root = buildTree(Code, Target);
+  EXPECT_EQ(Diags->getClient()->getNumErrors(), 0u)
+  << "Source file has syntax errors, they were printed to the test log";
   std::string Actual = std::string(StringRef(Root->dump(*Arena)).trim());
   EXPECT_EQ(Expected, Actual)
   << "for target " << Target << " the resulting dump is:\n"
@@ -180,8 +191,10 @@
   }
 
   // Data fields.
+  llvm::IntrusiveRefCntPtr DiagOpts =
+  new DiagnosticOptions();
   llvm::IntrusiveRefCntPtr Diags =
-  new DiagnosticsEngine(new DiagnosticIDs, new DiagnosticOptions);
+  new DiagnosticsEngine(new DiagnosticIDs, DiagOpts.get());
   IntrusiveRefCntPtr FS =
   new llvm::vfs::InMemoryFileSystem;
   llvm::IntrusiveRefCntPtr FileMgr =
@@ -517,11 +530,11 @@
   // Unhandled statements should end up as 'unknown statement'.
   // This example uses a 'label statement', which does not yet have a syntax
   // counterpart.
-  expectTreeDumpEqual("void main() { foo: return 100; }",
+  expectTreeDumpEqual("int main() { foo: return 100; }",
   R"txt(
 *: TranslationUnit
 `-SimpleDeclaration
-  |-void
+  |-int
   |-SimpleDeclarator
   | |-main
   | `-ParametersAndQualifiers
@@ -1166,7 +1179,7 @@
   // Free-standing classes, must live inside a SimpleDeclaration.
   expectTreeDumpEqual(
   R"cpp(
-sturct X;
+struct X;
 struct X {};
 
 struct Y *y1;
@@ -1177,7 +1190,7 @@
   R"txt(
 *: TranslationUnit
 |-SimpleDeclaration
-| |-sturct
+| |-struct
 | |-X
 | `-;
 |-SimpleDeclaration
@@ -1660,7 +1673,7 @@
 int a[10];
 int b[1][2][3];
 int c[] = {1,2,3};
-void f(int xs[static 10]);
+// void f(int xs[static 10]);
 )cpp",
   R"txt(
 *: TranslationUnit
@@ -1694,163 +1707,146 @@
 | |   | `-3
 | |   `-]
 | `-;
-|-SimpleDeclaration
-| |-int
-| |-SimpleDeclarator
-| | |-c
-| | |-ArraySubscript
-| | | |-[
-| | | `-]
-| | |-=
-| | `-UnknownExpression
-| |   `-UnknownExpression
-| | |-{
-| | |-UnknownExpression
-| | | `-1
-| | |-,
-| | |-UnknownExpression
-| | | `-2
-| | |-,
-| | |-UnknownExpression
-| | | `-3
-| | `-}
-| `-;
 `-SimpleDeclaration
-  |-void
+  |-int
   |-SimpleDeclarator
-  | |-f
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   |-SimpleDeclaration
-  |   | |-int
-  |   | `-SimpleDeclarator
-  |   |   |-xs
-  |   |   `-ArraySubscript
-  |   | |-[
-  |   | |-static
-  |   | |-UnknownExpression
-  |   | | `-10
-  |   | `-]
-  |   `-)
-  `-;
-   )txt");
+  | |-c
+  | |-ArraySubscript
+  | | |-[
+  | | `-]
+  | |-=
+  | `-UnknownExpression
+  |   `-UnknownExpression
+  | |-{
+  | |-UnknownExpression
+  | | `-1
+  | |-,
+  | |-UnknownExpression
+  | | `-2
+  | |-,
+  | |-UnknownExpression
+  | | `-3
+  | `-}
+  `-;   )txt");
 }
 
 

[PATCH] D80603: add isAtPosition narrowing matcher for parmVarDecl

2020-05-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D80603#2059122 , @gribozavr2 wrote:

> In D80603#2058019 , @aaron.ballman 
> wrote:
>
> > I'm sorry if I'm being dense, but `hasParameter`  traverses to the 
> > `ParmVarDecl`, so I'm not certain I understand why this new matcher is 
> > needed as a public matcher. It seems like you can already accomplish this 
> > without adding a second API to do effectively the same thing: 
> > `functionDecl(hasParameter(0, parmVarDecl().bind("param")))`, can't you?
>
>
> It is syntax sugar, true. Note that the proposed matcher is a narrowing 
> matcher for `parmVarDecl()`, while your suggestion is a narrowing matcher for 
> `functionDecl()`, so it is not an entirely apples-to-apples comparison. Think 
> about use cases like: `declRefExpr(to(parmVarDecl(at(...`. To rewrite 
> that with `hasParameter()`, we have to use `hasAncestor` to find the 
> `functionDecl` first, and then compare the AST node pointers. So while it is 
> possible to express this proposed operation today, it requires a complex 
> matcher for such a conceptually simple operation.


Thank you, that clarifies the need nicely for me!

Is there a reason we want to support blocks but not lambdas?

Also, you need to update Registry.cpp to add this to the list of dynamic 
matchers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80603



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


[clang] eca4191 - Improve test infrastructure in SyntaxTree

2020-05-28 Thread Dmitri Gribenko via cfe-commits

Author: Eduardo Caldas
Date: 2020-05-28T21:35:12+02:00
New Revision: eca41919d28b0616140a63c6a97483098ec1ffee

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

LOG: Improve test infrastructure in SyntaxTree

Summary:
* Test if the code sourcing the SyntaxTree compiles
* Output compiler errors and warnings to err
* Fix tests with code that did not compile

Reviewers: gribozavr2

Reviewed By: gribozavr2

Subscribers: cfe-commits

Tags: #clang

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

Added: 


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

Removed: 




diff  --git a/clang/unittests/Tooling/Syntax/TreeTest.cpp 
b/clang/unittests/Tooling/Syntax/TreeTest.cpp
index e81e3c2b8354..7051074d3b33 100644
--- a/clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ b/clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -15,6 +15,7 @@
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/FrontendAction.h"
+#include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "clang/Tooling/Syntax/BuildTree.h"
@@ -97,8 +98,12 @@ class SyntaxTreeTest : public ::testing::Test {
 
 constexpr const char *FileName = "./input.cpp";
 FS->addFile(FileName, time_t(), llvm::MemoryBuffer::getMemBufferCopy(""));
+
 if (!Diags->getClient())
-  Diags->setClient(new IgnoringDiagConsumer);
+  Diags->setClient(new TextDiagnosticPrinter(llvm::errs(), 
DiagOpts.get()));
+Diags->setSeverityForGroup(diag::Flavor::WarningOrError, "unused-value",
+   diag::Severity::Ignored, SourceLocation());
+
 // Prepare to run a compiler.
 std::vector Args = {
 "syntax-test", "-target",   Target.c_str(),
@@ -117,7 +122,11 @@ class SyntaxTreeTest : public ::testing::Test {
 
 syntax::TranslationUnit *Root = nullptr;
 BuildSyntaxTreeAction Recorder(Root, this->Arena);
-if (!Compiler.ExecuteAction(Recorder)) {
+
+// Action could not be executed but the frontend didn't identify any errors
+// in the code ==> problem in setting up the action.
+if (!Compiler.ExecuteAction(Recorder) &&
+Diags->getClient()->getNumErrors() == 0) {
   ADD_FAILURE() << "failed to run the frontend";
   std::abort();
 }
@@ -143,6 +152,8 @@ class SyntaxTreeTest : public ::testing::Test {
 continue;
   }
   auto *Root = buildTree(Code, Target);
+  EXPECT_EQ(Diags->getClient()->getNumErrors(), 0u)
+  << "Source file has syntax errors, they were printed to the test 
log";
   std::string Actual = std::string(StringRef(Root->dump(*Arena)).trim());
   EXPECT_EQ(Expected, Actual)
   << "for target " << Target << " the resulting dump is:\n"
@@ -180,8 +191,10 @@ class SyntaxTreeTest : public ::testing::Test {
   }
 
   // Data fields.
+  llvm::IntrusiveRefCntPtr DiagOpts =
+  new DiagnosticOptions();
   llvm::IntrusiveRefCntPtr Diags =
-  new DiagnosticsEngine(new DiagnosticIDs, new DiagnosticOptions);
+  new DiagnosticsEngine(new DiagnosticIDs, DiagOpts.get());
   IntrusiveRefCntPtr FS =
   new llvm::vfs::InMemoryFileSystem;
   llvm::IntrusiveRefCntPtr FileMgr =
@@ -517,11 +530,11 @@ TEST_F(SyntaxTreeTest, UnhandledStatement) {
   // Unhandled statements should end up as 'unknown statement'.
   // This example uses a 'label statement', which does not yet have a syntax
   // counterpart.
-  expectTreeDumpEqual("void main() { foo: return 100; }",
+  expectTreeDumpEqual("int main() { foo: return 100; }",
   R"txt(
 *: TranslationUnit
 `-SimpleDeclaration
-  |-void
+  |-int
   |-SimpleDeclarator
   | |-main
   | `-ParametersAndQualifiers
@@ -1166,7 +1179,7 @@ TEST_F(SyntaxTreeTest, FreeStandingClasses) {
   // Free-standing classes, must live inside a SimpleDeclaration.
   expectTreeDumpEqual(
   R"cpp(
-sturct X;
+struct X;
 struct X {};
 
 struct Y *y1;
@@ -1177,7 +1190,7 @@ struct {} *a1;
   R"txt(
 *: TranslationUnit
 |-SimpleDeclaration
-| |-sturct
+| |-struct
 | |-X
 | `-;
 |-SimpleDeclaration
@@ -1660,7 +1673,7 @@ TEST_F(SyntaxTreeTest, ArraySubscriptsInDeclarators) {
 int a[10];
 int b[1][2][3];
 int c[] = {1,2,3};
-void f(int xs[static 10]);
+// void f(int xs[static 10]);
 )cpp",
   R"txt(
 *: TranslationUnit
@@ -1694,163 +1707,146 @@ void f(int xs[static 10]);
 | |   | `-3
 | |   `-]
 | `-;
-|-SimpleDeclaration
-| |-int
-| |-SimpleDeclarator
-| | |-c
-| | |-ArraySubscript
-| | | |-[
-| | | `-]
-| | |-=
-| | `-UnknownExpression
-| |   `-UnknownExpression
-| | |-{
-| | |-UnknownExpression
-| | | `-1
-| | |-,
-| | |-UnknownExpression
-| | | `-2
-| | |-,
-| | 

[PATCH] D77836: [Attribute] Fix noderef attribute false-negatives

2020-05-28 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

*ping*


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77836



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


[PATCH] D80692: Run Coverage pass before other *San passes under new pass manager, round 2

2020-05-28 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks marked 2 inline comments as done.
aeubanks added inline comments.



Comment at: llvm/include/llvm/Passes/PassBuilder.h:597-598
   ///
   /// This extension point allows adding optimizations at the very end of the
   /// function optimization pipeline. A key difference between this and the
   /// legacy PassManager's OptimizerLast callback is that this extension point

leonardchan wrote:
> Will need to change the wording on this if this doesn't handle function 
> passes anymore.
This doesn't say that `registerOptimizerLastEPCallback()` handles function 
passes, it says it handles passes that will run right after all the default 
function optimization passes. I believe that's still true. The passes were 
previously added at the end of `OptimizePM`, now they're added right after 
`OptimizePM`, which is the same thing.



Comment at: llvm/lib/Passes/PassBuilder.cpp:1078
 
+  for (auto  : OptimizerLastEPCallbacks)
+C(MPM, Level);

leonardchan wrote:
> Would it be better to add another `SmallVector` and `register*Calback()` for 
> modules in in `PassBuilder` that we could loop through here instead of 
> changing how these extension points work?
> 
> I imagine it would still be meaningful in the future to be able to add 
> function passes at the end of the function optimization pipeline.
You can still add function passes via `createModuleToFunctionPassAdaptor()`, 
which is what I've done here for the existing usages. Given that the number of 
calls to `registerOptimizerLastEPCallback()` is small, I don't see a huge 
benefit to create a both a vector of module passes and function passes that run 
at the same place. If in the future we end up calling 
`registerOptimizerLastEPCallback()` with lots of function passes we can revisit 
this but for now it seems unnecessary.

This change doesn't change the ordering of any passes aside from sanitizer 
coverage (I believe), all usages of `registerOptimizerLastEPCallback()` will 
still end up putting the passes in the same place in the pipeline.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80692



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


[PATCH] D80369: [DebugInfo][CallSites] Remove decl subprograms from 'retainedTypes:'

2020-05-28 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: clang/test/Modules/ModuleDebugInfo.m:46-47
 
-// The forward declaration should not be in the module scope.
-// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "OpaqueData", file
-

Did this type go missing with this change? (ie: was this type /only/ accessible 
via a subprogram in the retained types list?)


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

https://reviews.llvm.org/D80369



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


[PATCH] D80753: [clang-tidy] remove duplicate fixes of alias checkers

2020-05-28 Thread Daniel via Phabricator via cfe-commits
Daniel599 created this revision.
Daniel599 added reviewers: alexfh, hokein.
Daniel599 added a project: clang-tools-extra.
Herald added subscribers: cfe-commits, Charusso, xazax.hun.
Herald added a project: clang.

when both a check and its alias are enabled, we should only take the fixes of 
one of them and not both.
This patch fixes bug 45577
https://bugs.llvm.org/show_bug.cgi?id=45577


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80753

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
  
clang-tools-extra/test/clang-tidy/infrastructure/duplicate-fixes-of-alias-checkers.cpp

Index: clang-tools-extra/test/clang-tidy/infrastructure/duplicate-fixes-of-alias-checkers.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/infrastructure/duplicate-fixes-of-alias-checkers.cpp
@@ -0,0 +1,52 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-member-init,hicpp-member-init,modernize-use-emplace,hicpp-use-emplace %t
+
+#include 
+namespace std {
+template 
+class initializer_list {
+public:
+  initializer_list() noexcept {}
+};
+
+template 
+class vector {
+public:
+  vector() = default;
+  vector(initializer_list) {}
+
+  void push_back(const T &) {}
+  void push_back(T &&) {}
+
+  template 
+  void emplace_back(Args &&... args){};
+  ~vector();
+};
+} // namespace std
+
+class Foo {
+public:
+  Foo() : _num1(0)
+  // CHECK-MESSAGES: warning: constructor does not initialize these fields: _num2 [cppcoreguidelines-pro-type-member-init]
+  // CHECK-MESSAGES: warning: constructor does not initialize these fields: _num2 [hicpp-member-init]
+  // CHECK-MESSAGES: note: this fix will not be applied because an alias checker has already provided it, see 'cppcoreguidelines-pro-type-member-init'
+  {
+printf("some code so it won't be a trival ctor\n");
+  }
+
+  int use_the_members() const {
+return _num1 + _num2;
+  }
+
+private:
+  int _num1;
+  int _num2;
+  // CHECK-FIXES: _num2{};
+};
+
+int should_use_emplace(std::vector ) {
+  v.push_back(Foo());
+  // CHECK-FIXES: v.emplace_back();
+  // CHECK-MESSAGES: warning: use emplace_back instead of push_back [hicpp-use-emplace]
+  // CHECK-MESSAGES: warning: use emplace_back instead of push_back [modernize-use-emplace]
+  // CHECK-MESSAGES: note: this fix will not be applied because an alias checker has already provided it, see 'hicpp-use-emplace'
+}
\ No newline at end of file
Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -246,6 +246,7 @@
 private:
   void finalizeLastError();
   void removeIncompatibleErrors();
+  void removeDuplicatedFixesOfAliasCheckers();
 
   /// Returns the \c HeaderFilter constructed for the options set in the
   /// context.
Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -634,6 +634,8 @@
 std::tuple Priority;
   };
 
+  removeDuplicatedFixesOfAliasCheckers();
+
   // Compute error sizes.
   std::vector Sizes;
   std::vector<
@@ -728,3 +730,34 @@
 removeIncompatibleErrors();
   return std::move(Errors);
 }
+
+namespace {
+struct LessClangTidyErrorWithoutDiagnosticName {
+  bool operator()(const ClangTidyError *LHS, const ClangTidyError *RHS) const {
+const tooling::DiagnosticMessage  = LHS->Message;
+const tooling::DiagnosticMessage  = RHS->Message;
+
+return std::tie(M1.FilePath, M1.FileOffset, M1.Message) <
+   std::tie(M2.FilePath, M2.FileOffset, M2.Message);
+  }
+};
+} // end anonymous namespace
+
+void ClangTidyDiagnosticConsumer::removeDuplicatedFixesOfAliasCheckers() {
+  std::set
+  UniqueErrors;
+  for (auto  : Errors) {
+auto Inserted = UniqueErrors.insert();
+
+// If we already have an error like this, just with the different
+// DiagnosticName, Remove its Fix since we don't need same fix twice
+if (!Inserted.second && !Error.Message.Fix.empty()) {
+  Error.Message.Fix.clear();
+  std::string FixAlreadyExists =
+  "this fix will not be applied because an alias checker has already "
+  "provided it, see '" +
+  (*Inserted.first)->DiagnosticName + "'";
+  Error.Notes.emplace_back(std::move(FixAlreadyExists));
+}
+  }
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69764: [clang-format] Add East/West Const fixer capability

2020-05-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D69764#2058590 , @rsmith wrote:

> In D69764#2058334 , @MyDeveloperDay 
> wrote:
>
> > @rsmith, Thank you for your comments, I don't agree, but thank you anyway.
> >
> > I will continue to feel there is some value here, My hope is that others 
> > will feel the same.
>
>
> To be clear: I do think a tool that will reorder specifiers to match a coding 
> standard has value. My concern is that it seems like scope creep for 
> clang-format in particular to do that, and that scope creep makes me 
> uncomfortable -- we're moving further away from the set of transformations 
> that clang-format can be very confident don't change the meaning of the 
> program, and we have seen problems with such scope creep in the past. But I'm 
> only uncomfortable, not opposed. Looking back through the review thread, I 
> don't think I'm raising anything that @sammccall didn't already bring up, and 
> it seems to me like you have consensus for doing this despite those concerns. 
> So be it. :)


I share the concern about this functionality causing a reformat to change the 
behavior of the program. I think a condition of accepting this feature into 
clang-format is that it not change the meaning of the user's code (except 
perhaps in very rare circumstances where there's consensus we should not care 
about that kind of input source code). If that means we can't have the feature 
in clang-format and need it in clang-tidy, so be it.

> I think that if we are reordering `const`, we should be reordering all 
> //decl-specifier//s -- I'd like to see `int static constexpr unsigned const 
> long inline` reordered to something like `static constexpr inline const 
> unsigned long int` too. Applying this only to `const` seems incomplete to me.

Agreed; I brought that up earlier in the review and still think it's valuable.




Comment at: clang/lib/Format/EastWestConstFixer.cpp:157-158
+  IsCVQualifierOrType(Tok->Next->Next)) {
+// The unsigned/signed case  `const unsigned int` -> `unsigned int
+// const`
+swapFirstThreeTokens(SourceMgr, Fixes, Tok, Tok->Next, Tok->Next->Next,

MyDeveloperDay wrote:
> MyDeveloperDay wrote:
> > aaron.ballman wrote:
> > > What about something like `const unsigned long long` or the 
> > > less-common-but-equally-valid `long const long unsigned`? Or multiple 
> > > qualifiers like `unsigned volatile long const long * restrict`
> > I would like to cover as many cases as possible, but a small part of me 
> > thinks that at least initially if we skip a case or two like this I'd be 
> > fine.
> > 
> > But I'll take a look and see what I think we could add easily in terms of 
> > multiple simple types in a row.
> @aaron.ballman  if you saw
> 
> `long const long unsigned` what would you expect it to become in both east 
> and west const cases? 
> 
> my assumption is:
> 
>  - east : `long long unsigned const`
>  - west: `const long long unsigned`
> 
> Or something else?
> 
> same for
> 
> `unsigned volatile long const long * restrict` I assume:
> 
>  - east : `unsigned volatile long long const * restrict`
>  - west: ` const unsigned volatile long long* restrict`
> 
> Its it would help if I understood the typical expectation in these situations?
> 
> 
I would assume the same thing you're assuming in these cases. Similar for:
```
long static constexpr unsigned long const int i = 12;

// East
static constexpr unsigned long long int const i = 12;
// West
static constexpr const unsigned long long int i = 12;
```
Uncertain how others feel, esp about the non-qualifier behavior, which I 
envision being: keep the non-qualifiers in whatever order they appear in the 
original source, shift the qualifiers left/right as needed (keeping the order 
in which they appear, if we decide to support all qualifiers instead of just 
`const` as part of this patch).



Comment at: clang/lib/Format/EastWestConstFixer.cpp:293
+  Tok->Next->Next->Next && Tok->Next->Next->Next->is(tok::kw_const)) {
+swapFourTokens(SourceMgr, Fixes, Tok, Tok->Next, Tok->Next, 
Tok->Next->Next->Next,
+ /*West=*/true);

curdeius wrote:
> MyDeveloperDay wrote:
> > rsmith wrote:
> > > There can be more than four type-specifiers / cv-qualifiers in a row. Eg: 
> > > `unsigned long long int volatile const` -> `const volatile unsigned long 
> > > long int`.
> > you have the volatile moving too? if you had the choice would it become:
> > 
> > - `const unsigned long long int volatile`
> > - `const volatile unsigned long long int`
> > - `volatile const unsigned long long int`
> > 
> > Any reason why? or is that personal taste? what would be the ideal?
> > 
> > 
> Given the size of this revision, it would be probably wiser not to touch 
> anything else than `const`.
> Any reason why? or is that personal taste? what would be the ideal?

It's a bit odd 

[PATCH] D80752: [AArch64]: BFloat MatMul Intrinsics

2020-05-28 Thread Luke Geeson via Phabricator via cfe-commits
LukeGeeson created this revision.
LukeGeeson added reviewers: SjoerdMeijer, t.p.northover, sdesmalen, labrinea.
Herald added subscribers: llvm-commits, cfe-commits, danielkiss, hiraditya, 
kristof.beyls.
Herald added projects: clang, LLVM.
LukeGeeson added a parent revision: D80716: [AArch64]: BFloat Load/Store 
Intrinsics

This patch upstreams support for BFloat Matrix Multiplication Intrinsics
and Code Generation from __bf16 to AArch64. This includes IR intrinsics. 
Unittests are
provided as needed. AArch32 Intrinsics + CodeGen will come after this
patch.

This patch is part of a series implementing the Bfloat16 extension of
the
Armv8.6-a architecture, as detailed here:

https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/arm-architecture-developments-armv8-6-a

The bfloat type, and its properties are specified in the Arm
Architecture
Reference Manual:

https://developer.arm.com/docs/ddi0487/latest/arm-architecture-reference-manual-armv8-for-armv8-a-architecture-profile

The following people contributed to this patch:

- Luke Geeson
- Momchil Velikov
- Mikhail Maltsev
- Luke Cheeseman


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80752

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-bf16-dotprod-intrinsics.c
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64InstrFormats.td
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/test/CodeGen/AArch64/aarch64-bf16-dotprod-intrinsics.ll

Index: llvm/test/CodeGen/AArch64/aarch64-bf16-dotprod-intrinsics.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/aarch64-bf16-dotprod-intrinsics.ll
@@ -0,0 +1,149 @@
+; RUN: llc -mtriple aarch64-arm-none-eabi  -mattr=+bf16 %s -o - | FileCheck %s
+
+; CHECK-LABEL: test_vbfdot_f32
+; CHECK: bfdot   v0.2s, v1.4h, v2.4h
+define <2 x float> @test_vbfdot_f32(<2 x float> %r, <4 x bfloat> %a, <4 x bfloat> %b) {
+entry:
+  %0 = bitcast <4 x bfloat> %a to <8 x i8>
+  %1 = bitcast <4 x bfloat> %b to <8 x i8>
+  %vbfdot1.i = tail call <2 x float> @llvm.aarch64.neon.bfdot.v2f32.v8i8(<2 x float> %r, <8 x i8> %0, <8 x i8> %1)
+  ret <2 x float> %vbfdot1.i
+}
+
+; CHECK-LABEL: test_vbfdotq_f32
+; CHECK: bfdot   v0.4s, v1.8h, v2.8h
+define <4 x float> @test_vbfdotq_f32(<4 x float> %r, <8 x bfloat> %a, <8 x bfloat> %b) {
+entry:
+  %0 = bitcast <8 x bfloat> %a to <16 x i8>
+  %1 = bitcast <8 x bfloat> %b to <16 x i8>
+  %vbfdot1.i = tail call <4 x float> @llvm.aarch64.neon.bfdot.v4f32.v16i8(<4 x float> %r, <16 x i8> %0, <16 x i8> %1)
+  ret <4 x float> %vbfdot1.i
+}
+
+; CHECK-LABEL: test_vbfdot_lane_f32
+; CHECK: bfdot v0.2s, v1.4h, v2.2h[0]
+define <2 x float> @test_vbfdot_lane_f32(<2 x float> %r, <4 x bfloat> %a, <4 x bfloat> %b) {
+entry:
+  %0 = bitcast <4 x bfloat> %b to <2 x float>
+  %shuffle = shufflevector <2 x float> %0, <2 x float> undef, <2 x i32> zeroinitializer
+  %1 = bitcast <4 x bfloat> %a to <8 x i8>
+  %2 = bitcast <2 x float> %shuffle to <8 x i8>
+  %vbfdot1.i = tail call <2 x float> @llvm.aarch64.neon.bfdot.v2f32.v8i8(<2 x float> %r, <8 x i8> %1, <8 x i8> %2)
+  ret <2 x float> %vbfdot1.i
+}
+
+; CHECK-LABEL: test_vbfdotq_laneq_f32
+; CHECK: bfdot v0.4s, v1.8h, v2.2h[3]
+define <4 x float> @test_vbfdotq_laneq_f32(<4 x float> %r, <8 x bfloat> %a, <8 x bfloat> %b) {
+entry:
+  %0 = bitcast <8 x bfloat> %b to <4 x float>
+  %shuffle = shufflevector <4 x float> %0, <4 x float> undef, <4 x i32> 
+  %1 = bitcast <8 x bfloat> %a to <16 x i8>
+  %2 = bitcast <4 x float> %shuffle to <16 x i8>
+  %vbfdot1.i = tail call <4 x float> @llvm.aarch64.neon.bfdot.v4f32.v16i8(<4 x float> %r, <16 x i8> %1, <16 x i8> %2)
+  ret <4 x float> %vbfdot1.i
+}
+
+; CHECK-LABEL: test_vbfdot_laneq_f32
+; CHECK: bfdot v0.2s, v1.4h, v2.2h[3]
+define <2 x float> @test_vbfdot_laneq_f32(<2 x float> %r, <4 x bfloat> %a, <8 x bfloat> %b) {
+entry:
+  %0 = bitcast <8 x bfloat> %b to <4 x float>
+  %shuffle = shufflevector <4 x float> %0, <4 x float> undef, <2 x i32> 
+  %1 = bitcast <4 x bfloat> %a to <8 x i8>
+  %2 = bitcast <2 x float> %shuffle to <8 x i8>
+  %vbfdot1.i = tail call <2 x float> @llvm.aarch64.neon.bfdot.v2f32.v8i8(<2 x float> %r, <8 x i8> %1, <8 x i8> %2)
+  ret <2 x float> %vbfdot1.i
+}
+
+; CHECK-LABEL: test_vbfdotq_lane_f32
+; CHECK: bfdot  v0.4s, v1.8h, v2.2h[0]
+define <4 x float> @test_vbfdotq_lane_f32(<4 x float> %r, <8 x bfloat> %a, <4 x bfloat> %b) {
+entry:
+  %0 = bitcast <4 x bfloat> %b to <2 x float>
+  %shuffle = shufflevector <2 x float> %0, <2 x float> undef, <4 x i32> zeroinitializer
+  %1 = bitcast <8 x bfloat> %a to <16 x i8>
+  %2 = bitcast <4 x float> %shuffle to <16 x i8>
+  %vbfdot1.i = tail call <4 x float> @llvm.aarch64.neon.bfdot.v4f32.v16i8(<4 x float> %r, <16 x i8> %1, <16 x i8> %2)
+  ret <4 x float> %vbfdot1.i
+}
+
+; CHECK-LABEL: test_vbfmmlaq_f32
+; CHECK: bfmmla v0.4s, v1.8h, v2.8h
+define <4 x float> 

[PATCH] D80697: [clang-tidy] Reworked TransformerClangTidyCheck to simplify usage of Options

2020-05-28 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

Thanks for the suggestioned change. However, I think we can do somewhat 
simpler. What do you think of just providing a setter on the super class

  void setRule(Optional Rule) { this->Rule = 
std::move(Rule); }

Subclasses will call `setRule` in their constructor body . Or not.  The code in 
the superclass doesn't change either way, since it already needed to check the 
optional. There's no initialization logic, no virtual functions, no need to 
delete the existing constructors (though we should deprecate them in favor of 
this simpler mechanism).




Comment at: clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h:44-58
-  // \p MakeRule generates the rewrite rule to be used by the check, based on
-  // the given language and clang-tidy options. It can return \c None to handle
-  // cases where the options disable the check.
-  //
-  // All cases in the rule generated by \p MakeRule must have a non-null \c
-  // Explanation, even though \c Explanation is optional for RewriteRule in
-  // general. Because the primary purpose of clang-tidy checks is to provide

This should be deprecated and then deleted after a delay (1-2 weeks) giving 
clients time to transition rather than breaking them right off.



Comment at: clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h:62
-  // of the language or clang-tidy options.
-  TransformerClangTidyCheck(transformer::RewriteRule R, StringRef Name,
-ClangTidyContext *Context);

Why delete this? It is the most commonly used constructor and cleaner than the 
OOP goop of the virtual method.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80697



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


[PATCH] D80751: [clang][diagnostics] Add '-Wundef-prefix' warning option

2020-05-28 Thread Zixu Wang via Phabricator via cfe-commits
zixuw created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
zixuw added reviewers: ributzka, steven_wu, cishida, bruno, arphaman.
Herald added a subscriber: dexonsmith.
zixuw edited the summary of this revision.

- Add an `-Wundef-prefix=,...` option, which is similar to 
`-Wundef`, but only give warnings for undefined macros with the given prefixes.
- Make `-Wundef` an alias of `-Wundef-prefix=""` so that when the two options 
are given together, `-Wundef` takes precedence over `-Wundef-prefix`, as all 
strings are prefixed by the empty string.

rdar://55684778


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80751

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/include/clang/Basic/DiagnosticOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Lex/PPExpressions.cpp
  clang/test/Preprocessor/warn-macro-undef-prefix.c
  clang/test/Preprocessor/warn-macro-undef.c

Index: clang/test/Preprocessor/warn-macro-undef.c
===
--- /dev/null
+++ clang/test/Preprocessor/warn-macro-undef.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -Eonly -Wundef -verify
+// RUN: %clang_cc1 %s -Eonly -Wundef -Wundef-prefix=A -verify
+
+extern int x;
+
+#if A // expected-warning {{'A' is not defined, evaluates to 0}}
+#endif
+
+#if B // expected-warning {{'B' is not defined, evaluates to 0}}
+#endif
Index: clang/test/Preprocessor/warn-macro-undef-prefix.c
===
--- /dev/null
+++ clang/test/Preprocessor/warn-macro-undef-prefix.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 %s -Eonly -Wundef-prefix=A,BC -verify
+
+extern int x;
+
+#if A // expected-warning {{'A' is not defined, evaluates to 0}}
+#endif
+
+#if A1 // expected-warning {{'A1' is not defined, evaluates to 0}}
+#endif
+
+#if B // no warning
+#endif
+
+#define BC 0
+#if BC // no warning
+#endif
+
+#undef BC
+#if BC // expected-warning {{'BC' is not defined, evaluates to 0}}
+#endif
+
+#if BC1 // expected-warning {{'BC1' is not defined, evaluates to 0}}
+#endif
Index: clang/lib/Lex/PPExpressions.cpp
===
--- clang/lib/Lex/PPExpressions.cpp
+++ clang/lib/Lex/PPExpressions.cpp
@@ -251,8 +251,21 @@
 // If this identifier isn't 'defined' or one of the special
 // preprocessor keywords and it wasn't macro expanded, it turns
 // into a simple 0
-if (ValueLive)
-  PP.Diag(PeekTok, diag::warn_pp_undef_identifier) << II;
+if (ValueLive) {
+  const auto  =
+  PP.getDiagnostics().getDiagnosticOptions().UndefPrefixes;
+  const auto  = II->getName();
+  // Check whether UndefPrefixes is empty for standalone
+  // "-Werror=undef" to work.
+  // "-Werror=undef" implies "-Wundef" but does not add an empty
+  // string to UndefPrefixes as an explicit "-Wundef" does.
+  if (UndefPrefixes.empty() ||
+  llvm::any_of(UndefPrefixes,
+   [](const auto ) {
+ return IdentifierName.startswith(Prefix);
+   }))
+PP.Diag(PeekTok, diag::warn_pp_undef_identifier) << II;
+}
 Result.Val = 0;
 Result.Val.setIsUnsigned(false); // "0" is signed intmax_t 0.
 Result.setIdentifier(II);
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1820,6 +1820,16 @@
   }
   Opts.MessageLength =
   getLastArgIntValue(Args, OPT_fmessage_length_EQ, 0, Diags);
+
+  for (const auto *A : Args.filtered(OPT_Wundef_prefix_EQ)) {
+SmallVector Prefixes;
+// Keep empty strings to allow '-Wundef' (aliased to '-Wundef-prefix=""')
+// to generate diagnostics for all undefined macros.
+StringRef{A->getValue()}.split(Prefixes, ",");
+for (const auto  : Prefixes)
+  Opts.UndefPrefixes.push_back(P.str());
+  }
+
   addDiagnosticArgs(Args, OPT_W_Group, OPT_W_value_Group, Opts.Warnings);
   addDiagnosticArgs(Args, OPT_R_Group, OPT_R_value_Group, Opts.Remarks);
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -465,6 +465,14 @@
 def Wp_COMMA : CommaJoined<["-"], "Wp,">,
   HelpText<"Pass the comma separated arguments in  to the preprocessor">,
   MetaVarName<"">, Group;
+def Wundef_prefix_EQ : Joined<["-"], "Wundef-prefix=">, Group,
+  Flags<[CC1Option, CoreOption]>, MetaVarName<"">,
+  HelpText<"Enable warnings for undefined macros with a prefix in the comma separated list ">;
+// Rely on the implementation that a Flag alias 

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

2020-05-28 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 266976.
yaxunl added a comment.

Emit target id module flag metadata.


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

https://reviews.llvm.org/D60620

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/OffloadArch.h
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/OffloadArch.cpp
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/AMDGPU.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/AMDGPU.h
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/test/CodeGenCUDA/target-id.hip
  clang/test/CodeGenOpenCL/target-id.cl
  clang/test/Driver/amdgpu-macros.cl
  clang/test/Driver/invalid-target-id.cl
  clang/test/Driver/invalid-target-id.hip
  clang/test/Driver/target-id-macros.cl
  clang/test/Driver/target-id-macros.hip
  clang/test/Driver/target-id.cl
  clang/test/Driver/target-id.hip

Index: clang/test/Driver/target-id.hip
===
--- /dev/null
+++ clang/test/Driver/target-id.hip
@@ -0,0 +1,51 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   -x hip --offload-arch=gfx908 \
+// RUN:   --offload-arch=gfx908:xnack+:sramecc+ \
+// RUN:   --offload-arch=gfx908:xnack+:sramecc- \
+// RUN:   --hip-device-lib-path=%S/Inputs/hip_dev_lib \
+// RUN:   %s 2>&1 | FileCheck %s
+
+// CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
+// CHECK-SAME: {{.*}} "-target-cpu" "gfx908" "-fcuda-is-device"
+
+// CHECK: [[OPT:".*opt"]] {{.*}} "-mtriple=amdgcn-amd-amdhsa"
+// CHECK-SAME: "-mcpu=gfx908"
+// CHECK-SAME: "-o" [[OPT_906_BC:".*-gfx908-optimized.*bc"]]
+
+// CHECK: [[LLC: ".*llc"]] [[OPT_906_BC]]
+// CHECK-SAME: "-mtriple=amdgcn-amd-amdhsa"
+// CHECK-SAME: {{.*}} "-mcpu=gfx908"
+
+// CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
+// CHECK-SAME: {{.*}} "-target-cpu" "gfx908"
+// CHECK-SAME: {{.*}} "-target-feature" "+xnack"
+// CHECK-SAME: {{.*}} "-target-feature" "+sram-ecc"
+
+// CHECK: [[OPT]] {{.*"}} "-mtriple=amdgcn-amd-amdhsa"
+// CHECK-SAME: "-mcpu=gfx908"
+// CHECK-SAME: "-o" [[OPT_906XE_BC:".*-gfx908:xnack\+:sramecc\+.*bc"]]
+
+// CHECK: [[LLC]] [[OPT_906XE_BC]]
+// CHECK-SAME: "-mtriple=amdgcn-amd-amdhsa"
+// CHECK-SAME: {{.*}} "-mcpu=gfx908"
+
+// CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
+// CHECK-SAME: {{.*}} "-target-cpu" "gfx908"
+// CHECK-SAME: {{.*}} "-target-feature" "+xnack"
+// CHECK-SAME: {{.*}} "-target-feature" "-sram-ecc"
+
+// CHECK: [[OPT]] {{.*}} "-mtriple=amdgcn-amd-amdhsa"
+// CHECK-SAME: "-mcpu=gfx908"
+// CHECK-SAME: "-o" [[OPT_906XN_BC:".*-gfx908:xnack\+:sramecc\-.*bc"]]
+
+// CHECK: [[LLC]] [[OPT_906XN_BC]]
+// CHECK-SAME: "-mtriple=amdgcn-amd-amdhsa"
+// CHECK-SAME: {{.*}} "-mcpu=gfx908"
+
+
+// CHECK: {{".*clang-offload-bundler"}}
+// CHECK-SAME: "-targets=host-x86_64-unknown-linux,hip-amdgcn-amd-amdhsa-gfx908,hip-amdgcn-amd-amdhsa-gfx908:xnack+:sramecc+,hip-amdgcn-amd-amdhsa-gfx908:xnack+:sramecc-"
Index: clang/test/Driver/target-id.cl
===
--- /dev/null
+++ clang/test/Driver/target-id.cl
@@ -0,0 +1,21 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang -### -target amdgcn-amd-amdhsa \
+// RUN:   -mcpu=gfx908:xnack+:sramecc- \
+// RUN:   -nostdlib %s 2>&1 | FileCheck %s
+
+
+// RUN: %clang -### -target amdgcn-amd-amdpal \
+// RUN:   -mcpu=gfx908:xnack+:sramecc- \
+// RUN:   -nostdlib %s 2>&1 | FileCheck %s
+
+
+// RUN: %clang -### -target amdgcn--mesa3d \
+// RUN:   -mcpu=gfx908:xnack+:sramecc- \
+// RUN:   -nostdlib %s 2>&1 | FileCheck %s
+
+// CHECK: "-target-cpu" "gfx908"
+// CHECK-SAME: "-target-feature" "+xnack"
+// CHECK-SAME: "-target-feature" "-sram-ecc"
Index: clang/test/Driver/target-id-macros.hip
===
--- /dev/null
+++ clang/test/Driver/target-id-macros.hip
@@ -0,0 +1,12 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang -E -dM -target x86_64-linux-gnu --cuda-device-only \
+// RUN:   --offload-arch=gfx908:xnack+:sramecc- -nogpulib -o - %s 2>&1 \
+// RUN:   | FileCheck %s
+
+// CHECK-DAG: #define __amdgcn_processor__ "gfx908"
+// CHECK-DAG: #define __amdgcn_xnack__ 1
+// CHECK-DAG: #define __amdgcn_sramecc__ 0
+// CHECK-DAG: #define __amdgcn_target_id__ "gfx908:xnack+:sramecc-"
Index: clang/test/Driver/target-id-macros.cl
===
--- /dev/null
+++ clang/test/Driver/target-id-macros.cl
@@ -0,0 +1,20 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: 

[PATCH] D80492: Avoid linking libdl unless needed

2020-05-28 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0073c293a401: [clang] Avoid linking libdl unless needed 
(authored by thieta, committed by mstorsjo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80492

Files:
  clang/tools/libclang/CMakeLists.txt


Index: clang/tools/libclang/CMakeLists.txt
===
--- clang/tools/libclang/CMakeLists.txt
+++ clang/tools/libclang/CMakeLists.txt
@@ -66,9 +66,8 @@
   endif ()
 endif ()
 
-find_library(DL_LIBRARY_PATH dl)
-if (DL_LIBRARY_PATH)
-  list(APPEND LIBS dl)
+if (HAVE_LIBDL)
+  list(APPEND LIBS ${CMAKE_DL_LIBS})
 endif()
 
 option(LIBCLANG_BUILD_STATIC


Index: clang/tools/libclang/CMakeLists.txt
===
--- clang/tools/libclang/CMakeLists.txt
+++ clang/tools/libclang/CMakeLists.txt
@@ -66,9 +66,8 @@
   endif ()
 endif ()
 
-find_library(DL_LIBRARY_PATH dl)
-if (DL_LIBRARY_PATH)
-  list(APPEND LIBS dl)
+if (HAVE_LIBDL)
+  list(APPEND LIBS ${CMAKE_DL_LIBS})
 endif()
 
 option(LIBCLANG_BUILD_STATIC
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80748: [clang] Add '-Wundef-prefix' warning option

2020-05-28 Thread Zixu Wang via Phabricator via cfe-commits
zixuw created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
zixuw abandoned this revision.

Add an `-Wundef-prefix=,...` option, which is similar to
`-Wundef`, but only give warnings for undefined macros with the given
prefixes.
Make `-Wundef` an alias of `-Wundef-prefix=""` so that when the two
options are given together, `-Wundef` takes precedence over
`-Wundef-prefix`, as all strings are prefixed by the empty string.

rdar://55684778


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80748

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/include/clang/Basic/DiagnosticOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Lex/PPExpressions.cpp
  clang/test/Preprocessor/warn-macro-undef-prefix.c
  clang/test/Preprocessor/warn-macro-undef.c

Index: clang/test/Preprocessor/warn-macro-undef.c
===
--- /dev/null
+++ clang/test/Preprocessor/warn-macro-undef.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -Eonly -Wundef -verify
+// RUN: %clang_cc1 %s -Eonly -Wundef -Wundef-prefix=A -verify
+
+extern int x;
+
+#if A // expected-warning {{'A' is not defined, evaluates to 0}}
+#endif
+
+#if B // expected-warning {{'B' is not defined, evaluates to 0}}
+#endif
Index: clang/test/Preprocessor/warn-macro-undef-prefix.c
===
--- /dev/null
+++ clang/test/Preprocessor/warn-macro-undef-prefix.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 %s -Eonly -Wundef-prefix=A,BC -verify
+
+extern int x;
+
+#if A // expected-warning {{'A' is not defined, evaluates to 0}}
+#endif
+
+#if A1 // expected-warning {{'A1' is not defined, evaluates to 0}}
+#endif
+
+#if B // no warning
+#endif
+
+#define BC 0
+#if BC // no warning
+#endif
+
+#undef BC
+#if BC // expected-warning {{'BC' is not defined, evaluates to 0}}
+#endif
+
+#if BC1 // expected-warning {{'BC1' is not defined, evaluates to 0}}
+#endif
Index: clang/lib/Lex/PPExpressions.cpp
===
--- clang/lib/Lex/PPExpressions.cpp
+++ clang/lib/Lex/PPExpressions.cpp
@@ -251,8 +251,21 @@
 // If this identifier isn't 'defined' or one of the special
 // preprocessor keywords and it wasn't macro expanded, it turns
 // into a simple 0
-if (ValueLive)
-  PP.Diag(PeekTok, diag::warn_pp_undef_identifier) << II;
+if (ValueLive) {
+  const auto  =
+  PP.getDiagnostics().getDiagnosticOptions().UndefPrefixes;
+  const auto  = II->getName();
+  // Check whether UndefPrefixes is empty for standalone
+  // "-Werror=undef" to work.
+  // "-Werror=undef" implies "-Wundef" but does not add an empty
+  // string to UndefPrefixes as an explicit "-Wundef" does.
+  if (UndefPrefixes.empty() ||
+  llvm::any_of(UndefPrefixes,
+   [](const auto ) {
+ return IdentifierName.startswith(Prefix);
+   }))
+PP.Diag(PeekTok, diag::warn_pp_undef_identifier) << II;
+}
 Result.Val = 0;
 Result.Val.setIsUnsigned(false); // "0" is signed intmax_t 0.
 Result.setIdentifier(II);
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1820,6 +1820,16 @@
   }
   Opts.MessageLength =
   getLastArgIntValue(Args, OPT_fmessage_length_EQ, 0, Diags);
+
+  for (const auto *A : Args.filtered(OPT_Wundef_prefix_EQ)) {
+SmallVector Prefixes;
+// Keep empty strings to allow '-Wundef' (aliased to '-Wundef-prefix=""')
+// to generate diagnostics for all undefined macros.
+StringRef{A->getValue()}.split(Prefixes, ",");
+for (const auto  : Prefixes)
+  Opts.UndefPrefixes.push_back(P.str());
+  }
+
   addDiagnosticArgs(Args, OPT_W_Group, OPT_W_value_Group, Opts.Warnings);
   addDiagnosticArgs(Args, OPT_R_Group, OPT_R_value_Group, Opts.Remarks);
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -465,6 +465,14 @@
 def Wp_COMMA : CommaJoined<["-"], "Wp,">,
   HelpText<"Pass the comma separated arguments in  to the preprocessor">,
   MetaVarName<"">, Group;
+def Wundef_prefix_EQ : Joined<["-"], "Wundef-prefix=">, Group,
+  Flags<[CC1Option, CoreOption]>, MetaVarName<"">,
+  HelpText<"Enable warnings for undefined macros with a prefix in the comma separated list ">;
+// Rely on the implementation that a Flag alias for a Joined option is provided a default argument
+// of an empty string (""). So we have -Wundef => -Wundef-prefix=""
+def 

[PATCH] D80727: AMDGPU: Add intrinsic for s_setreg

2020-05-28 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm added a comment.

97f3f0bab0982f84745c7ac5ce8fb6b0918ff718 



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

https://reviews.llvm.org/D80727



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


[PATCH] D80692: Run Coverage pass before other *San passes under new pass manager, round 2

2020-05-28 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added inline comments.



Comment at: llvm/include/llvm/Passes/PassBuilder.h:597-598
   ///
   /// This extension point allows adding optimizations at the very end of the
   /// function optimization pipeline. A key difference between this and the
   /// legacy PassManager's OptimizerLast callback is that this extension point

Will need to change the wording on this if this doesn't handle function passes 
anymore.



Comment at: llvm/lib/Passes/PassBuilder.cpp:1078
 
+  for (auto  : OptimizerLastEPCallbacks)
+C(MPM, Level);

Would it be better to add another `SmallVector` and `register*Calback()` for 
modules in in `PassBuilder` that we could loop through here instead of changing 
how these extension points work?

I imagine it would still be meaningful in the future to be able to add function 
passes at the end of the function optimization pipeline.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80692



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


[PATCH] D80697: [clang-tidy] Reworked TransformerClangTidyCheck to simplify usage of Options

2020-05-28 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 266957.
njames93 added a comment.

- Renamed makeRule to buildRule to avoid ambiguity with tooling::makeRule


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80697

Files:
  clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp
  clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.h
  clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
@@ -10,6 +10,7 @@
 #include "ClangTidyTest.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Tooling/Transformer/RangeSelector.h"
+#include "clang/Tooling/Transformer/RewriteRule.h"
 #include "clang/Tooling/Transformer/Stencil.h"
 #include "clang/Tooling/Transformer/Transformer.h"
 #include "gtest/gtest.h"
@@ -28,23 +29,23 @@
 using transformer::statement;
 
 // Invert the code of an if-statement, while maintaining its semantics.
-RewriteRule invertIf() {
-  StringRef C = "C", T = "T", E = "E";
-  RewriteRule Rule = tooling::makeRule(
-  ifStmt(hasCondition(expr().bind(C)), hasThen(stmt().bind(T)),
- hasElse(stmt().bind(E))),
-  change(statement(std::string(RewriteRule::RootID)),
- cat("if(!(", node(std::string(C)), ")) ",
- statement(std::string(E)), " else ",
- statement(std::string(T,
-  cat("negate condition and reverse `then` and `else` branches"));
-  return Rule;
-}
-
 class IfInverterCheck : public TransformerClangTidyCheck {
 public:
   IfInverterCheck(StringRef Name, ClangTidyContext *Context)
-  : TransformerClangTidyCheck(invertIf(), Name, Context) {}
+  : TransformerClangTidyCheck(Name, Context) {}
+
+  Optional buildRule() const override {
+StringRef C = "C", T = "T", E = "E";
+RewriteRule Rule = tooling::makeRule(
+ifStmt(hasCondition(expr().bind(C)), hasThen(stmt().bind(T)),
+   hasElse(stmt().bind(E))),
+change(statement(std::string(RewriteRule::RootID)),
+   cat("if(!(", node(std::string(C)), ")) ",
+   statement(std::string(E)), " else ",
+   statement(std::string(T,
+cat("negate condition and reverse `then` and `else` branches"));
+return Rule;
+  }
 };
 
 // Basic test of using a rewrite rule as a ClangTidy.
@@ -70,10 +71,12 @@
 class IntLitCheck : public TransformerClangTidyCheck {
 public:
   IntLitCheck(StringRef Name, ClangTidyContext *Context)
-  : TransformerClangTidyCheck(tooling::makeRule(integerLiteral(),
-change(cat("LIT")),
-cat("no message")),
-  Name, Context) {}
+  : TransformerClangTidyCheck(Name, Context) {}
+
+  Optional buildRule() const override {
+return tooling::makeRule(integerLiteral(), change(cat("LIT")),
+ cat("no message"));
+  }
 };
 
 // Tests that two changes in a single macro expansion do not lead to conflicts
@@ -94,11 +97,13 @@
 class BinOpCheck : public TransformerClangTidyCheck {
 public:
   BinOpCheck(StringRef Name, ClangTidyContext *Context)
-  : TransformerClangTidyCheck(
-tooling::makeRule(
-binaryOperator(hasOperatorName("+"), hasRHS(expr().bind("r"))),
-change(node("r"), cat("RIGHT")), cat("no message")),
-Name, Context) {}
+  : TransformerClangTidyCheck(Name, Context) {}
+
+  Optional buildRule() const override {
+return tooling::makeRule(
+binaryOperator(hasOperatorName("+"), hasRHS(expr().bind("r"))),
+change(node("r"), cat("RIGHT")), cat("no message"));
+  }
 };
 
 // Tests case where the rule's match spans both source from the macro and its
@@ -118,18 +123,20 @@
 }
 
 // A trivial rewrite-rule generator that requires Objective-C code.
-Optional needsObjC(const LangOptions ,
-const ClangTidyCheck::OptionsView ) {
-  if (!LangOpts.ObjC)
-return None;
-  return tooling::makeRule(clang::ast_matchers::functionDecl(),
-   change(cat("void changed() {}")), cat("no message"));
-}
-
 class NeedsObjCCheck : public TransformerClangTidyCheck {
 public:
   NeedsObjCCheck(StringRef Name, ClangTidyContext *Context)
-  : TransformerClangTidyCheck(needsObjC, Name, Context) {}
+  : TransformerClangTidyCheck(Name, Context) {}
+
+  bool isLanguageVersionSupported(const LangOptions ) 

[clang] 97f3f0b - AMDGPU: Add intrinsic for s_setreg

2020-05-28 Thread Matt Arsenault via cfe-commits

Author: Matt Arsenault
Date: 2020-05-28T14:26:38-04:00
New Revision: 97f3f0bab0982f84745c7ac5ce8fb6b0918ff718

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

LOG: AMDGPU: Add intrinsic for s_setreg

This will be more useful with fenv access implemented.

Added: 
llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.s.setreg.ll
llvm/test/CodeGen/AMDGPU/llvm.amdgcn.s.setreg.ll

Modified: 
clang/include/clang/Basic/BuiltinsAMDGPU.def
clang/test/CodeGenOpenCL/builtins-amdgcn.cl
clang/test/SemaOpenCL/builtins-amdgcn-error.cl
llvm/include/llvm/IR/IntrinsicsAMDGPU.td
llvm/lib/Target/AMDGPU/AMDGPUInstrInfo.td
llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
llvm/lib/Target/AMDGPU/SIISelLowering.cpp
llvm/lib/Target/AMDGPU/SIInstrInfo.td
llvm/lib/Target/AMDGPU/SOPInstructions.td

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def 
b/clang/include/clang/Basic/BuiltinsAMDGPU.def
index 5633ccd5d744..28379142b05a 100644
--- a/clang/include/clang/Basic/BuiltinsAMDGPU.def
+++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def
@@ -44,6 +44,7 @@ BUILTIN(__builtin_amdgcn_mbcnt_lo, "UiUiUi", "nc")
 // Instruction builtins.
 
//===--===//
 BUILTIN(__builtin_amdgcn_s_getreg, "UiIi", "n")
+BUILTIN(__builtin_amdgcn_s_setreg, "vIiUi", "n")
 BUILTIN(__builtin_amdgcn_s_getpc, "LUi", "n")
 BUILTIN(__builtin_amdgcn_s_waitcnt, "vIi", "n")
 BUILTIN(__builtin_amdgcn_s_sendmsg, "vIiUi", "n")

diff  --git a/clang/test/CodeGenOpenCL/builtins-amdgcn.cl 
b/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
index 8f2f149103b3..3563ad464c66 100644
--- a/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
+++ b/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -715,6 +715,12 @@ kernel void test_mqsad_u32_u8(global uint4* out, ulong 
src0, uint src1, uint4 sr
   *out = __builtin_amdgcn_mqsad_u32_u8(src0, src1, src2);
 }
 
+// CHECK-LABEL: test_s_setreg(
+// CHECK: call void @llvm.amdgcn.s.setreg(i32 8193, i32 %val)
+kernel void test_s_setreg(uint val) {
+  __builtin_amdgcn_s_setreg(8193, val);
+}
+
 // CHECK-DAG: [[$WI_RANGE]] = !{i32 0, i32 1024}
 // CHECK-DAG: [[$WS_RANGE]] = !{i16 1, i16 1025}
 // CHECK-DAG: attributes #[[$NOUNWIND_READONLY:[0-9]+]] = { nounwind readonly }

diff  --git a/clang/test/SemaOpenCL/builtins-amdgcn-error.cl 
b/clang/test/SemaOpenCL/builtins-amdgcn-error.cl
index ad5e8776b2e8..dbe2900b600b 100644
--- a/clang/test/SemaOpenCL/builtins-amdgcn-error.cl
+++ b/clang/test/SemaOpenCL/builtins-amdgcn-error.cl
@@ -139,3 +139,8 @@ void test_fence() {
   const char ptr[] = "workgroup";
   __builtin_amdgcn_fence(__ATOMIC_ACQUIRE, ptr); // expected-error 
{{expression is not a string literal}}
 }
+
+void test_s_setreg(int x, int y) {
+  __builtin_amdgcn_s_setreg(x, 0); // expected-error {{argument to 
'__builtin_amdgcn_s_setreg' must be a constant integer}}
+  __builtin_amdgcn_s_setreg(x, y); // expected-error {{argument to 
'__builtin_amdgcn_s_setreg' must be a constant integer}}
+}

diff  --git a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td 
b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
index e2d8f3cb1bd6..40449304ed04 100644
--- a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
+++ b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
@@ -1207,6 +1207,16 @@ def int_amdgcn_s_getreg :
   [IntrInaccessibleMemOnly, IntrReadMem, IntrSpeculatable, ImmArg>]
 >;
 
+// Note this can be used to set FP environment properties that are
+// unsafe to change in non-strictfp functions. The register properties
+// available (and value required to access them) may 
diff er per
+// subtarget. llvm.amdgcn.s.setreg(hwmode, value)
+def int_amdgcn_s_setreg :
+  GCCBuiltin<"__builtin_amdgcn_s_setreg">,
+  Intrinsic<[], [llvm_i32_ty, llvm_i32_ty],
+  [IntrNoMem, IntrHasSideEffects, ImmArg>]
+>;
+
 // int_amdgcn_s_getpc is provided to allow a specific style of position
 // independent code to determine the high part of its address when it is
 // known (through convention) that the code and any data of interest does

diff  --git a/llvm/lib/Target/AMDGPU/AMDGPUInstrInfo.td 
b/llvm/lib/Target/AMDGPU/AMDGPUInstrInfo.td
index 3b8f88271458..59f9866b93b6 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUInstrInfo.td
+++ b/llvm/lib/Target/AMDGPU/AMDGPUInstrInfo.td
@@ -202,13 +202,6 @@ def AMDGPUSetCCOp : SDTypeProfile<1, 3, [// setcc
 
 def AMDGPUsetcc : SDNode<"AMDGPUISD::SETCC", AMDGPUSetCCOp>;
 
-def AMDGPUSetRegOp :  SDTypeProfile<0, 2, [
-  SDTCisInt<0>, SDTCisInt<1>
-]>;
-
-def AMDGPUsetreg : SDNode<"AMDGPUISD::SETREG", AMDGPUSetRegOp, [
-  SDNPHasChain, SDNPSideEffect, SDNPOptInGlue, SDNPOutGlue]>;
-
 def AMDGPUfma : SDNode<"AMDGPUISD::FMA_W_CHAIN", SDTFPTernaryOp, [
SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
 

diff  --git 

[clang] 0073c29 - [clang] Avoid linking libdl unless needed

2020-05-28 Thread Martin Storsjö via cfe-commits

Author: Tobias Hieta
Date: 2020-05-28T21:08:00+03:00
New Revision: 0073c293a401774ac96b4b3d27f05e13f379f98e

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

LOG: [clang] Avoid linking libdl unless needed

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

Added: 


Modified: 
clang/tools/libclang/CMakeLists.txt

Removed: 




diff  --git a/clang/tools/libclang/CMakeLists.txt 
b/clang/tools/libclang/CMakeLists.txt
index ba286b672772..9b34682cc49b 100644
--- a/clang/tools/libclang/CMakeLists.txt
+++ b/clang/tools/libclang/CMakeLists.txt
@@ -66,9 +66,8 @@ if (LIBCLANG_INCLUDE_CLANG_TOOLS_EXTRA)
   endif ()
 endif ()
 
-find_library(DL_LIBRARY_PATH dl)
-if (DL_LIBRARY_PATH)
-  list(APPEND LIBS dl)
+if (HAVE_LIBDL)
+  list(APPEND LIBS ${CMAKE_DL_LIBS})
 endif()
 
 option(LIBCLANG_BUILD_STATIC



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


[PATCH] D80626: [analyzer] SATestBuild.py: Make verbosity level a cmd option

2020-05-28 Thread Valeriy Savchenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5395389475bc: [analyzer] SATestBuild.py: Make verbosity 
level a cmd option (authored by vsavchenko).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80626

Files:
  clang/utils/analyzer/SATestBuild.py


Index: clang/utils/analyzer/SATestBuild.py
===
--- clang/utils/analyzer/SATestBuild.py
+++ clang/utils/analyzer/SATestBuild.py
@@ -389,7 +389,7 @@
 start_time = time.time()
 
 project_dir = self.get_project_dir()
-if VERBOSE == 1:
+if VERBOSE >= 1:
 stdout(f"  Build directory: {project_dir}.\n")
 
 # Set the build results directory.
@@ -431,7 +431,7 @@
 
 # Clean up scan build results.
 if os.path.exists(output_dir):
-if VERBOSE == 1:
+if VERBOSE >= 1:
 stdout(f"  Removing old results: {output_dir}\n")
 
 shutil.rmtree(output_dir)
@@ -517,7 +517,7 @@
 
 command_to_run = command_prefix + command
 
-if VERBOSE == 1:
+if VERBOSE >= 1:
 stdout(f"  Executing: {command_to_run}\n")
 
 check_call(command_to_run, cwd=cwd,
@@ -575,7 +575,7 @@
 log_path = os.path.join(fail_path, file_name + ".stderr.txt")
 with open(log_path, "w+") as log_file:
 try:
-if VERBOSE == 1:
+if VERBOSE >= 1:
 stdout(f"  Executing: {command}\n")
 
 check_call(command, cwd=directory, stderr=log_file,
@@ -744,7 +744,7 @@
 for ref_dir, new_dir in zip(ref_list, new_list):
 assert(ref_dir != new_dir)
 
-if VERBOSE == 1:
+if VERBOSE >= 1:
 stdout(f"  Comparing Results: {ref_dir} {new_dir}\n")
 
 patched_source = os.path.join(directory, PATCHED_SOURCE_DIR_NAME)
@@ -818,7 +818,7 @@
 
 # Clean up the log file.
 if os.path.exists(build_log_path):
-if VERBOSE == 1:
+if VERBOSE >= 1:
 stdout(f"  Removing log file: {build_log_path}\n")
 
 os.remove(build_log_path)
@@ -887,29 +887,31 @@
 
 if __name__ == "__main__":
 # Parse command line arguments.
-Parser = argparse.ArgumentParser(
+parser = argparse.ArgumentParser(
 description="Test the Clang Static Analyzer.")
 
-Parser.add_argument("--strictness", dest="strictness", type=int, default=0,
+parser.add_argument("--strictness", dest="strictness", type=int, default=0,
 help="0 to fail on runtime errors, 1 to fail when the "
 "number of found bugs are different from the "
 "reference, 2 to fail on any difference from the "
 "reference. Default is 0.")
-Parser.add_argument("-r", dest="regenerate", action="store_true",
+parser.add_argument("-r", dest="regenerate", action="store_true",
 default=False, help="Regenerate reference output.")
-Parser.add_argument("--override-compiler", action="store_true",
+parser.add_argument("--override-compiler", action="store_true",
 default=False, help="Call scan-build with "
 "--override-compiler option.")
-Parser.add_argument("-j", "--jobs", dest="jobs", type=int,
+parser.add_argument("-j", "--jobs", dest="jobs", type=int,
 default=0,
 help="Number of projects to test concurrently")
-Parser.add_argument("--extra-analyzer-config",
+parser.add_argument("--extra-analyzer-config",
 dest="extra_analyzer_config", type=str,
 default="",
 help="Arguments passed to to -analyzer-config")
+parser.add_argument("-v", "--verbose", action="count", default=0)
 
-args = Parser.parse_args()
+args = parser.parse_args()
 
+VERBOSE = args.verbose
 tester = RegressionTester(args.jobs, args.override_compiler,
   args.extra_analyzer_config, args.regenerate,
   args.strictness)


Index: clang/utils/analyzer/SATestBuild.py
===
--- clang/utils/analyzer/SATestBuild.py
+++ clang/utils/analyzer/SATestBuild.py
@@ -389,7 +389,7 @@
 start_time = time.time()
 
 project_dir = self.get_project_dir()
-if VERBOSE == 1:
+if VERBOSE >= 1:
 stdout(f"  Build directory: {project_dir}.\n")
 
 # Set the build results directory.
@@ -431,7 +431,7 @@
 
 # Clean up scan build results.
 if os.path.exists(output_dir):
-if VERBOSE == 1:
+if VERBOSE >= 1:
 stdout(f"  Removing old results: 

[PATCH] D80222: Replace Clang's createRuntimeFunction with the definitions in OMPKinds.def

2020-05-28 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

I figured out what the problem is and we can relatively easily fix it *once* we 
always have an OpenMPIRBuilder available in Clangs CG. As noted in D80735 
, we should remove `IdentQTy` as it is used to 
create a new ident_t in some situations. The entire 
`getOrCreateDefaultLocation` in clangs CG, should be replaced by 
`OpenMPIRBuilder::getOrCreateIdent`. We do this later.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80222



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


[PATCH] D76793: [Matrix] Implement + and - operators for MatrixType.

2020-05-28 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Thanks, functionality is looking good for the non-assignment operators.




Comment at: clang/lib/Sema/SemaExpr.cpp:12112
+return InvalidOperands(Loc, OriginalLHS, OriginalRHS);
+  }
+

You need to not actually apply this conversion to the LHS if this is a compound 
assignment.  You can handle that in a follow-up patch, I think, since this 
patch isn't doing those yet.



Comment at: clang/lib/Sema/SemaOverload.cpp:8591
 
+  /// Add binary operators overloads for each candidate matrix type M1, M2:
+  ///  * (M1, M1) -> M1

"operator overloads"



Comment at: clang/test/CodeGenCXX/matrix-type-operators.cpp:374
+  // CHECK-NEXT:%1 = bitcast [90 x double]* %value to <90 x double>*
+  // CHECK-NEXT:%2 = load <90 x double>, <90 x double>* %1, align 8
+  // CHECK-NEXT:%call = call double 
@_ZN14DoubleWrapper1cvdEv(%struct.DoubleWrapper1* %w1)

Please don't test for exact value numbers; it makes updating the test really 
painful for relatively minor IR changes.  Use FileCheck variables instead.

More generally, can you make these tests a little more targeted instead of 
testing the entire function body?  You might find it easier to do so if you do 
a single operation per function.



Comment at: clang/test/SemaCXX/matrix-type-operators.cpp:188
+// expected-note@-3 {{candidate function}}
+// expected-note@-4 {{candidate function}}
+return {};

`expected-note` can take a repeat count


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76793



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


[PATCH] D80374: [Clang] Enable KF and KC mode for [_Complex] __float128

2020-05-28 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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80374



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


[PATCH] D80023: [clang-tidy] Add abseil-string-find-str-contains checker.

2020-05-28 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

Fixed with commit a1b88afe46d7a0f72d2acd8792951bd959b27545 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80023



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


[PATCH] D80531: [clang-tidy]: Added modernize-replace-disallow-copy-and-assign-macro

2020-05-28 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

Few changes and nits then LGTM




Comment at: 
clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.cpp:25
+  const SourceManager )
+  : Check(Check), PP(PP), SM(SM) {}
+

nit: You don't need to store a reference to the `SourceManager` as the 
`Preprocessor` holds a reference to it.



Comment at: 
clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.cpp:32
+  return;
+if (Info->getNameStart() != Check.MacroName)
+  return;

Use `Info->getName()` here, the Length is stored internally so its not 
expensive to get and makes the code look more readable.



Comment at: 
clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.cpp:45-46
+
+// FIXME: Maybe someday I will know how to expand the macro and not use my
+// pre-written code snippet. But for now, this is okay.
+std::string Replacement = llvm::formatv(

This FIXME can probably be removed as expanding the macro isn't a good idea. 
The macro should expand to just defining the function rather than deleting it 
like we want.



Comment at: 
clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.cpp:50
+const {0} =(const {0} &) = delete{1})cpp",
+ClassIdent->getNameStart(), shouldAppendSemi(Range) ? ";" : "");
+

ditto: use `ClassIdent->getName()` as well.



Comment at: 
clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.cpp:52
+
+Check.diag(MacroNameTok.getLocation(), "using copy and assign macro '%0'")
+<< Check.MacroName

nit: Not a fan of the warning message, would prefer something like
`prefer deleting copy constructor and assignment operator over using macro 
'%0'` to explain what we are trying to do. Though if someone can think of 
something shorter that gets the same point I'm open to that.



Comment at: 
clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.cpp:59
+private:
+  /// \returns \c true if the next token after the given \a MacroLoc is \b not 
a
+  /// semicolon.

Use `\p` before `MacroLoc` instead of `\a` as its a parameter.



Comment at: 
clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.h:52
+
+  const std::string MacroName;
+};

Make this private with a get function and I'll be happy. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80531



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


[PATCH] D74387: [OpenMP][SYCL] Improve diagnosing of unsupported types usage

2020-05-28 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon updated this revision to Diff 266942.
Fznamznon marked an inline comment as done and an inline comment as not done.
Fznamznon added a comment.

Included test cases from Johannes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74387

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/CMakeLists.txt
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaSYCL.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/Headers/nvptx_device_math_sin.c
  clang/test/Headers/nvptx_device_math_sin.cpp
  clang/test/OpenMP/nvptx_unsupported_type_codegen.cpp
  clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
  clang/test/SemaSYCL/float128.cpp

Index: clang/test/SemaSYCL/float128.cpp
===
--- /dev/null
+++ clang/test/SemaSYCL/float128.cpp
@@ -0,0 +1,96 @@
+// RUN: %clang_cc1 -triple spir64 -fsycl -fsycl-is-device -verify -fsyntax-only %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsycl -fsycl-is-device -fsyntax-only %s
+
+typedef __float128 BIGTY;
+
+template 
+class Z {
+public:
+  // expected-note@+1 {{'field' defined here}}
+  T field;
+  // expected-note@+1 2{{'field1' defined here}}
+  __float128 field1;
+  using BIGTYPE = __float128;
+  // expected-note@+1 {{'bigfield' defined here}}
+  BIGTYPE bigfield;
+};
+
+void host_ok(void) {
+  __float128 A;
+  int B = sizeof(__float128);
+  Z<__float128> C;
+  C.field1 = A;
+}
+
+void usage() {
+  // expected-note@+1 3{{'A' defined here}}
+  __float128 A;
+  Z<__float128> C;
+  // expected-error@+2 {{'A' requires 128 bit size '__float128' type support, but device 'spir64' does not support it}}
+  // expected-error@+1 {{'field1' requires 128 bit size '__float128' type support, but device 'spir64' does not support it}}
+  C.field1 = A;
+  // expected-error@+1 {{'bigfield' requires 128 bit size 'Z::BIGTYPE' (aka '__float128') type support, but device 'spir64' does not support it}}
+  C.bigfield += 1.0;
+
+  // expected-error@+1 {{'A' requires 128 bit size '__float128' type support, but device 'spir64' does not support it}}
+  auto foo1 = [=]() {
+__float128 AA;
+// expected-note@+2 {{'BB' defined here}}
+// expected-error@+1 {{'A' requires 128 bit size '__float128' type support, but device 'spir64' does not support it}}
+auto BB = A;
+// expected-error@+1 {{'BB' requires 128 bit size '__float128' type support, but device 'spir64' does not support it}}
+BB += 1;
+  };
+
+  // expected-note@+1 {{called by 'usage'}}
+  foo1();
+}
+
+template 
+void foo2(){};
+
+// expected-note@+3 {{'P' defined here}}
+// expected-error@+2 {{'P' requires 128 bit size '__float128' type support, but device 'spir64' does not support it}}
+// expected-note@+1 2{{'foo' defined here}}
+__float128 foo(__float128 P) { return P; }
+
+template 
+__attribute__((sycl_kernel)) void kernel(Func kernelFunc) {
+  // expected-note@+1 5{{called by 'kernel}}
+  kernelFunc();
+}
+
+int main() {
+  // expected-note@+1 {{'CapturedToDevice' defined here}}
+  __float128 CapturedToDevice = 1;
+  host_ok();
+  kernel([=]() {
+decltype(CapturedToDevice) D;
+// expected-error@+1 {{'CapturedToDevice' requires 128 bit size '__float128' type support, but device 'spir64' does not support it}}
+auto C = CapturedToDevice;
+Z<__float128> S;
+// expected-error@+1 {{'field1' requires 128 bit size '__float128' type support, but device 'spir64' does not support it}}
+S.field1 += 1;
+// expected-error@+1 {{'field' requires 128 bit size '__float128' type support, but device 'spir64' does not support it}}
+S.field = 1;
+  });
+
+  kernel([=]() {
+// expected-note@+1 2{{called by 'operator()'}}
+usage();
+// expected-note@+1 {{'' defined here}}
+BIGTY ;
+// expected-note@+3 {{called by 'operator()'}}
+// expected-error@+2 2{{'foo' requires 128 bit size '__float128' type support, but device 'spir64' does not support it}}
+// expected-error@+1 {{'' requires 128 bit size 'BIGTY' (aka '__float128') type support, but device 'spir64' does not support it}}
+auto A = foo();
+  });
+
+  kernel([=]() {
+Z<__float128> S;
+foo2<__float128>();
+auto A = sizeof(CapturedToDevice);
+  });
+
+  return 0;
+}
Index: clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
===
--- clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
+++ clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
@@ -7,18 +7,23 @@
 struct T {
   char a;
 #ifndef _ARCH_PPC
+  // expected-note@+1 {{'f' defined here}}
   __float128 f;
 #else
+  // expected-note@+1 {{'f' defined here}}
   long double f;
 #endif
   char c;
   T() : a(12), f(15) {}
 #ifndef _ARCH_PPC
-// 

[PATCH] D69764: [clang-format] Add East/West Const fixer capability

2020-05-28 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay marked an inline comment as done.
MyDeveloperDay added inline comments.



Comment at: clang/lib/Format/EastWestConstFixer.cpp:195
+FormatToken *Tok) {
+  // We only need to think about streams that begin with const.
+  if (!Tok->is(tok::kw_const)) {

curdeius wrote:
> MyDeveloperDay wrote:
> > curdeius wrote:
> > > Why? What about `unsigned const int`?
> > @curdeius would you help me understand your expectation here?
> > 
> >  - east: `unsigned int const`
> >  - west: `const unsigned int`
> > 
> > ?
> Yes, precisely this. And as for all other cases, I would only move `const`, 
> nothing else.
Ok that will now will work (but I'll add these specific unit tests to prove it)

`unsigned const int`

will see `unsigned const` and then swap it to be `const unsigned`

resulting in 

`const unsigned int`

similar will happen in the "east" const sense too (but again I'll add the tests)




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

https://reviews.llvm.org/D69764



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


[PATCH] D80743: (PR46111) Desugar Elaborated types in Deduction Guides.

2020-05-28 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added reviewers: rsmith, rjmccall.
erichkeane added a comment.

I hope that @rsmith pays particular attention here for me, I'm unable to come 
up with any cases where this isn't sufficient/breaks other things, but I also 
don't feel like I know deduction guides well enough to claim that I don't break 
anything :)  All the lit tests pass, for what its worth.


As reported in PR46111, implicit instantiation of a deduction guide
causes us to have an elaborated type as the parameter, rather than the
dependent type.  This patch makes sure we desugar the elaborated types
when generating the deduction guides.


Repository:
  rC Clang

https://reviews.llvm.org/D80743

Files:
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/AST/deduction-guides.cpp


Index: clang/test/AST/deduction-guides.cpp
===
--- /dev/null
+++ clang/test/AST/deduction-guides.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only %s -ast-dump -std=c++17 | FileCheck %s
+
+namespace PR46111 {
+template 
+struct S;
+
+template 
+struct HasDeductionGuide {
+  typedef PR46111::S STy;
+  HasDeductionGuide(typename STy::Child);
+  };
+
+// This causes deduction guides to be generated for all constructors.
+HasDeductionGuide() ->HasDeductionGuide;
+
+// The parameter to this one shouldn't be an elaborated type.
+// CHECK: CXXDeductionGuideDecl {{.*}} implicit  'auto (typename S::Child) -> HasDeductionGuide'
+// CHECK: CXXDeductionGuideDecl {{.*}} implicit  'auto (HasDeductionGuide) -> HasDeductionGuide'
+// CHECK: CXXDeductionGuideDecl {{.*}} implicit  'auto () -> HasDeductionGuide'
+} // namespace PR46111
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -1958,6 +1958,10 @@
 TLB,
 TL.getTypedefNameDecl()->getTypeSourceInfo()->getTypeLoc());
   }
+
+  QualType TransformElaboratedType(TypeLocBuilder , ElaboratedTypeLoc TL) {
+return TransformType(TLB, TL.getNamedTypeLoc());
+  }
 };
 
 /// Transform to convert portions of a constructor declaration into the


Index: clang/test/AST/deduction-guides.cpp
===
--- /dev/null
+++ clang/test/AST/deduction-guides.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only %s -ast-dump -std=c++17 | FileCheck %s
+
+namespace PR46111 {
+template 
+struct S;
+
+template 
+struct HasDeductionGuide {
+  typedef PR46111::S STy;
+  HasDeductionGuide(typename STy::Child);
+  };
+
+// This causes deduction guides to be generated for all constructors.
+HasDeductionGuide() ->HasDeductionGuide;
+
+// The parameter to this one shouldn't be an elaborated type.
+// CHECK: CXXDeductionGuideDecl {{.*}} implicit  'auto (typename S::Child) -> HasDeductionGuide'
+// CHECK: CXXDeductionGuideDecl {{.*}} implicit  'auto (HasDeductionGuide) -> HasDeductionGuide'
+// CHECK: CXXDeductionGuideDecl {{.*}} implicit  'auto () -> HasDeductionGuide'
+} // namespace PR46111
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -1958,6 +1958,10 @@
 TLB,
 TL.getTypedefNameDecl()->getTypeSourceInfo()->getTypeLoc());
   }
+
+  QualType TransformElaboratedType(TypeLocBuilder , ElaboratedTypeLoc TL) {
+return TransformType(TLB, TL.getNamedTypeLoc());
+  }
 };
 
 /// Transform to convert portions of a constructor declaration into the
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80743: (PR46111) Desugar Elaborated types in Deduction Guides.

2020-05-28 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

I hope that @rsmith pays particular attention here for me, I'm unable to come 
up with any cases where this isn't sufficient/breaks other things, but I also 
don't feel like I know deduction guides well enough to claim that I don't break 
anything :)  All the lit tests pass, for what its worth.


Repository:
  rC Clang

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

https://reviews.llvm.org/D80743



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


[clang] 5395389 - [analyzer] SATestBuild.py: Make verbosity level a cmd option

2020-05-28 Thread Valeriy Savchenko via cfe-commits

Author: Valeriy Savchenko
Date: 2020-05-28T20:47:06+03:00
New Revision: 5395389475bcaba16966ab62125f2f54ea81c915

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

LOG: [analyzer] SATestBuild.py: Make verbosity level a cmd option

Reviewers: NoQ, dcoughlin

Subscribers: xazax.hun, baloghadamsoftware, szepet, a.sidorin, mikhail.ramalho, 
Szelethus, donat.nagy, dkrupp, Charusso, ASDenysPetrov, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/utils/analyzer/SATestBuild.py

Removed: 




diff  --git a/clang/utils/analyzer/SATestBuild.py 
b/clang/utils/analyzer/SATestBuild.py
index e2fe6a95138b..5ff430d5fcf3 100755
--- a/clang/utils/analyzer/SATestBuild.py
+++ b/clang/utils/analyzer/SATestBuild.py
@@ -389,7 +389,7 @@ def test(self) -> bool:
 start_time = time.time()
 
 project_dir = self.get_project_dir()
-if VERBOSE == 1:
+if VERBOSE >= 1:
 stdout(f"  Build directory: {project_dir}.\n")
 
 # Set the build results directory.
@@ -431,7 +431,7 @@ def build(self, directory: str, output_dir: str):
 
 # Clean up scan build results.
 if os.path.exists(output_dir):
-if VERBOSE == 1:
+if VERBOSE >= 1:
 stdout(f"  Removing old results: {output_dir}\n")
 
 shutil.rmtree(output_dir)
@@ -517,7 +517,7 @@ def scan_build(self, directory: str, output_dir: str, 
build_log_file: IO):
 
 command_to_run = command_prefix + command
 
-if VERBOSE == 1:
+if VERBOSE >= 1:
 stdout(f"  Executing: {command_to_run}\n")
 
 check_call(command_to_run, cwd=cwd,
@@ -575,7 +575,7 @@ def analyze_preprocessed(self, directory: str, output_dir: 
str):
 log_path = os.path.join(fail_path, file_name + ".stderr.txt")
 with open(log_path, "w+") as log_file:
 try:
-if VERBOSE == 1:
+if VERBOSE >= 1:
 stdout(f"  Executing: {command}\n")
 
 check_call(command, cwd=directory, stderr=log_file,
@@ -744,7 +744,7 @@ def run_cmp_results(directory: str, strictness: int = 0) -> 
bool:
 for ref_dir, new_dir in zip(ref_list, new_list):
 assert(ref_dir != new_dir)
 
-if VERBOSE == 1:
+if VERBOSE >= 1:
 stdout(f"  Comparing Results: {ref_dir} {new_dir}\n")
 
 patched_source = os.path.join(directory, PATCHED_SOURCE_DIR_NAME)
@@ -818,7 +818,7 @@ def remove_log_file(output_dir: str):
 
 # Clean up the log file.
 if os.path.exists(build_log_path):
-if VERBOSE == 1:
+if VERBOSE >= 1:
 stdout(f"  Removing log file: {build_log_path}\n")
 
 os.remove(build_log_path)
@@ -887,29 +887,31 @@ def validate_project_file(map_file: IO):
 
 if __name__ == "__main__":
 # Parse command line arguments.
-Parser = argparse.ArgumentParser(
+parser = argparse.ArgumentParser(
 description="Test the Clang Static Analyzer.")
 
-Parser.add_argument("--strictness", dest="strictness", type=int, default=0,
+parser.add_argument("--strictness", dest="strictness", type=int, default=0,
 help="0 to fail on runtime errors, 1 to fail when the "
 "number of found bugs are 
diff erent from the "
 "reference, 2 to fail on any 
diff erence from the "
 "reference. Default is 0.")
-Parser.add_argument("-r", dest="regenerate", action="store_true",
+parser.add_argument("-r", dest="regenerate", action="store_true",
 default=False, help="Regenerate reference output.")
-Parser.add_argument("--override-compiler", action="store_true",
+parser.add_argument("--override-compiler", action="store_true",
 default=False, help="Call scan-build with "
 "--override-compiler option.")
-Parser.add_argument("-j", "--jobs", dest="jobs", type=int,
+parser.add_argument("-j", "--jobs", dest="jobs", type=int,
 default=0,
 help="Number of projects to test concurrently")
-Parser.add_argument("--extra-analyzer-config",
+parser.add_argument("--extra-analyzer-config",
 dest="extra_analyzer_config", type=str,
 default="",
 help="Arguments passed to to -analyzer-config")
+parser.add_argument("-v", "--verbose", action="count", default=0)
 
-args = Parser.parse_args()
+args = parser.parse_args()
 
+VERBOSE = args.verbose
 tester = RegressionTester(args.jobs, args.override_compiler,

[clang-tools-extra] a1b88af - [clang-tidy] Fix build broken by commit 7cfdff7b4a6704b8ef2a1b594e1ec19d2d89f385 (D80023)

2020-05-28 Thread Yitzhak Mandelbaum via cfe-commits

Author: Yitzhak Mandelbaum
Date: 2020-05-28T13:39:58-04:00
New Revision: a1b88afe46d7a0f72d2acd8792951bd959b27545

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

LOG: [clang-tidy] Fix build broken by commit 
7cfdff7b4a6704b8ef2a1b594e1ec19d2d89f385 (D80023)

Added: 


Modified: 
clang-tools-extra/clang-tidy/abseil/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/abseil/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/abseil/CMakeLists.txt
index c4efa0fe2743..5926717c6c0a 100644
--- a/clang-tools-extra/clang-tidy/abseil/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/abseil/CMakeLists.txt
@@ -33,4 +33,5 @@ add_clang_library(clangTidyAbseilModule
   clangTidy
   clangTidyUtils
   clangTooling
+  clangTransformer
   )



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


[clang] 116dcbe - [analyzer] Remove unused function declaration. NFC.

2020-05-28 Thread Valeriy Savchenko via cfe-commits

Author: Valeriy Savchenko
Date: 2020-05-28T20:28:17+03:00
New Revision: 116dcbebc6a1648b4acd1a1a391c1d66a3eb4b5f

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

LOG: [analyzer] Remove unused function declaration. NFC.

Added: 


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

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp 
b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
index 0822a9461fa7..a14b29c6face 100644
--- a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -801,7 +801,6 @@ class RangeConstraintManager : public 
RangedConstraintManager {
   RangeSet::Factory F;
 
   RangeSet getRange(ProgramStateRef State, SymbolRef Sym);
-  const RangeSet *getRangeForMinusSymbol(ProgramStateRef State, SymbolRef Sym);
 
   RangeSet getSymLTRange(ProgramStateRef St, SymbolRef Sym,
  const llvm::APSInt ,



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


[PATCH] D80023: [clang-tidy] Add abseil-string-find-str-contains checker.

2020-05-28 Thread Tom Lokovic via Phabricator via cfe-commits
tdl-g added a comment.

We see this broke the build for shared-lib config  
http://lab.llvm.org:8011/builders/llvm-avr-linux/builds/1879

Looking now (and I look forward to determining what I should have done to avoid 
this).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80023



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


  1   2   3   >