[PATCH] D63174: [clang][NewPM] Add RUNS for tests that produce slightly different IR under new PM

2019-06-20 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

I'm going to try to work on the X86 tests. Can we hold off on committing those?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63174



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


[PATCH] D63498: [RISC-V] Add -msave-restore and -mno-save-restore to clang driver

2019-06-20 Thread Alex Bradbury via Phabricator via cfe-commits
asb accepted this revision.
asb added a comment.
This revision is now accepted and ready to land.

LGTM, thanks! There was some discussion about the potential stdout+stderr 
merging issues 
http://lists.llvm.org/pipermail/llvm-dev/2017-February/110469.html but I don't 
think it resulted in any new recommended best practice.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63498



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


[PATCH] D62368: Add support for Hygon Dhyana processor

2019-06-20 Thread Jinke Fan via Phabricator via cfe-commits
fanjinke added reviewers: 01alchemist, 4tXJ7f.
fanjinke added a comment.

Hi,

  Please help with the patch reveiw.

Hi cryptoad,
@cryptoad  IS there anything incorrectly?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62368



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


[PATCH] D63174: [clang][NewPM] Add RUNS for tests that produce slightly different IR under new PM

2019-06-20 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc accepted this revision.
chandlerc added a comment.
This revision is now accepted and ready to land.

Eh, this seems close enough now. I'd like a better approach for the x86 
builtins, but no idea what it will end up being.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63174



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


[PATCH] D63626: [clang][NewPM] Remove exception handling before loading pgo sample profile data

2019-06-20 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc added reviewers: davidxl, tejohnson.
chandlerc added a comment.

See inline comment, but I think we should just drop the testing of the function 
attribute bit here rather than adjusting the pipeline.




Comment at: llvm/lib/Passes/PassBuilder.cpp:665-668
+// We must also remove exception handling before attaching sample profile
+// data.
+MPM.addPass(
+createModuleToPostOrderCGSCCPassAdaptor(PostOrderFunctionAttrsPass()));

Does the this need to go before the EarlyFPM as well as before the sample 
profile loader?

Also, this is ... a pretty expensive thing to do... Do we really need this? 
We've been using ThinLTO and sample PGO with the new PM for a long time and 
haven't seen any real issue. I think we can probably just leave this difference 
between the two pass managers and remove the test for this pass running rather 
than adding it.

CC-ing some others just to double check, but I'm not aware of any issues we've 
seen with PGO that were because of this discrepancy.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63626



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


[PATCH] D63156: [clang][NewPM] Add -fno-experimental-new-pass-manager to tests

2019-06-20 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc accepted this revision.
chandlerc added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63156



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


Re: LLVM buildmaster will be off-line for about 30 minutes today at 5 pm

2019-06-20 Thread Galina Kistanova via cfe-commits
Hello everyone,

I was investigating the buildbot e-mail notifications.

Some of you may receive old notifications, some might get some
notifications again.
Please ignore them. Sorry for the inconvenience and thanks for your
understanding.

Thanks

Galina



On Thu, Jun 20, 2019 at 3:41 PM Galina Kistanova 
wrote:

> Hello everyone,
>
> LLVM buildmaster will be off-line for about 30 minutes today after 5 pm
> PST for maintenance.
> Thank you for understanding.
>
> Thanks
>
>
>
> Galina
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D63579: [clang-scan-deps] print the dependencies to stdout and remove the need to use -MD options in the CDB

2019-06-20 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 205938.
arphaman added a comment.

Use the shared stream as suggested.


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

https://reviews.llvm.org/D63579

Files:
  clang/include/clang/Frontend/Utils.h
  clang/lib/Frontend/DependencyFile.cpp
  clang/test/ClangScanDeps/Inputs/regular_cdb.json
  clang/test/ClangScanDeps/regular_cdb.cpp
  clang/tools/clang-scan-deps/ClangScanDeps.cpp

Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -29,12 +29,43 @@
 
 namespace {
 
+class SharedStream {
+public:
+  SharedStream(raw_ostream ) : OS(OS) {}
+  void applyLocked(llvm::function_ref Fn) {
+std::unique_lock LockGuard(Lock);
+Fn(OS);
+OS.flush();
+  }
+
+private:
+  std::mutex Lock;
+  raw_ostream 
+};
+
+/// Prints out all of the gathered dependencies into one output stream instead
+/// of using the output dependency file.
+class DependencyPrinter : public DependencyFileGenerator {
+public:
+  DependencyPrinter(std::unique_ptr Opts,
+SharedStream )
+  : DependencyFileGenerator(*Opts), Opts(std::move(Opts)), OS(OS) {}
+
+  void finishedMainFile(DiagnosticsEngine ) override {
+OS.applyLocked([this](raw_ostream ) { outputDependencyFile(OS); });
+  }
+
+private:
+  std::unique_ptr Opts;
+  SharedStream 
+};
+
 /// A clang tool that runs the preprocessor only for the given compiler
 /// invocation.
 class PreprocessorOnlyTool : public tooling::ToolAction {
 public:
-  PreprocessorOnlyTool(StringRef WorkingDirectory)
-  : WorkingDirectory(WorkingDirectory) {}
+  PreprocessorOnlyTool(StringRef WorkingDirectory, SharedStream )
+  : WorkingDirectory(WorkingDirectory), OS(OS) {}
 
   bool runInvocation(std::shared_ptr Invocation,
  FileManager *FileMgr,
@@ -53,6 +84,21 @@
 
 Compiler.createSourceManager(*FileMgr);
 
+// Create the dependency collector that will collect the produced
+// dependencies.
+//
+// This also moves the existing dependency output options from the
+// invocation to the collector. The options in the invocation are reset,
+// which ensures that the compiler won't create new dependency collectors,
+// and thus won't write out the extra '.d' files to disk.
+auto Opts = llvm::make_unique(
+std::move(Compiler.getInvocation().getDependencyOutputOpts()));
+// We need at least one -MT equivalent for the generator to work.
+if (Opts->Targets.empty())
+  Opts->Targets = {"clang-scan-deps dependency"};
+Compiler.addDependencyCollector(
+std::make_shared(std::move(Opts), OS));
+
 auto Action = llvm::make_unique();
 const bool Result = Compiler.ExecuteAction(*Action);
 FileMgr->clearStatCache();
@@ -61,6 +107,7 @@
 
 private:
   StringRef WorkingDirectory;
+  SharedStream 
 };
 
 /// A proxy file system that doesn't call `chdir` when changing the working
@@ -93,8 +140,9 @@
   ///
   /// \param Compilations The reference to the compilation database that's
   /// used by the clang tool.
-  DependencyScanningTool(const tooling::CompilationDatabase )
-  : Compilations(Compilations) {
+  DependencyScanningTool(const tooling::CompilationDatabase ,
+ SharedStream )
+  : Compilations(Compilations), OS(OS) {
 PCHContainerOps = std::make_shared();
 BaseFS = new ProxyFileSystemWithoutChdir(llvm::vfs::getRealFileSystem());
   }
@@ -107,12 +155,13 @@
 tooling::ClangTool Tool(Compilations, Input, PCHContainerOps, BaseFS);
 Tool.clearArgumentsAdjusters();
 Tool.setRestoreWorkingDir(false);
-PreprocessorOnlyTool Action(CWD);
+PreprocessorOnlyTool Action(CWD, OS);
 return Tool.run();
   }
 
 private:
   const tooling::CompilationDatabase 
+  SharedStream 
   std::shared_ptr PCHContainerOps;
   /// The real filesystem used as a base for all the operations performed by the
   /// tool.
@@ -176,12 +225,14 @@
 return AdjustedArgs;
   });
 
+  // Print out the dependency results to STDOUT by default.
+  SharedStream DependencyOS(llvm::outs());
   unsigned NumWorkers =
   NumThreads == 0 ? llvm::hardware_concurrency() : NumThreads;
   std::vector> WorkerTools;
   for (unsigned I = 0; I < NumWorkers; ++I)
-WorkerTools.push_back(
-llvm::make_unique(*AdjustingCompilations));
+WorkerTools.push_back(llvm::make_unique(
+*AdjustingCompilations, DependencyOS));
 
   std::vector WorkerThreads;
   std::atomic HadErrors(false);
Index: clang/test/ClangScanDeps/regular_cdb.cpp
===
--- clang/test/ClangScanDeps/regular_cdb.cpp
+++ clang/test/ClangScanDeps/regular_cdb.cpp
@@ -2,26 +2,35 @@
 // RUN: rm -rf %t.cdb
 // RUN: mkdir -p %t.dir
 // RUN: cp %s %t.dir/regular_cdb.cpp
+// RUN: cp %s %t.dir/regular_cdb2.cpp
 // 

[PATCH] D63636: [PowerPC][Altivec] Fix offsets for vec_xl and vec_xst

2019-06-20 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai created this revision.
nemanjai added reviewers: hfinkel, jsji, rzurob, saghir.
Herald added a subscriber: kbarton.
Herald added a project: clang.

As we currently have it implemented in altivec.h, the offsets for these two 
intrinsics are element offsets. The documentation in the ABI (as well as the 
implementation in both XL and GCC) states that these should be byte offsets.


Repository:
  rC Clang

https://reviews.llvm.org/D63636

Files:
  lib/Headers/altivec.h
  test/CodeGen/builtins-ppc-xl-xst.c

Index: test/CodeGen/builtins-ppc-xl-xst.c
===
--- test/CodeGen/builtins-ppc-xl-xst.c
+++ test/CodeGen/builtins-ppc-xl-xst.c
@@ -0,0 +1,849 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -target-feature +altivec -target-feature +vsx -triple powerpc64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -target-feature +altivec -target-feature +vsx -target-feature +power8-vector -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-P8
+#include 
+
+// CHECK-LABEL: @test1(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[__VEC_ADDR_I:%.*]] = alloca <8 x i16>, align 16
+// CHECK-NEXT:[[__OFFSET_ADDR_I1:%.*]] = alloca i64, align 8
+// CHECK-NEXT:[[__PTR_ADDR_I2:%.*]] = alloca i16*, align 8
+// CHECK-NEXT:[[ADJUSTED_I3:%.*]] = alloca i8*, align 8
+// CHECK-NEXT:[[__OFFSET_ADDR_I:%.*]] = alloca i64, align 8
+// CHECK-NEXT:[[__PTR_ADDR_I:%.*]] = alloca i16*, align 8
+// CHECK-NEXT:[[ADJUSTED_I:%.*]] = alloca i8*, align 8
+// CHECK-NEXT:[[C_ADDR:%.*]] = alloca <8 x i16>*, align 8
+// CHECK-NEXT:[[PTR_ADDR:%.*]] = alloca i16*, align 8
+// CHECK-NEXT:store <8 x i16>* [[C:%.*]], <8 x i16>** [[C_ADDR]], align 8
+// CHECK-NEXT:store i16* [[PTR:%.*]], i16** [[PTR_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load i16*, i16** [[PTR_ADDR]], align 8
+// CHECK-NEXT:store i64 3, i64* [[__OFFSET_ADDR_I]], align 8
+// CHECK-NEXT:store i16* [[TMP0]], i16** [[__PTR_ADDR_I]], align 8
+// CHECK-NEXT:[[TMP1:%.*]] = load i16*, i16** [[__PTR_ADDR_I]], align 8
+// CHECK-NEXT:[[TMP2:%.*]] = bitcast i16* [[TMP1]] to i8*
+// CHECK-NEXT:[[TMP3:%.*]] = load i64, i64* [[__OFFSET_ADDR_I]], align 8
+// CHECK-NEXT:[[ADD_PTR_I:%.*]] = getelementptr inbounds i8, i8* [[TMP2]], i64 [[TMP3]]
+// CHECK-NEXT:store i8* [[ADD_PTR_I]], i8** [[ADJUSTED_I]], align 8
+// CHECK-NEXT:[[TMP4:%.*]] = load i8*, i8** [[ADJUSTED_I]], align 8
+// CHECK-NEXT:[[TMP5:%.*]] = bitcast i8* [[TMP4]] to i16*
+// CHECK-NEXT:[[TMP6:%.*]] = bitcast i16* [[TMP5]] to <8 x i16>*
+// CHECK-NEXT:[[TMP7:%.*]] = load <8 x i16>, <8 x i16>* [[TMP6]], align 1
+// CHECK-NEXT:[[TMP8:%.*]] = load <8 x i16>*, <8 x i16>** [[C_ADDR]], align 8
+// CHECK-NEXT:store <8 x i16> [[TMP7]], <8 x i16>* [[TMP8]], align 16
+// CHECK-NEXT:[[TMP9:%.*]] = load <8 x i16>*, <8 x i16>** [[C_ADDR]], align 8
+// CHECK-NEXT:[[TMP10:%.*]] = load <8 x i16>, <8 x i16>* [[TMP9]], align 16
+// CHECK-NEXT:[[TMP11:%.*]] = load i16*, i16** [[PTR_ADDR]], align 8
+// CHECK-NEXT:store <8 x i16> [[TMP10]], <8 x i16>* [[__VEC_ADDR_I]], align 16
+// CHECK-NEXT:store i64 7, i64* [[__OFFSET_ADDR_I1]], align 8
+// CHECK-NEXT:store i16* [[TMP11]], i16** [[__PTR_ADDR_I2]], align 8
+// CHECK-NEXT:[[TMP12:%.*]] = load i16*, i16** [[__PTR_ADDR_I2]], align 8
+// CHECK-NEXT:[[TMP13:%.*]] = bitcast i16* [[TMP12]] to i8*
+// CHECK-NEXT:[[TMP14:%.*]] = load i64, i64* [[__OFFSET_ADDR_I1]], align 8
+// CHECK-NEXT:[[ADD_PTR_I4:%.*]] = getelementptr inbounds i8, i8* [[TMP13]], i64 [[TMP14]]
+// CHECK-NEXT:store i8* [[ADD_PTR_I4]], i8** [[ADJUSTED_I3]], align 8
+// CHECK-NEXT:[[TMP15:%.*]] = load <8 x i16>, <8 x i16>* [[__VEC_ADDR_I]], align 16
+// CHECK-NEXT:[[TMP16:%.*]] = load i8*, i8** [[ADJUSTED_I3]], align 8
+// CHECK-NEXT:[[TMP17:%.*]] = bitcast i8* [[TMP16]] to <8 x i16>*
+// CHECK-NEXT:store <8 x i16> [[TMP15]], <8 x i16>* [[TMP17]], align 1
+// CHECK-NEXT:ret void
+//
+// CHECK-P8-LABEL: @test1(
+// CHECK-P8-NEXT:  entry:
+// CHECK-P8-NEXT:[[__VEC_ADDR_I:%.*]] = alloca <8 x i16>, align 16
+// CHECK-P8-NEXT:[[__OFFSET_ADDR_I1:%.*]] = alloca i64, align 8
+// CHECK-P8-NEXT:[[__PTR_ADDR_I2:%.*]] = alloca i16*, align 8
+// CHECK-P8-NEXT:[[ADJUSTED_I3:%.*]] = alloca i8*, align 8
+// CHECK-P8-NEXT:[[__OFFSET_ADDR_I:%.*]] = alloca i64, align 8
+// CHECK-P8-NEXT:[[__PTR_ADDR_I:%.*]] = alloca i16*, align 8
+// CHECK-P8-NEXT:[[ADJUSTED_I:%.*]] = alloca i8*, align 8
+// CHECK-P8-NEXT:[[C_ADDR:%.*]] = alloca <8 x i16>*, align 8
+// CHECK-P8-NEXT:[[PTR_ADDR:%.*]] = alloca i16*, align 8
+// CHECK-P8-NEXT:store <8 x i16>* [[C:%.*]], <8 x i16>** [[C_ADDR]], align 8
+// CHECK-P8-NEXT:store i16* [[PTR:%.*]], i16** [[PTR_ADDR]], align 8
+// 

[PATCH] D63617: [COFF, ARM64] Fix encoding of __debugbreak

2019-06-20 Thread Tom Tan via Phabricator via cfe-commits
TomTan added a comment.

In D63617#1552615 , @rnk wrote:

> Even if `BRK #0xF000` is a Windows convention, it's still possible for ISel 
> to select different instructions for different OSs, and I'd prefer to 
> implement it that way.


Ok, did the implementation in LLVM in https://reviews.llvm.org/D63635.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63617



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


[PATCH] D62883: [analyzer] Track conditions of terminator statements on which the reported node depends on

2019-06-20 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Oh, wait, no, loops.


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

https://reviews.llvm.org/D62883



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


[PATCH] D62883: [analyzer] Track conditions of terminator statements on which the reported node depends on

2019-06-20 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D62883#1552969 , @xazax.hun wrote:

> In D62883#1552870 , @Szelethus wrote:
>
> > - Uniqueing already tracked conditions as an (`Expr`, `ExplodedNode`) pair 
> > instead of on `Expr`
>
>
> I would be surprised to see the same ExploderNode multiple time a lot.  Also, 
> ExploderNode will have a program point, so having both an ExploderNode and an 
> Expr feels redundant to me.


(`Expr`, `LocationContext`) sounds right.


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

https://reviews.llvm.org/D62883



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


[PATCH] D62883: [analyzer] Track conditions of terminator statements on which the reported node depends on

2019-06-20 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In D62883#1552870 , @Szelethus wrote:

> - Now using `CFGBlock::getTerminatorConditionExpr()`
> - Uniqueing already tracked conditions as an (`Expr`, `ExplodedNode`) pair 
> instead of on `Expr`


I would be surprised to see the same ExploderNode multiple time a lot.  Also, 
ExploderNode will have a program point, so having both an ExploderNode and an 
Expr feels redundant to me.

> - Add a `TODO:` about caching
> - Add plenty of new test cases for good measure (examples from my latest mail 
> http://lists.llvm.org/pipermail/cfe-dev/2019-June/062613.html)




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

https://reviews.llvm.org/D62883



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


[PATCH] D62888: [NewPM] Port Sancov

2019-06-20 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added inline comments.



Comment at: clang/lib/CodeGen/BackendUtil.cpp:1231-1232
+  MPM.addPass(ModuleSanitizerCoveragePass(SancovOpts));
+  MPM.addPass(
+  
createModuleToFunctionPassAdaptor(SanitizerCoveragePass(SancovOpts)));
+}

chandlerc wrote:
> leonardchan wrote:
> > chandlerc wrote:
> > > Is there an existing function pass pipeline we can put this in, maybe by 
> > > using an extension point? That would make it much faster to run I suspect.
> > I tried this earlier, but when I use `registerOptimizerLastEPCallback()` 
> > before the default module pipeline is made, I end up getting this linker 
> > error for `-O2` runs:
> > 
> > ```
> > fuzzer.c:(.text.sancov.module_ctor_8bit_counters[sancov.module_ctor_8bit_counters]+0x11):
> >  undefined reference to `__start___sancov_pcs'
> > fuzzer.c:(.text.sancov.module_ctor_8bit_counters[sancov.module_ctor_8bit_counters]+0x16):
> >  undefined reference to `__stop___sancov_pcs'
> > ```
> > 
> > I don't understand how I get this because the symbols are declared in the 
> > IR dump as:
> > 
> > ```
> > @__start___sancov_pcs = external hidden global i64*
> > @__stop___sancov_pcs = external hidden global i64*
> > ```
> > 
> > for both the optimized cases if I use the adaptor or EP. I'm still linking 
> > with the same compiler-rt in each case.
> > 
> > The only difference I think of using the adaptor after 
> > `buildPerModuleDefaultPipeline()` vs using the extension point callback 
> > before is that the order in which the pass will be called changes, although 
> > I still don't see how it could lead to this undefined reference if I still 
> > link against compiler-rt.
> > 
> > Additionally, the only difference between the IR between using the adaptor 
> > vs the EP is a few extra globals/declarations seem to be missing when using 
> > the EP, which makes me think another pass that ran after this one removed 
> > them, although these don't seem to be related to the error.
> > 
> Hmm...
> 
> Maybe those missing globals / declarations are relevant. Maybe they are 
> necessary to get the linking against the sancov runtime to work correctly?
> 
> You could try adding these globals / declarations to the 'used' set so they 
> don't get removed by later passes:
> https://llvm.org/docs/LangRef.html#the-llvm-compiler-used-global-variable
> 
> Otherwise, I have no idea, maybe makes sense to loop in the sanitizer folks 
> explicitly for help debugging this...
Ah ok. I did not know about this global before. So it seems that the problem 
was related to the `__sancov_pcs` section being optimized out. Adding 
`__sancov_gen_` to `llvm.compiler.used` fixes this.

I did a little extra digging and I think it's `ConstantMergePass` or some other 
pass that works with this that seems to cause this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62888



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


[PATCH] D62888: [NewPM] Port Sancov

2019-06-20 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 205922.
leonardchan marked 3 inline comments as done.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62888

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/sancov-new-pm.c
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/Transforms/Instrumentation.h
  llvm/include/llvm/Transforms/Instrumentation/SanitizerCoverage.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
  llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
  llvm/test/Instrumentation/SanitizerCoverage/abort-in-entry-block.ll
  llvm/test/Instrumentation/SanitizerCoverage/backedge-pruning.ll
  llvm/test/Instrumentation/SanitizerCoverage/chains.ll
  llvm/test/Instrumentation/SanitizerCoverage/cmp-tracing-api-x86_32.ll
  llvm/test/Instrumentation/SanitizerCoverage/cmp-tracing-api-x86_64.ll
  llvm/test/Instrumentation/SanitizerCoverage/cmp-tracing.ll
  llvm/test/Instrumentation/SanitizerCoverage/coff-comdat.ll
  
llvm/test/Instrumentation/SanitizerCoverage/coff-pc-table-inline-8bit-counters.ll
  llvm/test/Instrumentation/SanitizerCoverage/coff-used-ctor.ll
  llvm/test/Instrumentation/SanitizerCoverage/const-cmp-tracing.ll
  llvm/test/Instrumentation/SanitizerCoverage/coverage-dbg.ll
  llvm/test/Instrumentation/SanitizerCoverage/coverage.ll
  llvm/test/Instrumentation/SanitizerCoverage/coverage2-dbg.ll
  llvm/test/Instrumentation/SanitizerCoverage/div-tracing.ll
  llvm/test/Instrumentation/SanitizerCoverage/gep-tracing.ll
  llvm/test/Instrumentation/SanitizerCoverage/inline-8bit-counters.ll
  llvm/test/Instrumentation/SanitizerCoverage/interposable-symbol-nocomdat.ll
  llvm/test/Instrumentation/SanitizerCoverage/no-func.ll
  llvm/test/Instrumentation/SanitizerCoverage/pc-table.ll
  llvm/test/Instrumentation/SanitizerCoverage/postdominator_check.ll
  llvm/test/Instrumentation/SanitizerCoverage/seh.ll
  
llvm/test/Instrumentation/SanitizerCoverage/stack-depth-variable-declared-by-user.ll
  llvm/test/Instrumentation/SanitizerCoverage/stack-depth.ll
  llvm/test/Instrumentation/SanitizerCoverage/switch-tracing.ll
  llvm/test/Instrumentation/SanitizerCoverage/trace-pc-guard-comdat.ll
  
llvm/test/Instrumentation/SanitizerCoverage/trace-pc-guard-inline-8bit-counters.ll
  llvm/test/Instrumentation/SanitizerCoverage/trace-pc-guard-nocomdat.ll
  llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
  llvm/test/Instrumentation/SanitizerCoverage/tracing.ll
  llvm/test/Instrumentation/SanitizerCoverage/unreachable-critedge.ll
  llvm/test/Instrumentation/SanitizerCoverage/wineh.ll

Index: llvm/test/Instrumentation/SanitizerCoverage/wineh.ll
===
--- llvm/test/Instrumentation/SanitizerCoverage/wineh.ll
+++ llvm/test/Instrumentation/SanitizerCoverage/wineh.ll
@@ -1,4 +1,5 @@
 ; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc -S | FileCheck %s --check-prefix=CHECK
+; RUN: opt < %s -passes='module(sancov-module),function(sancov-func)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc -S | FileCheck %s --check-prefix=CHECK
 
 ; Generated from this C++ source:
 ; $ clang -O2 t.cpp -S -emit-llvm
Index: llvm/test/Instrumentation/SanitizerCoverage/unreachable-critedge.ll
===
--- llvm/test/Instrumentation/SanitizerCoverage/unreachable-critedge.ll
+++ llvm/test/Instrumentation/SanitizerCoverage/unreachable-critedge.ll
@@ -1,4 +1,5 @@
 ; RUN: opt < %s -S -sancov -sanitizer-coverage-level=3 | FileCheck %s
+; RUN: opt < %s -S -passes='module(sancov-module),function(sancov-func)' -sanitizer-coverage-level=3 | FileCheck %s
 
 ; The critical edges to unreachable_bb should not be split.
 define i32 @foo(i32 %c, i32 %d) {
Index: llvm/test/Instrumentation/SanitizerCoverage/tracing.ll
===
--- llvm/test/Instrumentation/SanitizerCoverage/tracing.ll
+++ llvm/test/Instrumentation/SanitizerCoverage/tracing.ll
@@ -3,6 +3,10 @@
 ; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S | FileCheck %s --check-prefix=CHECK_PC_GUARD
 ; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S -mtriple=x86_64-apple-macosx | FileCheck %s --check-prefix=CHECK_PC_GUARD_DARWIN
 
+; RUN: opt < %s -passes='module(sancov-module),function(sancov-func)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc  -S | FileCheck %s --check-prefix=CHECK_PC
+; RUN: opt < %s -passes='module(sancov-module),function(sancov-func)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S | FileCheck %s --check-prefix=CHECK_PC_GUARD
+; RUN: opt < %s -passes='module(sancov-module),function(sancov-func)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S 

[PATCH] D63579: [clang-scan-deps] print the dependencies to stdout and remove the need to use -MD options in the CDB

2019-06-20 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman marked an inline comment as done.
arphaman added inline comments.



Comment at: clang/tools/clang-scan-deps/ClangScanDeps.cpp:32
 
+class DependencyCollectorFactory {
+public:

aganea wrote:
> arphaman wrote:
> > aganea wrote:
> > > Do you envision future uses for this factory?
> > Most likely, yes.
> > 
> > I don't want to lock-in into creating the dependency printer in the 
> > `PreprocessorOnlyTool`, as the eventual goal is to have it in a library, 
> > and allow clients to consume modular dependencies not only using 
> > `clang-scan-deps` tool itself, but using the C++ library directly 
> > (potentially through a libclang C interface as well). The printer should be 
> > in `clang-scan-deps` tool itself though, so it wouldn't be ideal to 
> > reference it from `PreprocessorOnlyTool` now.
> My initial question was, what are the future planned factories? (and thus the 
> other `DependencyCollector` implementations?)
> 
> Do you think we could have the printer in the library as well?
> 
> On a related note - we're already testing `clang-scan-deps` compiled as a 
> DLL. Our use-case right now is to call it from each of [[ 
> https://github.com/fastbuild/fastbuild | Fastbuild ]]'s worker threads. We 
> are using `main()` below almost as-is (except for the multithreading part 
> which Fastbuild already does). The CDB JSON is passed by value from the 
> Fastbuild thread, so it doesn't go through a file. I'd like to get back 
> dependencies-as-a-string instead of `llvm::outs()`. The bottleneck currently 
> is, as you can imagine, reading / writing files (seen in ETW traces), this 
> patch should improve things a bit. I can send a sample of how we're using it 
> after you commit.
> My initial question was, what are the future planned factories? (and thus the 
> other DependencyCollector implementations?)

The only factory and collector right now that I have in mind is the factory 
that collects the dependency list from the generator, and returns them to the 
user of `PreprocessorOnlyTool`. Something like this:

```
class DependencyConsumer : public DependencyFileGenerator {
public:
  class Factory : public DependencyCollectorFactory {
  public:
std::shared_ptr createDependencyCollector(
std::unique_ptr Opts) override {
   return DependencyConsumer(std::move(Opts));
 }
  };

  DependencyConsumer(std::unique_ptr Opts)
  : DependencyFileGenerator(*Opts), Opts(std::move(Opts)) {}

  void finishedMainFile(DiagnosticsEngine ) override {
Dependencies = getDependencies();
  }
private:
  std::vector Dependencies;
};
```

But the current design is not ideal for supporting that actually. I think I'll 
rework it following the suggested SharedStream you mentioned earlier.

> Do you think we could have the printer in the library as well?

Yes

> On a related note - we're already testing clang-scan-deps compiled as a DLL. 
> Our use-case right now is to call it from each of Fastbuild's worker threads. 
> We are using main() below almost as-is (except for the multithreading part 
> which Fastbuild already does). 

Nice! I think the library will be a great fit for you then, the plan is to have 
a service object in it which will own the shared state (like the cache of the 
minimized sources), and worker objects which you can use in each thread to do 
the actual work.


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

https://reviews.llvm.org/D63579



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


[PATCH] D63623: [clang-tidy] Add a check on expected return values of posix functions (except posix_openpt) in Android module.

2019-06-20 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/clang-tidy/android/PosixReturnCheck.h:1
+//===--- PosixReturnCheck.h - clang-tidy*- C++ 
-*-//
+//

Please use - before *- C++ -* to fill line. See other checks as example.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:199
 
+- New :doc:`android-posix-return
+  ` check.

Please move into new checks list (in alphabetical order).



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:202
+
+  Checks if any alls to posix functions (except posix_openpt) expect negative
+  return values

calls? posix -> POSIX. Please enclose posix_openpt in double back-ticks.



Comment at: clang-tools-extra/docs/clang-tidy/checks/android-posix-return.rst:4
+android-posix-return
+=
+

Please make same length as name.



Comment at: clang-tools-extra/docs/clang-tidy/checks/android-posix-return.rst:6
+
+Checks if any calls to posix functions (except posix_openpt) expect negative
+return values. These functions return either 0 on success or an errno on 
failure,

Please make same changes as in Release Notes.



Comment at: clang-tools-extra/docs/clang-tidy/checks/android-posix-return.rst:7
+Checks if any calls to posix functions (except posix_openpt) expect negative
+return values. These functions return either 0 on success or an errno on 
failure,
+which is positive only.

Please enclose 0 and errno into double back-ticks.



Comment at: clang-tools-extra/docs/clang-tidy/checks/android-posix-return.rst:16
+
+This will never happen as the return value is always non-negative. A simple 
fix could be
+

Please add colon at end.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63623



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


[PATCH] D62619: [analyzer][IDF] Add a control dependency calculator + a new debug checker

2019-06-20 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus updated this revision to Diff 205917.
Szelethus added a comment.

Rebase on previous patches.


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

https://reviews.llvm.org/D62619

Files:
  clang/include/clang/Analysis/Analyses/Dominators.h
  clang/include/clang/Analysis/CFG.h
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp
  clang/test/Analysis/domtest.c
  clang/test/Analysis/domtest.cpp
  clang/unittests/Analysis/CFGDominatorTree.cpp

Index: clang/unittests/Analysis/CFGDominatorTree.cpp
===
--- clang/unittests/Analysis/CFGDominatorTree.cpp
+++ clang/unittests/Analysis/CFGDominatorTree.cpp
@@ -117,6 +117,99 @@
   EXPECT_TRUE(PostDom.dominates(nullptr, ExitBlock));
 }
 
+TEST(CFGDominatorTree, ControlDependency) {
+  const char *Code = R"(bool coin();
+
+void funcWithBranch() {
+  int x = 0;
+  if (coin()) {
+if (coin()) {
+  x = 5;
+}
+int j = 10 / x;
+(void)j;
+  }
+};)";
+  BuildResult Result = BuildCFG(Code);
+  EXPECT_EQ(BuildResult::BuiltCFG, Result.getStatus());
+
+  //  1st if  2nd if
+  //  [B5 (ENTRY)]  -> [B4] -> [B3] -> [B2] -> [B1] -> [B0 (EXIT)]
+  //\\  / /
+  // \-> /
+  //  -->
+
+  CFG *cfg = Result.getCFG();
+
+  // Sanity checks.
+  EXPECT_EQ(cfg->size(), 6u);
+
+  CFGBlock *ExitBlock = *cfg->begin();
+  EXPECT_EQ(ExitBlock, >getExit());
+
+  CFGBlock *NullDerefBlock = *(cfg->begin() + 1);
+
+  CFGBlock *SecondThenBlock = *(cfg->begin() + 2);
+
+  CFGBlock *SecondIfBlock = *(cfg->begin() + 3);
+  EXPECT_TRUE(hasStmtType(SecondIfBlock));
+
+  CFGBlock *FirstIfBlock = *(cfg->begin() + 4);
+  EXPECT_TRUE(hasStmtType(FirstIfBlock));
+
+  CFGBlock *EntryBlock = *(cfg->begin() + 5);
+  EXPECT_EQ(EntryBlock, >getEntry());
+
+  ControlDependencyCalculator Control(cfg);
+
+  EXPECT_TRUE(Control.isControlDependent(SecondThenBlock, SecondIfBlock));
+  EXPECT_TRUE(Control.isControlDependent(SecondIfBlock, FirstIfBlock));
+  EXPECT_FALSE(Control.isControlDependent(NullDerefBlock, SecondIfBlock));
+}
+
+TEST(CFGDominatorTree, ControlDependencyWithLoops) {
+  const char *Code = R"(int test3() {
+  int x,y,z;
+
+  x = y = z = 1;
+  if (x > 0) {
+while (x >= 0){
+  while (y >= x) {
+x = x-1;
+y = y/2;
+  }
+}
+  }
+  z = y;
+
+  return 0;
+})";
+  BuildResult Result = BuildCFG(Code);
+  EXPECT_EQ(BuildResult::BuiltCFG, Result.getStatus());
+
+  //   <- [B2] <-
+  //  /  \
+  // [B8 (ENTRY)] -> [B7] -> [B6] ---> [B5] -> [B4] -> [B3]
+  //   \   | \  /
+  //\  |  <-
+  // \  \
+  //  > [B1] -> [B0 (EXIT)]
+
+  CFG *cfg = Result.getCFG();
+
+  ControlDependencyCalculator Control(cfg);
+
+  auto GetBlock = [cfg] (unsigned Index) -> CFGBlock * {
+assert(Index < cfg->size());
+return *(cfg->begin() + Index);
+  };
+
+  // While not immediately obvious, the second block in fact post dominates the
+  // fifth, hence B5 is not a control dependency of 2.
+  EXPECT_FALSE(Control.isControlDependent(GetBlock(5), GetBlock(2)));
+}
+
+
 } // namespace
 } // namespace analysis
 } // namespace clang
Index: clang/test/Analysis/domtest.cpp
===
--- clang/test/Analysis/domtest.cpp
+++ clang/test/Analysis/domtest.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_analyze_cc1 %s \
 // RUN:   -analyzer-checker=debug.DumpDominators \
 // RUN:   -analyzer-checker=debug.DumpPostDominators \
+// RUN:   -analyzer-checker=debug.DumpControlDependencies \
 // RUN:   2>&1 | FileCheck %s
 
 bool coin();
@@ -20,7 +21,8 @@
 
 //  [B3 (ENTRY)]  -> [B1] -> [B2] -> [B0 (EXIT)]
 
-// CHECK:  Immediate dominance tree (Node#,IDom#):
+// CHECK:  Control dependencies (Node#,Dependency#):
+// CHECK-NEXT: Immediate dominance tree (Node#,IDom#):
 // CHECK-NEXT: (0,2)
 // CHECK-NEXT: (1,3)
 // CHECK-NEXT: (2,1)
@@ -42,13 +44,18 @@
   }
 }
 
-//> [B2] >
-//   /\
-// [B5 (ENTRY)] -> [B4] -> [B3] ---> [B1]
-//   

[PATCH] D62611: [analyzer][Dominators] Add unittests

2019-06-20 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

Gentle ping :^)


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

https://reviews.llvm.org/D62611



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


[PATCH] D62883: [analyzer] Track conditions of terminator statements on which the reported node depends on

2019-06-20 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus updated this revision to Diff 205916.
Szelethus marked an inline comment as done.
Szelethus added a comment.

- Now using `CFGBlock::getTerminatorConditionExpr()`
- Uniqueing already tracked conditions as an (`Expr`, `ExplodedNode`) pair 
instead of on `Expr`
- Add a `TODO:` about caching
- Add plenty of new test cases for good measure (examples from my latest mail 
http://lists.llvm.org/pipermail/cfe-dev/2019-June/062613.html)


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

https://reviews.llvm.org/D62883

Files:
  clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/test/Analysis/analyzer-config.c
  clang/test/Analysis/track-control-dependency-conditions.cpp

Index: clang/test/Analysis/track-control-dependency-conditions.cpp
===
--- /dev/null
+++ clang/test/Analysis/track-control-dependency-conditions.cpp
@@ -0,0 +1,287 @@
+// RUN: %clang_analyze_cc1 %s -verify -DTRACKING_CONDITIONS \
+// RUN:   -analyzer-config track-conditions=true \
+// RUN:   -analyzer-output=text \
+// RUN:   -analyzer-checker=core
+//
+// RUN: %clang_analyze_cc1 %s -verify \
+// RUN:   -analyzer-output=text \
+// RUN:   -analyzer-checker=core
+
+namespace example_1 {
+int flag;
+bool coin();
+
+void foo() {
+  flag = coin();
+#ifdef TRACKING_CONDITIONS
+  // expected-note@-2{{Value assigned to 'flag'}}
+#endif // TRACKING_CONDITIONS
+}
+
+void test() {
+  int *x = 0; // expected-note{{'x' initialized to a null pointer value}}
+  flag = 1;
+
+  foo(); // TODO: Add nodes here about flag's value being invalidated.
+  if (flag) // expected-note   {{Assuming 'flag' is 0}}
+// expected-note@-1{{Taking false branch}}
+x = new int;
+
+  foo();
+#ifdef TRACKING_CONDITIONS
+  // expected-note@-2{{Calling 'foo'}}
+  // expected-note@-3{{Returning from 'foo'}}
+#endif // TRACKING_CONDITIONS
+
+  if (flag) // expected-note   {{Assuming 'flag' is not equal to 0}}
+// expected-note@-1{{Taking true branch}}
+*x = 5; // expected-warning{{Dereference of null pointer}}
+// expected-note@-1{{Dereference of null pointer}}
+}
+} // end of namespace example_1
+
+namespace example_2 {
+int flag;
+bool coin();
+
+void foo() {
+  flag = coin();
+#ifdef TRACKING_CONDITIONS
+  // expected-note@-2{{Value assigned to 'flag'}}
+#endif // TRACKING_CONDITIONS
+}
+
+void test() {
+  int *x = 0;
+  flag = 1;
+
+  foo();
+  if (flag) // expected-note   {{Assuming 'flag' is 0}}
+// expected-note@-1{{Taking false branch}}
+x = new int;
+
+  x = 0; // expected-note{{Null pointer value stored to 'x'}}
+
+  foo();
+#ifdef TRACKING_CONDITIONS
+  // expected-note@-2{{Calling 'foo'}}
+  // expected-note@-3{{Returning from 'foo'}}
+#endif // TRACKING_CONDITIONS
+
+  if (flag) // expected-note   {{Assuming 'flag' is not equal to 0}}
+// expected-note@-1{{Taking true branch}}
+*x = 5; // expected-warning{{Dereference of null pointer}}
+// expected-note@-1{{Dereference of null pointer}}
+}
+} // end of namespace example_2
+
+namespace global_variable_invalidation {
+int flag;
+bool coin();
+
+void foo() {
+  // coin() could write bar, do it's invalidated.
+  flag = coin();
+#ifdef TRACKING_CONDITIONS
+  // expected-note@-2{{Value assigned to 'flag'}}
+  // expected-note@-3{{Value assigned to 'bar'}}
+#endif // TRACKING_CONDITIONS
+}
+
+int bar;
+
+void test() {
+  int *x = 0; // expected-note{{'x' initialized to a null pointer value}}
+  flag = 1;
+
+  foo();
+#ifdef TRACKING_CONDITIONS
+  // expected-note@-2{{Calling 'foo'}}
+  // expected-note@-3{{Returning from 'foo'}}
+#endif // TRACKING_CONDITIONS
+
+  if (bar) // expected-note   {{Assuming 'bar' is not equal to 0}}
+   // expected-note@-1{{Taking true branch}}
+if (flag) // expected-note   {{Assuming 'flag' is not equal to 0}}
+  // expected-note@-1{{Taking true branch}}
+  *x = 5; // expected-warning{{Dereference of null pointer}}
+  // expected-note@-1{{Dereference of null pointer}}
+}
+} // end of namespace global_variable_invalidation
+
+namespace variable_declaration_in_condition {
+bool coin();
+
+bool foo() {
+  return coin();
+#ifdef TRACKING_CONDITIONS
+  // expected-note@-2{{Returning value}}
+#endif // TRACKING_CONDITIONS
+}
+
+int bar;
+
+void test() {
+  int *x = 0; // expected-note{{'x' initialized to a null pointer value}}
+
+  if (int flag = foo())
+#ifdef TRACKING_CONDITIONS
+// expected-note@-2{{Calling 'foo'}}
+// expected-note@-3{{Returning from 'foo'}}
+// expected-note@-4{{'flag' initialized here}}
+#endif // TRACKING_CONDITIONS
+// expected-note@-6{{Assuming 'flag' is not equal to 0}}
+// expected-note@-7{{Taking true branch}}
+*x = 5; // expected-warning{{Dereference of null pointer}}
+// 

LLVM buildmaster will be off-line for about 30 minutes today at 5 pm

2019-06-20 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM buildmaster will be off-line for about 30 minutes today after 5 pm PST
for maintenance.
Thank you for understanding.

Thanks



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


[PATCH] D63625: [CodeGen][test] Use -fno-discard-value-names for better test support

2019-06-20 Thread Jordan Rupprecht via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG73986707bd57: [CodeGen][test] Use FileCheck variable 
matchers for better test support (authored by rupprecht).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63625

Files:
  clang/test/CodeGenCXX/debug-info-nrvo.cpp


Index: clang/test/CodeGenCXX/debug-info-nrvo.cpp
===
--- clang/test/CodeGenCXX/debug-info-nrvo.cpp
+++ clang/test/CodeGenCXX/debug-info-nrvo.cpp
@@ -1,5 +1,10 @@
-// RUN: %clangxx -target x86_64-unknown-unknown -g %s -emit-llvm -S -o - | 
FileCheck %s
-// RUN: %clangxx -target x86_64-unknown-unknown -g -fno-elide-constructors %s 
-emit-llvm -S -o - | FileCheck %s -check-prefix=NOELIDE
+// RUN: %clangxx -target x86_64-unknown-unknown -g \
+// RUN:   %s -emit-llvm -S -o - | FileCheck %s
+
+// RUN: %clangxx -target x86_64-unknown-unknown -g \
+// RUN:   -fno-elide-constructors %s -emit-llvm -S -o - | \
+// RUN:   FileCheck %s -check-prefix=NOELIDE
+
 struct Foo {
   Foo() = default;
   Foo(Foo &) { x = other.x; }
@@ -21,8 +26,10 @@
 // Check that NRVO variables are stored as a pointer with deref if they are
 // stored in the return register.
 
-// CHECK: %result.ptr = alloca i8*, align 8
-// CHECK: call void @llvm.dbg.declare(metadata i8** %result.ptr,
+// CHECK: %[[RESULT:.*]] = alloca i8*, align 8
+// CHECK: call void @llvm.dbg.declare(metadata i8** %[[RESULT]],
 // CHECK-SAME: metadata !DIExpression(DW_OP_deref)
-// NOELIDE: call void @llvm.dbg.declare(metadata %struct.Foo* %foo,
+
+// NOELIDE: %[[FOO:.*]] = alloca %struct.Foo, align 4
+// NOELIDE: call void @llvm.dbg.declare(metadata %struct.Foo* %[[FOO]],
 // NOELIDE-SAME:metadata !DIExpression()


Index: clang/test/CodeGenCXX/debug-info-nrvo.cpp
===
--- clang/test/CodeGenCXX/debug-info-nrvo.cpp
+++ clang/test/CodeGenCXX/debug-info-nrvo.cpp
@@ -1,5 +1,10 @@
-// RUN: %clangxx -target x86_64-unknown-unknown -g %s -emit-llvm -S -o - | FileCheck %s
-// RUN: %clangxx -target x86_64-unknown-unknown -g -fno-elide-constructors %s -emit-llvm -S -o - | FileCheck %s -check-prefix=NOELIDE
+// RUN: %clangxx -target x86_64-unknown-unknown -g \
+// RUN:   %s -emit-llvm -S -o - | FileCheck %s
+
+// RUN: %clangxx -target x86_64-unknown-unknown -g \
+// RUN:   -fno-elide-constructors %s -emit-llvm -S -o - | \
+// RUN:   FileCheck %s -check-prefix=NOELIDE
+
 struct Foo {
   Foo() = default;
   Foo(Foo &) { x = other.x; }
@@ -21,8 +26,10 @@
 // Check that NRVO variables are stored as a pointer with deref if they are
 // stored in the return register.
 
-// CHECK: %result.ptr = alloca i8*, align 8
-// CHECK: call void @llvm.dbg.declare(metadata i8** %result.ptr,
+// CHECK: %[[RESULT:.*]] = alloca i8*, align 8
+// CHECK: call void @llvm.dbg.declare(metadata i8** %[[RESULT]],
 // CHECK-SAME: metadata !DIExpression(DW_OP_deref)
-// NOELIDE: call void @llvm.dbg.declare(metadata %struct.Foo* %foo,
+
+// NOELIDE: %[[FOO:.*]] = alloca %struct.Foo, align 4
+// NOELIDE: call void @llvm.dbg.declare(metadata %struct.Foo* %[[FOO]],
 // NOELIDE-SAME:metadata !DIExpression()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r363996 - [CodeGen][test] Use FileCheck variable matchers for better test support

2019-06-20 Thread Jordan Rupprecht via cfe-commits
Author: rupprecht
Date: Thu Jun 20 15:35:52 2019
New Revision: 363996

URL: http://llvm.org/viewvc/llvm-project?rev=363996=rev
Log:
[CodeGen][test] Use FileCheck variable matchers for better test support

Summary: Depending on how clang is built, it may discard the IR names and use 
names like `%2` instead of `%result.ptr`, causing tests that rely on the IR 
name to fail. Using FileCheck matchers makes the test work regardless of how 
clang is built.

This test passes with both `-fno-discard-value-names` and 
`-fdiscard-value-names` to make sure it passes regardless of the build mode.

Reviewers: rnk, akhuang, aprantl, lebedev.ri

Subscribers: cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/test/CodeGenCXX/debug-info-nrvo.cpp

Modified: cfe/trunk/test/CodeGenCXX/debug-info-nrvo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-nrvo.cpp?rev=363996=363995=363996=diff
==
--- cfe/trunk/test/CodeGenCXX/debug-info-nrvo.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-nrvo.cpp Thu Jun 20 15:35:52 2019
@@ -1,5 +1,10 @@
-// RUN: %clangxx -target x86_64-unknown-unknown -g %s -emit-llvm -S -o - | 
FileCheck %s
-// RUN: %clangxx -target x86_64-unknown-unknown -g -fno-elide-constructors %s 
-emit-llvm -S -o - | FileCheck %s -check-prefix=NOELIDE
+// RUN: %clangxx -target x86_64-unknown-unknown -g \
+// RUN:   %s -emit-llvm -S -o - | FileCheck %s
+
+// RUN: %clangxx -target x86_64-unknown-unknown -g \
+// RUN:   -fno-elide-constructors %s -emit-llvm -S -o - | \
+// RUN:   FileCheck %s -check-prefix=NOELIDE
+
 struct Foo {
   Foo() = default;
   Foo(Foo &) { x = other.x; }
@@ -21,8 +26,10 @@ int main() {
 // Check that NRVO variables are stored as a pointer with deref if they are
 // stored in the return register.
 
-// CHECK: %result.ptr = alloca i8*, align 8
-// CHECK: call void @llvm.dbg.declare(metadata i8** %result.ptr,
+// CHECK: %[[RESULT:.*]] = alloca i8*, align 8
+// CHECK: call void @llvm.dbg.declare(metadata i8** %[[RESULT]],
 // CHECK-SAME: metadata !DIExpression(DW_OP_deref)
-// NOELIDE: call void @llvm.dbg.declare(metadata %struct.Foo* %foo,
+
+// NOELIDE: %[[FOO:.*]] = alloca %struct.Foo, align 4
+// NOELIDE: call void @llvm.dbg.declare(metadata %struct.Foo* %[[FOO]],
 // NOELIDE-SAME:metadata !DIExpression()


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


r363995 - [analyzer] DeadStores: Update the crude suppression for files generated by IIG.

2019-06-20 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Thu Jun 20 15:29:40 2019
New Revision: 363995

URL: http://llvm.org/viewvc/llvm-project?rev=363995=rev
Log:
[analyzer] DeadStores: Update the crude suppression for files generated by IIG.

They changed the comments that we were looking for.

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
cfe/trunk/test/Analysis/deadstores-driverkit.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp?rev=363995=363994=363995=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp Thu Jun 20 
15:29:40 2019
@@ -174,7 +174,7 @@ public:
 
 // Files autogenerated by DriverKit IIG contain some dead stores that
 // we don't want to report.
-if (Data.startswith("/* iig generated from"))
+if (Data.startswith("/* iig"))
   return true;
 
 return false;

Modified: cfe/trunk/test/Analysis/deadstores-driverkit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/deadstores-driverkit.cpp?rev=363995=363994=363995=diff
==
--- cfe/trunk/test/Analysis/deadstores-driverkit.cpp (original)
+++ cfe/trunk/test/Analysis/deadstores-driverkit.cpp Thu Jun 20 15:29:40 2019
@@ -1,4 +1,4 @@
-/* iig generated from SomethingSomething.iig */
+/* iig(DriverKit-60) generated from SomethingSomething.iig */
 
 // The comment above is the whole point of the test.
 // That's how the suppression works.


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


[PATCH] D63625: [CodeGen][test] Use -fno-discard-value-names for better test support

2019-06-20 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Thanks. This is surprisingly the first time I've heard of fdiscard-value-names. 
Seems useful, since now you can test your IR both ways without having to 
completely recompile clang.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63625



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


[PATCH] D63625: [CodeGen][test] Use -fno-discard-value-names for better test support

2019-06-20 Thread Amy Huang via Phabricator via cfe-commits
akhuang accepted this revision.
akhuang added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63625



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


r363994 - [X86] Change LL to O in the definitions for the vp2intersect builtins.

2019-06-20 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Thu Jun 20 15:19:16 2019
New Revision: 363994

URL: http://llvm.org/viewvc/llvm-project?rev=363994=rev
Log:
[X86] Change LL to O in the definitions for the vp2intersect builtins.

This is needed to support OpenCL where long long is 128 bits.

This was done for the other builtins already, but I think
vp2intersect was in phabricator at the time.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=363994=363993=363994=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Thu Jun 20 15:19:16 2019
@@ -1844,9 +1844,9 @@ TARGET_BUILTIN(__builtin_ia32_dpbf16ps_2
 TARGET_BUILTIN(__builtin_ia32_dpbf16ps_512, "V16fV16fV16iV16i", "ncV:512:", 
"avx512bf16")
 TARGET_BUILTIN(__builtin_ia32_cvtsbf162ss_32, "fUs", "nc", "avx512bf16")
 
-TARGET_BUILTIN(__builtin_ia32_vp2intersect_q_512, "vV8LLiV8LLiUc*Uc*", 
"nV:512:", "avx512vp2intersect")
-TARGET_BUILTIN(__builtin_ia32_vp2intersect_q_256, "vV4LLiV4LLiUc*Uc*", 
"nV:256:", "avx512vp2intersect,avx512vl")
-TARGET_BUILTIN(__builtin_ia32_vp2intersect_q_128, "vV2LLiV2LLiUc*Uc*", 
"nV:128:", "avx512vp2intersect,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vp2intersect_q_512, "vV8OiV8OiUc*Uc*", 
"nV:512:", "avx512vp2intersect")
+TARGET_BUILTIN(__builtin_ia32_vp2intersect_q_256, "vV4OiV4OiUc*Uc*", 
"nV:256:", "avx512vp2intersect,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vp2intersect_q_128, "vV2OiV2OiUc*Uc*", 
"nV:128:", "avx512vp2intersect,avx512vl")
 TARGET_BUILTIN(__builtin_ia32_vp2intersect_d_512, "vV16iV16iUs*Us*", 
"nV:512:", "avx512vp2intersect")
 TARGET_BUILTIN(__builtin_ia32_vp2intersect_d_256, "vV8iV8iUc*Uc*", "nV:256:", 
"avx512vp2intersect,avx512vl")
 TARGET_BUILTIN(__builtin_ia32_vp2intersect_d_128, "vV4iV4iUc*Uc*", "nV:128:", 
"avx512vp2intersect,avx512vl")


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


[PATCH] D63625: [CodeGen][test] Use -fno-discard-value-names for better test support

2019-06-20 Thread Jordan Rupprecht via Phabricator via cfe-commits
rupprecht added a comment.

Sounds good, changed to use variable matching instead. This passes w/ either 
`-fno-discard-value-names` or `-fdiscard-value-names` used.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63625



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


[PATCH] D63625: [CodeGen][test] Use -fno-discard-value-names for better test support

2019-06-20 Thread Jordan Rupprecht via Phabricator via cfe-commits
rupprecht updated this revision to Diff 205912.
rupprecht added a comment.

- Use filecheck variable matching instead of an explicit 
-fno-discard-value-names option


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63625

Files:
  clang/test/CodeGenCXX/debug-info-nrvo.cpp


Index: clang/test/CodeGenCXX/debug-info-nrvo.cpp
===
--- clang/test/CodeGenCXX/debug-info-nrvo.cpp
+++ clang/test/CodeGenCXX/debug-info-nrvo.cpp
@@ -1,5 +1,10 @@
-// RUN: %clangxx -target x86_64-unknown-unknown -g %s -emit-llvm -S -o - | 
FileCheck %s
-// RUN: %clangxx -target x86_64-unknown-unknown -g -fno-elide-constructors %s 
-emit-llvm -S -o - | FileCheck %s -check-prefix=NOELIDE
+// RUN: %clangxx -target x86_64-unknown-unknown -g \
+// RUN:   %s -emit-llvm -S -o - | FileCheck %s
+
+// RUN: %clangxx -target x86_64-unknown-unknown -g \
+// RUN:   -fno-elide-constructors %s -emit-llvm -S -o - | \
+// RUN:   FileCheck %s -check-prefix=NOELIDE
+
 struct Foo {
   Foo() = default;
   Foo(Foo &) { x = other.x; }
@@ -21,8 +26,10 @@
 // Check that NRVO variables are stored as a pointer with deref if they are
 // stored in the return register.
 
-// CHECK: %result.ptr = alloca i8*, align 8
-// CHECK: call void @llvm.dbg.declare(metadata i8** %result.ptr,
+// CHECK: %[[RESULT:.*]] = alloca i8*, align 8
+// CHECK: call void @llvm.dbg.declare(metadata i8** %[[RESULT]],
 // CHECK-SAME: metadata !DIExpression(DW_OP_deref)
-// NOELIDE: call void @llvm.dbg.declare(metadata %struct.Foo* %foo,
+
+// NOELIDE: %[[FOO:.*]] = alloca %struct.Foo, align 4
+// NOELIDE: call void @llvm.dbg.declare(metadata %struct.Foo* %[[FOO]],
 // NOELIDE-SAME:metadata !DIExpression()


Index: clang/test/CodeGenCXX/debug-info-nrvo.cpp
===
--- clang/test/CodeGenCXX/debug-info-nrvo.cpp
+++ clang/test/CodeGenCXX/debug-info-nrvo.cpp
@@ -1,5 +1,10 @@
-// RUN: %clangxx -target x86_64-unknown-unknown -g %s -emit-llvm -S -o - | FileCheck %s
-// RUN: %clangxx -target x86_64-unknown-unknown -g -fno-elide-constructors %s -emit-llvm -S -o - | FileCheck %s -check-prefix=NOELIDE
+// RUN: %clangxx -target x86_64-unknown-unknown -g \
+// RUN:   %s -emit-llvm -S -o - | FileCheck %s
+
+// RUN: %clangxx -target x86_64-unknown-unknown -g \
+// RUN:   -fno-elide-constructors %s -emit-llvm -S -o - | \
+// RUN:   FileCheck %s -check-prefix=NOELIDE
+
 struct Foo {
   Foo() = default;
   Foo(Foo &) { x = other.x; }
@@ -21,8 +26,10 @@
 // Check that NRVO variables are stored as a pointer with deref if they are
 // stored in the return register.
 
-// CHECK: %result.ptr = alloca i8*, align 8
-// CHECK: call void @llvm.dbg.declare(metadata i8** %result.ptr,
+// CHECK: %[[RESULT:.*]] = alloca i8*, align 8
+// CHECK: call void @llvm.dbg.declare(metadata i8** %[[RESULT]],
 // CHECK-SAME: metadata !DIExpression(DW_OP_deref)
-// NOELIDE: call void @llvm.dbg.declare(metadata %struct.Foo* %foo,
+
+// NOELIDE: %[[FOO:.*]] = alloca %struct.Foo, align 4
+// NOELIDE: call void @llvm.dbg.declare(metadata %struct.Foo* %[[FOO]],
 // NOELIDE-SAME:metadata !DIExpression()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D63538: [analyzer][CFG] Return the correct terminator condition

2019-06-20 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Ok, thanks!


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

https://reviews.llvm.org/D63538



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


[PATCH] D63538: [analyzer][CFG] Return the correct terminator condition

2019-06-20 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus updated this revision to Diff 205909.
Szelethus added a comment.

Addressing reviewer feedback!


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

https://reviews.llvm.org/D63538

Files:
  clang/include/clang/Analysis/CFG.h
  clang/lib/Analysis/CFG.cpp

Index: clang/lib/Analysis/CFG.cpp
===
--- clang/lib/Analysis/CFG.cpp
+++ clang/lib/Analysis/CFG.cpp
@@ -5615,69 +5615,21 @@
   Out << JsonFormat(TempOut.str(), AddQuotes);
 }
 
-Stmt *CFGBlock::getTerminatorCondition(bool StripParens) {
-  Stmt *Terminator = getTerminatorStmt();
-  if (!Terminator)
+const Stmt *CFGBlock::getTerminatorCondition(bool StripParens) const {
+  // If the terminator is a temporary dtor or a virtual base, etc, we can't
+  // retrieve a meaningful condition, bail out.
+  if (rbegin()->getKind() != CFGElement::Kind::Statement)
 return nullptr;
 
-  Expr *E = nullptr;
-
-  switch (Terminator->getStmtClass()) {
-default:
-  break;
-
-case Stmt::CXXForRangeStmtClass:
-  E = cast(Terminator)->getCond();
-  break;
-
-case Stmt::ForStmtClass:
-  E = cast(Terminator)->getCond();
-  break;
-
-case Stmt::WhileStmtClass:
-  E = cast(Terminator)->getCond();
-  break;
-
-case Stmt::DoStmtClass:
-  E = cast(Terminator)->getCond();
-  break;
-
-case Stmt::IfStmtClass:
-  E = cast(Terminator)->getCond();
-  break;
-
-case Stmt::ChooseExprClass:
-  E = cast(Terminator)->getCond();
-  break;
-
-case Stmt::IndirectGotoStmtClass:
-  E = cast(Terminator)->getTarget();
-  break;
-
-case Stmt::SwitchStmtClass:
-  E = cast(Terminator)->getCond();
-  break;
-
-case Stmt::BinaryConditionalOperatorClass:
-  E = cast(Terminator)->getCond();
-  break;
-
-case Stmt::ConditionalOperatorClass:
-  E = cast(Terminator)->getCond();
-  break;
-
-case Stmt::BinaryOperatorClass: // '&&' and '||'
-  E = cast(Terminator)->getLHS();
-  break;
-
-case Stmt::ObjCForCollectionStmtClass:
-  return Terminator;
+  // This should be the condition of the terminator block.
+  const Stmt *S = rbegin()->castAs().getStmt();
+  if (isa(S)) {
+return getTerminatorStmt();
   }
 
-  if (!StripParens)
-return E;
-
-  return E ? E->IgnoreParens() : nullptr;
+  // Only ObjCForCollectionStmt is known not to be a non-Expr terminator.
+  const Expr *Cond = cast(S);
+  return StripParens ? Cond->IgnoreParens() : Cond;
 }
 
 //===--===//
Index: clang/include/clang/Analysis/CFG.h
===
--- clang/include/clang/Analysis/CFG.h
+++ clang/include/clang/Analysis/CFG.h
@@ -860,10 +860,12 @@
   Stmt *getTerminatorStmt() { return Terminator.getStmt(); }
   const Stmt *getTerminatorStmt() const { return Terminator.getStmt(); }
 
-  Stmt *getTerminatorCondition(bool StripParens = true);
+  /// \returns the condition of the terminator (condition of an if statement,
+  /// for loop, etc).
+  const Stmt *getTerminatorCondition(bool StripParens = true) const;
 
-  const Stmt *getTerminatorCondition(bool StripParens = true) const {
-return const_cast(this)->getTerminatorCondition(StripParens);
+  const Expr *getTerminatorConditionExpr(bool StripParens = true) const {
+return dyn_cast_or_null(getTerminatorCondition(StripParens));
   }
 
   const Stmt *getLoopTarget() const { return LoopTarget; }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D63578: AMDGPU: Add DS GWS sema builtins

2019-06-20 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm added a comment.

r363986


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

https://reviews.llvm.org/D63578



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


[PATCH] D63156: [clang][NewPM] Add -fno-experimental-new-pass-manager to tests

2019-06-20 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added inline comments.



Comment at: clang/test/CodeGen/pgo-sample.c:12-14
+// NEWPM-DAG: PostOrderFunctionAttrsPass
+// NEWPM-DAG: SimplifyCFGPass
+// NEWPM-DAG: SampleProfileLoaderPass

chandlerc wrote:
> The DAG worries me a bit ... The point here is to check that we remove EH 
> before attaching sample profile data, and with the DAG it isn't clear that 
> this happens *before*.
It turns out that `SampleProfileLoaderPass` was added before either of these. I 
moved this into a separate patch that addresses it since it comes with a small 
clang + llvm change (D63626).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63156



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


[PATCH] D63156: [clang][NewPM] Add -fno-experimental-new-pass-manager to tests

2019-06-20 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 205906.
leonardchan marked 3 inline comments as done.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63156

Files:
  clang/test/CodeGen/aggregate-assign-call.c
  clang/test/CodeGen/arm_acle.c
  clang/test/CodeGen/cspgo-instrumentation.c
  clang/test/CodeGen/cspgo-instrumentation_lto.c
  clang/test/CodeGen/cspgo-instrumentation_thinlto.c
  clang/test/CodeGen/pgo-instrumentation.c
  clang/test/CodeGen/thinlto-debug-pm.c
  clang/test/CodeGenCXX/auto-var-init.cpp
  clang/test/CodeGenCXX/conditional-temporaries.cpp
  clang/test/CodeGenCXX/member-function-pointer-calls.cpp
  clang/test/CodeGenObjC/os_log.m
  clang/test/CodeGenObjCXX/os_log.mm
  clang/test/Misc/pr32207.c

Index: clang/test/Misc/pr32207.c
===
--- clang/test/Misc/pr32207.c
+++ clang/test/Misc/pr32207.c
@@ -1,4 +1,4 @@
 // test for r305179
-// RUN: %clang_cc1 -emit-llvm -O -mllvm -print-after-all %s -o %t 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -O2 -fno-experimental-new-pass-manager -mllvm -print-after-all %s -o %t 2>&1 | FileCheck %s
 // CHECK: *** IR Dump After Function Integration/Inlining ***
 void foo() {}
Index: clang/test/CodeGenObjCXX/os_log.mm
===
--- clang/test/CodeGenObjCXX/os_log.mm
+++ clang/test/CodeGenObjCXX/os_log.mm
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple x86_64-darwin-apple -fobjc-arc \
-// RUN:   -fexceptions -fcxx-exceptions -O1 | FileCheck %s
+// RUN:   -fexceptions -fcxx-exceptions -O1 -fno-experimental-new-pass-manager | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple x86_64-darwin-apple -fobjc-arc \
+// RUN:   -fexceptions -fcxx-exceptions -O1 -fexperimental-new-pass-manager -fno-inline | FileCheck %s
 
 // Check that no EH cleanup is emitted around the call to __os_log_helper.
 namespace no_eh_cleanup {
Index: clang/test/CodeGenObjC/os_log.m
===
--- clang/test/CodeGenObjC/os_log.m
+++ clang/test/CodeGenObjC/os_log.m
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - -triple x86_64-darwin-apple -fobjc-arc -O2 | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple x86_64-darwin-apple -fobjc-arc -O2 -fno-experimental-new-pass-manager | FileCheck %s --check-prefixes=CHECK,CHECK-LEGACY
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple x86_64-darwin-apple -fobjc-arc -O2 -fexperimental-new-pass-manager | FileCheck %s --check-prefixes=CHECK,CHECK-NEWPM
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple x86_64-darwin-apple -fobjc-arc -O0 | FileCheck %s -check-prefix=CHECK-O0
 
 // Make sure we emit clang.arc.use before calling objc_release as part of the
@@ -22,7 +23,8 @@
   // CHECK: %[[CALL:.*]] = tail call %[[TY0:.*]]* (...) @GenString()
   // CHECK: %[[V0:.*]] = bitcast %[[TY0]]* %[[CALL]] to i8*
   // CHECK: %[[V1:.*]] = notail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %[[V0]])
-  // CHECK: %[[V2:.*]] = ptrtoint %[[TY0]]* %[[CALL]] to i64
+  // CHECK-LEGACY: %[[V2:.*]] = ptrtoint %[[TY0]]* %[[CALL]] to i64
+  // CHECK-NEWPM: %[[V2:.*]] = ptrtoint i8* %[[V1]] to i64
   // CHECK: store i8 2, i8* %[[BUF]], align 1
   // CHECK: %[[NUMARGS_I:.*]] = getelementptr i8, i8* %[[BUF]], i64 1
   // CHECK: store i8 1, i8* %[[NUMARGS_I]], align 1
@@ -33,8 +35,10 @@
   // CHECK: %[[ARGDATA_I:.*]] = getelementptr i8, i8* %[[BUF]], i64 4
   // CHECK: %[[ARGDATACAST_I:.*]] = bitcast i8* %[[ARGDATA_I]] to i64*
   // CHECK: store i64 %[[V2]], i64* %[[ARGDATACAST_I]], align 1
-  // CHECK: tail call void (...) @llvm.objc.clang.arc.use(%[[TY0]]* %[[CALL]])
-  // CHECK: tail call void @llvm.objc.release(i8* %[[V0]])
+  // CHECK-LEGACY: tail call void (...) @llvm.objc.clang.arc.use(%[[TY0]]* %[[CALL]])
+  // CHECK-LEGACY: tail call void @llvm.objc.release(i8* %[[V0]])
+  // CHECK-NEWPM: tail call void (...) @llvm.objc.clang.arc.use(i8* %[[V1]])
+  // CHECK-NEWPM: tail call void @llvm.objc.release(i8* %[[V1]])
   // CHECK: ret i8* %[[BUF]]
 
   // clang.arc.use is used and removed in IR optimizations. At O0, we should not
Index: clang/test/CodeGenCXX/member-function-pointer-calls.cpp
===
--- clang/test/CodeGenCXX/member-function-pointer-calls.cpp
+++ clang/test/CodeGenCXX/member-function-pointer-calls.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -O3 -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -O3 -fno-experimental-new-pass-manager  -o - | FileCheck %s --check-prefixes=CHECK,CHECK-LEGACY
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -O3 -fexperimental-new-pass-manager  -o - | FileCheck %s --check-prefixes=CHECK,CHECK-NEWPM
 // RUN: %clang_cc1 %s -triple=x86_64-windows-gnu -emit-llvm -o - | FileCheck %s -check-prefix 

[PATCH] D63625: [CodeGen][test] Use -fno-discard-value-names for better test support

2019-06-20 Thread Amy Huang via Phabricator via cfe-commits
akhuang added a comment.

> Why isn't this using FileCheck variable matching in the first place? That's 
> the least fragile solution.

No reason, just something I overlooked when I wrote it-


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63625



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


[PATCH] D63626: [clang][NewPM] Remove exception handling before loading pgo sample profile data

2019-06-20 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan created this revision.
leonardchan added reviewers: chandlerc, phosek, serge-sans-paille, echristo.
leonardchan added a project: clang.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
leonardchan added a parent revision: D63156: [clang][NewPM] Add 
-fno-experimental-new-pass-manager to tests.

This patch ensures that  SimplifyCFGPass and PostOrderFunctionAttrsPass come 
before SampleProfileLoaderPass on PGO runs in the new PM and fixes 
`clang/test/CodeGen/pgo-sample.c`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D63626

Files:
  clang/test/CodeGen/pgo-sample.c
  llvm/lib/Passes/PassBuilder.cpp
  llvm/test/Other/new-pm-pgo.ll


Index: llvm/test/Other/new-pm-pgo.ll
===
--- llvm/test/Other/new-pm-pgo.ll
+++ llvm/test/Other/new-pm-pgo.ll
@@ -16,11 +16,13 @@
 ; USE: Running pass: PGOMemOPSizeOpt
 ; SAMPLE_USE_O: Running pass: 
ModuleToFunctionPassAdaptor<{{.*}}AddDiscriminatorsPass{{.*}}>
 ; SAMPLE_USE_PRE_LINK: Running pass: 
ModuleToFunctionPassAdaptor<{{.*}}AddDiscriminatorsPass{{.*}}>
+; SAMPLE_USE_POST_LINK: Running pass: 
ModuleToPostOrderCGSCCPassAdaptor
 ; SAMPLE_USE: Running pass: SimplifyCFGPass
 ; SAMPLE_USE: Running pass: SROA
 ; SAMPLE_USE: Running pass: EarlyCSEPass
 ; SAMPLE_USE: Running pass: LowerExpectIntrinsicPass
 ; SAMPLE_USE_POST_LINK: Running pass: InstCombinePass
+; SAMPLE_USE_POST_LINK: Running pass: SimplifyCFGPass
 ; SAMPLE_USE: Running pass: SampleProfileLoaderPass
 ; SAMPLE_USE_O: Running pass: PGOIndirectCallPromotion
 ; SAMPLE_USE_POST_LINK-NOT: Running pass: GlobalOptPass
Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -659,8 +659,15 @@
   // More details about SamplePGO design can be found in:
   // https://research.google.com/pubs/pub45290.html
   // FIXME: revisit how SampleProfileLoad/Inliner/ICP is structured.
-  if (LoadSampleProfile)
+  if (LoadSampleProfile) {
 EarlyFPM.addPass(InstCombinePass());
+
+// We must also remove exception handling before attaching sample profile
+// data.
+MPM.addPass(
+createModuleToPostOrderCGSCCPassAdaptor(PostOrderFunctionAttrsPass()));
+EarlyFPM.addPass(SimplifyCFGPass());
+  }
   MPM.addPass(createModuleToFunctionPassAdaptor(std::move(EarlyFPM)));
 
   if (LoadSampleProfile) {
Index: clang/test/CodeGen/pgo-sample.c
===
--- clang/test/CodeGen/pgo-sample.c
+++ clang/test/CodeGen/pgo-sample.c
@@ -1,6 +1,16 @@
 // Test if PGO sample use passes are invoked.
 //
 // Ensure Pass PGOInstrumentationGenPass is invoked.
-// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample.prof %s 
-mllvm -debug-pass=Structure -emit-llvm -o - 2>&1 | FileCheck %s
-// CHECK: Remove unused exception handling info
-// CHECK: Sample profile pass
+// RUN: %clang_cc1 -O2 -fno-experimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample.prof %s -mllvm -debug-pass=Structure 
-emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=LEGACY
+// RUN: %clang_cc1 -O2 -fexperimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample.prof %s -fdebug-pass-manager 
-emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=NEWPM
+
+// LEGACY: Remove unused exception handling info
+// LEGACY: Sample profile pass
+
+// The new pass manager analog to PruneEH is a combination of 'function-attrs'
+// and 'function(simplify-cgf)'.
+// NEWPM-DAG: PostOrderFunctionAttrsPass
+// NEWPM-DAG: SimplifyCFGPass
+// NEWPM: SampleProfileLoaderPass
+
+int func(int a) { return a; }


Index: llvm/test/Other/new-pm-pgo.ll
===
--- llvm/test/Other/new-pm-pgo.ll
+++ llvm/test/Other/new-pm-pgo.ll
@@ -16,11 +16,13 @@
 ; USE: Running pass: PGOMemOPSizeOpt
 ; SAMPLE_USE_O: Running pass: ModuleToFunctionPassAdaptor<{{.*}}AddDiscriminatorsPass{{.*}}>
 ; SAMPLE_USE_PRE_LINK: Running pass: ModuleToFunctionPassAdaptor<{{.*}}AddDiscriminatorsPass{{.*}}>
+; SAMPLE_USE_POST_LINK: Running pass: ModuleToPostOrderCGSCCPassAdaptor
 ; SAMPLE_USE: Running pass: SimplifyCFGPass
 ; SAMPLE_USE: Running pass: SROA
 ; SAMPLE_USE: Running pass: EarlyCSEPass
 ; SAMPLE_USE: Running pass: LowerExpectIntrinsicPass
 ; SAMPLE_USE_POST_LINK: Running pass: InstCombinePass
+; SAMPLE_USE_POST_LINK: Running pass: SimplifyCFGPass
 ; SAMPLE_USE: Running pass: SampleProfileLoaderPass
 ; SAMPLE_USE_O: Running pass: PGOIndirectCallPromotion
 ; SAMPLE_USE_POST_LINK-NOT: Running pass: GlobalOptPass
Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -659,8 +659,15 @@
   // More details about SamplePGO design can be found in:
   // https://research.google.com/pubs/pub45290.html
   // 

[PATCH] D63625: [CodeGen][test] Use -fno-discard-value-names for better test support

2019-06-20 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D63625#1552756 , @akhuang wrote:

> Looks good, alternatively I think we can just change `%result.ptr` into a 
> variable match?


Why isn't this using FileCheck variable matching in the first place? That's the 
least fragile solution.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63625



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


[PATCH] D63625: [CodeGen][test] Use -fno-discard-value-names for better test support

2019-06-20 Thread Amy Huang via Phabricator via cfe-commits
akhuang added a comment.

Looks good, alternatively I think we can just change `%result.ptr` into a 
variable match?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63625



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


r363986 - AMDGPU: Add DS GWS sema builtins

2019-06-20 Thread Matt Arsenault via cfe-commits
Author: arsenm
Date: Thu Jun 20 14:33:57 2019
New Revision: 363986

URL: http://llvm.org/viewvc/llvm-project?rev=363986=rev
Log:
AMDGPU: Add DS GWS sema builtins

Modified:
cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-ci.cl
cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl
cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error-ci.cl

Modified: cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def?rev=363986=363985=363986=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def Thu Jun 20 14:33:57 2019
@@ -47,6 +47,9 @@ BUILTIN(__builtin_amdgcn_s_dcache_inv, "
 BUILTIN(__builtin_amdgcn_buffer_wbinvl1, "v", "n")
 BUILTIN(__builtin_amdgcn_ds_gws_init, "vUiUi", "n")
 BUILTIN(__builtin_amdgcn_ds_gws_barrier, "vUiUi", "n")
+BUILTIN(__builtin_amdgcn_ds_gws_sema_v, "vUi", "n")
+BUILTIN(__builtin_amdgcn_ds_gws_sema_br, "vUiUi", "n")
+BUILTIN(__builtin_amdgcn_ds_gws_sema_p, "vUi", "n")
 
 // FIXME: Need to disallow constant address space.
 BUILTIN(__builtin_amdgcn_div_scale, "dddbb*", "n")
@@ -108,6 +111,7 @@ BUILTIN(__builtin_amdgcn_ds_consume, "ii
 
//===--===//
 TARGET_BUILTIN(__builtin_amdgcn_s_dcache_inv_vol, "v", "n", "ci-insts")
 TARGET_BUILTIN(__builtin_amdgcn_buffer_wbinvl1_vol, "v", "n", "ci-insts")
+TARGET_BUILTIN(__builtin_amdgcn_ds_gws_sema_release_all, "vUi", "n", 
"ci-insts")
 
 
//===--===//
 // Interpolation builtins.

Modified: cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-ci.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-ci.cl?rev=363986=363985=363986=diff
==
--- cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-ci.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-ci.cl Thu Jun 20 14:33:57 2019
@@ -3,6 +3,8 @@
 // RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu fiji -S 
-emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx906 -S 
-emit-llvm -o - %s | FileCheck %s
 
+typedef unsigned int uint;
+
 // CHECK-LABEL: @test_s_dcache_inv_vol
 // CHECK: call void @llvm.amdgcn.s.dcache.inv.vol(
 void test_s_dcache_inv_vol()
@@ -17,3 +19,9 @@ void test_buffer_wbinvl1_vol()
   __builtin_amdgcn_buffer_wbinvl1_vol();
 }
 
+// CHECK-LABEL: @test_gws_sema_release_all(
+// CHECK: call void @llvm.amdgcn.ds.gws.sema.release.all(i32 %id)
+void test_gws_sema_release_all(uint id)
+{
+  __builtin_amdgcn_ds_gws_sema_release_all(id);
+}

Modified: cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl?rev=363986=363985=363986=diff
==
--- cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl Thu Jun 20 14:33:57 2019
@@ -560,6 +560,24 @@ kernel void test_gws_barrier(uint value,
   __builtin_amdgcn_ds_gws_barrier(value, id);
 }
 
+// CHECK-LABEL: @test_gws_sema_v(
+// CHECK: call void @llvm.amdgcn.ds.gws.sema.v(i32 %id)
+kernel void test_gws_sema_v(uint id) {
+  __builtin_amdgcn_ds_gws_sema_v(id);
+}
+
+// CHECK-LABEL: @test_gws_sema_br(
+// CHECK: call void @llvm.amdgcn.ds.gws.sema.br(i32 %value, i32 %id)
+kernel void test_gws_sema_br(uint value, uint id) {
+  __builtin_amdgcn_ds_gws_sema_br(value, id);
+}
+
+// CHECK-LABEL: @test_gws_sema_p(
+// CHECK: call void @llvm.amdgcn.ds.gws.sema.p(i32 %id)
+kernel void test_gws_sema_p(uint id) {
+  __builtin_amdgcn_ds_gws_sema_p(id);
+}
+
 // CHECK-DAG: [[$WI_RANGE]] = !{i32 0, i32 1024}
 // CHECK-DAG: attributes #[[$NOUNWIND_READONLY:[0-9]+]] = { nounwind readonly }
 // CHECK-DAG: attributes #[[$READ_EXEC_ATTRS]] = { convergent }

Modified: cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error-ci.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error-ci.cl?rev=363986=363985=363986=diff
==
--- cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error-ci.cl (original)
+++ cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error-ci.cl Thu Jun 20 14:33:57 
2019
@@ -1,8 +1,9 @@
 // REQUIRES: amdgpu-registered-target
 // RUN: %clang_cc1 -triple amdgcn-- -target-cpu tahiti -verify -S -o - %s
 
-void test_ci_biltins()
+void test_ci_builtins()
 {
   __builtin_amdgcn_s_dcache_inv_vol(); // expected-error 
{{'__builtin_amdgcn_s_dcache_inv_vol' needs target feature ci-insts}}
   __builtin_amdgcn_buffer_wbinvl1_vol(); // expected-error 
{{'__builtin_amdgcn_buffer_wbinvl1_vol' needs target feature 

[PATCH] D63600: [test][Driver] Fix Clang :: Driver/cl-response-file.c

2019-06-20 Thread Rainer Orth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL363985: [test][Driver] Fix Clang :: 
Driver/cl-response-file.c (authored by ro, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D63600?vs=205793=205903#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D63600

Files:
  cfe/trunk/test/Driver/cl-response-file.c


Index: cfe/trunk/test/Driver/cl-response-file.c
===
--- cfe/trunk/test/Driver/cl-response-file.c
+++ cfe/trunk/test/Driver/cl-response-file.c
@@ -4,7 +4,7 @@
 
 
 
-// RUN: echo '/I%S\Inputs\cl-response-file\ /DFOO=2' > %t.rsp
+// RUN: printf '/I%S\Inputs\\cl-response-file\ /DFOO=2' > %t.rsp
 // RUN: %clang_cl /c -### @%t.rsp -- %s 2>&1 | FileCheck %s
 
 // CHECK: "-I" "{{.*}}\\Inputs\\cl-response-file\\" "-D" "FOO=2"


Index: cfe/trunk/test/Driver/cl-response-file.c
===
--- cfe/trunk/test/Driver/cl-response-file.c
+++ cfe/trunk/test/Driver/cl-response-file.c
@@ -4,7 +4,7 @@
 
 
 
-// RUN: echo '/I%S\Inputs\cl-response-file\ /DFOO=2' > %t.rsp
+// RUN: printf '/I%S\Inputs\\cl-response-file\ /DFOO=2' > %t.rsp
 // RUN: %clang_cl /c -### @%t.rsp -- %s 2>&1 | FileCheck %s
 
 // CHECK: "-I" "{{.*}}\\Inputs\\cl-response-file\\" "-D" "FOO=2"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D63625: [CodeGen][test] Use -fno-discard-value-names for better test support

2019-06-20 Thread Jordan Rupprecht via Phabricator via cfe-commits
rupprecht created this revision.
rupprecht added reviewers: rnk, akhuang, aprantl.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Depending on how clang is built, it may discard the IR names and use names like 
`%2` instead of `%result.ptr`, causing tests that rely on the IR name to fail. 
Using `fno-discard-value-names` ensures the actual name is present regardless 
of the build mode.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D63625

Files:
  clang/test/CodeGenCXX/debug-info-nrvo.cpp


Index: clang/test/CodeGenCXX/debug-info-nrvo.cpp
===
--- clang/test/CodeGenCXX/debug-info-nrvo.cpp
+++ clang/test/CodeGenCXX/debug-info-nrvo.cpp
@@ -1,5 +1,10 @@
-// RUN: %clangxx -target x86_64-unknown-unknown -g %s -emit-llvm -S -o - | 
FileCheck %s
-// RUN: %clangxx -target x86_64-unknown-unknown -g -fno-elide-constructors %s 
-emit-llvm -S -o - | FileCheck %s -check-prefix=NOELIDE
+// RUN: %clangxx -target x86_64-unknown-unknown -g -fno-discard-value-names \
+// RUN:   %s -emit-llvm -S -o - | FileCheck %s
+
+// RUN: %clangxx -target x86_64-unknown-unknown -g -fno-discard-value-names \
+// RUN:   -fno-elide-constructors %s -emit-llvm -S -o - | \
+// RUN:   FileCheck %s -check-prefix=NOELIDE
+
 struct Foo {
   Foo() = default;
   Foo(Foo &) { x = other.x; }


Index: clang/test/CodeGenCXX/debug-info-nrvo.cpp
===
--- clang/test/CodeGenCXX/debug-info-nrvo.cpp
+++ clang/test/CodeGenCXX/debug-info-nrvo.cpp
@@ -1,5 +1,10 @@
-// RUN: %clangxx -target x86_64-unknown-unknown -g %s -emit-llvm -S -o - | FileCheck %s
-// RUN: %clangxx -target x86_64-unknown-unknown -g -fno-elide-constructors %s -emit-llvm -S -o - | FileCheck %s -check-prefix=NOELIDE
+// RUN: %clangxx -target x86_64-unknown-unknown -g -fno-discard-value-names \
+// RUN:   %s -emit-llvm -S -o - | FileCheck %s
+
+// RUN: %clangxx -target x86_64-unknown-unknown -g -fno-discard-value-names \
+// RUN:   -fno-elide-constructors %s -emit-llvm -S -o - | \
+// RUN:   FileCheck %s -check-prefix=NOELIDE
+
 struct Foo {
   Foo() = default;
   Foo(Foo &) { x = other.x; }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r363985 - [test][Driver] Fix Clang :: Driver/cl-response-file.c

2019-06-20 Thread Rainer Orth via cfe-commits
Author: ro
Date: Thu Jun 20 14:33:09 2019
New Revision: 363985

URL: http://llvm.org/viewvc/llvm-project?rev=363985=rev
Log:
[test][Driver] Fix Clang :: Driver/cl-response-file.c

Clang :: Driver/cl-response-file.c currently FAILs on Solaris:

  Command Output (stderr):
  --
  /vol/llvm/src/clang/dist/test/Driver/cl-response-file.c:10:11: error: CHECK: 
expected string not found in input
  // CHECK: "-I" "{{.*}}\\Inputs\\cl-response-file\\" "-D" "FOO=2"
^

Looking at the generated response file reveals that this is no surprise:

  /I/vol/llvm/src/clang/dist/test/Driver\Inputs

with no newline at the end.  The echo command used to create it boils down to

  echo 'a\cb'

However, one cannot expect \c to be emitted literally: e.g. bash's builtin
echo has

  \csuppress further output

I've tried various combinations of builtin echo, /usr/bin/echo, GNU echo if
different, the same for printf, and the backslash unescaped and quoted
(a\cb and a\\cb).  The only combination that worked reliably on Solaris,
Linux, and macOS was

  printf 'a\\cb'

so this is what this patch uses.  Tested on amd64-pc-solaris2.11 and
x86_64-pc-linux-gnu.

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

Modified:
cfe/trunk/test/Driver/cl-response-file.c

Modified: cfe/trunk/test/Driver/cl-response-file.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-response-file.c?rev=363985=363984=363985=diff
==
--- cfe/trunk/test/Driver/cl-response-file.c (original)
+++ cfe/trunk/test/Driver/cl-response-file.c Thu Jun 20 14:33:09 2019
@@ -4,7 +4,7 @@
 
 
 
-// RUN: echo '/I%S\Inputs\cl-response-file\ /DFOO=2' > %t.rsp
+// RUN: printf '/I%S\Inputs\\cl-response-file\ /DFOO=2' > %t.rsp
 // RUN: %clang_cl /c -### @%t.rsp -- %s 2>&1 | FileCheck %s
 
 // CHECK: "-I" "{{.*}}\\Inputs\\cl-response-file\\" "-D" "FOO=2"


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


[PATCH] D63600: [test][Driver] Fix Clang :: Driver/cl-response-file.c

2019-06-20 Thread Jan Korous via Phabricator via cfe-commits
jkorous accepted this revision.
jkorous added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: dexonsmith.

LGTM


Repository:
  rC Clang

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

https://reviews.llvm.org/D63600



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


[PATCH] D63623: [clang-tidy] Add a check on expected return values of posix functions (except posix_openpt) in Android module.

2019-06-20 Thread Jian Cai via Phabricator via cfe-commits
jcai19 added a comment.

In D63623#1552679 , @lebedev.ri wrote:

> Why is this in android module?
>  Is that android-specific behavior, or posix?


I implemented it for Andriod as requested, but it would be completely fine to 
move it if it is better to place the check at a different location. Where do 
you suggest we should move this check to? Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63623



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


[PATCH] D63623: [clang-tidy] Add a check on expected return values of posix functions (except posix_openpt) in Android module.

2019-06-20 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv added a comment.

just a few drive-by nits/comments from me. as usual, not super familiar with 
clang-tidy, so i won't be able to stamp this.

thanks!




Comment at: clang-tools-extra/clang-tidy/android/PosixReturnCheck.cpp:23
+  binaryOperator(
+  hasOperatorName("<"),
+  hasLHS(callExpr(callee(functionDecl(matchesName("^::posix_"), 
unless(hasName("posix_openpt")),

should we also try to catch `<= ${negative_value}` (or `< ${negative_value}`)?



Comment at: clang-tools-extra/clang-tidy/android/PosixReturnCheck.cpp:29
+  binaryOperator(
+  hasOperatorName("=="),
+  hasLHS(callExpr(callee(functionDecl(matchesName("^::posix_"), 
unless(hasName("posix_openpt")),

similarly, should we complain about `!= ${negative_value}`?



Comment at: clang-tools-extra/clang-tidy/android/PosixReturnCheck.cpp:36
+
+
+void PosixReturnCheck::check(const MatchFinder::MatchResult ) {

nit: please clang-format



Comment at: clang-tools-extra/clang-tidy/android/PosixReturnCheck.cpp:39
+  const auto  = *Result.Nodes.getNodeAs("binop");
+  diag(BinOp.getOperatorLoc(), "posix functions (except posix_openpt) never 
return negative values");
+}

would it be helpful to add fixits for simple cases? e.g. we can probably offer 
to replace `posix_whatever() < 0` with `posix_whatever() > 0` or `!= 0`



Comment at: clang-tools-extra/test/clang-tidy/android-posix-return.cpp:57
+
+void WarningWithMacro () {
+  if (posix_fadvise(0, 0, 0, 0) < ZERO) {}

nit: no space in `Macro ()`, please


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63623



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


[PATCH] D63451: P0840R2: support for [[no_unique_address]] attribute

2019-06-20 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D63451#1552609 , @rsmith wrote:

> In D63451#1549563 , @rjmccall wrote:
>
> > Can this attribute not be applied to a base class, or to a type?
>
>
> The standard attribute forbids that right now. We could add a custom 
> attribute that permits it, but we're required to diagnose application of the 
> standard attribute to a type -- though a warning would suffice to satisfy 
> that requirement. (Because this gives "same as a base class" layout, adding 
> it to a base class wouldn't have any effect right now, but we could certainly 
> say that the attribute on a class type also implies the class is not POD for 
> the purpose of layout, to permit tail padding reuse.)


I think we're talking about slightly different things.

You're trying to make sure that fields can take advantage of the layout 
optimizations available to base classes so that library code doesn't need to 
contort to e.g. use the empty-base-class optimization just to avoid wasting an 
entire pointer to store an empty allocator.  This attribute seems well-targeted 
for that.

Totally separately from that — but perhaps better-related to the name of the 
attribute — I know that some projects have, in the past, had surprising 
problems with the rule that class layout can't place empty base classes at the 
same offset as other objects of the same type.  For example, IIRC WebKit used 
to have a `Noncopyable` class that deleted its copy constructor and 
copy-assignment operators, and there was an idiom to inherit from this in order 
to disable copying, and at one point they discovered that some fairly important 
class was quite a bit larger than expected because of this rule — I think they 
were also using the base class redundantly throughout the hierarchy because 
they didn't expect there to be any harm to doing so.  They would've no doubt 
appreciated the ability to just put the attribute on `Noncopyable`.  But of 
course they fixed that years ago, so I can't say that it's a serious issue for 
them now.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D63451



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


[PATCH] D63603: [ASTImporter] Propagate error from ImportDeclContext

2019-06-20 Thread Jan Korous via Phabricator via cfe-commits
jkorous added a comment.

I don't have the insight to LGTM the whole change - just a nit about 
implementation detail.




Comment at: clang/lib/AST/ASTImporter.cpp:1724
+  };
+  DefinitionCompleter CompleterRAII(To);
 

You might consider using just a lambda with `llvm::make_scope_exit`.

https://llvm.org/doxygen/namespacellvm.html#a4896534f3c6278be56967444daf38e3f

For example:
```
To->startDefinition();
auto DefinitionCompleter = llvm::make_scope_exit( 
[To](){To->completeDefinition();} );
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63603



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


[PATCH] D63623: [clang-tidy] Add a check on expected return values of posix functions (except posix_openpt) in Android module.

2019-06-20 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Why is this in android module?
Is that android-specific behavior, or posix?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63623



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


[PATCH] D63161: Devirtualize destructor of final class.

2019-06-20 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: test/CodeGenCXX/devirtualize-dtor-final.cpp:20
+  void evil(D *p) {
+// CHECK-NOT: call void@_ZN5Test11DD1Ev
+delete p;

Missing space after `void` here


Repository:
  rC Clang

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

https://reviews.llvm.org/D63161



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


[PATCH] D63161: Devirtualize destructor of final class.

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

Thanks! Minor comment then feel free to commit.




Comment at: lib/CodeGen/CGExprCXX.cpp:1877
+  DevirtualizedDtor->getParent();
+  if (getCXXRecord(Base) == DevirtualizedClass) {
+// Devirtualized to the class of the base type (the type of the

There's no guarantee that you get the same declaration of the class in both 
cases; use `declaresSameEntity` here instead of `==` to compare whether you 
have the same class.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63161



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


[PATCH] D63623: Add a check on expected return values of posix functions (except posix_openpt) in Android module.

2019-06-20 Thread Jian Cai via Phabricator via cfe-commits
jcai19 created this revision.
Herald added subscribers: cfe-commits, mgorny, srhines.
Herald added a project: clang.

Checks if any calls to posix functions (except posix_openpt) expect negative 
return values.
These functions return either 0 on success or an errno on failure, which is 
positive only.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D63623

Files:
  clang-tools-extra/clang-tidy/android/AndroidTidyModule.cpp
  clang-tools-extra/clang-tidy/android/CMakeLists.txt
  clang-tools-extra/clang-tidy/android/PosixReturnCheck.cpp
  clang-tools-extra/clang-tidy/android/PosixReturnCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/android-posix-return.rst
  clang-tools-extra/test/clang-tidy/android-posix-return.cpp

Index: clang-tools-extra/test/clang-tidy/android-posix-return.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/android-posix-return.cpp
@@ -0,0 +1,89 @@
+// RUN: %check_clang_tidy %s android-posix-return %t
+
+#define NULL nullptr
+#define ZERO 0
+#define NEGATIVE_ONE -1
+
+typedef long off_t;
+typedef int size_t;
+typedef int pid_t;
+typedef struct __posix_spawn_file_actions* posix_spawn_file_actions_t;
+typedef struct __posix_spawnattr* posix_spawnattr_t;
+
+extern "C" int posix_fadvise(int fd, off_t offset, off_t len, int advice);
+extern "C" int posix_fallocate(int fd, off_t offset, off_t len);
+extern "C" int posix_madvise(void *addr, size_t len, int advice);
+extern "C" int posix_memalign(void **memptr, size_t alignment, size_t size);
+extern "C" int posix_openpt(int flags);
+extern "C" int posix_spawn(pid_t *pid, const char *path,
+const posix_spawn_file_actions_t *file_actions,
+const posix_spawnattr_t *attrp,
+char *const argv[], char *const envp[]);
+extern "C" int posix_spawnp(pid_t *pid, const char *file,
+ const posix_spawn_file_actions_t *file_actions,
+ const posix_spawnattr_t *attrp,
+ char *const argv[], char *const envp[]);
+
+void warningLtZero() {
+  if (posix_fadvise(0, 0, 0, 0) < 0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:33: warning:
+  if (posix_fallocate(0, 0, 0) < 0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:32: warning:
+  if (posix_madvise(NULL, 0, 0) < 0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:33: warning:
+  if (posix_memalign(NULL, 0, 0) < 0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning:
+  if (posix_spawn(NULL, NULL, NULL, NULL, {NULL}, {NULL}) < 0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:59: warning:
+  if (posix_spawnp(NULL, NULL, NULL, NULL, {NULL}, {NULL}) < 0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:60: warning:
+}
+
+void warningEqualsNegative() {
+  if (posix_fadvise(0, 0, 0, 0) == -1) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:33: warning:
+  if (posix_fallocate(0, 0, 0) == -1) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:32: warning:
+  if (posix_madvise(NULL, 0, 0) == -1) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:33: warning:
+  if (posix_memalign(NULL, 0, 0) == -1) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning:
+  if (posix_spawn(NULL, NULL, NULL, NULL, {NULL}, {NULL}) == -1) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:59: warning:
+  if (posix_spawnp(NULL, NULL, NULL, NULL, {NULL}, {NULL}) == -1) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:60: warning:
+}
+
+void WarningWithMacro () {
+  if (posix_fadvise(0, 0, 0, 0) < ZERO) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:33: warning:
+  if (posix_fadvise(0, 0, 0, 0) == NEGATIVE_ONE) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:33: warning:
+}
+
+void noWarning() {
+  if (posix_openpt(0) < 0) {}
+  if (posix_openpt(0) == -1) {}
+  if (posix_fadvise(0, 0, 0, 0) >= 0) {}
+  if (posix_fadvise(0, 0, 0, 0) == 1) {}
+}
+
+namespace i {
+int posix_fadvise(int fd, off_t offset, off_t len, int advice);
+
+void noWarning() {
+  if (posix_fadvise(0, 0, 0, 0) < 0) {}
+  if (posix_fadvise(0, 0, 0, 0) == -1) {}
+}
+
+} // namespace i
+
+class G {
+ public:
+  int posix_fadvise(int fd, off_t offset, off_t len, int advice);
+
+  void noWarning() {
+if (posix_fadvise(0, 0, 0, 0) < 0) {}
+if (posix_fadvise(0, 0, 0, 0) == -1) {}
+  }
+};
Index: clang-tools-extra/docs/clang-tidy/checks/android-posix-return.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/android-posix-return.rst
@@ -0,0 +1,21 @@
+.. title:: clang-tidy - android-posix-return
+
+android-posix-return
+=
+
+Checks if any calls to posix functions (except posix_openpt) expect negative
+return values. These functions return either 0 on success or an errno on failure,
+which is positive only.
+
+Example buggy usage looks like:
+
+.. code-block:: c
+
+  if (posix_fadvise(...) < 0) {
+
+This will never happen as the return value is always non-negative. A simple fix could be
+
+.. code-block:: c
+
+  int ret = posix_fadvise(...);
+  if (ret != 0) ...
Index: 

[PATCH] D63451: P0840R2: support for [[no_unique_address]] attribute

2019-06-20 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith marked an inline comment as done.
rsmith added inline comments.



Comment at: lib/CodeGen/CGExprAgg.cpp:1850
+AggValueSlot::Overlap_t
+CodeGenFunction::overlapForFieldInit(const FieldDecl *FD) {
+  if (!FD->hasAttr() || !FD->getType()->isRecordType())

rjmccall wrote:
> rsmith wrote:
> > rsmith wrote:
> > > rjmccall wrote:
> > > > `getOverlapForFieldInit`?  `overlap` is a verb.
> > > Good idea. (Both this and `overlapForBaseInit` are pre-existing; I'll 
> > > rename both.)
> > I'm going to do this in a separate change since there are quite a few uses 
> > of these and it'll add noise to the patch.
> SGTM
Done in r363980.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D63451



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


r363980 - Rename CodeGenFunction::overlapFor* to getOverlapFor*.

2019-06-20 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Jun 20 13:56:20 2019
New Revision: 363980

URL: http://llvm.org/viewvc/llvm-project?rev=363980=rev
Log:
Rename CodeGenFunction::overlapFor* to getOverlapFor*.

Modified:
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGExprAgg.cpp
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/lib/CodeGen/CGStmt.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=363980=363979=363980=diff
==
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Thu Jun 20 13:56:20 2019
@@ -556,7 +556,7 @@ static void EmitBaseInitializer(CodeGenF
   AggValueSlot::IsDestructed,
   AggValueSlot::DoesNotNeedGCBarriers,
   AggValueSlot::IsNotAliased,
-  CGF.overlapForBaseInit(ClassDecl, BaseClassDecl, isBaseVirtual));
+  CGF.getOverlapForBaseInit(ClassDecl, BaseClassDecl, isBaseVirtual));
 
   CGF.EmitAggExpr(BaseInit->getInit(), AggSlot);
 
@@ -645,7 +645,7 @@ static void EmitMemberInitializer(CodeGe
   LValue Src = CGF.EmitLValueForFieldInitialization(ThisRHSLV, Field);
 
   // Copy the aggregate.
-  CGF.EmitAggregateCopy(LHS, Src, FieldType, 
CGF.overlapForFieldInit(Field),
+  CGF.EmitAggregateCopy(LHS, Src, FieldType, 
CGF.getOverlapForFieldInit(Field),
 LHS.isVolatileQualified());
   // Ensure that we destroy the objects if an exception is thrown later in
   // the constructor.
@@ -681,7 +681,7 @@ void CodeGenFunction::EmitInitializerFor
 AggValueSlot::IsDestructed,
 AggValueSlot::DoesNotNeedGCBarriers,
 AggValueSlot::IsNotAliased,
-overlapForFieldInit(Field),
+getOverlapForFieldInit(Field),
 AggValueSlot::IsNotZeroed,
 // Checks are made by the code that calls constructor.
 AggValueSlot::IsSanitizerChecked);

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=363980=363979=363980=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Thu Jun 20 13:56:20 2019
@@ -1894,7 +1894,7 @@ void CodeGenFunction::EmitExprAsInit(con
   if (isa(D))
 Overlap = AggValueSlot::DoesNotOverlap;
   else if (auto *FD = dyn_cast(D))
-Overlap = overlapForFieldInit(FD);
+Overlap = getOverlapForFieldInit(FD);
   // TODO: how can we delay here if D is captured by its initializer?
   EmitAggExpr(init, AggValueSlot::forLValue(lvalue,
   AggValueSlot::IsDestructed,

Modified: cfe/trunk/lib/CodeGen/CGExprAgg.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprAgg.cpp?rev=363980=363979=363980=diff
==
--- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprAgg.cpp Thu Jun 20 13:56:20 2019
@@ -1494,7 +1494,7 @@ void AggExprEmitter::VisitInitListExpr(I
   AggValueSlot::IsDestructed,
   AggValueSlot::DoesNotNeedGCBarriers,
   AggValueSlot::IsNotAliased,
-  CGF.overlapForBaseInit(CXXRD, BaseRD, Base.isVirtual()));
+  CGF.getOverlapForBaseInit(CXXRD, BaseRD, Base.isVirtual()));
   CGF.EmitAggExpr(E->getInit(curInitIndex++), AggSlot);
 
   if (QualType::DestructionKind dtorKind =
@@ -1847,7 +1847,7 @@ LValue CodeGenFunction::EmitAggExprToLVa
 }
 
 AggValueSlot::Overlap_t
-CodeGenFunction::overlapForFieldInit(const FieldDecl *FD) {
+CodeGenFunction::getOverlapForFieldInit(const FieldDecl *FD) {
   if (!FD->hasAttr() || !FD->getType()->isRecordType())
 return AggValueSlot::DoesNotOverlap;
 
@@ -1865,7 +1865,7 @@ CodeGenFunction::overlapForFieldInit(con
   return AggValueSlot::MayOverlap;
 }
 
-AggValueSlot::Overlap_t CodeGenFunction::overlapForBaseInit(
+AggValueSlot::Overlap_t CodeGenFunction::getOverlapForBaseInit(
 const CXXRecordDecl *RD, const CXXRecordDecl *BaseRD, bool IsVirtual) {
   // If the most-derived object is a field declared with [[no_unique_address]],
   // the tail padding of any virtual base could be reused for other subobjects

Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=363980=363979=363980=diff
==
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Thu Jun 20 13:56:20 2019
@@ -1157,7 +1157,7 @@ CodeGenFunction::generateObjCGetterBody(
   // that's not necessarily the same as "on the stack", so
   // we still potentially need 

[PATCH] D63579: [clang-scan-deps] print the dependencies to stdout and remove the need to use -MD options in the CDB

2019-06-20 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added inline comments.



Comment at: clang/tools/clang-scan-deps/ClangScanDeps.cpp:32
 
+class DependencyCollectorFactory {
+public:

arphaman wrote:
> aganea wrote:
> > Do you envision future uses for this factory?
> Most likely, yes.
> 
> I don't want to lock-in into creating the dependency printer in the 
> `PreprocessorOnlyTool`, as the eventual goal is to have it in a library, and 
> allow clients to consume modular dependencies not only using 
> `clang-scan-deps` tool itself, but using the C++ library directly 
> (potentially through a libclang C interface as well). The printer should be 
> in `clang-scan-deps` tool itself though, so it wouldn't be ideal to reference 
> it from `PreprocessorOnlyTool` now.
My initial question was, what are the future planned factories? (and thus the 
other `DependencyCollector` implementations?)

Do you think we could have the printer in the library as well?

On a related note - we're already testing `clang-scan-deps` compiled as a DLL. 
Our use-case right now is to call it from each of [[ 
https://github.com/fastbuild/fastbuild | Fastbuild ]]'s worker threads. We are 
using `main()` below almost as-is (except for the multithreading part which 
Fastbuild already does). The CDB JSON is passed by value from the Fastbuild 
thread, so it doesn't go through a file. I'd like to get back 
dependencies-as-a-string instead of `llvm::outs()`. The bottleneck currently 
is, as you can imagine, reading / writing files (seen in ETW traces), this 
patch should improve things a bit. I can send a sample of how we're using it 
after you commit.


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

https://reviews.llvm.org/D63579



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


[PATCH] D63451: P0840R2: support for [[no_unique_address]] attribute

2019-06-20 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL363976: P0840R2: support for [[no_unique_address]] attribute 
(authored by rsmith, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D63451

Files:
  cfe/trunk/include/clang/AST/Decl.h
  cfe/trunk/include/clang/AST/DeclCXX.h
  cfe/trunk/include/clang/Basic/Attr.td
  cfe/trunk/include/clang/Basic/AttrDocs.td
  cfe/trunk/lib/AST/Decl.cpp
  cfe/trunk/lib/AST/DeclCXX.cpp
  cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/lib/CodeGen/CGExprAgg.cpp
  cfe/trunk/lib/CodeGen/CGExprConstant.cpp
  cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
  cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/lib/Parse/ParseDeclCXX.cpp
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/test/CodeGenCXX/no-unique-address.cpp
  cfe/trunk/test/CodeGenCXX/tail-padding.cpp
  cfe/trunk/test/Layout/no-unique-address.cpp
  cfe/trunk/test/SemaCXX/cxx2a-no-unique-address.cpp
  cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
  cfe/trunk/www/cxx_status.html

Index: cfe/trunk/www/cxx_status.html
===
--- cfe/trunk/www/cxx_status.html
+++ cfe/trunk/www/cxx_status.html
@@ -934,7 +934,7 @@
 
   [[no_unique_address]] attribute
   http://wg21.link/p0840r2;>P0840R2
-  No
+  SVN
 
 
   [[likely]] and [[unlikely]] attributes
Index: cfe/trunk/include/clang/AST/DeclCXX.h
===
--- cfe/trunk/include/clang/AST/DeclCXX.h
+++ cfe/trunk/include/clang/AST/DeclCXX.h
@@ -334,10 +334,12 @@
 /// True when this class is a POD-type.
 unsigned PlainOldData : 1;
 
-/// true when this class is empty for traits purposes,
-/// i.e. has no data members other than 0-width bit-fields, has no
-/// virtual function/base, and doesn't inherit from a non-empty
-/// class. Doesn't take union-ness into account.
+/// True when this class is empty for traits purposes, that is:
+///  * has no data members other than 0-width bit-fields and empty fields
+///marked [[no_unique_address]]
+///  * has no virtual function/base, and
+///  * doesn't inherit from a non-empty class.
+/// Doesn't take union-ness into account.
 unsigned Empty : 1;
 
 /// True when this class is polymorphic, i.e., has at
Index: cfe/trunk/include/clang/AST/Decl.h
===
--- cfe/trunk/include/clang/AST/Decl.h
+++ cfe/trunk/include/clang/AST/Decl.h
@@ -2729,6 +2729,11 @@
   /// bit-fields.
   bool isZeroLengthBitField(const ASTContext ) const;
 
+  /// Determine if this field is a subobject of zero size, that is, either a
+  /// zero-length bit-field or a field of empty class type with the
+  /// [[no_unique_address]] attribute.
+  bool isZeroSize(const ASTContext ) const;
+
   /// Get the kind of (C++11) default member initializer that this field has.
   InClassInitStyle getInClassInitStyle() const {
 InitStorageKind storageKind = InitStorage.getInt();
Index: cfe/trunk/include/clang/Basic/Attr.td
===
--- cfe/trunk/include/clang/Basic/Attr.td
+++ cfe/trunk/include/clang/Basic/Attr.td
@@ -14,6 +14,7 @@
 }
 def DocCatFunction : DocumentationCategory<"Function Attributes">;
 def DocCatVariable : DocumentationCategory<"Variable Attributes">;
+def DocCatField : DocumentationCategory<"Field Attributes">;
 def DocCatType : DocumentationCategory<"Type Attributes">;
 def DocCatStmt : DocumentationCategory<"Statement Attributes">;
 def DocCatDecl : DocumentationCategory<"Declaration Attributes">;
@@ -315,12 +316,14 @@
   // Specifies Operating Systems for which the target applies, based off the
   // OSType enumeration in Triple.h
   list OSes;
-  // Specifies the C++ ABIs for which the target applies, based off the
-  // TargetCXXABI::Kind in TargetCXXABI.h.
-  list CXXABIs;
   // Specifies Object Formats for which the target applies, based off the
   // ObjectFormatType enumeration in Triple.h
   list ObjectFormats;
+  // A custom predicate, written as an expression evaluated in a context
+  // with the following declarations in scope:
+  //   const clang::TargetInfo 
+  //   const llvm::Triple  = Target.getTriple();
+  code CustomCode = [{}];
 }
 
 class TargetArch arches> : TargetSpec {
@@ -338,8 +341,11 @@
 def TargetWindows : TargetArch<["x86", "x86_64", "arm", "thumb", "aarch64"]> {
   let OSes = ["Win32"];
 }
+def TargetItaniumCXXABI : TargetSpec {
+  let CustomCode = [{ Target.getCXXABI().isItaniumFamily() }];
+}
 def TargetMicrosoftCXXABI : TargetArch<["x86", "x86_64", "arm", "thumb", "aarch64"]> {
-  let CXXABIs = ["Microsoft"];
+  let CustomCode = [{ 

[PATCH] D63617: [COFF, ARM64] Fix encoding of __debugbreak

2019-06-20 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Even if `BRK #0xF000` is a Windows convention, it's still possible for ISel to 
select different instructions for different OSs, and I'd prefer to implement it 
that way.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63617



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


r363976 - P0840R2: support for [[no_unique_address]] attribute

2019-06-20 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Jun 20 13:44:45 2019
New Revision: 363976

URL: http://llvm.org/viewvc/llvm-project?rev=363976=rev
Log:
P0840R2: support for [[no_unique_address]] attribute

Summary:
Add support for the C++2a [[no_unique_address]] attribute for targets using the 
Itanium C++ ABI.

This depends on D63371.

Reviewers: rjmccall, aaron.ballman

Subscribers: dschuff, aheejin, cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/CodeGenCXX/no-unique-address.cpp
cfe/trunk/test/Layout/no-unique-address.cpp
cfe/trunk/test/SemaCXX/cxx2a-no-unique-address.cpp
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprAgg.cpp
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/CodeGenCXX/tail-padding.cpp
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=363976=363975=363976=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Thu Jun 20 13:44:45 2019
@@ -2729,6 +2729,11 @@ public:
   /// bit-fields.
   bool isZeroLengthBitField(const ASTContext ) const;
 
+  /// Determine if this field is a subobject of zero size, that is, either a
+  /// zero-length bit-field or a field of empty class type with the
+  /// [[no_unique_address]] attribute.
+  bool isZeroSize(const ASTContext ) const;
+
   /// Get the kind of (C++11) default member initializer that this field has.
   InClassInitStyle getInClassInitStyle() const {
 InitStorageKind storageKind = InitStorage.getInt();

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=363976=363975=363976=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Thu Jun 20 13:44:45 2019
@@ -334,10 +334,12 @@ class CXXRecordDecl : public RecordDecl
 /// True when this class is a POD-type.
 unsigned PlainOldData : 1;
 
-/// true when this class is empty for traits purposes,
-/// i.e. has no data members other than 0-width bit-fields, has no
-/// virtual function/base, and doesn't inherit from a non-empty
-/// class. Doesn't take union-ness into account.
+/// True when this class is empty for traits purposes, that is:
+///  * has no data members other than 0-width bit-fields and empty fields
+///marked [[no_unique_address]]
+///  * has no virtual function/base, and
+///  * doesn't inherit from a non-empty class.
+/// Doesn't take union-ness into account.
 unsigned Empty : 1;
 
 /// True when this class is polymorphic, i.e., has at

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=363976=363975=363976=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Thu Jun 20 13:44:45 2019
@@ -14,6 +14,7 @@ class DocumentationCategory
 }
 def DocCatFunction : DocumentationCategory<"Function Attributes">;
 def DocCatVariable : DocumentationCategory<"Variable Attributes">;
+def DocCatField : DocumentationCategory<"Field Attributes">;
 def DocCatType : DocumentationCategory<"Type Attributes">;
 def DocCatStmt : DocumentationCategory<"Statement Attributes">;
 def DocCatDecl : DocumentationCategory<"Declaration Attributes">;
@@ -315,12 +316,14 @@ class TargetSpec {
   // Specifies Operating Systems for which the target applies, based off the
   // OSType enumeration in Triple.h
   list OSes;
-  // Specifies the C++ ABIs for which the target applies, based off the
-  // TargetCXXABI::Kind in TargetCXXABI.h.
-  list CXXABIs;
   // Specifies Object Formats for which the target applies, based off the
   // ObjectFormatType enumeration in Triple.h
   list ObjectFormats;
+  // A custom predicate, written as an expression evaluated in a context
+  // with the following declarations in scope:
+  //   const clang::TargetInfo 
+  //   const llvm::Triple  = Target.getTriple();
+  code CustomCode = [{}];
 }
 
 class TargetArch arches> : TargetSpec {
@@ -338,8 +341,11 @@ def 

[PATCH] D63451: P0840R2: support for [[no_unique_address]] attribute

2019-06-20 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added inline comments.



Comment at: include/clang/Basic/Attr.td:326
+  //   const llvm::Triple  = Target.getTriple();
+  code CustomCode = [{}];
 }

Thanks!



Comment at: lib/CodeGen/CGExprAgg.cpp:1850
+AggValueSlot::Overlap_t
+CodeGenFunction::overlapForFieldInit(const FieldDecl *FD) {
+  if (!FD->hasAttr() || !FD->getType()->isRecordType())

rsmith wrote:
> rsmith wrote:
> > rjmccall wrote:
> > > `getOverlapForFieldInit`?  `overlap` is a verb.
> > Good idea. (Both this and `overlapForBaseInit` are pre-existing; I'll 
> > rename both.)
> I'm going to do this in a separate change since there are quite a few uses of 
> these and it'll add noise to the patch.
SGTM


Repository:
  rC Clang

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

https://reviews.llvm.org/D63451



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


[PATCH] D63451: P0840R2: support for [[no_unique_address]] attribute

2019-06-20 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D63451#1549563 , @rjmccall wrote:

> Can this attribute not be applied to a base class, or to a type?


The standard attribute forbids that right now. We could add a custom attribute 
that permits it, but we're required to diagnose application of the standard 
attribute to a type -- though a warning would suffice to satisfy that 
requirement. (Because this gives "same as a base class" layout, adding it to a 
base class wouldn't have any effect right now, but we could certainly say that 
the attribute on a class type also implies the class is not POD for the purpose 
of layout, to permit tail padding reuse.)

> I think every time I've seen someone get bitten by the unique-address rule, 
> it was because they had a base class that deleted some constructors (or 
> something like that) and which was a base of a million different types; I'm 
> sure the language model they'd prefer would be to just add an attribute to 
> that one type instead of chasing down every place where they declared a field 
> of the type.

The place where we expect this to be used is where a class template wants to 
store a copy of some user-provided type that may well be empty (eg, an 
allocator, a comparator, that kind of thing). There are probably more producers 
of such types than consumers, so putting the attribute on the consumer seems to 
make some sense (though it really could go in either place, and both probably 
have reasonable use cases).

I'd be happy to go back to the committee with a proposal to extend this 
attribute to also apply to classes if you can provide a few convincing examples.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63451



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


[PATCH] D63617: [COFF, ARM64] Fix encoding of __debugbreak

2019-06-20 Thread Tom Tan via Phabricator via cfe-commits
TomTan added a comment.

In D63617#1552561 , @rnk wrote:

> I think it would be preferable to make `llvm.debugtrap` emit `brk #0xF000` on 
> aarch64-windows-*, so other frontends (Rust etc) get the right behavior by 
> default. Right now, AArch64 doesn't do anything special for DEBUGTRAP, so we 
> get the default behavior of `llvm.trap`.
>
> Is this `BRK #0xF000` convention universal to all OSs, or is it a specific 
> convention for Windows debuggers?


I looked at `llvm.debugtrap` but I am not sure the side-effect of that fix, 
like could there be some other ABI (mingw, etc.) on Windows ARM64 which expects 
DEBUGTRAP to be the same as `Android/Linux`.

I think this `BRK #0xF000` convention is only for Windows debugger and 
exception handler, such as we define `__fastfail` in the same way with 
different operand, not universal for all OSs.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63617



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


[PATCH] D63451: P0840R2: support for [[no_unique_address]] attribute

2019-06-20 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith updated this revision to Diff 205892.
rsmith marked 4 inline comments as done.
rsmith added a comment.

- Use custom code to specify CXXABI requirements on attributes.
- Remove dead code that would have handled [[no_unique_address]] in C.
- Extend documentation to include an example and to mention that this is a 
standard C++ attribute.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63451

Files:
  include/clang/AST/Decl.h
  include/clang/AST/DeclCXX.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  lib/AST/Decl.cpp
  lib/AST/DeclCXX.cpp
  lib/AST/RecordLayoutBuilder.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGRecordLayoutBuilder.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Parse/ParseDeclCXX.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGenCXX/no-unique-address.cpp
  test/CodeGenCXX/tail-padding.cpp
  test/Layout/no-unique-address.cpp
  test/SemaCXX/cxx2a-no-unique-address.cpp
  utils/TableGen/ClangAttrEmitter.cpp
  www/cxx_status.html

Index: www/cxx_status.html
===
--- www/cxx_status.html
+++ www/cxx_status.html
@@ -934,7 +934,7 @@
 
   [[no_unique_address]] attribute
   http://wg21.link/p0840r2;>P0840R2
-  No
+  SVN
 
 
   [[likely]] and [[unlikely]] attributes
Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -2810,7 +2810,7 @@
 
 // Helper function for GenerateTargetSpecificAttrChecks that alters the 'Test'
 // parameter with only a single check type, if applicable.
-static void GenerateTargetSpecificAttrCheck(const Record *R, std::string ,
+static bool GenerateTargetSpecificAttrCheck(const Record *R, std::string ,
 std::string *FnName,
 StringRef ListName,
 StringRef CheckAgainst,
@@ -2830,7 +2830,9 @@
 *FnName += Part;
 }
 Test += ")";
+return true;
   }
+  return false;
 }
 
 // Generate a conditional expression to check if the current target satisfies
@@ -2838,10 +2840,12 @@
 // those checks to the Test string. If the FnName string pointer is non-null,
 // append a unique suffix to distinguish this set of target checks from other
 // TargetSpecificAttr records.
-static void GenerateTargetSpecificAttrChecks(const Record *R,
+static bool GenerateTargetSpecificAttrChecks(const Record *R,
  std::vector ,
  std::string ,
  std::string *FnName) {
+  bool AnyTargetChecks = false;
+
   // It is assumed that there will be an llvm::Triple object
   // named "T" and a TargetInfo object named "Target" within
   // scope that can be used to determine whether the attribute exists in
@@ -2851,6 +2855,7 @@
   // differently because GenerateTargetRequirements needs to combine the list
   // with ParseKind.
   if (!Arches.empty()) {
+AnyTargetChecks = true;
 Test += " && (";
 for (auto I = Arches.begin(), E = Arches.end(); I != E; ++I) {
   StringRef Part = *I;
@@ -2865,16 +2870,24 @@
   }
 
   // If the attribute is specific to particular OSes, check those.
-  GenerateTargetSpecificAttrCheck(R, Test, FnName, "OSes", "T.getOS()",
-  "llvm::Triple::");
+  AnyTargetChecks |= GenerateTargetSpecificAttrCheck(
+  R, Test, FnName, "OSes", "T.getOS()", "llvm::Triple::");
 
-  // If one or more CXX ABIs are specified, check those as well.
-  GenerateTargetSpecificAttrCheck(R, Test, FnName, "CXXABIs",
-  "Target.getCXXABI().getKind()",
-  "TargetCXXABI::");
   // If one or more object formats is specified, check those.
-  GenerateTargetSpecificAttrCheck(R, Test, FnName, "ObjectFormats",
-  "T.getObjectFormat()", "llvm::Triple::");
+  AnyTargetChecks |=
+  GenerateTargetSpecificAttrCheck(R, Test, FnName, "ObjectFormats",
+  "T.getObjectFormat()", "llvm::Triple::");
+
+  // If custom code is specified, emit it.
+  StringRef Code = R->getValueAsString("CustomCode");
+  if (!Code.empty()) {
+AnyTargetChecks = true;
+Test += " && (";
+Test += Code;
+Test += ")";
+  }
+
+  return AnyTargetChecks;
 }
 
 static void GenerateHasAttrSpellingStringSwitch(
@@ -3510,7 +3523,7 @@
 
   std::string FnName = "isTarget";
   std::string Test;
-  GenerateTargetSpecificAttrChecks(R, Arches, Test, );
+  bool UsesT = GenerateTargetSpecificAttrChecks(R, Arches, Test, );
 
   // If this code has already been generated, simply return the previous
   

[PATCH] D63451: P0840R2: support for [[no_unique_address]] attribute

2019-06-20 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/CodeGen/CGExprAgg.cpp:1850
+AggValueSlot::Overlap_t
+CodeGenFunction::overlapForFieldInit(const FieldDecl *FD) {
+  if (!FD->hasAttr() || !FD->getType()->isRecordType())

rsmith wrote:
> rjmccall wrote:
> > `getOverlapForFieldInit`?  `overlap` is a verb.
> Good idea. (Both this and `overlapForBaseInit` are pre-existing; I'll rename 
> both.)
I'm going to do this in a separate change since there are quite a few uses of 
these and it'll add noise to the patch.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63451



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


[PATCH] D63613: [clang-tidy] Fail gracefully upon empty database fields

2019-06-20 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

Thanks @jkorous for the fast review o/


Repository:
  rL LLVM

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

https://reviews.llvm.org/D63613



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


[PATCH] D63613: [clang-tidy] Fail gracefully upon empty database fields

2019-06-20 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL363975: [clang-tidy] Fail gracefully upon empty database 
fields (authored by serge_sans_paille, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D63613?vs=205854=205890#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D63613

Files:
  cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp
  cfe/trunk/lib/Tooling/Tooling.cpp
  clang-tools-extra/trunk/test/clang-tidy/empty-database.cpp
  clang-tools-extra/trunk/test/clang-tidy/empty-database/compile_commands.json


Index: cfe/trunk/lib/Tooling/Tooling.cpp
===
--- cfe/trunk/lib/Tooling/Tooling.cpp
+++ cfe/trunk/lib/Tooling/Tooling.cpp
@@ -481,7 +481,7 @@
   if (OverlayFileSystem->setCurrentWorkingDirectory(
   CompileCommand.Directory))
 llvm::report_fatal_error("Cannot chdir into \"" +
- Twine(CompileCommand.Directory) + "\n!");
+ Twine(CompileCommand.Directory) + "\"!");
 
   // Now fill the in-memory VFS with the relative file mappings so it will
   // have the correct relative paths. We never remove mappings but that
Index: cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp
===
--- cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp
+++ cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp
@@ -150,7 +150,8 @@
 // spelling of each argument; re-rendering is lossy for aliased flags.
 // E.g. in CL mode, /W4 maps to -Wall.
 auto OptTable = clang::driver::createDriverOptTable();
-Cmd.CommandLine.emplace_back(OldArgs.front());
+if (!OldArgs.empty())
+  Cmd.CommandLine.emplace_back(OldArgs.front());
 for (unsigned Pos = 1; Pos < OldArgs.size();) {
   using namespace driver::options;
 
@@ -243,7 +244,8 @@
 }
 
 // Otherwise just check the clang executable file name.
-return llvm::sys::path::stem(CmdLine.front()).endswith_lower("cl");
+return !CmdLine.empty() &&
+   llvm::sys::path::stem(CmdLine.front()).endswith_lower("cl");
   }
 
   // Map the language from the --std flag to that of the -x flag.
Index: 
clang-tools-extra/trunk/test/clang-tidy/empty-database/compile_commands.json
===
--- clang-tools-extra/trunk/test/clang-tidy/empty-database/compile_commands.json
+++ clang-tools-extra/trunk/test/clang-tidy/empty-database/compile_commands.json
@@ -0,0 +1,4 @@
+[{
+"directory":"",
+"file":"/tmp/","arguments":[]
+}]
Index: clang-tools-extra/trunk/test/clang-tidy/empty-database.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/empty-database.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/empty-database.cpp
@@ -0,0 +1,3 @@
+// RUN: not clang-tidy -p %S/empty-database %s 2>&1 | FileCheck %s
+
+// CHECK: LLVM ERROR: Cannot chdir into ""!


Index: cfe/trunk/lib/Tooling/Tooling.cpp
===
--- cfe/trunk/lib/Tooling/Tooling.cpp
+++ cfe/trunk/lib/Tooling/Tooling.cpp
@@ -481,7 +481,7 @@
   if (OverlayFileSystem->setCurrentWorkingDirectory(
   CompileCommand.Directory))
 llvm::report_fatal_error("Cannot chdir into \"" +
- Twine(CompileCommand.Directory) + "\n!");
+ Twine(CompileCommand.Directory) + "\"!");
 
   // Now fill the in-memory VFS with the relative file mappings so it will
   // have the correct relative paths. We never remove mappings but that
Index: cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp
===
--- cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp
+++ cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp
@@ -150,7 +150,8 @@
 // spelling of each argument; re-rendering is lossy for aliased flags.
 // E.g. in CL mode, /W4 maps to -Wall.
 auto OptTable = clang::driver::createDriverOptTable();
-Cmd.CommandLine.emplace_back(OldArgs.front());
+if (!OldArgs.empty())
+  Cmd.CommandLine.emplace_back(OldArgs.front());
 for (unsigned Pos = 1; Pos < OldArgs.size();) {
   using namespace driver::options;
 
@@ -243,7 +244,8 @@
 }
 
 // Otherwise just check the clang executable file name.
-return llvm::sys::path::stem(CmdLine.front()).endswith_lower("cl");
+return !CmdLine.empty() &&
+   llvm::sys::path::stem(CmdLine.front()).endswith_lower("cl");
   }
 
   // Map the language from the --std flag to that of the -x flag.
Index: 

[clang-tools-extra] r363975 - [clang-tidy] Fail gracefully upon empty database fields

2019-06-20 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Thu Jun 20 13:25:59 2019
New Revision: 363975

URL: http://llvm.org/viewvc/llvm-project?rev=363975=rev
Log:
[clang-tidy] Fail gracefully upon empty database fields

Fix bz#42281

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

Added:
clang-tools-extra/trunk/test/clang-tidy/empty-database/
clang-tools-extra/trunk/test/clang-tidy/empty-database.cpp
clang-tools-extra/trunk/test/clang-tidy/empty-database/compile_commands.json

Added: clang-tools-extra/trunk/test/clang-tidy/empty-database.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/empty-database.cpp?rev=363975=auto
==
--- clang-tools-extra/trunk/test/clang-tidy/empty-database.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/empty-database.cpp Thu Jun 20 
13:25:59 2019
@@ -0,0 +1,3 @@
+// RUN: not clang-tidy -p %S/empty-database %s 2>&1 | FileCheck %s
+
+// CHECK: LLVM ERROR: Cannot chdir into ""!

Added: 
clang-tools-extra/trunk/test/clang-tidy/empty-database/compile_commands.json
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/empty-database/compile_commands.json?rev=363975=auto
==
--- 
clang-tools-extra/trunk/test/clang-tidy/empty-database/compile_commands.json 
(added)
+++ 
clang-tools-extra/trunk/test/clang-tidy/empty-database/compile_commands.json 
Thu Jun 20 13:25:59 2019
@@ -0,0 +1,4 @@
+[{
+"directory":"",
+"file":"/tmp/","arguments":[]
+}]


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


r363975 - [clang-tidy] Fail gracefully upon empty database fields

2019-06-20 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Thu Jun 20 13:25:59 2019
New Revision: 363975

URL: http://llvm.org/viewvc/llvm-project?rev=363975=rev
Log:
[clang-tidy] Fail gracefully upon empty database fields

Fix bz#42281

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

Modified:
cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp
cfe/trunk/lib/Tooling/Tooling.cpp

Modified: cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp?rev=363975=363974=363975=diff
==
--- cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp (original)
+++ cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp Thu Jun 20 
13:25:59 2019
@@ -150,7 +150,8 @@ struct TransferableCommand {
 // spelling of each argument; re-rendering is lossy for aliased flags.
 // E.g. in CL mode, /W4 maps to -Wall.
 auto OptTable = clang::driver::createDriverOptTable();
-Cmd.CommandLine.emplace_back(OldArgs.front());
+if (!OldArgs.empty())
+  Cmd.CommandLine.emplace_back(OldArgs.front());
 for (unsigned Pos = 1; Pos < OldArgs.size();) {
   using namespace driver::options;
 
@@ -243,7 +244,8 @@ private:
 }
 
 // Otherwise just check the clang executable file name.
-return llvm::sys::path::stem(CmdLine.front()).endswith_lower("cl");
+return !CmdLine.empty() &&
+   llvm::sys::path::stem(CmdLine.front()).endswith_lower("cl");
   }
 
   // Map the language from the --std flag to that of the -x flag.

Modified: cfe/trunk/lib/Tooling/Tooling.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Tooling.cpp?rev=363975=363974=363975=diff
==
--- cfe/trunk/lib/Tooling/Tooling.cpp (original)
+++ cfe/trunk/lib/Tooling/Tooling.cpp Thu Jun 20 13:25:59 2019
@@ -481,7 +481,7 @@ int ClangTool::run(ToolAction *Action) {
   if (OverlayFileSystem->setCurrentWorkingDirectory(
   CompileCommand.Directory))
 llvm::report_fatal_error("Cannot chdir into \"" +
- Twine(CompileCommand.Directory) + "\n!");
+ Twine(CompileCommand.Directory) + "\"!");
 
   // Now fill the in-memory VFS with the relative file mappings so it will
   // have the correct relative paths. We never remove mappings but that


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


[PATCH] D63617: [COFF, ARM64] Fix encoding of __debugbreak

2019-06-20 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I think it would be preferable to make `llvm.debugtrap` emit `brk #0xF000` on 
aarch64-windows-*, so other frontends (Rust etc) get the right behavior by 
default. Right now, AArch64 doesn't do anything special for DEBUGTRAP, so we 
get the default behavior of `llvm.trap`.

Is this `BRK #0xF000` convention universal to all OSs, or is it a specific 
convention for Windows debuggers?


Repository:
  rC Clang

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

https://reviews.llvm.org/D63617



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


[PATCH] D63579: [clang-scan-deps] print the dependencies to stdout and remove the need to use -MD options in the CDB

2019-06-20 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: clang/tools/clang-scan-deps/ClangScanDeps.cpp:32
 
+class DependencyCollectorFactory {
+public:

aganea wrote:
> Do you envision future uses for this factory?
Most likely, yes.

I don't want to lock-in into creating the dependency printer in the 
`PreprocessorOnlyTool`, as the eventual goal is to have it in a library, and 
allow clients to consume modular dependencies not only using `clang-scan-deps` 
tool itself, but using the C++ library directly (potentially through a libclang 
C interface as well). The printer should be in `clang-scan-deps` tool itself 
though, so it wouldn't be ideal to reference it from `PreprocessorOnlyTool` now.



Comment at: clang/tools/clang-scan-deps/ClangScanDeps.cpp:50
+std::unique_ptr Opts) override {
+  std::unique_lock LockGuard(SharedLock);
+  return std::make_shared(std::move(Opts), SharedLock,

aganea wrote:
> Do you need the blocking behavior here? You're simply passing the Lock by 
> reference, but not using the stream that it protects.
Right, I don't need it here. removed in the updated patch.


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

https://reviews.llvm.org/D63579



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


[PATCH] D63579: [clang-scan-deps] print the dependencies to stdout and remove the need to use -MD options in the CDB

2019-06-20 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 205886.
arphaman marked 3 inline comments as done.
arphaman added a comment.

removed the lock


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

https://reviews.llvm.org/D63579

Files:
  clang/include/clang/Frontend/Utils.h
  clang/lib/Frontend/DependencyFile.cpp
  clang/test/ClangScanDeps/Inputs/regular_cdb.json
  clang/test/ClangScanDeps/regular_cdb.cpp
  clang/tools/clang-scan-deps/ClangScanDeps.cpp

Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -29,12 +29,58 @@
 
 namespace {
 
+class DependencyCollectorFactory {
+public:
+  virtual ~DependencyCollectorFactory() {}
+
+  virtual std::shared_ptr createDependencyCollector(
+  const std::unique_ptr Opts) = 0;
+};
+
+/// Prints out all of the gathered dependencies into one output stream instead
+/// of using the output dependency file.
+class DependencyPrinter : public DependencyFileGenerator {
+public:
+  class Factory : public DependencyCollectorFactory {
+  public:
+Factory(raw_ostream ) : OS(OS) {}
+
+std::shared_ptr createDependencyCollector(
+std::unique_ptr Opts) override {
+  return std::make_shared(std::move(Opts), SharedLock,
+ OS);
+}
+
+  private:
+std::mutex SharedLock;
+raw_ostream 
+  };
+
+  DependencyPrinter(std::unique_ptr Opts,
+std::mutex , raw_ostream )
+  : DependencyFileGenerator(*Opts), Opts(std::move(Opts)), Lock(Lock),
+OS(OS) {}
+
+  void finishedMainFile(DiagnosticsEngine ) override {
+std::unique_lock LockGuard(Lock);
+outputDependencyFile(OS);
+OS.flush();
+  }
+
+private:
+  std::unique_ptr Opts;
+  std::mutex 
+  raw_ostream 
+};
+
 /// A clang tool that runs the preprocessor only for the given compiler
 /// invocation.
 class PreprocessorOnlyTool : public tooling::ToolAction {
 public:
-  PreprocessorOnlyTool(StringRef WorkingDirectory)
-  : WorkingDirectory(WorkingDirectory) {}
+  PreprocessorOnlyTool(StringRef WorkingDirectory,
+   DependencyCollectorFactory )
+  : WorkingDirectory(WorkingDirectory),
+DepCollectorFactory(DepCollectorFactory) {}
 
   bool runInvocation(std::shared_ptr Invocation,
  FileManager *FileMgr,
@@ -53,6 +99,21 @@
 
 Compiler.createSourceManager(*FileMgr);
 
+// Create the dependency collector that will collect the produced
+// dependencies.
+//
+// This also moves the existing dependency output options from the
+// invocation to the collector. The options in the invocation are reset,
+// which ensures that the compiler won't create new dependency collectors,
+// and thus won't write out the extra '.d' files to disk.
+auto Opts = llvm::make_unique(
+std::move(Compiler.getInvocation().getDependencyOutputOpts()));
+// We need at least one -MT equivalent for the generator to work.
+if (Opts->Targets.empty())
+  Opts->Targets = {"clang-scan-deps dependency"};
+Compiler.addDependencyCollector(
+DepCollectorFactory.createDependencyCollector(std::move(Opts)));
+
 auto Action = llvm::make_unique();
 const bool Result = Compiler.ExecuteAction(*Action);
 FileMgr->clearStatCache();
@@ -61,6 +122,7 @@
 
 private:
   StringRef WorkingDirectory;
+  DependencyCollectorFactory 
 };
 
 /// A proxy file system that doesn't call `chdir` when changing the working
@@ -93,8 +155,9 @@
   ///
   /// \param Compilations The reference to the compilation database that's
   /// used by the clang tool.
-  DependencyScanningTool(const tooling::CompilationDatabase )
-  : Compilations(Compilations) {
+  DependencyScanningTool(const tooling::CompilationDatabase ,
+ DependencyCollectorFactory )
+  : Compilations(Compilations), DepCollectorFactory(DepCollectorFactory) {
 PCHContainerOps = std::make_shared();
 BaseFS = new ProxyFileSystemWithoutChdir(llvm::vfs::getRealFileSystem());
   }
@@ -107,12 +170,13 @@
 tooling::ClangTool Tool(Compilations, Input, PCHContainerOps, BaseFS);
 Tool.clearArgumentsAdjusters();
 Tool.setRestoreWorkingDir(false);
-PreprocessorOnlyTool Action(CWD);
+PreprocessorOnlyTool Action(CWD, DepCollectorFactory);
 return Tool.run();
   }
 
 private:
   const tooling::CompilationDatabase 
+  DependencyCollectorFactory 
   std::shared_ptr PCHContainerOps;
   /// The real filesystem used as a base for all the operations performed by the
   /// tool.
@@ -176,12 +240,14 @@
 return AdjustedArgs;
   });
 
+  // Print out the dependency results to STDOUT by default.
+  DependencyPrinter::Factory DepPrintFactory(llvm::outs());
   unsigned NumWorkers =
   NumThreads == 0 ? llvm::hardware_concurrency() : NumThreads;
   std::vector> WorkerTools;
   

r363973 - Fix passing structs and AVX vectors through sysv_abi

2019-06-20 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu Jun 20 13:07:20 2019
New Revision: 363973

URL: http://llvm.org/viewvc/llvm-project?rev=363973=rev
Log:
Fix passing structs and AVX vectors through sysv_abi

Do this the same way we did it for ms_abi in r324594.

Fixes PR36806.

Added:
cfe/trunk/test/CodeGen/sysv_abi.c
Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=363973=363972=363973=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Thu Jun 20 13:07:20 2019
@@ -,8 +,8 @@ public:
 /// WinX86_64ABIInfo - The Windows X86_64 ABI information.
 class WinX86_64ABIInfo : public SwiftABIInfo {
 public:
-  WinX86_64ABIInfo(CodeGen::CodeGenTypes )
-  : SwiftABIInfo(CGT),
+  WinX86_64ABIInfo(CodeGen::CodeGenTypes , X86AVXABILevel AVXLevel)
+  : SwiftABIInfo(CGT), AVXLevel(AVXLevel),
 IsMingw64(getTarget().getTriple().isWindowsGNUEnvironment()) {}
 
   void computeInfo(CGFunctionInfo ) const override;
@@ -2259,7 +2259,9 @@ private:
   void computeVectorCallArgs(CGFunctionInfo , unsigned FreeSSERegs,
  bool IsVectorCall, bool IsRegCall) const;
 
-bool IsMingw64;
+  X86AVXABILevel AVXLevel;
+
+  bool IsMingw64;
 };
 
 class X86_64TargetCodeGenInfo : public TargetCodeGenInfo {
@@ -2409,7 +2411,7 @@ class WinX86_64TargetCodeGenInfo : publi
 public:
   WinX86_64TargetCodeGenInfo(CodeGen::CodeGenTypes ,
  X86AVXABILevel AVXLevel)
-  : TargetCodeGenInfo(new WinX86_64ABIInfo(CGT)) {}
+  : TargetCodeGenInfo(new WinX86_64ABIInfo(CGT, AVXLevel)) {}
 
   void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
CodeGen::CodeGenModule ) const override;
@@ -3562,7 +3564,7 @@ void X86_64ABIInfo::computeInfo(CGFuncti
   // using __attribute__((ms_abi)). In such case to correctly emit Win64
   // compatible code delegate this call to WinX86_64ABIInfo::computeInfo.
   if (CallingConv == llvm::CallingConv::Win64) {
-WinX86_64ABIInfo Win64ABIInfo(CGT);
+WinX86_64ABIInfo Win64ABIInfo(CGT, AVXLevel);
 Win64ABIInfo.computeInfo(FI);
 return;
   }
@@ -4016,9 +4018,17 @@ void WinX86_64ABIInfo::computeVectorCall
 }
 
 void WinX86_64ABIInfo::computeInfo(CGFunctionInfo ) const {
-  bool IsVectorCall =
-  FI.getCallingConvention() == llvm::CallingConv::X86_VectorCall;
-  bool IsRegCall = FI.getCallingConvention() == llvm::CallingConv::X86_RegCall;
+  const unsigned CC = FI.getCallingConvention();
+  bool IsVectorCall = CC == llvm::CallingConv::X86_VectorCall;
+  bool IsRegCall = CC == llvm::CallingConv::X86_RegCall;
+
+  // If __attribute__((sysv_abi)) is in use, use the SysV argument
+  // classification rules.
+  if (CC == llvm::CallingConv::X86_64_SysV) {
+X86_64ABIInfo SysVABIInfo(CGT, AVXLevel);
+SysVABIInfo.computeInfo(FI);
+return;
+  }
 
   unsigned FreeSSERegs = 0;
   if (IsVectorCall) {

Added: cfe/trunk/test/CodeGen/sysv_abi.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sysv_abi.c?rev=363973=auto
==
--- cfe/trunk/test/CodeGen/sysv_abi.c (added)
+++ cfe/trunk/test/CodeGen/sysv_abi.c Thu Jun 20 13:07:20 2019
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -triple x86_64-pc-win32 -emit-llvm  -target-cpu 
skylake-avx512 < %s | FileCheck %s --check-prefixes=CHECK,AVX
+// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm  -target-cpu skylake-avx512 
< %s | FileCheck %s --check-prefixes=CHECK,AVX
+// RUN: %clang_cc1 -triple x86_64-pc-win32 -emit-llvm < %s | FileCheck %s 
--check-prefixes=CHECK,NOAVX
+// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm < %s | FileCheck %s 
--check-prefixes=CHECK,NOAVX
+
+#define SYSV_CC __attribute__((sysv_abi))
+
+// Make sure we coerce structs according to the SysV rules instead of passing
+// them indirectly as we would for Win64.
+struct StringRef {
+  char *Str;
+  __SIZE_TYPE__ Size;
+};
+extern volatile char gc;
+void SYSV_CC take_stringref(struct StringRef s);
+void callit() {
+  struct StringRef s = {"asdf", 4};
+  take_stringref(s);
+}
+// CHECK: define {{(dso_local )?}}void @callit()
+// CHECK: call {{(x86_64_sysvcc )?}}void @take_stringref(i8* {{[^,]*}}, i64 
{{[^,]*}})
+// CHECK: declare {{(dso_local )?}}{{(x86_64_sysvcc )?}}void 
@take_stringref(i8*, i64)
+
+// Check that we pass vectors directly if the target feature is enabled, and
+// not otherwise.
+typedef __attribute__((vector_size(32))) float my_m256;
+typedef __attribute__((vector_size(64))) float my_m512;
+
+my_m256 SYSV_CC get_m256(void);
+void SYSV_CC take_m256(my_m256);
+my_m512 SYSV_CC get_m512(void);
+void SYSV_CC take_m512(my_m512);
+
+void use_vectors() {
+  my_m256 v1 = get_m256();
+  take_m256(v1);
+  my_m512 v2 = get_m512();
+  take_m512(v2);
+}
+
+// CHECK: 

[PATCH] D63621: [git-clang-format] recognize hxx as a C++ file

2019-06-20 Thread Miklos Vajna via Phabricator via cfe-commits
vmiklos created this revision.
vmiklos added reviewers: jbcoe, djasper.
Herald added subscribers: cfe-commits, kadircet, ilya-biryukov.
Herald added a project: clang.

clangd, clang-tidy, etc does that already, no reason why git-clang-format 
should skip hxx files.


Repository:
  rC Clang

https://reviews.llvm.org/D63621

Files:
  clang/tools/clang-format/git-clang-format


Index: clang/tools/clang-format/git-clang-format
===
--- clang/tools/clang-format/git-clang-format
+++ clang/tools/clang-format/git-clang-format
@@ -77,7 +77,7 @@
   'c', 'h',  # C
   'm',  # ObjC
   'mm',  # ObjC++
-  'cc', 'cp', 'cpp', 'c++', 'cxx', 'hpp',  # C++
+  'cc', 'cp', 'cpp', 'c++', 'cxx', 'hpp', 'hxx',  # C++
   'cu',  # CUDA
   # Other languages that clang-format supports
   'proto', 'protodevel',  # Protocol Buffers


Index: clang/tools/clang-format/git-clang-format
===
--- clang/tools/clang-format/git-clang-format
+++ clang/tools/clang-format/git-clang-format
@@ -77,7 +77,7 @@
   'c', 'h',  # C
   'm',  # ObjC
   'mm',  # ObjC++
-  'cc', 'cp', 'cpp', 'c++', 'cxx', 'hpp',  # C++
+  'cc', 'cp', 'cpp', 'c++', 'cxx', 'hpp', 'hxx',  # C++
   'cu',  # CUDA
   # Other languages that clang-format supports
   'proto', 'protodevel',  # Protocol Buffers
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D59963: [clang-tidy] Add a module for the Linux kernel.

2019-06-20 Thread Nick Desaulniers via cfe-commits
Sounds like a good start.

On Thu, Jun 20, 2019 at 11:55 AM Tom Roeder via Phabricator
 wrote:
>
> tmroeder marked an inline comment as done.
> tmroeder added inline comments.
>
>
> 
> Comment at: clang-tools-extra/test/clang-tidy/linuxkernel-must-check-errs.c:6
> +// Prototypes of the error functions.
> +void * __must_check ERR_PTR(long error);
> +long  __must_check PTR_ERR(const void *ptr);
> 
> nickdesaulniers wrote:
> > Let's come up with another check; `__must_check` has a bug upstream in the 
> > kernel sources (I looked into this maybe a month ago).  The kernel disables 
> > a warning group that this would be under, if I re-enable the lone warning, 
> > then this works properly at compile time. (I forget the warning, and should 
> > have filed a bug).  Point being, fixing this upstream in kernel sources is 
> > preferable to me to a clang tidy check, but it's a good start.
> Good point. How about the related smatch checks in 
> https://repo.or.cz/smatch.git/blob_plain/HEAD:/check_err_ptr_deref.c
>
> It looks for cases where possible ERR_PTR values are dereferenced (wrong 
> because it's not a pointer), and passing non-negative values to ERR_PTR.
>
> What do you think?
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D59963/new/
>
> https://reviews.llvm.org/D59963
>
>
>


-- 
Thanks,
~Nick Desaulniers
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r363972 - Fix crash and rejects-valid when a later template parameter or default

2019-06-20 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Jun 20 12:49:13 2019
New Revision: 363972

URL: http://llvm.org/viewvc/llvm-project?rev=363972=rev
Log:
Fix crash and rejects-valid when a later template parameter or default
template argument contains a backreference to a dependently-typed
earlier parameter.

In a case like:
  template struct X {};
  template auto Y = X();
we previously treated both references to `A` in the third parameter as
being of type `int` when checking the template-id in `Y`. That`s wrong;
the type of `A` in these contexts is the dependent type `U`.

When we encounter a non-type template argument that we can't convert to
the parameter type because of type-dependence, we now insert a dependent
conversion node so that the SubstNonTypeTemplateParmExpr for the
template argument will have the parameter's type rather than whatever
type the argument had.

Modified:
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaTemplate/resolve-single-template-id.cpp
cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp

Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=363972=363971=363972=diff
==
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Thu Jun 20 12:49:13 2019
@@ -4499,7 +4499,7 @@ void CXXNameMangler::mangleTemplateArg(T
 // It's possible to end up with a DeclRefExpr here in certain
 // dependent cases, in which case we should mangle as a
 // declaration.
-const Expr *E = A.getAsExpr()->IgnoreParens();
+const Expr *E = A.getAsExpr()->IgnoreParenImpCasts();
 if (const DeclRefExpr *DRE = dyn_cast(E)) {
   const ValueDecl *D = DRE->getDecl();
   if (isa(D) || isa(D)) {

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=363972=363971=363972=diff
==
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Thu Jun 20 12:49:13 2019
@@ -491,6 +491,7 @@ ExprResult Sema::ImpCastExprToType(Expr
 default:
   llvm_unreachable("can't implicitly cast lvalue to rvalue with this cast "
"kind");
+case CK_Dependent:
 case CK_LValueToRValue:
 case CK_ArrayToPointerDecay:
 case CK_FunctionToPointerDecay:
@@ -499,7 +500,8 @@ ExprResult Sema::ImpCastExprToType(Expr
   break;
 }
   }
-  assert((VK == VK_RValue || !E->isRValue()) && "can't cast rvalue to lvalue");
+  assert((VK == VK_RValue || Kind == CK_Dependent || !E->isRValue()) &&
+ "can't cast rvalue to lvalue");
 #endif
 
   diagnoseNullableToNonnullConversion(Ty, E->getType(), E->getBeginLoc());

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=363972=363971=363972=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu Jun 20 12:49:13 2019
@@ -4888,10 +4888,22 @@ bool Sema::CheckTemplateArgument(NamedDe
 
   TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack,
 Converted);
-  NTTPType = SubstType(NTTPType,
-   MultiLevelTemplateArgumentList(TemplateArgs),
-   NTTP->getLocation(),
-   NTTP->getDeclName());
+
+  // If the parameter is a pack expansion, expand this slice of the pack.
+  if (auto *PET = NTTPType->getAs()) {
+Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(*this,
+   ArgumentPackIndex);
+NTTPType = SubstType(PET->getPattern(),
+ MultiLevelTemplateArgumentList(TemplateArgs),
+ NTTP->getLocation(),
+ NTTP->getDeclName());
+  } else {
+NTTPType = SubstType(NTTPType,
+ MultiLevelTemplateArgumentList(TemplateArgs),
+ NTTP->getLocation(),
+ NTTP->getDeclName());
+  }
+
   // If that worked, check the non-type template parameter type
   // for validity.
   if (!NTTPType.isNull())
@@ -6310,9 +6322,7 @@ ExprResult Sema::CheckTemplateArgument(N
 // When checking a deduced template argument, deduce from its type even if
 // the type is dependent, in order to check the types of non-type template
 // arguments line up properly in partial ordering.
-Optional Depth;
-if (CTAK != CTAK_Specified)
-  Depth = Param->getDepth() + 1;
+Optional Depth = Param->getDepth() + 1;
 if (DeduceAutoType(
 

[PATCH] D63580: [clang][NewPM] Do not eliminate available_externally durng `-O2 -flto` runs

2019-06-20 Thread Leonard Chan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
leonardchan marked an inline comment as done.
Closed by commit rG97dc622ab3f7: [clang][NewPM] Do not eliminate 
available_externally durng `-O2 -flto` runs (authored by leonardchan).

Changed prior to commit:
  https://reviews.llvm.org/D63580?vs=205699=205881#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63580

Files:
  clang/test/CodeGen/available-externally-suppress.c
  llvm/lib/Passes/PassBuilder.cpp
  llvm/test/Other/available-externally-lto.ll


Index: llvm/test/Other/available-externally-lto.ll
===
--- /dev/null
+++ llvm/test/Other/available-externally-lto.ll
@@ -0,0 +1,23 @@
+; Ensure that we don't emit available_externally functions at -O2, unless
+; -flto is present in which case we should preserve them for link-time inlining
+; decisions.
+; RUN: opt < %s -S -passes='default' | FileCheck %s
+; RUN: opt < %s -S -passes='lto-pre-link' | FileCheck %s --check-prefix=LTO
+
+@x = common local_unnamed_addr global i32 0, align 4
+
+define void @test() local_unnamed_addr #0 {
+entry:
+  tail call void @f0(i32 17)
+  ret void
+}
+
+; CHECK: declare void @f0(i32)
+; LTO: define available_externally void @f0(i32 %y)
+define available_externally void @f0(i32 %y) local_unnamed_addr #0 {
+entry:
+  store i32 %y, i32* @x, align 4
+  ret void
+}
+
+attributes #0 = { noinline }
Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -812,8 +812,10 @@
   // available externally globals. Eventually they will be suppressed during
   // codegen, but eliminating here enables more opportunity for GlobalDCE as it
   // may make globals referenced by available external functions dead and saves
-  // running remaining passes on the eliminated functions.
-  MPM.addPass(EliminateAvailableExternallyPass());
+  // running remaining passes on the eliminated functions. These should be
+  // preserved during prelinking for link-time inlining decisions.
+  if (!LTOPreLink)
+MPM.addPass(EliminateAvailableExternallyPass());
 
   if (EnableOrderFileInstrumentation)
 MPM.addPass(InstrOrderFilePass());
Index: clang/test/CodeGen/available-externally-suppress.c
===
--- clang/test/CodeGen/available-externally-suppress.c
+++ clang/test/CodeGen/available-externally-suppress.c
@@ -1,6 +1,9 @@
-// RUN: %clang_cc1 -emit-llvm -o - -triple x86_64-apple-darwin10 %s | 
FileCheck %s
-// RUN: %clang_cc1 -O2 -fno-inline -emit-llvm -o - -triple 
x86_64-apple-darwin10 %s | FileCheck %s
-// RUN: %clang_cc1 -flto -O2 -fno-inline -emit-llvm -o - -triple 
x86_64-apple-darwin10 %s | FileCheck %s -check-prefix=LTO
+// RUN: %clang_cc1 -fno-experimental-new-pass-manager -emit-llvm -o - -triple 
x86_64-apple-darwin10 %s | FileCheck %s
+// RUN: %clang_cc1 -fno-experimental-new-pass-manager -O2 -fno-inline 
-emit-llvm -o - -triple x86_64-apple-darwin10 %s | FileCheck %s
+// RUN: %clang_cc1 -fno-experimental-new-pass-manager -flto -O2 -fno-inline 
-emit-llvm -o - -triple x86_64-apple-darwin10 %s | FileCheck %s 
-check-prefix=LTO
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -emit-llvm -o - -triple 
x86_64-apple-darwin10 %s | FileCheck %s
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -O2 -fno-inline -emit-llvm 
-o - -triple x86_64-apple-darwin10 %s | FileCheck %s
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -flto -O2 -fno-inline 
-emit-llvm -o - -triple x86_64-apple-darwin10 %s | FileCheck %s 
-check-prefix=LTO
 
 // Ensure that we don't emit available_externally functions at -O0.
 // Also should not emit them at -O2, unless -flto is present in which case


Index: llvm/test/Other/available-externally-lto.ll
===
--- /dev/null
+++ llvm/test/Other/available-externally-lto.ll
@@ -0,0 +1,23 @@
+; Ensure that we don't emit available_externally functions at -O2, unless
+; -flto is present in which case we should preserve them for link-time inlining
+; decisions.
+; RUN: opt < %s -S -passes='default' | FileCheck %s
+; RUN: opt < %s -S -passes='lto-pre-link' | FileCheck %s --check-prefix=LTO
+
+@x = common local_unnamed_addr global i32 0, align 4
+
+define void @test() local_unnamed_addr #0 {
+entry:
+  tail call void @f0(i32 17)
+  ret void
+}
+
+; CHECK: declare void @f0(i32)
+; LTO: define available_externally void @f0(i32 %y)
+define available_externally void @f0(i32 %y) local_unnamed_addr #0 {
+entry:
+  store i32 %y, i32* @x, align 4
+  ret void
+}
+
+attributes #0 = { noinline }
Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -812,8 

[PATCH] D63613: [clang-tidy] Fail gracefully upon empty database fields

2019-06-20 Thread Jan Korous via Phabricator via cfe-commits
jkorous accepted this revision.
jkorous added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: dexonsmith.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63613



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


r363971 - [clang][NewPM] Do not eliminate available_externally durng `-O2 -flto` runs

2019-06-20 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Thu Jun 20 12:44:51 2019
New Revision: 363971

URL: http://llvm.org/viewvc/llvm-project?rev=363971=rev
Log:
[clang][NewPM] Do not eliminate available_externally durng `-O2 -flto` runs

This fixes CodeGen/available-externally-suppress.c when the new pass manager is
turned on by default. available_externally was not emitted during -O2 -flto
runs when it should still be retained for link time inlining purposes. This can
be fixed by checking that we aren't LTOPrelinking when adding the
EliminateAvailableExternallyPass.

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

Modified:
cfe/trunk/test/CodeGen/available-externally-suppress.c

Modified: cfe/trunk/test/CodeGen/available-externally-suppress.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/available-externally-suppress.c?rev=363971=363970=363971=diff
==
--- cfe/trunk/test/CodeGen/available-externally-suppress.c (original)
+++ cfe/trunk/test/CodeGen/available-externally-suppress.c Thu Jun 20 12:44:51 
2019
@@ -1,6 +1,9 @@
-// RUN: %clang_cc1 -emit-llvm -o - -triple x86_64-apple-darwin10 %s | 
FileCheck %s
-// RUN: %clang_cc1 -O2 -fno-inline -emit-llvm -o - -triple 
x86_64-apple-darwin10 %s | FileCheck %s
-// RUN: %clang_cc1 -flto -O2 -fno-inline -emit-llvm -o - -triple 
x86_64-apple-darwin10 %s | FileCheck %s -check-prefix=LTO
+// RUN: %clang_cc1 -fno-experimental-new-pass-manager -emit-llvm -o - -triple 
x86_64-apple-darwin10 %s | FileCheck %s
+// RUN: %clang_cc1 -fno-experimental-new-pass-manager -O2 -fno-inline 
-emit-llvm -o - -triple x86_64-apple-darwin10 %s | FileCheck %s
+// RUN: %clang_cc1 -fno-experimental-new-pass-manager -flto -O2 -fno-inline 
-emit-llvm -o - -triple x86_64-apple-darwin10 %s | FileCheck %s 
-check-prefix=LTO
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -emit-llvm -o - -triple 
x86_64-apple-darwin10 %s | FileCheck %s
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -O2 -fno-inline -emit-llvm 
-o - -triple x86_64-apple-darwin10 %s | FileCheck %s
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -flto -O2 -fno-inline 
-emit-llvm -o - -triple x86_64-apple-darwin10 %s | FileCheck %s 
-check-prefix=LTO
 
 // Ensure that we don't emit available_externally functions at -O0.
 // Also should not emit them at -O2, unless -flto is present in which case


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


[PATCH] D63577: [clang][NewPM] Move EntryExitInstrumenterPass to the start of the pipeline

2019-06-20 Thread Leonard Chan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL363969: [clang][NewPM] Move EntryExitInstrumenterPass to the 
start of the pipeline (authored by leonardchan, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D63577?vs=205688=205880#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D63577

Files:
  cfe/trunk/lib/CodeGen/BackendUtil.cpp
  cfe/trunk/test/CodeGen/x86_64-instrument-functions.c


Index: cfe/trunk/test/CodeGen/x86_64-instrument-functions.c
===
--- cfe/trunk/test/CodeGen/x86_64-instrument-functions.c
+++ cfe/trunk/test/CodeGen/x86_64-instrument-functions.c
@@ -1,6 +1,9 @@
 // REQUIRES: x86-registered-target
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -S -finstrument-functions 
-O2 -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -S 
-finstrument-functions-after-inlining -O2 -o - %s | FileCheck 
-check-prefix=NOINLINE %s
+// RUN: %clang_cc1 -fno-experimental-new-pass-manager -triple 
x86_64-unknown-unknown -S -finstrument-functions -O2 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fno-experimental-new-pass-manager -triple 
x86_64-unknown-unknown -S -finstrument-functions-after-inlining -O2 -o - %s | 
FileCheck -check-prefix=NOINLINE %s
+
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -triple 
x86_64-unknown-unknown -S -finstrument-functions -O2 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -triple 
x86_64-unknown-unknown -S -finstrument-functions-after-inlining -O2 -o - %s | 
FileCheck -check-prefix=NOINLINE %s
 
 // It's not so nice having asm tests in Clang, but we need to check that we set
 // up the pipeline correctly in order to have the instrumentation inserted.
Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -67,6 +67,7 @@
 #include "llvm/Transforms/Scalar/GVN.h"
 #include "llvm/Transforms/Utils.h"
 #include "llvm/Transforms/Utils/CanonicalizeAliases.h"
+#include "llvm/Transforms/Utils/EntryExitInstrumenter.h"
 #include "llvm/Transforms/Utils/NameAnonGlobals.h"
 #include "llvm/Transforms/Utils/SymbolRewriter.h"
 #include 
@@ -1131,6 +1132,11 @@
   // configure the pipeline.
   PassBuilder::OptimizationLevel Level = mapToLevel(CodeGenOpts);
 
+  PB.registerPipelineStartEPCallback([](ModulePassManager ) {
+MPM.addPass(createModuleToFunctionPassAdaptor(
+EntryExitInstrumenterPass(/*PostInlining=*/false)));
+  });
+
   // Register callbacks to schedule sanitizer passes at the appropriate 
part of
   // the pipeline.
   // FIXME: either handle asan/the remaining sanitizers or error out


Index: cfe/trunk/test/CodeGen/x86_64-instrument-functions.c
===
--- cfe/trunk/test/CodeGen/x86_64-instrument-functions.c
+++ cfe/trunk/test/CodeGen/x86_64-instrument-functions.c
@@ -1,6 +1,9 @@
 // REQUIRES: x86-registered-target
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -S -finstrument-functions -O2 -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -S -finstrument-functions-after-inlining -O2 -o - %s | FileCheck -check-prefix=NOINLINE %s
+// RUN: %clang_cc1 -fno-experimental-new-pass-manager -triple x86_64-unknown-unknown -S -finstrument-functions -O2 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fno-experimental-new-pass-manager -triple x86_64-unknown-unknown -S -finstrument-functions-after-inlining -O2 -o - %s | FileCheck -check-prefix=NOINLINE %s
+
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -triple x86_64-unknown-unknown -S -finstrument-functions -O2 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -triple x86_64-unknown-unknown -S -finstrument-functions-after-inlining -O2 -o - %s | FileCheck -check-prefix=NOINLINE %s
 
 // It's not so nice having asm tests in Clang, but we need to check that we set
 // up the pipeline correctly in order to have the instrumentation inserted.
Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -67,6 +67,7 @@
 #include "llvm/Transforms/Scalar/GVN.h"
 #include "llvm/Transforms/Utils.h"
 #include "llvm/Transforms/Utils/CanonicalizeAliases.h"
+#include "llvm/Transforms/Utils/EntryExitInstrumenter.h"
 #include "llvm/Transforms/Utils/NameAnonGlobals.h"
 #include "llvm/Transforms/Utils/SymbolRewriter.h"
 #include 
@@ -1131,6 +1132,11 @@
   // configure the pipeline.
   PassBuilder::OptimizationLevel Level = mapToLevel(CodeGenOpts);
 
+  

r363969 - [clang][NewPM] Move EntryExitInstrumenterPass to the start of the pipeline

2019-06-20 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Thu Jun 20 12:35:25 2019
New Revision: 363969

URL: http://llvm.org/viewvc/llvm-project?rev=363969=rev
Log:
[clang][NewPM] Move EntryExitInstrumenterPass to the start of the pipeline

This fixes CodeGen/x86_64-instrument-functions.c when running under the new
pass manager. The pass should go before any other pass to prevent
`__cyg_profile_func_enter/exit()` from not being emitted by inlined functions.

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

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/test/CodeGen/x86_64-instrument-functions.c

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=363969=363968=363969=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jun 20 12:35:25 2019
@@ -67,6 +67,7 @@
 #include "llvm/Transforms/Scalar/GVN.h"
 #include "llvm/Transforms/Utils.h"
 #include "llvm/Transforms/Utils/CanonicalizeAliases.h"
+#include "llvm/Transforms/Utils/EntryExitInstrumenter.h"
 #include "llvm/Transforms/Utils/NameAnonGlobals.h"
 #include "llvm/Transforms/Utils/SymbolRewriter.h"
 #include 
@@ -1131,6 +1132,11 @@ void EmitAssemblyHelper::EmitAssemblyWit
   // configure the pipeline.
   PassBuilder::OptimizationLevel Level = mapToLevel(CodeGenOpts);
 
+  PB.registerPipelineStartEPCallback([](ModulePassManager ) {
+MPM.addPass(createModuleToFunctionPassAdaptor(
+EntryExitInstrumenterPass(/*PostInlining=*/false)));
+  });
+
   // Register callbacks to schedule sanitizer passes at the appropriate 
part of
   // the pipeline.
   // FIXME: either handle asan/the remaining sanitizers or error out

Modified: cfe/trunk/test/CodeGen/x86_64-instrument-functions.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/x86_64-instrument-functions.c?rev=363969=363968=363969=diff
==
--- cfe/trunk/test/CodeGen/x86_64-instrument-functions.c (original)
+++ cfe/trunk/test/CodeGen/x86_64-instrument-functions.c Thu Jun 20 12:35:25 
2019
@@ -1,6 +1,9 @@
 // REQUIRES: x86-registered-target
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -S -finstrument-functions 
-O2 -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -S 
-finstrument-functions-after-inlining -O2 -o - %s | FileCheck 
-check-prefix=NOINLINE %s
+// RUN: %clang_cc1 -fno-experimental-new-pass-manager -triple 
x86_64-unknown-unknown -S -finstrument-functions -O2 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fno-experimental-new-pass-manager -triple 
x86_64-unknown-unknown -S -finstrument-functions-after-inlining -O2 -o - %s | 
FileCheck -check-prefix=NOINLINE %s
+
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -triple 
x86_64-unknown-unknown -S -finstrument-functions -O2 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -triple 
x86_64-unknown-unknown -S -finstrument-functions-after-inlining -O2 -o - %s | 
FileCheck -check-prefix=NOINLINE %s
 
 // It's not so nice having asm tests in Clang, but we need to check that we set
 // up the pipeline correctly in order to have the instrumentation inserted.


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


[PATCH] D63617: [COFF, ARM64] Fix encoding of __debugbreak

2019-06-20 Thread Tom Tan via Phabricator via cfe-commits
TomTan created this revision.
TomTan added reviewers: efriedma, rnk.
Herald added subscribers: cfe-commits, kristof.beyls, javed.absar.
Herald added a project: clang.

On Windows ARM64, intrinsic `__debugbreak` should be compiled into `brk 
#0xF000` which is different from llvm intrinsic `debugtrap` as `brk #0`. This 
change fixes this by transforming `__debugbreak` to the expected inline 
assembly in Clang.


Repository:
  rC Clang

https://reviews.llvm.org/D63617

Files:
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/ms-intrinsics.c


Index: test/CodeGen/ms-intrinsics.c
===
--- test/CodeGen/ms-intrinsics.c
+++ test/CodeGen/ms-intrinsics.c
@@ -1379,6 +1379,14 @@
 // CHECK-INTEL: call void asm sideeffect "int $$0x29", "{cx}"(i32 42) 
#[[NORETURN]]
 // CHECK-ARM64: call void asm sideeffect "brk #0xF003", "{w0}"(i32 42) 
#[[NORETURN:[0-9]+]]
 
+void test__debugbreak() {
+  __debugbreak();
+}
+// CHECK_LABEL: define{{.*}} void @test__debugbreak() {
+// CHECK-INTEL: call void @llvm.debugtrap()
+// CHECK-ARM: call void @llvm.debugtrap()
+// CHECK-ARM64: call void asm sideeffect "brk #0xF000", ""()
+
 // Attributes come last.
 
 // CHECK: attributes #[[NORETURN]] = { noreturn{{.*}} }
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -2125,8 +2125,20 @@
   }
   case Builtin::BI__builtin_trap:
 return RValue::get(EmitTrapCall(Intrinsic::trap));
-  case Builtin::BI__debugbreak:
-return RValue::get(EmitTrapCall(Intrinsic::debugtrap));
+  case Builtin::BI__debugbreak: {
+llvm::Triple::ArchType ISA = getTarget().getTriple().getArch();
+switch (ISA) {
+default:
+  return RValue::get(EmitTrapCall(Intrinsic::debugtrap));
+case llvm::Triple::aarch64: {
+  llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, false);
+  llvm::InlineAsm *IA =
+llvm::InlineAsm::get(FTy, "brk #0xF000", "", /*SideEffects=*/true);
+  llvm::CallInst *CI = Builder.CreateCall(IA);
+  return RValue::get(CI);
+}
+}
+  }
   case Builtin::BI__builtin_unreachable: {
 EmitUnreachable(E->getExprLoc());
 


Index: test/CodeGen/ms-intrinsics.c
===
--- test/CodeGen/ms-intrinsics.c
+++ test/CodeGen/ms-intrinsics.c
@@ -1379,6 +1379,14 @@
 // CHECK-INTEL: call void asm sideeffect "int $$0x29", "{cx}"(i32 42) #[[NORETURN]]
 // CHECK-ARM64: call void asm sideeffect "brk #0xF003", "{w0}"(i32 42) #[[NORETURN:[0-9]+]]
 
+void test__debugbreak() {
+  __debugbreak();
+}
+// CHECK_LABEL: define{{.*}} void @test__debugbreak() {
+// CHECK-INTEL: call void @llvm.debugtrap()
+// CHECK-ARM: call void @llvm.debugtrap()
+// CHECK-ARM64: call void asm sideeffect "brk #0xF000", ""()
+
 // Attributes come last.
 
 // CHECK: attributes #[[NORETURN]] = { noreturn{{.*}} }
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -2125,8 +2125,20 @@
   }
   case Builtin::BI__builtin_trap:
 return RValue::get(EmitTrapCall(Intrinsic::trap));
-  case Builtin::BI__debugbreak:
-return RValue::get(EmitTrapCall(Intrinsic::debugtrap));
+  case Builtin::BI__debugbreak: {
+llvm::Triple::ArchType ISA = getTarget().getTriple().getArch();
+switch (ISA) {
+default:
+  return RValue::get(EmitTrapCall(Intrinsic::debugtrap));
+case llvm::Triple::aarch64: {
+  llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, false);
+  llvm::InlineAsm *IA =
+llvm::InlineAsm::get(FTy, "brk #0xF000", "", /*SideEffects=*/true);
+  llvm::CallInst *CI = Builder.CreateCall(IA);
+  return RValue::get(CI);
+}
+}
+  }
   case Builtin::BI__builtin_unreachable: {
 EmitUnreachable(E->getExprLoc());
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r363966 - Print additional information about @encode expressions when dumping the AST to JSON.

2019-06-20 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu Jun 20 12:11:35 2019
New Revision: 363966

URL: http://llvm.org/viewvc/llvm-project?rev=363966=rev
Log:
Print additional information about @encode expressions when dumping the AST to 
JSON.

Modified:
cfe/trunk/include/clang/AST/JSONNodeDumper.h
cfe/trunk/lib/AST/JSONNodeDumper.cpp
cfe/trunk/test/AST/ast-dump-stmt-json.m

Modified: cfe/trunk/include/clang/AST/JSONNodeDumper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/JSONNodeDumper.h?rev=363966=363965=363966=diff
==
--- cfe/trunk/include/clang/AST/JSONNodeDumper.h (original)
+++ cfe/trunk/include/clang/AST/JSONNodeDumper.h Thu Jun 20 12:11:35 2019
@@ -232,6 +232,7 @@ public:
   void VisitObjCPropertyDecl(const ObjCPropertyDecl *D);
   void VisitObjCPropertyImplDecl(const ObjCPropertyImplDecl *D);
   void VisitBlockDecl(const BlockDecl *D);
+  void VisitObjCEncodeExpr(const ObjCEncodeExpr *OEE);
 
   void VisitDeclRefExpr(const DeclRefExpr *DRE);
   void VisitPredefinedExpr(const PredefinedExpr *PE);

Modified: cfe/trunk/lib/AST/JSONNodeDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/JSONNodeDumper.cpp?rev=363966=363965=363966=diff
==
--- cfe/trunk/lib/AST/JSONNodeDumper.cpp (original)
+++ cfe/trunk/lib/AST/JSONNodeDumper.cpp Thu Jun 20 12:11:35 2019
@@ -834,6 +834,10 @@ void JSONNodeDumper::VisitBlockDecl(cons
   attributeOnlyIfTrue("capturesThis", D->capturesCXXThis());
 }
 
+void JSONNodeDumper::VisitObjCEncodeExpr(const ObjCEncodeExpr *OEE) {
+  JOS.attribute("encodedType", createQualType(OEE->getEncodedType()));
+}
+
 void JSONNodeDumper::VisitDeclRefExpr(const DeclRefExpr *DRE) {
   JOS.attribute("referencedDecl", createBareDeclRef(DRE->getDecl()));
   if (DRE->getDecl() != DRE->getFoundDecl())

Modified: cfe/trunk/test/AST/ast-dump-stmt-json.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-stmt-json.m?rev=363966=363965=363966=diff
==
--- cfe/trunk/test/AST/ast-dump-stmt-json.m (original)
+++ cfe/trunk/test/AST/ast-dump-stmt-json.m Thu Jun 20 12:11:35 2019
@@ -19,6 +19,11 @@ void TestObjCAtCatchStmt() {
   }
 }
 
+void TestObjCEncode() {
+  @encode(int);
+  @encode(typeof(^{;}));
+}
+
 
 // CHECK:  "kind": "FunctionDecl", 
 // CHECK-NEXT:  "loc": {
@@ -726,6 +731,144 @@ void TestObjCAtCatchStmt() {
 // CHECK-NEXT:   }
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
+// CHECK-NEXT:]
+// CHECK-NEXT:   }
+// CHECK-NEXT:  ]
+// CHECK-NEXT: }
+
+
+// CHECK:  "kind": "FunctionDecl", 
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "col": 6, 
+// CHECK-NEXT:   "file": "{{.*}}", 
+// CHECK-NEXT:   "line": 22
+// CHECK-NEXT:  }, 
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"col": 1, 
+// CHECK-NEXT:"file": "{{.*}}", 
+// CHECK-NEXT:"line": 22
+// CHECK-NEXT:   }, 
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"col": 1, 
+// CHECK-NEXT:"file": "{{.*}}", 
+// CHECK-NEXT:"line": 25
+// CHECK-NEXT:   }
+// CHECK-NEXT:  }, 
+// CHECK-NEXT:  "name": "TestObjCEncode", 
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "void ()"
+// CHECK-NEXT:  }, 
+// CHECK-NEXT:  "inner": [
+// CHECK-NEXT:   {
+// CHECK-NEXT:"id": "0x{{.*}}", 
+// CHECK-NEXT:"kind": "CompoundStmt", 
+// CHECK-NEXT:"range": {
+// CHECK-NEXT: "begin": {
+// CHECK-NEXT:  "col": 23, 
+// CHECK-NEXT:  "file": "{{.*}}", 
+// CHECK-NEXT:  "line": 22
+// CHECK-NEXT: }, 
+// CHECK-NEXT: "end": {
+// CHECK-NEXT:  "col": 1, 
+// CHECK-NEXT:  "file": "{{.*}}", 
+// CHECK-NEXT:  "line": 25
+// CHECK-NEXT: }
+// CHECK-NEXT:}, 
+// CHECK-NEXT:"inner": [
+// CHECK-NEXT: {
+// CHECK-NEXT:  "id": "0x{{.*}}", 
+// CHECK-NEXT:  "kind": "ImplicitCastExpr", 
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"col": 3, 
+// CHECK-NEXT:"file": "{{.*}}", 
+// CHECK-NEXT:"line": 23
+// CHECK-NEXT:   }, 
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"col": 14, 
+// CHECK-NEXT:"file": "{{.*}}", 
+// CHECK-NEXT:"line": 23
+// CHECK-NEXT:   }
+// CHECK-NEXT:  }, 
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "char *"
+// CHECK-NEXT:  }, 
+// CHECK-NEXT:  "valueCategory": "rvalue", 
+// CHECK-NEXT:  "castKind": "ArrayToPointerDecay", 
+// CHECK-NEXT:  "inner": [
+// CHECK-NEXT:   {
+// CHECK-NEXT:"id": "0x{{.*}}", 
+// CHECK-NEXT:"kind": "ObjCEncodeExpr", 
+// CHECK-NEXT:"range": {
+// CHECK-NEXT: "begin": {
+// CHECK-NEXT:  "col": 3, 
+// CHECK-NEXT:  "file": "{{.*}}", 
+// CHECK-NEXT:  "line": 23
+// CHECK-NEXT: }, 
+// CHECK-NEXT: "end": {
+// CHECK-NEXT:  

[PATCH] D60225: [clang-format] [PR19056] Add support for indenting class members and methods one level under the modifiers

2019-06-20 Thread Denis Rouzaud via Phabricator via cfe-commits
3nids added a comment.

Hi, may I ask why this is abandoned?
We are eagerly waiting on this to move to clang-format.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60225



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


[PATCH] D59963: [clang-tidy] Add a module for the Linux kernel.

2019-06-20 Thread Tom Roeder via Phabricator via cfe-commits
tmroeder marked an inline comment as done.
tmroeder added inline comments.



Comment at: clang-tools-extra/test/clang-tidy/linuxkernel-must-check-errs.c:6
+// Prototypes of the error functions.
+void * __must_check ERR_PTR(long error);
+long  __must_check PTR_ERR(const void *ptr);

nickdesaulniers wrote:
> Let's come up with another check; `__must_check` has a bug upstream in the 
> kernel sources (I looked into this maybe a month ago).  The kernel disables a 
> warning group that this would be under, if I re-enable the lone warning, then 
> this works properly at compile time. (I forget the warning, and should have 
> filed a bug).  Point being, fixing this upstream in kernel sources is 
> preferable to me to a clang tidy check, but it's a good start.
Good point. How about the related smatch checks in 
https://repo.or.cz/smatch.git/blob_plain/HEAD:/check_err_ptr_deref.c

It looks for cases where possible ERR_PTR values are dereferenced (wrong 
because it's not a pointer), and passing non-negative values to ERR_PTR.

What do you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59963



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


[PATCH] D63616: Implement `-fsanitize-coverage-whitelist` and `-fsanitize-coverage-blacklist` for clang

2019-06-20 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Test coverage missing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63616



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


[PATCH] D63616: Implement `-fsanitize-coverage-whitelist` and `-fsanitize-coverage-blacklist` for clang

2019-06-20 Thread Yannis Juglaret via Phabricator via cfe-commits
tuktuk created this revision.
tuktuk added reviewers: kcc, morehouse.
tuktuk added projects: clang, Sanitizers.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya.
Herald added a project: LLVM.

This commit adds two command-line options to clang.
These options let the user decide which functions will receive 
SanitizerCoverage instrumentation.
This is most useful in the libFuzzer use case, where it enables targeted 
coverage-guided fuzzing.

Patch by Yannis Juglaret of DGA-MI, Rennes, France

libFuzzer tests its target against an evolving corpus, and relies on 
SanitizerCoverage instrumentation to collect the code coverage information that 
drives corpus evolution. Currently, libFuzzer collects such information for all 
functions of the target under test, and adds to the corpus every mutated sample 
that finds a new code coverage path in any function of the target. We propose 
instead to let the user specify which functions' code coverage information is 
relevant for building the upcoming fuzzing campaign's corpus. To this end, we 
add two new command line options for clang, enabling targeted coverage-guided 
fuzzing with libFuzzer. We see targeted coverage guided fuzzing as a simple way 
to leverage libFuzzer for big targets with thousands of functions or multiple 
dependencies. We publish this patch as work from DGA-MI of Rennes, France, with 
proper authorization from the hierarchy.

Targeted coverage-guided fuzzing can accelerate bug finding for two reasons. 
First, the compiler will avoid costly instrumentation for non-relevant 
functions, accelerating fuzzer execution for each call to any of these 
functions. Second, the built fuzzer will produce and use a more accurate 
corpus, because it will not keep the samples that find new coverage paths in 
non-relevant functions.

The two new command line options are `-fsanitize-coverage-whitelist` and 
`-fsanitize-coverage-blacklist`. They accept files in the same format as the 
existing `-fsanitize-blacklist` option 
. The new 
options influence SanitizerCoverage so that it will only instrument a subset of 
the functions in the target. We explain these options in detail in 
`clang/docs/SanitizerCoverage.rst`.

Consider now the woff2 fuzzing example from the libFuzzer tutorial 
.
 We are aware that we cannot conclude much from this example because mutating 
compressed data is generally a bad idea, but let us use it anyway as an 
illustration for its simplicity. Let us use an empty blacklist together with 
one of the three following whitelists:

  # (a)
  src:*
  fun:*
  
  # (b)
  src:SRC/*
  fun:*
  
  # (c)
  src:SRC/src/woff2_dec.cc
  fun:*

Running the built fuzzers shows how many instrumentation points the compiler 
adds, the fuzzer will output //XXX PCs//. Whitelist (a) is the 
instrument-everything whitelist, it produces 11912 instrumentation points. 
Whitelist (b) focuses coverage to instrument woff2 source code only, ignoring 
the dependency code for brotli (de)compression; it produces 3984 instrumented 
instrumentation points. Whitelist (c) focuses coverage to only instrument 
functions in the main file that deals with WOFF2 to TTF conversion, resulting 
in 1056 instrumentation points.

For experimentation purposes, we ran each fuzzer approximately 100 times, 
single process, with the initial corpus provided in the tutorial. We let the 
fuzzer run until it either found the heap buffer overflow or went out of 
memory. On this simple example, whitelists (b) and (c) found the heap buffer 
overflow more reliably and 5x faster than whitelist (a). The average execution 
times when finding the heap buffer overflow were as follows: (a) 904 s, (b) 156 
s, and (c) 176 s.

We explain these results by the fact that WOFF2 to TTF conversion calls the 
brotli decompression algorithm's functions, which are mostly irrelevant for 
finding bugs in WOFF2 font reconstruction but nevertheless instrumented and 
used by whitelist (a) to guide fuzzing. This results in longer execution time 
for these functions and a partially irrelevant corpus. Contrary to whitelist 
(a), whitelists (b) and (c) will execute brotli-related functions without 
instrumentation overhead, and ignore new code paths found in them. This results 
in faster bug finding for WOFF2 font reconstruction.

The results for whitelist (b) are similar to the ones for whitelist (c). 
Indeed, WOFF2 to TTF conversion calls functions that are mostly located in 
SRC/src/woff2_dec.cc. The 2892 extra instrumentation points allowed by 
whitelist (b) do not tamper with bug finding, even though they are mostly 
irrelevant, simply because most of these functions do not get called. We get a 
slightly faster average time for bug finding with whitelist (b), which might 
indicate that some of the extra instrumentation points are actually relevant, 
or might just 

r363963 - [NFC] Fix for InterfaceStubs tests (adding REQUIRES: x86-registered-target).

2019-06-20 Thread Puyan Lotfi via cfe-commits
Author: zer0
Date: Thu Jun 20 11:28:21 2019
New Revision: 363963

URL: http://llvm.org/viewvc/llvm-project?rev=363963=rev
Log:
[NFC] Fix for InterfaceStubs tests (adding REQUIRES: x86-registered-target).

clang-hexagon-elf bot was failing with:

'No available targets are compatible with triple "x86_64-unknown-linux-gnu"'

Adding a "// REQUIRES: x86-registered-target" to these tests to quiet the bot.

Modified:
cfe/trunk/test/InterfaceStubs/bad-format.cpp
cfe/trunk/test/InterfaceStubs/class-template-specialization.cpp
cfe/trunk/test/InterfaceStubs/externstatic.c
cfe/trunk/test/InterfaceStubs/function-template-specialization.cpp
cfe/trunk/test/InterfaceStubs/hidden-class-inheritance.cpp
cfe/trunk/test/InterfaceStubs/inline.c
cfe/trunk/test/InterfaceStubs/inline.h
cfe/trunk/test/InterfaceStubs/object.cpp
cfe/trunk/test/InterfaceStubs/template-namespace-function.cpp
cfe/trunk/test/InterfaceStubs/virtual.cpp
cfe/trunk/test/InterfaceStubs/visibility.cpp
cfe/trunk/test/InterfaceStubs/weak.cpp

Modified: cfe/trunk/test/InterfaceStubs/bad-format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/InterfaceStubs/bad-format.cpp?rev=363963=363962=363963=diff
==
--- cfe/trunk/test/InterfaceStubs/bad-format.cpp (original)
+++ cfe/trunk/test/InterfaceStubs/bad-format.cpp Thu Jun 20 11:28:21 2019
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target
 // RUN: not %clang -target x86_64-linux-gnu -o - -emit-interface-stubs \
 // RUN: -interface-stub-version=bar-format %s 2>&1 | FileCheck %s
 

Modified: cfe/trunk/test/InterfaceStubs/class-template-specialization.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/InterfaceStubs/class-template-specialization.cpp?rev=363963=363962=363963=diff
==
--- cfe/trunk/test/InterfaceStubs/class-template-specialization.cpp (original)
+++ cfe/trunk/test/InterfaceStubs/class-template-specialization.cpp Thu Jun 20 
11:28:21 2019
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target
 // RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
 // RUN: -interface-stub-version=experimental-tapi-elf-v1 %s | \
 // RUN: FileCheck -check-prefix=CHECK-TAPI %s

Modified: cfe/trunk/test/InterfaceStubs/externstatic.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/InterfaceStubs/externstatic.c?rev=363963=363962=363963=diff
==
--- cfe/trunk/test/InterfaceStubs/externstatic.c (original)
+++ cfe/trunk/test/InterfaceStubs/externstatic.c Thu Jun 20 11:28:21 2019
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target
 // RUN: %clang -DSTORAGE="extern" -target x86_64-unknown-linux-gnu -o - \
 // RUN: -emit-interface-stubs \
 // RUN: -interface-stub-version=experimental-yaml-elf-v1 -std=c99 -xc %s | \

Modified: cfe/trunk/test/InterfaceStubs/function-template-specialization.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/InterfaceStubs/function-template-specialization.cpp?rev=363963=363962=363963=diff
==
--- cfe/trunk/test/InterfaceStubs/function-template-specialization.cpp 
(original)
+++ cfe/trunk/test/InterfaceStubs/function-template-specialization.cpp Thu Jun 
20 11:28:21 2019
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target
 // RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
 // RUN: -interface-stub-version=experimental-tapi-elf-v1 %s | FileCheck %s
 

Modified: cfe/trunk/test/InterfaceStubs/hidden-class-inheritance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/InterfaceStubs/hidden-class-inheritance.cpp?rev=363963=363962=363963=diff
==
--- cfe/trunk/test/InterfaceStubs/hidden-class-inheritance.cpp (original)
+++ cfe/trunk/test/InterfaceStubs/hidden-class-inheritance.cpp Thu Jun 20 
11:28:21 2019
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target
 // RUN: %clang -target x86_64-unknown-linux-gnu -o - -emit-interface-stubs \
 // RUN: -interface-stub-version=experimental-tapi-elf-v1 \
 // RUN: -DPARENT_CLASS_VISIBILITY="" -DCHILD_CLASS_VISIBILITY="" \

Modified: cfe/trunk/test/InterfaceStubs/inline.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/InterfaceStubs/inline.c?rev=363963=363962=363963=diff
==
--- cfe/trunk/test/InterfaceStubs/inline.c (original)
+++ cfe/trunk/test/InterfaceStubs/inline.c Thu Jun 20 11:28:21 2019
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target
 // RUN: %clang -DINLINE=inline -target x86_64-unknown-linux-gnu -o - \
 // RUN: -emit-interface-stubs \
 // RUN: -interface-stub-version=experimental-yaml-elf-v1 -std=gnu89 -xc %s | \

Modified: cfe/trunk/test/InterfaceStubs/inline.h
URL: 

r363961 - [X86] Make _mm_mask_cvtps_ph, _mm_maskz_cvtps_ph, _mm256_mask_cvtps_ph, and _mm256_maskz_cvtps_ph aliases for their corresponding cvt_roundps_ph intrinsic.

2019-06-20 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Thu Jun 20 11:24:29 2019
New Revision: 363961

URL: http://llvm.org/viewvc/llvm-project?rev=363961=rev
Log:
[X86] Make _mm_mask_cvtps_ph, _mm_maskz_cvtps_ph, _mm256_mask_cvtps_ph, and 
_mm256_maskz_cvtps_ph aliases for their corresponding cvt_roundps_ph intrinsic.

These intrinsics should always take an immediate for the rounding mode.
The base instruction comes from before EVEX embdedded rounding. The
user should always provide the immediate rather than us assuming
CUR_DIRECTION.

Make the 512-bit versions also explicit aliases instead of copy
pasting the code.

Modified:
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/lib/Headers/avx512vlintrin.h
cfe/trunk/test/CodeGen/avx512vl-builtins.c

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=363961=363960=363961=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Thu Jun 20 11:24:29 2019
@@ -3779,20 +3779,9 @@ _mm512_mask_cvtpd_pslo (__m512 __W, __mm
 (__v16hi)_mm256_setzero_si256(), \
 (__mmask16)(W))
 
-#define _mm512_cvtps_ph(A, I) \
-  (__m256i)__builtin_ia32_vcvtps2ph512_mask((__v16sf)(__m512)(A), (int)(I), \
-(__v16hi)_mm256_setzero_si256(), \
-(__mmask16)-1)
-
-#define _mm512_mask_cvtps_ph(U, W, A, I) \
-  (__m256i)__builtin_ia32_vcvtps2ph512_mask((__v16sf)(__m512)(A), (int)(I), \
-(__v16hi)(__m256i)(U), \
-(__mmask16)(W))
-
-#define _mm512_maskz_cvtps_ph(W, A, I) \
-  (__m256i)__builtin_ia32_vcvtps2ph512_mask((__v16sf)(__m512)(A), (int)(I), \
-(__v16hi)_mm256_setzero_si256(), \
-(__mmask16)(W))
+#define _mm512_cvtps_ph   _mm512_cvt_roundps_ph
+#define _mm512_mask_cvtps_ph  _mm512_mask_cvt_roundps_ph
+#define _mm512_maskz_cvtps_ph _mm512_maskz_cvt_roundps_ph
 
 #define _mm512_cvt_roundph_ps(A, R) \
   (__m512)__builtin_ia32_vcvtph2ps512_mask((__v16hi)(__m256i)(A), \

Modified: cfe/trunk/lib/Headers/avx512vlintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512vlintrin.h?rev=363961=363960=363961=diff
==
--- cfe/trunk/lib/Headers/avx512vlintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512vlintrin.h Thu Jun 20 11:24:29 2019
@@ -8411,22 +8411,6 @@ _mm256_maskz_cvtph_ps (__mmask8 __U, __m
 (__mmask8) __U);
 }
 
-static __inline __m128i __DEFAULT_FN_ATTRS128
-_mm_mask_cvtps_ph (__m128i __W, __mmask8 __U, __m128 __A)
-{
-  return (__m128i) __builtin_ia32_vcvtps2ph_mask ((__v4sf) __A, 
_MM_FROUND_CUR_DIRECTION,
-  (__v8hi) __W,
-  (__mmask8) __U);
-}
-
-static __inline __m128i __DEFAULT_FN_ATTRS128
-_mm_maskz_cvtps_ph (__mmask8 __U, __m128 __A)
-{
-  return (__m128i) __builtin_ia32_vcvtps2ph_mask ((__v4sf) __A, 
_MM_FROUND_CUR_DIRECTION,
-  (__v8hi) _mm_setzero_si128 
(),
-  (__mmask8) __U);
-}
-
 #define _mm_mask_cvt_roundps_ph(W, U, A, I) \
   (__m128i)__builtin_ia32_vcvtps2ph_mask((__v4sf)(__m128)(A), (int)(I), \
  (__v8hi)(__m128i)(W), \
@@ -8437,21 +8421,9 @@ _mm_maskz_cvtps_ph (__mmask8 __U, __m128
  (__v8hi)_mm_setzero_si128(), \
  (__mmask8)(U))
 
-static __inline __m128i __DEFAULT_FN_ATTRS256
-_mm256_mask_cvtps_ph (__m128i __W, __mmask8 __U, __m256 __A)
-{
-  return (__m128i) __builtin_ia32_vcvtps2ph256_mask ((__v8sf) __A, 
_MM_FROUND_CUR_DIRECTION,
-  (__v8hi) __W,
-  (__mmask8) __U);
-}
+#define _mm_mask_cvtps_ph  _mm_mask_cvt_roundps_ph
+#define _mm_maskz_cvtps_ph _mm_maskz_cvt_roundps_ph
 
-static __inline __m128i __DEFAULT_FN_ATTRS256
-_mm256_maskz_cvtps_ph ( __mmask8 __U, __m256 __A)
-{
-  return (__m128i) __builtin_ia32_vcvtps2ph256_mask ((__v8sf) __A, 
_MM_FROUND_CUR_DIRECTION,
-  (__v8hi) 
_mm_setzero_si128(),
-  (__mmask8) __U);
-}
 #define _mm256_mask_cvt_roundps_ph(W, U, A, I) \
   (__m128i)__builtin_ia32_vcvtps2ph256_mask((__v8sf)(__m256)(A), (int)(I), \
 (__v8hi)(__m128i)(W), \
@@ -8462,6 +8434,9 @@ _mm256_maskz_cvtps_ph ( __mmask8 __U, __

[PATCH] D63108: [OpenMP] Add support for handling declare target to clause when unified memory is required

2019-06-20 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL363959: [OpenMP] Add support for handling declare target to 
clause when unified memory… (authored by gbercea, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D63108

Files:
  cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
  cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/test/OpenMP/declare_target_codegen.cpp
  cfe/trunk/test/OpenMP/declare_target_link_codegen.cpp
  cfe/trunk/test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp

Index: cfe/trunk/test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
===
--- cfe/trunk/test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
+++ cfe/trunk/test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
@@ -1,5 +1,10 @@
 // Test declare target link under unified memory requirement.
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-cuda-mode -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK
+
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-cuda-mode -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK-HOST
+
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -fopenmp-cuda-mode -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -fopenmp-cuda-mode -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_70 -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHECK-DEVICE
+
 // expected-no-diagnostics
 
 #ifndef HEADER
@@ -8,53 +13,74 @@
 #define N 1000
 
 double var = 10.0;
+double to_var = 20.0;
 
 #pragma omp requires unified_shared_memory
 #pragma omp declare target link(var)
+#pragma omp declare target to(to_var)
 
 int bar(int n){
   double sum = 0;
 
 #pragma omp target
   for(int i = 0; i < n; i++) {
-sum += var;
+sum += var + to_var;
   }
 
   return sum;
 }
 
-// CHECK: [[VAR:@.+]] = global double 1.00e+01
-// CHECK: [[VAR_DECL_TGT_LINK_PTR:@.+]] = global double* [[VAR]]
+// CHECK-HOST: [[VAR:@.+]] = global double 1.00e+01
+// CHECK-HOST: [[VAR_DECL_TGT_LINK_PTR:@.+]] = global double* [[VAR]]
+
+// CHECK-HOST: [[TO_VAR:@.+]] = global double 2.00e+01
+// CHECK-HOST: [[VAR_DECL_TGT_TO_PTR:@.+]] = global double* [[TO_VAR]]
+
+// CHECK-HOST: [[OFFLOAD_SIZES:@.+]] = private unnamed_addr constant [2 x i64] [i64 4, i64 8]
+// CHECK-HOST: [[OFFLOAD_MAPTYPES:@.+]] = private unnamed_addr constant [2 x i64] [i64 800, i64 800]
+
+// CHECK-HOST: [[OMP_OFFLOAD_ENTRY_LINK_VAR_PTR_NAME:@.+]] = internal unnamed_addr constant [21 x i8]
+// CHECK-HOST: [[OMP_OFFLOAD_ENTRY_LINK_VAR_PTR:@.+]] = weak constant %struct.__tgt_offload_entry { i8* bitcast (double** [[VAR_DECL_TGT_LINK_PTR]] to i8*), i8* getelementptr inbounds ([21 x i8], [21 x i8]* [[OMP_OFFLOAD_ENTRY_LINK_VAR_PTR_NAME]], i32 0, i32 0), i64 8, i32 1, i32 0 }, section ".omp_offloading.entries"
+
+// CHECK-HOST: [[OMP_OFFLOAD_ENTRY_TO_VAR_PTR_NAME:@.+]] = internal unnamed_addr constant [24 x i8]
+// CHECK-HOST: [[OMP_OFFLOAD_ENTRY_TO_VAR_PTR:@.+]] = weak constant %struct.__tgt_offload_entry { i8* bitcast (double** [[VAR_DECL_TGT_TO_PTR]] to i8*), i8* getelementptr inbounds ([24 x i8], [24 x i8]* [[OMP_OFFLOAD_ENTRY_TO_VAR_PTR_NAME]], i32 0, i32 0), i64 8, i32 0, i32 0 }, section ".omp_offloading.entries"
+
+// CHECK-HOST: @llvm.used = appending global [2 x i8*] [i8* bitcast (double** [[VAR_DECL_TGT_LINK_PTR]] to i8*), i8* bitcast (double** [[VAR_DECL_TGT_TO_PTR]] to i8*)], section "llvm.metadata"
+
+// CHECK-HOST: [[N_CASTED:%.+]] = alloca i64
+// CHECK-HOST: [[SUM_CASTED:%.+]] = alloca i64
+
+// CHECK-HOST: [[OFFLOAD_BASEPTRS:%.+]] = alloca [2 x i8*]
+// CHECK-HOST: [[OFFLOAD_PTRS:%.+]] = alloca [2 x i8*]
+
+// CHECK-HOST: [[LOAD1:%.+]] = load i64, i64* [[N_CASTED]]
+// CHECK-HOST: [[LOAD2:%.+]] = load i64, i64* [[SUM_CASTED]]
+
+// CHECK-HOST: [[BPTR1:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OFFLOAD_BASEPTRS]], i32 0, i32 0
+// CHECK-HOST: [[BCAST1:%.+]] = bitcast i8** [[BPTR1]] to i64*
+// CHECK-HOST: store i64 [[LOAD1]], i64* [[BCAST1]]
+// CHECK-HOST: [[BPTR2:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OFFLOAD_PTRS]], i32 0, i32 0
+// CHECK-HOST: [[BCAST2:%.+]] = bitcast i8** [[BPTR2]] to i64*
+// CHECK-HOST: store i64 [[LOAD1]], i64* [[BCAST2]]
+
+// CHECK-HOST: [[BPTR3:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OFFLOAD_BASEPTRS]], i32 0, i32 1
+// 

r363959 - [OpenMP] Add support for handling declare target to clause when unified memory is required

2019-06-20 Thread Gheorghe-Teodor Bercea via cfe-commits
Author: gbercea
Date: Thu Jun 20 11:04:47 2019
New Revision: 363959

URL: http://llvm.org/viewvc/llvm-project?rev=363959=rev
Log:
[OpenMP] Add support for handling declare target to clause when unified memory 
is required

Summary:
This patch adds support for the handling of the variables under the declare 
target to clause.

The variables in this case are handled like link variables are. A pointer is 
created on the host and then mapped to the device. The runtime will then copy 
the address of the host variable in the device pointer.

Reviewers: ABataev, AlexEichenberger, caomhin

Reviewed By: ABataev

Subscribers: guansong, jdoerfert, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/OpenMP/declare_target_codegen.cpp
cfe/trunk/test/OpenMP/declare_target_link_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp

Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=363959=363958=363959=diff
==
--- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Thu Jun 20 11:04:47 2019
@@ -74,7 +74,7 @@ static void EmitDeclDestroy(CodeGenFunct
   // bails even if the attribute is not present.
   if (D.isNoDestroy(CGF.getContext()))
 return;
-  
+
   CodeGenModule  = CGF.CGM;
 
   // FIXME:  __attribute__((cleanup)) ?

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=363959=363958=363959=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Jun 20 11:04:47 2019
@@ -2295,15 +2295,22 @@ static LValue EmitThreadPrivateVarDeclLV
   return CGF.MakeAddrLValue(Addr, T, AlignmentSource::Decl);
 }
 
-static Address emitDeclTargetLinkVarDeclLValue(CodeGenFunction ,
-   const VarDecl *VD, QualType T) {
+static Address emitDeclTargetVarDeclLValue(CodeGenFunction ,
+   const VarDecl *VD, QualType T) {
   llvm::Optional Res =
   OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD);
-  if (!Res || *Res == OMPDeclareTargetDeclAttr::MT_To)
+  // Return an invalid address if variable is MT_To and unified
+  // memory is not enabled. For all other cases: MT_Link and
+  // MT_To with unified memory, return a valid address.
+  if (!Res || (*Res == OMPDeclareTargetDeclAttr::MT_To &&
+   !CGF.CGM.getOpenMPRuntime().hasRequiresUnifiedSharedMemory()))
 return Address::invalid();
-  assert(*Res == OMPDeclareTargetDeclAttr::MT_Link && "Expected link clause");
+  assert(((*Res == OMPDeclareTargetDeclAttr::MT_Link) ||
+  (*Res == OMPDeclareTargetDeclAttr::MT_To &&
+   CGF.CGM.getOpenMPRuntime().hasRequiresUnifiedSharedMemory())) &&
+ "Expected link clause OR to clause with unified memory enabled.");
   QualType PtrTy = CGF.getContext().getPointerType(VD->getType());
-  Address Addr = CGF.CGM.getOpenMPRuntime().getAddrOfDeclareTargetLink(VD);
+  Address Addr = CGF.CGM.getOpenMPRuntime().getAddrOfDeclareTargetVar(VD);
   return CGF.EmitLoadOfPointer(Addr, PtrTy->castAs());
 }
 
@@ -2359,7 +2366,7 @@ static LValue EmitGlobalVarDeclLValue(Co
   // Check if the variable is marked as declare target with link clause in
   // device codegen.
   if (CGF.getLangOpts().OpenMPIsDevice) {
-Address Addr = emitDeclTargetLinkVarDeclLValue(CGF, VD, T);
+Address Addr = emitDeclTargetVarDeclLValue(CGF, VD, T);
 if (Addr.isValid())
   return CGF.MakeAddrLValue(Addr, T, AlignmentSource::Decl);
   }

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=363959=363958=363959=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Jun 20 11:04:47 2019
@@ -2552,16 +2552,18 @@ CGOpenMPRuntime::createDispatchNextFunct
   return CGM.CreateRuntimeFunction(FnTy, Name);
 }
 
-Address CGOpenMPRuntime::getAddrOfDeclareTargetLink(const VarDecl *VD) {
+Address CGOpenMPRuntime::getAddrOfDeclareTargetVar(const VarDecl *VD) {
   if (CGM.getLangOpts().OpenMPSimd)
 return Address::invalid();
   llvm::Optional Res =
   OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD);
-  if (Res && *Res == OMPDeclareTargetDeclAttr::MT_Link) {
+  if (Res && (*Res == OMPDeclareTargetDeclAttr::MT_Link ||
+  (*Res == 

[PATCH] D63376: [clang] Small improvments after Adding APValue to ConstantExpr

2019-06-20 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:10298
+ bool AllowFold = true,
+ bool StoreResult = true);
   ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result,

Tyker wrote:
> rsmith wrote:
> > Do you need this new flag? No callers are passing it.
> the idea behind it is that not all integral constant expression benefit from 
> storing the result. i have not analyzed which benefit from it and which 
> don't. adding a FIXME would have probably be more appropriate.
It's useful to have a consistent AST representation, so I'd be inclined to at 
least always create a `ConstantExpr` node. Also, once we start allowing 
`consteval` evaluations that have side effects (for example, reflection-related 
actions that modify the AST), I think we'll need to always store the result to 
ensure we never evaluate a constant expression twice (and trigger its 
side-effects to occur twice).


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

https://reviews.llvm.org/D63376



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


[PATCH] D63361: Pretend NRVO variables are references so they can be found by debug info

2019-06-20 Thread Amy Huang via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL363952: Store a pointer to the return value in a static 
alloca and let the debugger use… (authored by akhuang, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D63361?vs=205712=205855#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D63361

Files:
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/lib/CodeGen/CGDebugInfo.h
  cfe/trunk/lib/CodeGen/CGDecl.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/test/CodeGen/arm64-microsoft-arguments.cpp
  cfe/trunk/test/CodeGenCXX/conditional-gnu-ext.cpp
  cfe/trunk/test/CodeGenCXX/debug-info-nrvo.cpp
  cfe/trunk/test/CodeGenCXX/lambda-expressions.cpp
  cfe/trunk/test/CodeGenObjC/objc-non-trivial-struct-nrvo.m
  debuginfo-tests/trunk/nrvo-string.cpp
  debuginfo-tests/trunk/win_cdb/nrvo.cpp
  llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
  llvm/trunk/test/DebugInfo/COFF/nrvo.ll

Index: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
===
--- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -1142,9 +1142,15 @@
 // If the variable has an attached offset expression, extract it.
 // FIXME: Try to handle DW_OP_deref as well.
 int64_t ExprOffset = 0;
-if (VI.Expr)
-  if (!VI.Expr->extractIfOffset(ExprOffset))
+bool Deref = false;
+if (VI.Expr) {
+  // If there is one DW_OP_deref element, use offset of 0 and keep going.
+  if (VI.Expr->getNumElements() == 1 &&
+  VI.Expr->getElement(0) == llvm::dwarf::DW_OP_deref)
+Deref = true;
+  else if (!VI.Expr->extractIfOffset(ExprOffset))
 continue;
+}
 
 // Get the frame register used and the offset.
 unsigned FrameReg = 0;
@@ -1154,6 +1160,7 @@
 // Calculate the label ranges.
 LocalVarDefRange DefRange =
 createDefRangeMem(CVReg, FrameOffset + ExprOffset);
+
 for (const InsnRange  : Scope->getRanges()) {
   const MCSymbol *Begin = getLabelBeforeInsn(Range.first);
   const MCSymbol *End = getLabelAfterInsn(Range.second);
@@ -1164,6 +1171,9 @@
 LocalVariable Var;
 Var.DIVar = VI.Var;
 Var.DefRanges.emplace_back(std::move(DefRange));
+if (Deref)
+  Var.UseReferenceType = true;
+
 recordLocalVariable(std::move(Var), Scope);
   }
 }
Index: llvm/trunk/test/DebugInfo/COFF/nrvo.ll
===
--- llvm/trunk/test/DebugInfo/COFF/nrvo.ll
+++ llvm/trunk/test/DebugInfo/COFF/nrvo.ll
@@ -0,0 +1,144 @@
+; RUN: llc < %s | FileCheck %s --check-prefix=ASM
+; RUN: llc < %s -filetype=obj | llvm-readobj - --codeview | FileCheck %s --check-prefix=OBJ
+
+; C++ source to regenerate:
+; struct Foo {
+;   Foo() = default;
+;   Foo(Foo &) { x = other.x; }
+;   int x;
+; };
+; void some_function(int);
+; Foo getFoo() {
+;   Foo foo;
+;   foo.x = 41;
+;   some_function(foo.x);
+;   return foo;
+; }
+;
+; int main() {
+;   Foo bar = getFoo();
+;   return bar.x;
+; }
+; $ clang t.cpp -S -emit-llvm -g -o t.ll
+
+; ASM-LABEL:  .long  241  # Symbol subsection for GetFoo
+; ASM:.short 4414 # Record kind: S_LOCAL
+; ASM-NEXT:   .long 4113  # TypeIndex
+; ASM-NEXT:   .short 0# Flags
+; ASM-NEXT:   .asciz "foo"
+; ASM-NEXT:   .p2align 2
+; ASM-NEXT: .Ltmp
+; ASM:.cv_def_range  .Ltmp{{.*}} .Ltmp{{.*}}, "B\021(\000\000\000"
+
+; OBJ: Subsection [
+; OBJ:   SubSectionType: Symbols (0xF1)
+; OBJ:   LocalSym {
+; OBJ: Kind: S_LOCAL (0x113E)
+; OBJ: Type: Foo& (0x1011)
+; OBJ: Flags [ (0x0)
+; OBJ: ]
+; OBJ: VarName: foo
+; OBJ:   }
+; OBJ:   DefRangeFramePointerRelSym {
+; OBJ: Kind: S_DEFRANGE_FRAMEPOINTER_REL (0x1142)
+; OBJ: Offset: 40
+; OBJ: LocalVariableAddrRange {
+; OBJ:   OffsetStart: .text+0x1D
+; OBJ:   ISectStart: 0x0
+; OBJ:   Range: 0x16
+; OBJ:   }
+
+; ModuleID = 't.cpp'
+source_filename = "t.cpp"
+target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-windows-msvc19.16.27030"
+
+%struct.Foo = type { i32 }
+
+; Function Attrs: noinline nounwind optnone uwtable
+define dso_local void @"?some_function@@YAXH@Z"(i32) #0 !dbg !8 {
+entry:
+  %.addr = alloca i32, align 4
+  store i32 %0, i32* %.addr, align 4
+  call void @llvm.dbg.declare(metadata i32* %.addr, metadata !12, metadata !DIExpression()), !dbg !13
+  ret void, !dbg !13
+}
+
+; Function Attrs: nounwind readnone speculatable
+declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
+
+; Function Attrs: noinline nounwind optnone uwtable
+define dso_local void @"?GetFoo@@YA?AUFoo@@XZ"(%struct.Foo* 

Re: [PATCH] D61879: WIP: Prototype of DSE optimizations for -ftrivial-auto-var-init

2019-06-20 Thread Vitaly Buka via cfe-commits
Not much, but it's not abandoned.
I was interrupted by other stuff.
Also I am concerned by the fact that zero initialization without any new
optimization is cheaper than pattern even with patches in progress.

On Thu, Jun 20, 2019 at 9:05 AM JF Bastien via Phabricator <
revi...@reviews.llvm.org> wrote:

> jfb added a comment.
>
> Hello! I'm still interested in this, have you been able to make any
> progress?
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D61879/new/
>
> https://reviews.llvm.org/D61879
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r363952 - Store a pointer to the return value in a static alloca and let the debugger use that

2019-06-20 Thread Amy Huang via cfe-commits
Author: akhuang
Date: Thu Jun 20 10:15:21 2019
New Revision: 363952

URL: http://llvm.org/viewvc/llvm-project?rev=363952=rev
Log:
Store a pointer to the return value in a static alloca and let the debugger use 
that
as the variable address for NRVO variables.

Subscribers: hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Added:
cfe/trunk/test/CodeGenCXX/debug-info-nrvo.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/CodeGen/arm64-microsoft-arguments.cpp
cfe/trunk/test/CodeGenCXX/conditional-gnu-ext.cpp
cfe/trunk/test/CodeGenCXX/lambda-expressions.cpp
cfe/trunk/test/CodeGenObjC/objc-non-trivial-struct-nrvo.m

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=363952=363951=363952=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Jun 20 10:15:21 2019
@@ -3835,7 +3835,8 @@ CGDebugInfo::EmitTypeForVarWithBlocksAtt
 llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const VarDecl *VD,
 llvm::Value *Storage,
 llvm::Optional ArgNo,
-CGBuilderTy ) {
+CGBuilderTy ,
+const bool UsePointerValue) {
   assert(DebugKind >= codegenoptions::LimitedDebugInfo);
   assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!");
   if (VD->hasAttr())
@@ -3940,6 +3941,16 @@ llvm::DILocalVariable *CGDebugInfo::Emit
 }
   }
 
+  // Clang stores the sret pointer provided by the caller in a static alloca.
+  // Use DW_OP_deref to tell the debugger to load the pointer and treat it as
+  // the address of the variable.
+  if (UsePointerValue) {
+assert(std::find(Expr.begin(), Expr.end(), llvm::dwarf::DW_OP_deref) ==
+   Expr.end() &&
+   "Debug info already contains DW_OP_deref.");
+Expr.push_back(llvm::dwarf::DW_OP_deref);
+  }
+
   // Create the descriptor for the variable.
   auto *D = ArgNo ? DBuilder.createParameterVariable(
 Scope, Name, *ArgNo, Unit, Line, Ty,
@@ -3958,9 +3969,10 @@ llvm::DILocalVariable *CGDebugInfo::Emit
 
 llvm::DILocalVariable *
 CGDebugInfo::EmitDeclareOfAutoVariable(const VarDecl *VD, llvm::Value *Storage,
-   CGBuilderTy ) {
+   CGBuilderTy ,
+   const bool UsePointerValue) {
   assert(DebugKind >= codegenoptions::LimitedDebugInfo);
-  return EmitDeclare(VD, Storage, llvm::None, Builder);
+  return EmitDeclare(VD, Storage, llvm::None, Builder, UsePointerValue);
 }
 
 void CGDebugInfo::EmitLabel(const LabelDecl *D, CGBuilderTy ) {

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=363952=363951=363952=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Thu Jun 20 10:15:21 2019
@@ -422,9 +422,10 @@ public:
   /// declaration.
   /// Returns a pointer to the DILocalVariable associated with the
   /// llvm.dbg.declare, or nullptr otherwise.
-  llvm::DILocalVariable *EmitDeclareOfAutoVariable(const VarDecl *Decl,
-   llvm::Value *AI,
-   CGBuilderTy );
+  llvm::DILocalVariable *
+  EmitDeclareOfAutoVariable(const VarDecl *Decl, llvm::Value *AI,
+CGBuilderTy ,
+const bool UsePointerValue = false);
 
   /// Emit call to \c llvm.dbg.label for an label.
   void EmitLabel(const LabelDecl *D, CGBuilderTy );
@@ -507,7 +508,8 @@ private:
   /// llvm.dbg.declare, or nullptr otherwise.
   llvm::DILocalVariable *EmitDeclare(const VarDecl *decl, llvm::Value *AI,
  llvm::Optional ArgNo,
- CGBuilderTy );
+ CGBuilderTy ,
+ const bool UsePointerValue = false);
 
   struct BlockByRefType {
 /// The wrapper struct used inside the __block_literal struct.

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=363952=363951=363952=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ 

[PATCH] D63613: [clang-tidy] Fail gracefully upon empty database fields

2019-06-20 Thread serge via Phabricator via cfe-commits
serge-sans-paille created this revision.
serge-sans-paille added a reviewer: alexfh.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D63613

Files:
  clang-tools-extra/test/clang-tidy/empty-database.cpp
  clang-tools-extra/test/clang-tidy/empty-database/compile_commands.json
  clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
  clang/lib/Tooling/Tooling.cpp


Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -481,7 +481,7 @@
   if (OverlayFileSystem->setCurrentWorkingDirectory(
   CompileCommand.Directory))
 llvm::report_fatal_error("Cannot chdir into \"" +
- Twine(CompileCommand.Directory) + "\n!");
+ Twine(CompileCommand.Directory) + "\"!");
 
   // Now fill the in-memory VFS with the relative file mappings so it will
   // have the correct relative paths. We never remove mappings but that
Index: clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
===
--- clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
+++ clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
@@ -150,7 +150,8 @@
 // spelling of each argument; re-rendering is lossy for aliased flags.
 // E.g. in CL mode, /W4 maps to -Wall.
 auto OptTable = clang::driver::createDriverOptTable();
-Cmd.CommandLine.emplace_back(OldArgs.front());
+if(!OldArgs.empty())
+  Cmd.CommandLine.emplace_back(OldArgs.front());
 for (unsigned Pos = 1; Pos < OldArgs.size();) {
   using namespace driver::options;
 
@@ -243,7 +244,7 @@
 }
 
 // Otherwise just check the clang executable file name.
-return llvm::sys::path::stem(CmdLine.front()).endswith_lower("cl");
+return !CmdLine.empty() && 
llvm::sys::path::stem(CmdLine.front()).endswith_lower("cl");
   }
 
   // Map the language from the --std flag to that of the -x flag.
Index: clang-tools-extra/test/clang-tidy/empty-database/compile_commands.json
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/empty-database/compile_commands.json
@@ -0,0 +1,4 @@
+[{
+"directory":"",
+"file":"/tmp/","arguments":[]
+}]
Index: clang-tools-extra/test/clang-tidy/empty-database.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/empty-database.cpp
@@ -0,0 +1,3 @@
+// RUN: not clang-tidy -p %S/empty-database %s 2>&1 | FileCheck %s
+
+// CHECK: LLVM ERROR: Cannot chdir into ""!


Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -481,7 +481,7 @@
   if (OverlayFileSystem->setCurrentWorkingDirectory(
   CompileCommand.Directory))
 llvm::report_fatal_error("Cannot chdir into \"" +
- Twine(CompileCommand.Directory) + "\n!");
+ Twine(CompileCommand.Directory) + "\"!");
 
   // Now fill the in-memory VFS with the relative file mappings so it will
   // have the correct relative paths. We never remove mappings but that
Index: clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
===
--- clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
+++ clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
@@ -150,7 +150,8 @@
 // spelling of each argument; re-rendering is lossy for aliased flags.
 // E.g. in CL mode, /W4 maps to -Wall.
 auto OptTable = clang::driver::createDriverOptTable();
-Cmd.CommandLine.emplace_back(OldArgs.front());
+if(!OldArgs.empty())
+  Cmd.CommandLine.emplace_back(OldArgs.front());
 for (unsigned Pos = 1; Pos < OldArgs.size();) {
   using namespace driver::options;
 
@@ -243,7 +244,7 @@
 }
 
 // Otherwise just check the clang executable file name.
-return llvm::sys::path::stem(CmdLine.front()).endswith_lower("cl");
+return !CmdLine.empty() && llvm::sys::path::stem(CmdLine.front()).endswith_lower("cl");
   }
 
   // Map the language from the --std flag to that of the -x flag.
Index: clang-tools-extra/test/clang-tidy/empty-database/compile_commands.json
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/empty-database/compile_commands.json
@@ -0,0 +1,4 @@
+[{
+"directory":"",
+"file":"/tmp/","arguments":[]
+}]
Index: clang-tools-extra/test/clang-tidy/empty-database.cpp
===
--- /dev/null
+++ 

[PATCH] D60974: Clang IFSO driver action.

2019-06-20 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi added a comment.

This was re-landed in r363948


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60974



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


r363948 - [clang-ifs] Clang Interface Stubs, first version (second landing attempt).

2019-06-20 Thread Puyan Lotfi via cfe-commits
Author: zer0
Date: Thu Jun 20 09:59:48 2019
New Revision: 363948

URL: http://llvm.org/viewvc/llvm-project?rev=363948=rev
Log:
[clang-ifs] Clang Interface Stubs, first version (second landing attempt).

This change reverts r363649; effectively re-landing r363626. At this point
clang::Index::CodegenNameGeneratorImpl has been refactored into
clang::AST::ASTNameGenerator. This makes it so that the previous circular link
dependency no longer exists, fixing the previous share lib
(-DBUILD_SHARED_LIBS=ON) build issue which was the reason for r363649.

Clang interface stubs (previously referred to as clang-ifsos) is a new frontend
action in clang that allows the generation of stub files that contain mangled
name info that can be used to produce a stub library. These stub libraries can
be useful for breaking up build dependencies and controlling access to a
library's internal symbols. Generation of these stubs can be invoked by:

clang -fvisibility= -emit-interface-stubs \
-interface-stub-version=

Notice that -fvisibility (along with use of visibility attributes) can be used
to control what symbols get generated. Currently the interface format is
experimental but there are a wide range of possibilities here.

Currently clang-ifs produces .ifs files that can be thought of as analogous to
object (.o) files, but just for the mangled symbol info. In a subsequent patch
I intend to add support for merging the .ifs files into one .ifs/.ifso file
that can be the input to something like llvm-elfabi to produce something like a
.so file or .dll (but without any of the code, just symbols).

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

Added:
cfe/trunk/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
cfe/trunk/test/InterfaceStubs/bad-format.cpp
cfe/trunk/test/InterfaceStubs/class-template-specialization.cpp
cfe/trunk/test/InterfaceStubs/externstatic.c
cfe/trunk/test/InterfaceStubs/function-template-specialization.cpp
cfe/trunk/test/InterfaceStubs/hidden-class-inheritance.cpp
cfe/trunk/test/InterfaceStubs/inline.c
cfe/trunk/test/InterfaceStubs/inline.h
cfe/trunk/test/InterfaceStubs/object.cpp
cfe/trunk/test/InterfaceStubs/template-namespace-function.cpp
cfe/trunk/test/InterfaceStubs/virtual.cpp
cfe/trunk/test/InterfaceStubs/visibility.cpp
cfe/trunk/test/InterfaceStubs/weak.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Driver/Types.def
cfe/trunk/include/clang/Frontend/FrontendActions.h
cfe/trunk/include/clang/Frontend/FrontendOptions.h
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CMakeLists.txt
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=363948=363947=363948=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Thu Jun 20 
09:59:48 2019
@@ -220,6 +220,8 @@ def err_module_header_file_not_found :
 def err_module_header_file_invalid :
   Error<"unexpected module header file input '%0'">, DefaultFatal;
 
+def err_interface_stubs : Error<"clang-ifs (-emit-iterface-stubs): %0">;
+
 def err_test_module_file_extension_version : Error<
   "test module file extension '%0' has different version (%1.%2) than expected 
"
   "(%3.%4)">;

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=363948=363947=363948=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Jun 20 09:59:48 2019
@@ -623,6 +623,9 @@ def emit_ast : Flag<["-"], "emit-ast">,
   HelpText<"Emit Clang AST files for source inputs">;
 def emit_llvm : Flag<["-"], "emit-llvm">, Flags<[CC1Option]>, 
Group,
   HelpText<"Use the LLVM representation for assembler and object files">;
+def emit_iterface_stubs : Flag<["-"], "emit-interface-stubs">, 
Flags<[CC1Option]>, Group,
+  HelpText<"Generate Inteface Stub Files.">;
+def iterface_stub_version_EQ : JoinedOrSeparate<["-"], 
"interface-stub-version=">, Flags<[CC1Option]>;
 def exported__symbols__list : Separate<["-"], "exported_symbols_list">;
 def e : JoinedOrSeparate<["-"], "e">, Group;
 def fPIC : Flag<["-"], "fPIC">, Group;

Modified: cfe/trunk/include/clang/Driver/Types.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Types.def?rev=363948=363947=363948=diff

[PATCH] D63607: [DO NOT SUBMIT] [clang][driver] Prototype --driver-mode=fortran support for new flang

2019-06-20 Thread Peter Waller via Phabricator via cfe-commits
peterwaller-arm added a comment.

Note: In case you see this early, the email isn't yet sent to the list. I'll 
link it here when it is, likely tomorrow.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63607



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


[PATCH] D63498: [RISC-V] Add -msave-restore and -mno-save-restore to clang driver

2019-06-20 Thread Sam Elliott via Phabricator via cfe-commits
lenary updated this revision to Diff 205846.
lenary added a comment.

- Add CHECK lines for warnings Hopefully these will work regardless of race 
conditions in the merging of stdout and stderr.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63498

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-features.c


Index: clang/test/Driver/riscv-features.c
===
--- clang/test/Driver/riscv-features.c
+++ clang/test/Driver/riscv-features.c
@@ -3,11 +3,23 @@
 
 // CHECK: fno-signed-char
 
+// RUN: %clang -target riscv32-unknown-elf -### %s 2>&1 | FileCheck %s 
-check-prefix=DEFAULT
+
 // RUN: %clang -target riscv32-unknown-elf -### %s -mrelax 2>&1 | FileCheck %s 
-check-prefix=RELAX
 // RUN: %clang -target riscv32-unknown-elf -### %s -mno-relax 2>&1 | FileCheck 
%s -check-prefix=NO-RELAX
-// RUN: %clang -target riscv32-unknown-elf -### %s 2>&1 | FileCheck %s 
-check-prefix=DEFAULT
 
 // RELAX: "-target-feature" "+relax"
 // NO-RELAX: "-target-feature" "-relax"
 // DEFAULT: "-target-feature" "+relax"
 // DEFAULT-NOT: "-target-feature" "-relax"
+
+// RUN: %clang -target riscv32-unknown-elf -### %s -msave-restore 2>&1 | 
FileCheck %s -check-prefix=SAVE-RESTORE
+// RUN: %clang -target riscv32-unknown-elf -### %s -mno-save-restore 2>&1 | 
FileCheck %s -check-prefix=NO-SAVE-RESTORE
+
+// SAVE-RESTORE: warning: the clang compiler does not support '-msave-restore'
+// DEFAULT-NOT: warning: the clang compiler does not support
+
+// SAVE-RESTORE: "-target-feature" "+save-restore"
+// NO-SAVE-RESTORE: "-target-feature" "-save-restore"
+// DEFAULT: "-target-feature" "-save-restore"
+// DEFAULT-NOT: "-target-feature" "+save-restore"
\ No newline at end of file
Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -358,6 +358,16 @@
   else
 Features.push_back("-relax");
 
+  // -mno-save-restore is default, unless -msave-restore is specified.
+  if (Args.hasFlag(options::OPT_msave_restore, options::OPT_mno_save_restore, 
false)) {
+Features.push_back("+save-restore");
+// ... but we don't yet support +save-restore, so issue a warning.
+D.Diag(diag::warn_drv_clang_unsupported)
+  << Args.getLastArg(options::OPT_msave_restore)->getAsString(Args);
+  } else {
+Features.push_back("-save-restore");
+  }
+
   // Now add any that the user explicitly requested on the command line,
   // which may override the defaults.
   handleTargetFeaturesGroup(Args, Features, 
options::OPT_m_riscv_Features_Group);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2125,6 +2125,10 @@
   HelpText<"Enable linker relaxation">;
 def mno_relax : Flag<["-"], "mno-relax">, Group,
   HelpText<"Disable linker relaxation">;
+def msave_restore : Flag<["-"], "msave-restore">, 
Group,
+  HelpText<"Enable using library calls for save and restore">;
+def mno_save_restore : Flag<["-"], "mno-save-restore">, 
Group,
+  HelpText<"Disable using library calls for save and restore">;
 
 def munaligned_access : Flag<["-"], "munaligned-access">, 
Group,
   HelpText<"Allow memory accesses to be unaligned (AArch32/AArch64 only)">;


Index: clang/test/Driver/riscv-features.c
===
--- clang/test/Driver/riscv-features.c
+++ clang/test/Driver/riscv-features.c
@@ -3,11 +3,23 @@
 
 // CHECK: fno-signed-char
 
+// RUN: %clang -target riscv32-unknown-elf -### %s 2>&1 | FileCheck %s -check-prefix=DEFAULT
+
 // RUN: %clang -target riscv32-unknown-elf -### %s -mrelax 2>&1 | FileCheck %s -check-prefix=RELAX
 // RUN: %clang -target riscv32-unknown-elf -### %s -mno-relax 2>&1 | FileCheck %s -check-prefix=NO-RELAX
-// RUN: %clang -target riscv32-unknown-elf -### %s 2>&1 | FileCheck %s -check-prefix=DEFAULT
 
 // RELAX: "-target-feature" "+relax"
 // NO-RELAX: "-target-feature" "-relax"
 // DEFAULT: "-target-feature" "+relax"
 // DEFAULT-NOT: "-target-feature" "-relax"
+
+// RUN: %clang -target riscv32-unknown-elf -### %s -msave-restore 2>&1 | FileCheck %s -check-prefix=SAVE-RESTORE
+// RUN: %clang -target riscv32-unknown-elf -### %s -mno-save-restore 2>&1 | FileCheck %s -check-prefix=NO-SAVE-RESTORE
+
+// SAVE-RESTORE: warning: the clang compiler does not support '-msave-restore'
+// DEFAULT-NOT: warning: the clang compiler does not support
+
+// SAVE-RESTORE: "-target-feature" "+save-restore"
+// NO-SAVE-RESTORE: "-target-feature" "-save-restore"
+// DEFAULT: "-target-feature" "-save-restore"
+// DEFAULT-NOT: "-target-feature" "+save-restore"
\ No newline at end of file
Index: 

[PATCH] D62574: Initial draft of target-configurable address spaces.

2019-06-20 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D62574#1534159 , @ebevhan wrote:

> >> I'll have to see if that's possible without breaking a few more 
> >> interfaces, since you can throw around Qualifiers and check for 
> >> compatibility without an ASTContext today.
> >> 
> >>> I was just thinking about testing the new logic. Should we add something 
> >>> like  `-ffake-address-space-map` 
> >>> (https://clang.llvm.org/docs/UsersManual.html#opencl-specific-options) 
> >>> that will force targets to use some implementation of fake address space 
> >>> conversions? It was quite useful in OpenCL before we added concrete 
> >>> targets with address spaces. Alternatively, we can try to use SPIR that 
> >>> is a generic Clang-only target that has address spaces.
> >> 
> >> Well, there are a couple targets which have target address spaces even 
> >> today, I think. AMDGPU should be one, right?
> > 
> > Yes, however I am not sure we will be able to test more than what we test 
> > with OpenCL. Also I am not sure AMD maintainer would be ok. Do you have any 
> > concrete idea of what to test?
>
> Well, since there is a mapping from the OpenCL address spaces to the AMDGPU 
> target spaces, I would presume that if the target spaces were used on their 
> own (via `__attribute__((address_space(1)))` for example) they should behave 
> similarly to their OpenCL counterparts. It wouldn't have to be much, just a 
> couple of type definitions and checks for implicit/explicit cast behavior.
>
> There's also the x86 case I mentioned. I'm not really sure how that feature 
> is used, though.


Ok, I think at some point you might want to test extra functionality that 
doesn't fit into OpenCL model, for example explicit conversion over 
non-overlapping address spaces? I think for this you might find useful to add 
the extra flag that switches on extra testing with "fake" setup of address 
spaces.




Comment at: include/clang/AST/ASTContext.h:2598
+  /// Returns true if address space A overlaps with B.
+  bool isAddressSpaceOverlapping(LangAS A, LangAS B) const {
+// A overlaps with B if either is a superset of the other.

Is there any advantage of keeping superset concept? Amd if yes, how do 
we position the new functionality with explicit cast?

I think I am missing a bit conceptual view... because I think we originally 
discussed to switch to implicit/explicit conversion model. Perhaps there is no 
reason to do it but I would just like to understand why? 



Comment at: lib/Sema/SemaCast.cpp:2224
+// the cast is explicitly legal as well.
+if (CStyle ? !Self.Context.isExplicitAddrSpaceConversionLegal(SrcQ, DestQ)
+   : !Self.Context.isAddressSpaceSupersetOf(DestQ, SrcQ)) {

It seems like you are changing the functionality here. Don't we need any test 
for this?



Comment at: lib/Sema/SemaCast.cpp:2319
+
+  Kind = CK_AddressSpaceConversion;
+  return TC_Success;

Btw I think this is set in:
https://reviews.llvm.org/D62299

Although I don't have any objections to changing to this.



Comment at: lib/Sema/SemaCast.cpp:2334
   // warn even though local -> generic is permitted.
-  if (Self.getLangOpts().OpenCL) {
-const Type *DestPtr, *SrcPtr;

I think you might need to update the comment above to reflect that you are 
generalizing the behavior.  


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

https://reviews.llvm.org/D62574



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


[PATCH] D62156: [Sema][PR41730] Diagnose addr space mismatch while constructing objects

2019-06-20 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia marked 2 inline comments as done.
Anastasia added inline comments.



Comment at: test/SemaCXX/address-space-ctor.cpp:11
+//expected-note@-6{{candidate constructor (the implicit move constructor) not 
viable: no known conversion from 'int' to 'MyType &&' for 1st argument}}
+//expected-note@-6{{candidate constructor ignored: cannot be used to construct 
an object in address space '__attribute__((address_space(10)))'}}
+//expected-note@-8{{candidate constructor ignored: cannot be used to construct 
an object in address space '__attribute__((address_space(10)))'}}

rjmccall wrote:
> Anastasia wrote:
> > Not sure if we should change to:
> >   cannot be used to construct an object with 
> > '__attribute__((address_space(10)))'
> > 
> > Although for OpenCL it would be ok as is.
> > 
> > Or may be it's better to add custom printing of addr spaces?
> Some sort of custom printing of address spaces would probably be best, yeah.  
> Users probably think of them as whatever custom syntax/macro they normally 
> write, not as an application of some weird attribute.  We do a similar sort 
> of thing with vector types where we generally just print them as `float4` or 
> whatever without an `aka` clause because we don't expect anyone to know about 
> those attributes.
Ok, sure. I will look into it later. Thanks!


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62156



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


[PATCH] D62738: [HIP] Support device_shadow variable

2019-06-20 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

> The problem is that we do not see generic usage of 
>  Although there is no texture specific handling on the compiler side, there 
> is texture specific handling of symbols

Please ignore this comment. It is some old comment submitted by accident.


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

https://reviews.llvm.org/D62738



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


  1   2   >