[PATCH] D69122: Add support to find out resource dir and add it as compilation args

2019-11-02 Thread Kousik Kumar via Phabricator via cfe-commits
kousikk updated this revision to Diff 227601.
kousikk added a comment.

Forgot to run clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69122

Files:
  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
@@ -12,6 +12,7 @@
 #include "clang/Tooling/DependencyScanning/DependencyScanningTool.h"
 #include "clang/Tooling/DependencyScanning/DependencyScanningWorker.h"
 #include "clang/Tooling/JSONCompilationDatabase.h"
+#include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Options.h"
 #include "llvm/Support/Program.h"
@@ -39,6 +40,64 @@
   raw_ostream 
 };
 
+class ResourceDirectoryCache {
+public:
+  /// FindResourceDir finds the resource directory relative to the clang
+  /// compiler being used in Args, by running it with "-print-resource-dir"
+  /// option and cache the results for reuse. \returns resource directory path
+  /// associated with the given invocation command or empty string if the
+  /// compiler path is NOT an absolute path.
+  std::string FindResourceDir(const tooling::CommandLineArguments ) {
+if (Args.size() < 1)
+  return "";
+
+const std::string  = Args[0];
+if (!llvm::sys::path::is_absolute(ClangBinaryPath))
+  return "";
+
+const std::string  =
+llvm::sys::path::filename(ClangBinaryPath);
+
+std::unique_lock LockGuard(CacheLock);
+const auto  = Cache.find(ClangBinaryPath);
+if (CachedResourceDir != Cache.end())
+  return CachedResourceDir->second;
+
+std::vector PrintResourceDirArgs{ClangBinaryName,
+"-print-resource-dir"};
+llvm::SmallString<64> OutputFile, ErrorFile;
+llvm::sys::fs::createTemporaryFile("print-resource-dir-output",
+   "" /*no-suffix*/, OutputFile);
+llvm::sys::fs::createTemporaryFile("print-resource-dir-error",
+   "" /*no-suffix*/, ErrorFile);
+llvm::FileRemover OutputRemover(OutputFile.c_str());
+llvm::FileRemover ErrorRemover(ErrorFile.c_str());
+llvm::Optional Redirects[] = {
+{""}, // Stdin
+StringRef(OutputFile),
+StringRef(ErrorFile),
+};
+if (const int RC = llvm::sys::ExecuteAndWait(
+ClangBinaryPath, PrintResourceDirArgs, {}, Redirects)) {
+  auto ErrorBuf = llvm::MemoryBuffer::getFile(ErrorFile.c_str());
+  llvm::errs() << ErrorBuf.get()->getBuffer();
+  return "";
+}
+
+auto OutputBuf = llvm::MemoryBuffer::getFile(OutputFile.c_str());
+if (!OutputBuf)
+  return "";
+StringRef Output = OutputBuf.get()->getBuffer().rtrim('\n');
+
+Cache[ClangBinaryPath] = Output.str();
+return Cache[ClangBinaryPath];
+  }
+
+private:
+  std::map Cache;
+  std::mutex CacheLock;
+};
+
 llvm::cl::opt Help("h", llvm::cl::desc("Alias for -help"),
  llvm::cl::Hidden);
 
@@ -169,12 +228,15 @@
   auto AdjustingCompilations =
   std::make_unique(
   std::move(Compilations));
+  ResourceDirectoryCache ResourceDirCache;
   AdjustingCompilations->appendArgumentsAdjuster(
-  [](const tooling::CommandLineArguments , StringRef FileName) {
+  [](const tooling::CommandLineArguments ,
+  StringRef FileName) {
 std::string LastO = "";
 bool HasMT = false;
 bool HasMQ = false;
 bool HasMD = false;
+bool HasResourceDir = false;
 // We need to find the last -o value.
 if (!Args.empty()) {
   std::size_t Idx = Args.size() - 1;
@@ -188,6 +250,8 @@
 HasMQ = true;
   if (Args[Idx] == "-MD")
 HasMD = true;
+  if (Args[Idx] == "-resource-dir")
+HasResourceDir = true;
 }
 --Idx;
   }
@@ -215,6 +279,15 @@
 AdjustedArgs.push_back("-Xclang");
 AdjustedArgs.push_back("-sys-header-deps");
 AdjustedArgs.push_back("-Wno-error");
+
+if (!HasResourceDir) {
+  const std::string  =
+  ResourceDirCache.FindResourceDir(Args);
+  if (!ResourceDir.empty()) {
+AdjustedArgs.push_back("-resource-dir");
+AdjustedArgs.push_back(ResourceDir);
+  }
+}
 return AdjustedArgs;
   });
   AdjustingCompilations->appendArgumentsAdjuster(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69122: Add support to find out resource dir and add it as compilation args

2019-11-02 Thread Kousik Kumar via Phabricator via cfe-commits
kousikk updated this revision to Diff 227600.
kousikk marked an inline comment as done.
kousikk added a comment.

@BigCheese - thanks, all the three points make sense!

> An alternative would be to only do FindResourceDir when given an absolute 
> path to a compiler, instead of trying to guess. I think I prefer this 
> approach, as if you have an installed clang in your path, there should be a 
> clang-scan-deps next to it, which would use the same resource dir.

I really like the idea of adding resource-dir only if the given clang path is 
an absolute path.
As you pointed out, this probably solves all the three concerns you mentioned.

Updated the patch with the change and reverted changes to clang/lib/Tooling.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69122

Files:
  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
@@ -13,6 +13,7 @@
 #include "clang/Tooling/DependencyScanning/DependencyScanningWorker.h"
 #include "clang/Tooling/JSONCompilationDatabase.h"
 #include "llvm/Support/InitLLVM.h"
+#include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/Options.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/Signals.h"
@@ -39,6 +40,59 @@
   raw_ostream 
 };
 
+class ResourceDirectoryCache {
+public:
+  /// FindResourceDir finds the resource directory relative to the clang compiler
+  /// being used in Args, by running it with "-print-resource-dir" option and
+  /// cache the results for reuse.
+  /// \returns resource directory path associated with the given invocation command or empty string if the compiler path is NOT an absolute path.
+  std::string FindResourceDir(const tooling::CommandLineArguments ) {
+if (Args.size() < 1)
+  return "";
+
+const std::string  = Args[0];
+if (!llvm::sys::path::is_absolute(ClangBinaryPath))
+  return "";
+
+const std::string  =
+llvm::sys::path::filename(ClangBinaryPath);
+
+std::unique_lock LockGuard(CacheLock);
+const auto& CachedResourceDir = Cache.find(ClangBinaryPath);
+if (CachedResourceDir != Cache.end())
+  return CachedResourceDir->second;
+
+std::vector PrintResourceDirArgs{ClangBinaryName, "-print-resource-dir"};
+llvm::SmallString<64> OutputFile, ErrorFile;
+llvm::sys::fs::createTemporaryFile("print-resource-dir-output", "" /*no-suffix*/, OutputFile);
+llvm::sys::fs::createTemporaryFile("print-resource-dir-error", ""/*no-suffix*/, ErrorFile);
+llvm::FileRemover OutputRemover(OutputFile.c_str());
+llvm::FileRemover ErrorRemover(ErrorFile.c_str());
+llvm::Optional Redirects[] = {
+  {""}, //Stdin
+  StringRef(OutputFile),
+  StringRef(ErrorFile),
+};
+if (const int RC = llvm::sys::ExecuteAndWait(ClangBinaryPath, PrintResourceDirArgs, {}, Redirects)) {
+  auto ErrorBuf = llvm::MemoryBuffer::getFile(ErrorFile.c_str());
+  llvm::errs() << ErrorBuf.get()->getBuffer();
+  return "";
+}
+
+auto OutputBuf = llvm::MemoryBuffer::getFile(OutputFile.c_str());
+if (!OutputBuf)
+  return "";
+StringRef Output = OutputBuf.get()->getBuffer().rtrim('\n');
+
+Cache[ClangBinaryPath] = Output.str();
+return Cache[ClangBinaryPath];
+  }
+
+private:
+  std::map Cache;
+  std::mutex CacheLock;
+};
+
 llvm::cl::opt Help("h", llvm::cl::desc("Alias for -help"),
  llvm::cl::Hidden);
 
@@ -169,12 +223,14 @@
   auto AdjustingCompilations =
   std::make_unique(
   std::move(Compilations));
+  ResourceDirectoryCache ResourceDirCache;
   AdjustingCompilations->appendArgumentsAdjuster(
-  [](const tooling::CommandLineArguments , StringRef FileName) {
+  [](const tooling::CommandLineArguments , StringRef FileName) {
 std::string LastO = "";
 bool HasMT = false;
 bool HasMQ = false;
 bool HasMD = false;
+bool HasResourceDir = false;
 // We need to find the last -o value.
 if (!Args.empty()) {
   std::size_t Idx = Args.size() - 1;
@@ -188,6 +244,8 @@
 HasMQ = true;
   if (Args[Idx] == "-MD")
 HasMD = true;
+  if (Args[Idx] == "-resource-dir")
+HasResourceDir = true;
 }
 --Idx;
   }
@@ -215,6 +273,14 @@
 AdjustedArgs.push_back("-Xclang");
 AdjustedArgs.push_back("-sys-header-deps");
 AdjustedArgs.push_back("-Wno-error");
+
+if (!HasResourceDir) {
+  const std::string  = ResourceDirCache.FindResourceDir(Args);
+  if (!ResourceDir.empty()) {
+AdjustedArgs.push_back("-resource-dir");
+AdjustedArgs.push_back(ResourceDir);
+  }
+}
 return 

[PATCH] D69759: [RFC][BPF] Add preserve_access_index attribute to record definition

2019-11-02 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song added a comment.

Discussed with Martin last Friday that it would be easier for CO-RE programming 
if we can annotate the structure itself. This is the RFC patch. Please let me 
whether this sounds a reasonable approach.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69759



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


[PATCH] D69759: [RFC][BPF] Add preserve_access_index attribute to record definition

2019-11-02 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song created this revision.
yonghong-song added reviewers: ast, anakryiko.
Herald added subscribers: cfe-commits, arphaman.
Herald added a project: clang.

This patch introduced a new bpf specific attribute which can
be added to struct or union definition. For example,

  struct s { ... } __attribute__((preserve_access_index));

The goal is to simplify user codes for cases
where preserve access index happens for certain struct/union,
so user does not need to use clang __builtin_preserve_access_index
for every members.

The attribute has no effect if -g is not specified.

When the attribute is specified and -g is specified, any member
access to that structure or union will be preserved through
__builtin_preserve_{struct,union}_access_index() IR intrinsics.
For bpf target, relocation will be generated.
Any access beyond member access is not preserved.

The following is an example to illustrate the usage:

  -bash-4.4$ cat t.c
  union s {
int a;
struct {
  int used1; 
  int b;
} __attribute__((preserve_access_index));
struct {
  int used2;
  int c;
};
int d[3];
  } __attribute__((preserve_access_index));
  
  int test1(union s *arg) { return arg->a; }
  int test2(union s *arg) { return arg->b; }
  int test3(union s *arg) { return arg->c; }
  int test4(union s *arg) { return arg->d[1]; }
  int test5(union s *arg) { return __builtin_preserve_access_index(arg->d[1]); }
  -bash-4.4$ clang -target bpf -O2 -S -g t.c

test1() generates a relocation for >a.
test2() generates a relocation for >b.
test3() generates a relocation for the anonymous
 struct which includes member "c", but no
 relocation is generated for anonymous structure
 member "c" access.
test4() generates a relocation for >d, but
 no relocation is generated for array acceess
 with index 1.
test5() generates a relocation for >d[1].


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69759

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/Sema/SemaDeclAttr.cpp

Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -5700,6 +5700,19 @@
   handleSimpleAttribute(S, D, AL);
 }
 
+static void handleBPFPreserveAccessIndex(Sema , Decl *D, const ParsedAttr ) {
+  if (!isa(D)) {
+S.Diag(D->getLocation(), diag::err_preserve_access_index_wrong_type)
+<< "preserve_addess_index" << "struct or union type";
+return;
+  }
+
+  if (!checkAttributeNumArgs(S, AL, 0))
+return;
+
+  D->addAttr(::new (S.Context) BPFPreserveAccessIndexAttr(S.Context, AL));
+}
+
 static void handleWebAssemblyImportModuleAttr(Sema , Decl *D, const ParsedAttr ) {
   if (!isFunctionOrMethod(D)) {
 S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type)
@@ -6576,6 +6589,9 @@
   case ParsedAttr::AT_AVRSignal:
 handleAVRSignalAttr(S, D, AL);
 break;
+  case ParsedAttr::AT_BPFPreserveAccessIndex:
+handleBPFPreserveAccessIndex(S, D, AL);
+break;
   case ParsedAttr::AT_WebAssemblyImportModule:
 handleWebAssemblyImportModuleAttr(S, D, AL);
 break;
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -3992,12 +3992,13 @@
 const CGBitFieldInfo  = RL.getBitFieldInfo(field);
 Address Addr = base.getAddress();
 unsigned Idx = RL.getLLVMFieldNo(field);
-if (!IsInPreservedAIRegion) {
+const RecordDecl *rec = field->getParent();
+if (!IsInPreservedAIRegion &&
+(!getDebugInfo() || !rec->hasAttr())) {
   if (Idx != 0)
 // For structs, we GEP to the field that the record layout suggests.
 Addr = Builder.CreateStructGEP(Addr, Idx, field->getName());
 } else {
-  const RecordDecl *rec = field->getParent();
   llvm::DIType *DbgInfo = getDebugInfo()->getOrCreateRecordType(
   getContext().getRecordType(rec), rec->getLocation());
   Addr = Builder.CreatePreserveStructAccessIndex(Addr, Idx,
@@ -4080,7 +4081,8 @@
   addr = Address(Builder.CreateLaunderInvariantGroup(addr.getPointer()),
  addr.getAlignment());
 
-if (IsInPreservedAIRegion) {
+if (IsInPreservedAIRegion ||
+(getDebugInfo() && rec->hasAttr())) {
   // Remember the original union field index
   llvm::DIType *DbgInfo = getDebugInfo()->getOrCreateRecordType(
   getContext().getRecordType(rec), rec->getLocation());
@@ -4094,7 +4096,8 @@
   addr = Builder.CreateElementBitCast(
   addr, CGM.getTypes().ConvertTypeForMem(FieldType), field->getName());
   } else {
-if (!IsInPreservedAIRegion)
+if (!IsInPreservedAIRegion &&
+(!getDebugInfo() || !rec->hasAttr()))
   // For structs, we GEP to the field that the record layout 

[PATCH] D69756: [opaque pointer types] Add element type argument to IRBuilder CreatePreserveStructAccessIndex and CreatePreserveArrayAccessIndex

2019-11-02 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm accepted this revision.
arsenm added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: wdng.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69756



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


[PATCH] D69758: [Gnu toolchain] Look at standard GCC paths for libstdcxx by default

2019-11-02 Thread Samuel Thibault via Phabricator via cfe-commits
sthibaul created this revision.
sthibaul added a reviewer: kristina.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Linux' current addLibCxxIncludePaths and addLibStdCxxIncludePaths are
actually almost non-Linux-specific at all, and can be reused almost as such
for all gcc toolchains. Only keep Android/Freescale/Cray hacks in Linux'
version.


Repository:
  rC Clang

https://reviews.llvm.org/D69758

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Gnu.h
  clang/lib/Driver/ToolChains/Hurd.cpp
  clang/lib/Driver/ToolChains/Hurd.h
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChains/Linux.h

Index: clang/lib/Driver/ToolChains/Linux.h
===
--- clang/lib/Driver/ToolChains/Linux.h
+++ clang/lib/Driver/ToolChains/Linux.h
@@ -26,9 +26,6 @@
   void
   AddClangSystemIncludeArgs(const llvm::opt::ArgList ,
 llvm::opt::ArgStringList ) const override;
-  void addLibCxxIncludePaths(
-  const llvm::opt::ArgList ,
-  llvm::opt::ArgStringList ) const override;
   void addLibStdCxxIncludePaths(
   const llvm::opt::ArgList ,
   llvm::opt::ArgStringList ) const override;
@@ -52,6 +49,10 @@
 protected:
   Tool *buildAssembler() const override;
   Tool *buildLinker() const override;
+
+  std::string getMultiarchTriple(const Driver ,
+ const llvm::Triple ,
+ StringRef SysRoot) const override;
 };
 
 } // end namespace toolchains
Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -37,9 +37,9 @@
 /// a target-triple directory in the library and header search paths.
 /// Unfortunately, this triple does not align with the vanilla target triple,
 /// so we provide a rough mapping here.
-static std::string getMultiarchTriple(const Driver ,
+std::string Linux::getMultiarchTriple(const Driver ,
   const llvm::Triple ,
-  StringRef SysRoot) {
+  StringRef SysRoot) const {
   llvm::Triple::EnvironmentType TargetEnvironment =
   TargetTriple.getEnvironment();
   bool IsAndroid = TargetTriple.isAndroid();
@@ -865,81 +865,23 @@
 addSystemInclude(DriverArgs, CC1Args, ResourceDirInclude);
 }
 
-static std::string DetectLibcxxIncludePath(llvm::vfs::FileSystem ,
-   StringRef base) {
-  std::error_code EC;
-  int MaxVersion = 0;
-  std::string MaxVersionString = "";
-  for (llvm::vfs::directory_iterator LI = vfs.dir_begin(base, EC), LE;
-   !EC && LI != LE; LI = LI.increment(EC)) {
-StringRef VersionText = llvm::sys::path::filename(LI->path());
-int Version;
-if (VersionText[0] == 'v' &&
-!VersionText.slice(1, StringRef::npos).getAsInteger(10, Version)) {
-  if (Version > MaxVersion) {
-MaxVersion = Version;
-MaxVersionString = VersionText;
-  }
-}
-  }
-  return MaxVersion ? (base + "/" + MaxVersionString).str() : "";
-}
-
-void Linux::addLibCxxIncludePaths(const llvm::opt::ArgList ,
-  llvm::opt::ArgStringList ) const {
-  const std::string& SysRoot = computeSysRoot();
-  const std::string LibCXXIncludePathCandidates[] = {
-  DetectLibcxxIncludePath(getVFS(), getDriver().Dir + "/../include/c++"),
-  // If this is a development, non-installed, clang, libcxx will
-  // not be found at ../include/c++ but it likely to be found at
-  // one of the following two locations:
-  DetectLibcxxIncludePath(getVFS(), SysRoot + "/usr/local/include/c++"),
-  DetectLibcxxIncludePath(getVFS(), SysRoot + "/usr/include/c++") };
-  for (const auto  : LibCXXIncludePathCandidates) {
-if (IncludePath.empty() || !getVFS().exists(IncludePath))
-  continue;
-// Use the first candidate that exists.
-addSystemInclude(DriverArgs, CC1Args, IncludePath);
-return;
-  }
-}
-
 void Linux::addLibStdCxxIncludePaths(const llvm::opt::ArgList ,
  llvm::opt::ArgStringList ) const {
+  // Try generic GCC detection first.
+  if (Generic_GCC::addGCCLibStdCxxIncludePaths(DriverArgs, CC1Args))
+return;
+
   // We need a detected GCC installation on Linux to provide libstdc++'s
-  // headers.
+  // headers in odd Linuxish places.
   if (!GCCInstallation.isValid())
 return;
 
-  // By default, look for the C++ headers in an include directory adjacent to
-  // the lib directory of the GCC installation. Note that this is expect to be
-  // equivalent to '/usr/include/c++/X.Y' in almost all cases.
   StringRef LibDir = GCCInstallation.getParentLibPath();
-  StringRef InstallDir = GCCInstallation.getInstallPath();
   StringRef TripleStr = GCCInstallation.getTriple().str();
   const Multilib  

[PATCH] D69757: [CodeGenCXX] Don't use new PM with union-tbaa2 test

2019-11-02 Thread Petr Hosek via Phabricator via cfe-commits
phosek abandoned this revision.
phosek added a subscriber: MaskRay.
phosek added a comment.

@MaskRay already landed rGe0b3a8c991569f8c05a4edb551b8cc2942e37ea1 
 so no 
longer needed.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69757



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


[PATCH] D69755: [LLD] Add NetBSD support as a new flavor of LLD (nb.lld)

2019-11-02 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added a comment.

In D69755#1731394 , @MaskRay wrote:

> I still have the feeling that such configurations should be added to 
> clangDriver/gcc specs or a shell script wrapper of lld.


OK, as you allow now a shell wrapper of lld, this is a progress. nb.lld is a 
C++ wrapper on steroids doing the right job and part of the upstream repo (this 
is required).

We do not allow downstream LLVM/Clang/... patches in our basesystem and keeping 
this code upstream is required. Also from maintenance burden as LLVM APIs 
evolve quickly.

> How do you decide to handle "Handling of indirect shared library 
> dependencies"? It does not seem to be favored by lld contributors.

The modern Linux/GNU behavior is rejected in NetBSD and we keep the traditional 
behavior that is considered by our community as desired.

This is another topic and indeed probably our next major target to get to work 
within LLD.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69755



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


[PATCH] D69756: [opaque pointer types] Add element type argument to IRBuilder CreatePreserveStructAccessIndex and CreatePreserveArrayAccessIndex

2019-11-02 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: jyknight, t.p.northover.
Herald added subscribers: cfe-commits, arphaman.
Herald added projects: clang, LLVM.

These were the only remaining users of the GetElementPtrInst::getGEPReturnType
method that gets the element type from the pointer type.

Remove that method since its now dead.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69756

Files:
  clang/lib/CodeGen/CGBuilder.h
  clang/lib/CodeGen/CGExpr.cpp
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/Instructions.h


Index: llvm/include/llvm/IR/Instructions.h
===
--- llvm/include/llvm/IR/Instructions.h
+++ llvm/include/llvm/IR/Instructions.h
@@ -1039,11 +1039,6 @@
 
   /// Returns the pointer type returned by the GEP
   /// instruction, which may be a vector of pointers.
-  static Type *getGEPReturnType(Value *Ptr, ArrayRef IdxList) {
-return getGEPReturnType(
-  cast(Ptr->getType()->getScalarType())->getElementType(),
-  Ptr, IdxList);
-  }
   static Type *getGEPReturnType(Type *ElTy, Value *Ptr,
 ArrayRef IdxList) {
 Type *PtrTy = PointerType::get(checkGEPType(getIndexedType(ElTy, IdxList)),
Index: llvm/include/llvm/IR/IRBuilder.h
===
--- llvm/include/llvm/IR/IRBuilder.h
+++ llvm/include/llvm/IR/IRBuilder.h
@@ -2521,8 +2521,9 @@
 return V;
   }
 
-  Value *CreatePreserveArrayAccessIndex(Value *Base, unsigned Dimension,
-unsigned LastIndex, MDNode *DbgInfo) {
+  Value *CreatePreserveArrayAccessIndex(Type *ElTy, Value *Base,
+unsigned Dimension, unsigned LastIndex,
+MDNode *DbgInfo) {
 assert(isa(Base->getType()) &&
"Invalid Base ptr type for preserve.array.access.index.");
 auto *BaseType = Base->getType();
@@ -2535,7 +2536,7 @@
 IdxList.push_back(LastIndexV);
 
 Type *ResultType =
-GetElementPtrInst::getGEPReturnType(Base, IdxList);
+GetElementPtrInst::getGEPReturnType(ElTy, Base, IdxList);
 
 Module *M = BB->getParent()->getParent();
 Function *FnPreserveArrayAccessIndex = Intrinsic::getDeclaration(
@@ -2569,8 +2570,9 @@
 return Fn;
   }
 
-  Value *CreatePreserveStructAccessIndex(Value *Base, unsigned Index,
- unsigned FieldIndex, MDNode *DbgInfo) 
{
+  Value *CreatePreserveStructAccessIndex(Type *ElTy, Value *Base,
+ unsigned Index, unsigned FieldIndex,
+ MDNode *DbgInfo) {
 assert(isa(Base->getType()) &&
"Invalid Base ptr type for preserve.struct.access.index.");
 auto *BaseType = Base->getType();
@@ -2578,7 +2580,7 @@
 Value *GEPIndex = getInt32(Index);
 Constant *Zero = ConstantInt::get(Type::getInt32Ty(Context), 0);
 Type *ResultType =
-GetElementPtrInst::getGEPReturnType(Base, {Zero, GEPIndex});
+GetElementPtrInst::getGEPReturnType(ElTy, Base, {Zero, GEPIndex});
 
 Module *M = BB->getParent()->getParent();
 Function *FnPreserveStructAccessIndex = Intrinsic::getDeclaration(
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -3438,7 +3438,8 @@
 llvm::DIType *DbgInfo = nullptr;
 if (arrayType)
   DbgInfo = CGF.getDebugInfo()->getOrCreateStandaloneType(*arrayType, loc);
-eltPtr = CGF.Builder.CreatePreserveArrayAccessIndex(addr.getPointer(),
+eltPtr = CGF.Builder.CreatePreserveArrayAccessIndex(addr.getElementType(),
+addr.getPointer(),
 indices.size() - 1,
 idx, DbgInfo);
   }
Index: clang/lib/CodeGen/CGBuilder.h
===
--- clang/lib/CodeGen/CGBuilder.h
+++ clang/lib/CodeGen/CGBuilder.h
@@ -309,7 +309,7 @@
 const llvm::StructLayout *Layout = DL.getStructLayout(ElTy);
 auto Offset = CharUnits::fromQuantity(Layout->getElementOffset(Index));
 
-return Address(CreatePreserveStructAccessIndex(Addr.getPointer(),
+return Address(CreatePreserveStructAccessIndex(ElTy, Addr.getPointer(),
Index, FieldIndex, DbgInfo),
Addr.getAlignment().alignmentAtOffset(Offset));
   }


Index: llvm/include/llvm/IR/Instructions.h
===
--- llvm/include/llvm/IR/Instructions.h
+++ llvm/include/llvm/IR/Instructions.h
@@ -1039,11 +1039,6 @@
 
   /// Returns the pointer type returned by the GEP
   /// instruction, which may be a vector of pointers.
-  

[PATCH] D69757: [CodeGenCXX] Don't use new PM with union-tbaa2 test

2019-11-02 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: xbolva00, Carrot, leonardchan.
Herald added subscribers: cfe-commits, kosarev.
Herald added a project: clang.

This test started failing after D68593  landed.


Repository:
  rC Clang

https://reviews.llvm.org/D69757

Files:
  clang/test/CodeGenCXX/union-tbaa2.cpp


Index: clang/test/CodeGenCXX/union-tbaa2.cpp
===
--- clang/test/CodeGenCXX/union-tbaa2.cpp
+++ clang/test/CodeGenCXX/union-tbaa2.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -O2 -std=c++11 -triple x86_64-unknown-linux-gnu 
-target-cpu x86-64 -target-feature +sse4.2 -target-feature +avx -emit-llvm -o - 
| FileCheck %s
+// RUN: %clang_cc1 %s -O2 -fno-experimental-new-pass-manager -std=c++11 
-triple x86_64-unknown-linux-gnu -target-cpu x86-64 -target-feature +sse4.2 
-target-feature +avx -emit-llvm -o - | FileCheck %s
 
 // Testcase from llvm.org/PR32056
 


Index: clang/test/CodeGenCXX/union-tbaa2.cpp
===
--- clang/test/CodeGenCXX/union-tbaa2.cpp
+++ clang/test/CodeGenCXX/union-tbaa2.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -O2 -std=c++11 -triple x86_64-unknown-linux-gnu -target-cpu x86-64 -target-feature +sse4.2 -target-feature +avx -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O2 -fno-experimental-new-pass-manager -std=c++11 -triple x86_64-unknown-linux-gnu -target-cpu x86-64 -target-feature +sse4.2 -target-feature +avx -emit-llvm -o - | FileCheck %s
 
 // Testcase from llvm.org/PR32056
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69755: [LLD] Add NetBSD support as a new flavor of LLD (nb.lld)

2019-11-02 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski marked an inline comment as done.
krytarowski added inline comments.



Comment at: lld/tools/nb.lld/nb.lld.cpp:94
+
+  // disable superfluous RUNPATH on NetBSD
+  args.push_back("--disable-new-dtags");

MaskRay wrote:
> You can't use DT_RUNPATH probably because the change `Add support for 
> DT_RUNPATH - it is just the same as we always have treated DT_RPATH.  
> Approved by core.` (2018-12-30) is still considered new. If you do this in 
> clangDriver, you need a comment with a TODO about the migration process.
I am pretty sure that the only reason to pick it was rust (prebuilt snapshot) 
and its hard-coding of RUNPATH. We still want to disable it everywhere always.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69755



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


[clang] e0b3a8c - [CodeGenCXX][test] Use -fno-experimental-new-pass-manager for CodeGenCXX/union-tbaa2.cpp after D68593/llvmorg-10-init-8907-gcecc0d27ad5

2019-11-02 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2019-11-02T15:58:54-07:00
New Revision: e0b3a8c991569f8c05a4edb551b8cc2942e37ea1

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

LOG: [CodeGenCXX][test] Use -fno-experimental-new-pass-manager for 
CodeGenCXX/union-tbaa2.cpp after D68593/llvmorg-10-init-8907-gcecc0d27ad5

It fails with -DENABLE_EXPERIMENTAL_NEW_PASS_MANAGER=0 builds. Temporarily use 
-fno-experimental-new-pass-manager while we are investigating the root cause.

Added: 


Modified: 
clang/test/CodeGenCXX/union-tbaa2.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/union-tbaa2.cpp 
b/clang/test/CodeGenCXX/union-tbaa2.cpp
index d3e37408c4a7..5d13ff1ad8d9 100644
--- a/clang/test/CodeGenCXX/union-tbaa2.cpp
+++ b/clang/test/CodeGenCXX/union-tbaa2.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -O2 -std=c++11 -triple x86_64-unknown-linux-gnu 
-target-cpu x86-64 -target-feature +sse4.2 -target-feature +avx -emit-llvm -o - 
| FileCheck %s
+// RUN: %clang_cc1 %s -O2 -fno-experimental-new-pass-manager -std=c++11 
-triple x86_64-unknown-linux-gnu -target-cpu x86-64 -target-feature +sse4.2 
-target-feature +avx -emit-llvm -o - | FileCheck %s
 
 // Testcase from llvm.org/PR32056
 



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


[PATCH] D69755: [LLD] Add NetBSD support as a new flavor of LLD (nb.lld)

2019-11-02 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

I still have the feeling that such configurations should be added to 
clangDriver/gcc specs or a shell script wrapper of lld.

How do you decide to handle "Handling of indirect shared library dependencies"? 
It does not seem to be favored by lld contributors.




Comment at: lld/tools/nb.lld/nb.lld.cpp:94
+
+  // disable superfluous RUNPATH on NetBSD
+  args.push_back("--disable-new-dtags");

You can't use DT_RUNPATH probably because the change `Add support for 
DT_RUNPATH - it is just the same as we always have treated DT_RPATH.  Approved 
by core.` (2018-12-30) is still considered new. If you do this in clangDriver, 
you need a comment with a TODO about the migration process.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69755



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


[PATCH] D69755: [LLD] Add NetBSD support as a new flavor of LLD (nb.lld)

2019-11-02 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski updated this revision to Diff 227593.
krytarowski added a comment.

- upload diff with wider context


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69755

Files:
  clang/lib/Driver/ToolChain.cpp
  lld/CMakeLists.txt
  lld/tools/lld/lld.cpp
  lld/tools/nb.lld/CMakeLists.txt
  lld/tools/nb.lld/Options.td
  lld/tools/nb.lld/nb.lld.cpp

Index: lld/tools/nb.lld/nb.lld.cpp
===
--- /dev/null
+++ lld/tools/nb.lld/nb.lld.cpp
@@ -0,0 +1,218 @@
+//===- nb.lld.cpp - NetBSD LLD standalone linker --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// The NetBSD flavor of LLD.
+//
+// This code wraps the default ELF/UNIX lld variation with NetBSD specific
+// customization.
+//
+//===--===//
+
+#include "llvm/ADT/Triple.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Option/Option.h"
+#include "llvm/Support/Host.h"
+#include "llvm/Support/InitLLVM.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
+#include "llvm/Support/TargetRegistry.h"
+#include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/WithColor.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace llvm;
+using namespace llvm::sys;
+
+#define LLD_PROGNAME "ld.lld"
+
+namespace {
+enum ID {
+  OPT_INVALID = 0, // This is not an option ID.
+#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  \
+   HELPTEXT, METAVAR, VALUES)  \
+  OPT_##ID,
+#include "Options.inc"
+#undef OPTION
+};
+
+#define PREFIX(NAME, VALUE) const char *const NAME[] = VALUE;
+#include "Options.inc"
+#undef PREFIX
+
+const opt::OptTable::Info InfoTable[] = {
+#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  \
+   HELPTEXT, METAVAR, VALUES)  \
+  {\
+  PREFIX,  NAME,  HELPTEXT,\
+  METAVAR, OPT_##ID,  opt::Option::KIND##Class,\
+  PARAM,   FLAGS, OPT_##GROUP, \
+  OPT_##ALIAS, ALIASARGS, VALUES},
+#include "Options.inc"
+#undef OPTION
+};
+
+class SLLDOptTable : public opt::OptTable {
+public:
+  SLLDOptTable() : OptTable(InfoTable) {}
+};
+} // namespace
+
+static Triple targetTriple;
+
+static void setTargetTriple(StringRef argv0, opt::InputArgList ) {
+  std::string targetError;
+
+  // Firstly, try to get it from program name prefix
+  std::string ProgName = llvm::sys::path::stem(argv0);
+  size_t lastComponent = ProgName.rfind('-');
+  if (lastComponent != std::string::npos) {
+std::string prefix = ProgName.substr(0, lastComponent);
+if (llvm::TargetRegistry::lookupTarget(prefix, targetError)) {
+  targetTriple = llvm::Triple(prefix);
+  return;
+}
+  }
+
+  // Secondly, use the default target triple
+  targetTriple = llvm::Triple(getDefaultTargetTriple());
+}
+
+static void appendSearchPath(std::vector , const char *path) {
+  args.push_back("--library-path");
+  args.push_back(path);
+}
+
+static void appendTargetCustomization(std::vector ) {
+  // force-disable RO segment on NetBSD due to ld.elf_so limitations
+  args.push_back("--no-rosegment");
+
+  // disable superfluous RUNPATH on NetBSD
+  args.push_back("--disable-new-dtags");
+
+  // set default image base address
+  switch (targetTriple.getArch()) {
+  case llvm::Triple::aarch64:
+  case llvm::Triple::aarch64_be:
+args.push_back("--image-base=0x20010");
+break;
+  default:
+break;
+  }
+
+  // NetBSD driver relies on the linker knowing the default search paths.
+  // Please keep this in sync with clang/lib/Driver/ToolChains/NetBSD.cpp
+  // (NetBSD::NetBSD constructor)
+  switch (targetTriple.getArch()) {
+  case llvm::Triple::x86:
+appendSearchPath(args, "=/usr/lib/i386");
+break;
+  case llvm::Triple::arm:
+  case llvm::Triple::armeb:
+  case llvm::Triple::thumb:
+  case llvm::Triple::thumbeb:
+switch (targetTriple.getEnvironment()) {
+case llvm::Triple::EABI:
+case llvm::Triple::GNUEABI:
+  appendSearchPath(args, "=/usr/lib/eabi");
+  break;
+case llvm::Triple::EABIHF:
+case llvm::Triple::GNUEABIHF:
+  appendSearchPath(args, "=/usr/lib/eabihf");
+  break;
+default:
+  appendSearchPath(args, "=/usr/lib/oabi");
+  break;
+}
+break;
+#if 0 // TODO
+  case llvm::Triple::mips64:
+  case llvm::Triple::mips64el:
+if 

[PATCH] D68074: [clang-tidy] Add readability-make-member-function-const

2019-11-02 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre marked 8 inline comments as done.
mgehre added a comment.

Thanks, fixed!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68074



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


[PATCH] D69755: [LLD] Add NetBSD support as a new flavor of LLD (nb.lld)

2019-11-02 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski created this revision.
krytarowski added reviewers: ruiu, joerg, mgorny, MaskRay.
krytarowski added a project: lld.
Herald added subscribers: llvm-commits, cfe-commits, fedor.sergeev, aheejin, 
emaste, dschuff.
Herald added projects: clang, LLVM.

The NetBSD target wraps the default Linux/ELF target with OS specific
customization. It is implemented as a light nb.lld program that
mutates arguments in argv[] and spawns ld.lld.

This flavor detects the native/current and target Triple based on
argv[0] parsing. This is prerequisite for cross-compilation, in
particular the NetBSD distribution is cross-built always.

The default configuration of the ELF target is tuned for Linux and
there is no way to costomize in-place for the NetBSD target in the
same way as FreeBSD/OpenBSD. FreeBSD whenever needed can check
emulation name ("*_fbsd") and OpenBSD calls its extensions
"PT_OPENBSD_*".

This distinct flavor is needed for NetBSD as:

- the linker MUST work in the standalone mode
- it must be useful with gcc/pcc/others out of the box
- clang NetBSD driver shall not hardcode LLD specific options
- the linker must have support for cross-building
- LLD shall be a drop-in replacement for (NetBSD-patched) GNU ld

nb.lld calls internally ld.lld and there is no code-duplication
between nb.lld and ld.lld. There is no functional or code
maintenance change for other Operating Systems, especially the ELF
ones.

Equivalent customization is already done for the Darwin mode. For
instance there are hardcoded default search paths such as "/usr/lib"
and "/Library/Frameworks" in DarwinLdDriver.cpp.

This change is a starting point for development of NetBSD support
in LLD. This is also another approach to achieve the same goal as
mutating the default LLD/ELF target based on Triple, but in a
less invasive way as everything is moved out of LLD to nb.lld now.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69755

Files:
  clang/lib/Driver/ToolChain.cpp
  lld/CMakeLists.txt
  lld/tools/lld/lld.cpp
  lld/tools/nb.lld/CMakeLists.txt
  lld/tools/nb.lld/Options.td
  lld/tools/nb.lld/nb.lld.cpp

Index: lld/tools/nb.lld/nb.lld.cpp
===
--- /dev/null
+++ lld/tools/nb.lld/nb.lld.cpp
@@ -0,0 +1,218 @@
+//===- nb.lld.cpp - NetBSD LLD standalone linker --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// The NetBSD flavor of LLD.
+//
+// This code wraps the default ELF/UNIX lld variation with NetBSD specific
+// customization.
+//
+//===--===//
+
+#include "llvm/ADT/Triple.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Option/Option.h"
+#include "llvm/Support/Host.h"
+#include "llvm/Support/InitLLVM.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
+#include "llvm/Support/TargetRegistry.h"
+#include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/WithColor.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace llvm;
+using namespace llvm::sys;
+
+#define LLD_PROGNAME "ld.lld"
+
+namespace {
+enum ID {
+  OPT_INVALID = 0, // This is not an option ID.
+#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  \
+   HELPTEXT, METAVAR, VALUES)  \
+  OPT_##ID,
+#include "Options.inc"
+#undef OPTION
+};
+
+#define PREFIX(NAME, VALUE) const char *const NAME[] = VALUE;
+#include "Options.inc"
+#undef PREFIX
+
+const opt::OptTable::Info InfoTable[] = {
+#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  \
+   HELPTEXT, METAVAR, VALUES)  \
+  {\
+  PREFIX,  NAME,  HELPTEXT,\
+  METAVAR, OPT_##ID,  opt::Option::KIND##Class,\
+  PARAM,   FLAGS, OPT_##GROUP, \
+  OPT_##ALIAS, ALIASARGS, VALUES},
+#include "Options.inc"
+#undef OPTION
+};
+
+class SLLDOptTable : public opt::OptTable {
+public:
+  SLLDOptTable() : OptTable(InfoTable) {}
+};
+} // namespace
+
+static Triple targetTriple;
+
+static void setTargetTriple(StringRef argv0, opt::InputArgList ) {
+  std::string targetError;
+
+  // Firstly, try to get it from program name prefix
+  std::string ProgName = llvm::sys::path::stem(argv0);
+  size_t lastComponent = ProgName.rfind('-');
+  if (lastComponent != std::string::npos) {
+std::string prefix = ProgName.substr(0, lastComponent);
+if (llvm::TargetRegistry::lookupTarget(prefix, targetError)) {
+  targetTriple = 

[PATCH] D69204: [OpenMP 5.0] - Extend defaultmap

2019-11-02 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen marked an inline comment as done.
cchen added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7368-7370
+  bool IsImplicit, OpenMPDefaultmapClauseModifier ImplicitBehavior =
+  OMPC_DEFAULTMAP_MODIFIER_default,
+  OpenMPDefaultmapClauseKind VariableCategory = OMPC_DEFAULTMAP_unknown,

ABataev wrote:
> Do you really need the default params values here?
I'm doing so since ImplicitBehavior and VariableCategory is only used when the  
`generateInfoForComponentList` is called inside `generateInfoForCapture`, and 
for other control flow, such as `generateInfoForComponentList` called inside 
`generateInfoForDeclareTargetLink`, we don't need to set this two argument .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69204



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


[PATCH] D69754: [hurd] Add --build-id option when enabled

2019-11-02 Thread Samuel Thibault via Phabricator via cfe-commits
sthibaul created this revision.
sthibaul added a reviewer: kristina.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D69754

Files:
  clang/lib/Driver/ToolChains/Hurd.cpp


Index: clang/lib/Driver/ToolChains/Hurd.cpp
===
--- clang/lib/Driver/ToolChains/Hurd.cpp
+++ clang/lib/Driver/ToolChains/Hurd.cpp
@@ -70,6 +70,10 @@
   const std::string OSLibDir = getOSLibDir(Triple, Args);
   const std::string MultiarchTriple = getMultiarchTriple(D, Triple, SysRoot);
 
+#ifdef ENABLE_LINKER_BUILD_ID
+  ExtraOpts.push_back("--build-id");
+#endif
+
   // If we are currently running Clang inside of the requested system root, add
   // its parent library paths to those searched.
   // FIXME: It's not clear whether we should use the driver's installed


Index: clang/lib/Driver/ToolChains/Hurd.cpp
===
--- clang/lib/Driver/ToolChains/Hurd.cpp
+++ clang/lib/Driver/ToolChains/Hurd.cpp
@@ -70,6 +70,10 @@
   const std::string OSLibDir = getOSLibDir(Triple, Args);
   const std::string MultiarchTriple = getMultiarchTriple(D, Triple, SysRoot);
 
+#ifdef ENABLE_LINKER_BUILD_ID
+  ExtraOpts.push_back("--build-id");
+#endif
+
   // If we are currently running Clang inside of the requested system root, add
   // its parent library paths to those searched.
   // FIXME: It's not clear whether we should use the driver's installed
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D55802: Change CGObjC to use objc intrinsics instead of runtime methods

2019-11-02 Thread Alina Sbirlea via cfe-commits
Following up on this, AFAICT this is working as intended on the LLVM side.

The different decision is made in GlobalsAA + MemoryDependencyAnalysis.
IIUC, the logic there is along the lines of: if I have a global G that's
"internal" ("static" in C), and an intrinsic method M, then M cannot read
from or write to G. In the LLVM IR for the test, @deallocCalled is an
internal global, @llvm.objc.autoreleasePoolPop is an intrinsic, hence
@llvm.objc.autoreleasePoolPop cannot read or write @deallocCalled.

Please note however that there are a couple of things that I found and
intend to fix in GlobalsAA, but they do not seem to affect this case.

The one problem in particular that I thought was relevant here is that the
"MayReadAnyGlobal" is not set on a path in
GlobalsAAResult::AnalyzeCallGraph, but should apply when the function is
not an intrinsic (judging by the other code paths). If
@llvm.objc.autoreleasePoolPop was not an intrinsic, then with the fix in
D69690  would resolve this miscompile.
Perhaps we should not rely on the assumption that intrinsics are restricted
to this behavior in GlobalsAA?

Best,
Alina


On Thu, Oct 17, 2019 at 3:00 PM Alina Sbirlea 
wrote:

> I only got a chance to look more into this now. I can reproduce it with
> re-inserting the "static".
>
> The miscompile is not related to MemorySSA, i.e. disabling all uses of
> MemorySSA doesn't help.
> It appears to be a GVN bug, but I haven't tracked it further than this.
>
> To repro, see attached .ll files. The only difference is the global
> variable being static or not, which in IR translates to internal or
> dso_local.
> A simple `opt -O3 AssociatedObject_O0_*.ll` shows the difference you
> mention.
>
> Reducing the pipeline, I believe the result after the following command is
> incorrect.
> `opt -globals-aa -gvn AssociatedObject_O0_*.ll`
> I'll need to dig deeper to confirm and track down the bug inside the pass.
>
>
> Thanks,
> Alina
>
>
> On Mon, Sep 30, 2019 at 4:30 AM David Chisnall <
> david.chisn...@cl.cam.ac.uk> wrote:
>
>> Hi,
>>
>> Yes, I believe it does still reproduce (at least, with the most recent
>> build that I tried).  We worked around the clang bug to make the test
>> pass:
>>
>>
>> https://github.com/gnustep/libobjc2/commit/eab35fce379eb6ab1423dbb6d7908cb782f13458#diff-7f1eea7fdb5c7c3bf21f08d1cfe98a19
>>
>> Reintroducing the 'static' on deallocCalled reduces the test case to
>> unconditionally failing the assert immediately after the pop, and DCEs
>> the rest of the code.
>>
>> David
>>
>> On 11/09/2019 01:17, Alina Sbirlea wrote:
>> > Hi David,
>> >
>> > Does this still reproduce?
>> > I'm seeing the load after the call to autoreleasePoolPop at ToT, but
>> > perhaps I'm not using the proper flags?
>> > I only checked out the github repo and did "clang
>> > -fobjc-runtime=gnustep-2.0 -O3 -emit-llvm -S
>> > libobjc2/Test/AssociatedObject.m" with a ToT clang.
>> >
>> > Thanks,
>> > Alina
>> >
>> >
>> > On Sun, Feb 24, 2019 at 9:56 AM Pete Cooper via llvm-commits
>> > mailto:llvm-comm...@lists.llvm.org>>
>> wrote:
>> >
>> > Hey David
>> >
>> > Thanks for letting me know, and analysing it this far!
>> >
>> > I also can't see anything wrong with the intrinsic.  Its just
>> > defined as:
>> >
>> > def int_objc_autoreleasePoolPop : Intrinsic<[],
>> > [llvm_ptr_ty]>;
>> >
>> >
>> > which (I believe) means it has unmodelled side effects so it should
>> > have been fine for your example.
>> >
>> > I'll try build the same file you did and see if I can reproduce.
>> >
>> > Cheers,
>> > Pete
>> >
>> >> On Feb 24, 2019, at 7:48 AM, David Chisnall via Phabricator
>> >> mailto:revi...@reviews.llvm.org>>
>> wrote:
>> >>
>> >> theraven added a comment.
>> >> Herald added a project: LLVM.
>> >>
>> >> After some bisection, it appears that this is the revision that
>> >> introduced the regression in the GNUstep Objective-C runtime test
>> >> suite that I reported on the list a few weeks ago.  In this is the
>> >> test (compiled with `-fobjc-runtime=gnustep-2.0 -O3` and an ELF
>> >> triple):
>> >>
>> >>
>> https://github.com/gnustep/libobjc2/blob/master/Test/AssociatedObject.m
>> >>
>> >> After this change, Early CSE w/ MemorySSA is determining that the
>> >> second load of `deallocCalled` is redundant.  The code goes from:
>> >>
>> >>%7 = load i1, i1* @deallocCalled, align 1
>> >>br i1 %7, label %8, label %9
>> >>
>> >>  ; :8:  ; preds = %0
>> >>call void @__assert(i8* getelementptr inbounds ([5 x i8], [5 x
>> >> i8]* @__func__.main, i64 0, i64 0), i8* getelementptr inbounds
>> >> ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 26, i8*
>> >> getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64
>> >> 0)) #5
>> >>unreachable
>> >>
>> >>  ; :9:  ; preds = %0
>> >>   

[clang] d0f3c82 - Fix uninitialized variable warnings. NFCI.

2019-11-02 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2019-11-02T18:03:21Z
New Revision: d0f3c822160e36e10588bc86dabde6ab8d63cf10

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

LOG: Fix uninitialized variable warnings. NFCI.

Added: 


Modified: 
clang/utils/TableGen/ClangDiagnosticsEmitter.cpp

Removed: 




diff  --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp 
b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
index 778375010041..f694c3e4380a 100644
--- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
+++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
@@ -134,7 +134,7 @@ namespace {
 
 const Record *ExplicitDef;
 
-GroupInfo() : ExplicitDef(nullptr) {}
+GroupInfo() : IDNo(0), ExplicitDef(nullptr) {}
   };
 } // end anonymous namespace.
 
@@ -554,7 +554,7 @@ struct SelectPiece : Piece {
 
   ModifierType ModKind;
   std::vector Options;
-  int Index;
+  int Index = 0;
 
   static bool classof(const Piece *P) {
 return P->getPieceClass() == SelectPieceClass ||
@@ -566,7 +566,7 @@ struct PluralPiece : SelectPiece {
   PluralPiece() : SelectPiece(PluralPieceClass, MT_Plural) {}
 
   std::vector OptionPrefixes;
-  int Index;
+  int Index = 0;
 
   static bool classof(const Piece *P) {
 return P->getPieceClass() == PluralPieceClass;



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


[PATCH] D69752: clang-format: Add a fallback style to Emacs mode

2019-11-02 Thread Mikhail Gusarov via Phabricator via cfe-commits
dottedmag created this revision.
dottedmag added a reviewer: djasper.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This allows one to enable `clang-format-buffer` on file save and avoid
reformatting files that are outside of any project with .clang-format style.


Repository:
  rC Clang

https://reviews.llvm.org/D69752

Files:
  tools/clang-format/clang-format.el


Index: tools/clang-format/clang-format.el
===
--- tools/clang-format/clang-format.el
+++ tools/clang-format/clang-format.el
@@ -57,6 +57,18 @@
   :safe #'stringp)
 (make-variable-buffer-local 'clang-format-style)
 
+(defcustom clang-format-fallback-style "none"
+  "Fallback style to pass to clang-format.
+
+This style will be used if clang-format-style is set to \"file\"
+and no .clang-format is found in the directory of the buffer or
+one of parent directories. Set to \"none\" to disable formatting
+in such buffers."
+  :group 'clang-format
+  :type 'string
+  :safe #'stringp)
+(make-variable-buffer-local 'clang-format-fallback-style)
+
 (defun clang-format--extract (xml-node)
   "Extract replacements and cursor information from XML-NODE."
   (unless (and (listp xml-node) (eq (xml-node-name xml-node) 'replacements))
@@ -162,6 +174,7 @@
,@(and assume-file-name
   (list "-assume-filename" 
assume-file-name))
,@(and style (list "-style" style))
+   "-fallback-style" ,clang-format-fallback-style
"-offset" ,(number-to-string file-start)
"-length" ,(number-to-string (- file-end 
file-start))
"-cursor" ,(number-to-string cursor


Index: tools/clang-format/clang-format.el
===
--- tools/clang-format/clang-format.el
+++ tools/clang-format/clang-format.el
@@ -57,6 +57,18 @@
   :safe #'stringp)
 (make-variable-buffer-local 'clang-format-style)
 
+(defcustom clang-format-fallback-style "none"
+  "Fallback style to pass to clang-format.
+
+This style will be used if clang-format-style is set to \"file\"
+and no .clang-format is found in the directory of the buffer or
+one of parent directories. Set to \"none\" to disable formatting
+in such buffers."
+  :group 'clang-format
+  :type 'string
+  :safe #'stringp)
+(make-variable-buffer-local 'clang-format-fallback-style)
+
 (defun clang-format--extract (xml-node)
   "Extract replacements and cursor information from XML-NODE."
   (unless (and (listp xml-node) (eq (xml-node-name xml-node) 'replacements))
@@ -162,6 +174,7 @@
,@(and assume-file-name
   (list "-assume-filename" assume-file-name))
,@(and style (list "-style" style))
+   "-fallback-style" ,clang-format-fallback-style
"-offset" ,(number-to-string file-start)
"-length" ,(number-to-string (- file-end file-start))
"-cursor" ,(number-to-string cursor
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69498: IR: Invert convergent attribute handling

2019-11-02 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

In D69498#1727650 , @dexonsmith wrote:

> In D69498#1723606 , @rjmccall wrote:
>
> > Perhaps there should be a global metadata, or something in the 
> > increasingly-misnamed "data layout" string, which says that convergence is 
> > meaningful, and we should only add the attribute in appropriately-annotated 
> > modules?
>
>
> Just wanted to resurface these alternatives from John.  Given that some 
> targets want a fundamentally different default from what most frontends 
> expect, I think we ought to find some way to encode the difference.


Just thought about a slight variation on this: what about adding a flag on the 
datalayout (or a module flag) but not use it in the transformations/analyses, 
instead use it only when creating Function by always setting the `convergent` 
attribute when the flag is present? This would require to always have a Module 
passed to the Function constructor though (the C API already does, we would 
just need to update the C++ users).

So creating a Function in a Module with this flag would have the convergent 
attribute set on creation (can be unset explicitly).


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

https://reviews.llvm.org/D69498



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


[PATCH] D69750: make -ftime-trace also trace time spent creating debug info

2019-11-02 Thread Luboš Luňák via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4f2104c5adbc: make -ftime-trace also trace time spent 
creating debug info (authored by llunak).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69750

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp


Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -46,6 +46,7 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MD5.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/TimeProfiler.h"
 using namespace clang;
 using namespace clang::CodeGen;
 
@@ -2968,6 +2969,13 @@
   if (Ty.isNull())
 return nullptr;
 
+  llvm::TimeTraceScope TimeScope("DebugType", [&]() {
+std::string Name;
+llvm::raw_string_ostream OS(Name);
+Ty.print(OS, getPrintingPolicy());
+return Name;
+  });
+
   // Unwrap the type as needed for debug information.
   Ty = UnwrapTypeForDebugInfo(Ty, CGM.getContext());
 
@@ -3686,6 +3694,15 @@
   if (!D)
 return;
 
+  llvm::TimeTraceScope TimeScope("DebugFunction", [&]() {
+std::string Name;
+llvm::raw_string_ostream OS(Name);
+if (const NamedDecl *ND = dyn_cast(D))
+  ND->getNameForDiagnostic(OS, getPrintingPolicy(),
+   /*Qualified=*/true);
+return Name;
+  });
+
   llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
   llvm::DIFile *Unit = getOrCreateFile(Loc);
   bool IsDeclForCallSite = Fn ? true : false;
@@ -4406,6 +4423,14 @@
   if (D->hasAttr())
 return;
 
+  llvm::TimeTraceScope TimeScope("DebugGlobalVariable", [&]() {
+std::string Name;
+llvm::raw_string_ostream OS(Name);
+D->getNameForDiagnostic(OS, getPrintingPolicy(),
+/*Qualified=*/true);
+return Name;
+  });
+
   // If we already created a DIGlobalVariable for this declaration, just attach
   // it to the llvm::GlobalVariable.
   auto Cached = DeclCache.find(D->getCanonicalDecl());
@@ -4466,6 +4491,14 @@
   assert(DebugKind >= codegenoptions::LimitedDebugInfo);
   if (VD->hasAttr())
 return;
+  llvm::TimeTraceScope TimeScope("DebugConstGlobalVariable", [&]() {
+std::string Name;
+llvm::raw_string_ostream OS(Name);
+VD->getNameForDiagnostic(OS, getPrintingPolicy(),
+ /*Qualified=*/true);
+return Name;
+  });
+
   auto Align = getDeclAlignIfRequired(VD, CGM.getContext());
   // Create the descriptor for the variable.
   llvm::DIFile *Unit = getOrCreateFile(VD->getLocation());


Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -46,6 +46,7 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MD5.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/TimeProfiler.h"
 using namespace clang;
 using namespace clang::CodeGen;
 
@@ -2968,6 +2969,13 @@
   if (Ty.isNull())
 return nullptr;
 
+  llvm::TimeTraceScope TimeScope("DebugType", [&]() {
+std::string Name;
+llvm::raw_string_ostream OS(Name);
+Ty.print(OS, getPrintingPolicy());
+return Name;
+  });
+
   // Unwrap the type as needed for debug information.
   Ty = UnwrapTypeForDebugInfo(Ty, CGM.getContext());
 
@@ -3686,6 +3694,15 @@
   if (!D)
 return;
 
+  llvm::TimeTraceScope TimeScope("DebugFunction", [&]() {
+std::string Name;
+llvm::raw_string_ostream OS(Name);
+if (const NamedDecl *ND = dyn_cast(D))
+  ND->getNameForDiagnostic(OS, getPrintingPolicy(),
+   /*Qualified=*/true);
+return Name;
+  });
+
   llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
   llvm::DIFile *Unit = getOrCreateFile(Loc);
   bool IsDeclForCallSite = Fn ? true : false;
@@ -4406,6 +4423,14 @@
   if (D->hasAttr())
 return;
 
+  llvm::TimeTraceScope TimeScope("DebugGlobalVariable", [&]() {
+std::string Name;
+llvm::raw_string_ostream OS(Name);
+D->getNameForDiagnostic(OS, getPrintingPolicy(),
+/*Qualified=*/true);
+return Name;
+  });
+
   // If we already created a DIGlobalVariable for this declaration, just attach
   // it to the llvm::GlobalVariable.
   auto Cached = DeclCache.find(D->getCanonicalDecl());
@@ -4466,6 +4491,14 @@
   assert(DebugKind >= codegenoptions::LimitedDebugInfo);
   if (VD->hasAttr())
 return;
+  llvm::TimeTraceScope TimeScope("DebugConstGlobalVariable", [&]() {
+std::string Name;
+llvm::raw_string_ostream OS(Name);
+VD->getNameForDiagnostic(OS, getPrintingPolicy(),
+ /*Qualified=*/true);
+return Name;
+  });
+
   auto Align = getDeclAlignIfRequired(VD, CGM.getContext());
   // Create the descriptor for the variable.
   llvm::DIFile *Unit = getOrCreateFile(VD->getLocation());

[PATCH] D69750: make -ftime-trace also trace time spent creating debug info

2019-11-02 Thread Anton Afanasyev via Phabricator via cfe-commits
anton-afanasyev accepted this revision.
anton-afanasyev added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rC Clang

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

https://reviews.llvm.org/D69750



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


[PATCH] D69750: make -ftime-trace also trace time spent creating debug info

2019-11-02 Thread Luboš Luňák via Phabricator via cfe-commits
llunak created this revision.
llunak added a reviewer: anton-afanasyev.
llunak added a project: clang.
Herald added subscribers: cfe-commits, aprantl.

In debug builds a noticeable time can be spent generating debug info, so make 
-ftime-trace track that too.


Repository:
  rC Clang

https://reviews.llvm.org/D69750

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp


Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -46,6 +46,7 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MD5.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/TimeProfiler.h"
 using namespace clang;
 using namespace clang::CodeGen;
 
@@ -2946,6 +2947,13 @@
   if (Ty.isNull())
 return nullptr;
 
+  llvm::TimeTraceScope TimeScope("DebugType", [&]() {
+std::string Name;
+llvm::raw_string_ostream OS(Name);
+Ty.print(OS, getPrintingPolicy());
+return Name;
+  });
+
   // Unwrap the type as needed for debug information.
   Ty = UnwrapTypeForDebugInfo(Ty, CGM.getContext());
 
@@ -3664,6 +3672,15 @@
   if (!D)
 return;
 
+  llvm::TimeTraceScope TimeScope("DebugFunction", [&]() {
+std::string Name;
+llvm::raw_string_ostream OS(Name);
+if (const NamedDecl *ND = dyn_cast(D))
+  ND->getNameForDiagnostic(OS, getPrintingPolicy(),
+   /*Qualified=*/true);
+return Name;
+  });
+
   llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
   llvm::DIFile *Unit = getOrCreateFile(Loc);
   bool IsDeclForCallSite = Fn ? true : false;
@@ -4384,6 +4401,14 @@
   if (D->hasAttr())
 return;
 
+  llvm::TimeTraceScope TimeScope("DebugGlobalVariable", [&]() {
+std::string Name;
+llvm::raw_string_ostream OS(Name);
+D->getNameForDiagnostic(OS, getPrintingPolicy(),
+/*Qualified=*/true);
+return Name;
+  });
+
   // If we already created a DIGlobalVariable for this declaration, just attach
   // it to the llvm::GlobalVariable.
   auto Cached = DeclCache.find(D->getCanonicalDecl());
@@ -,6 +4469,14 @@
   assert(DebugKind >= codegenoptions::LimitedDebugInfo);
   if (VD->hasAttr())
 return;
+  llvm::TimeTraceScope TimeScope("DebugConstGlobalVariable", [&]() {
+std::string Name;
+llvm::raw_string_ostream OS(Name);
+VD->getNameForDiagnostic(OS, getPrintingPolicy(),
+ /*Qualified=*/true);
+return Name;
+  });
+
   auto Align = getDeclAlignIfRequired(VD, CGM.getContext());
   // Create the descriptor for the variable.
   llvm::DIFile *Unit = getOrCreateFile(VD->getLocation());


Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -46,6 +46,7 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MD5.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/TimeProfiler.h"
 using namespace clang;
 using namespace clang::CodeGen;
 
@@ -2946,6 +2947,13 @@
   if (Ty.isNull())
 return nullptr;
 
+  llvm::TimeTraceScope TimeScope("DebugType", [&]() {
+std::string Name;
+llvm::raw_string_ostream OS(Name);
+Ty.print(OS, getPrintingPolicy());
+return Name;
+  });
+
   // Unwrap the type as needed for debug information.
   Ty = UnwrapTypeForDebugInfo(Ty, CGM.getContext());
 
@@ -3664,6 +3672,15 @@
   if (!D)
 return;
 
+  llvm::TimeTraceScope TimeScope("DebugFunction", [&]() {
+std::string Name;
+llvm::raw_string_ostream OS(Name);
+if (const NamedDecl *ND = dyn_cast(D))
+  ND->getNameForDiagnostic(OS, getPrintingPolicy(),
+   /*Qualified=*/true);
+return Name;
+  });
+
   llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
   llvm::DIFile *Unit = getOrCreateFile(Loc);
   bool IsDeclForCallSite = Fn ? true : false;
@@ -4384,6 +4401,14 @@
   if (D->hasAttr())
 return;
 
+  llvm::TimeTraceScope TimeScope("DebugGlobalVariable", [&]() {
+std::string Name;
+llvm::raw_string_ostream OS(Name);
+D->getNameForDiagnostic(OS, getPrintingPolicy(),
+/*Qualified=*/true);
+return Name;
+  });
+
   // If we already created a DIGlobalVariable for this declaration, just attach
   // it to the llvm::GlobalVariable.
   auto Cached = DeclCache.find(D->getCanonicalDecl());
@@ -,6 +4469,14 @@
   assert(DebugKind >= codegenoptions::LimitedDebugInfo);
   if (VD->hasAttr())
 return;
+  llvm::TimeTraceScope TimeScope("DebugConstGlobalVariable", [&]() {
+std::string Name;
+llvm::raw_string_ostream OS(Name);
+VD->getNameForDiagnostic(OS, getPrintingPolicy(),
+ /*Qualified=*/true);
+return Name;
+  });
+
   auto Align = getDeclAlignIfRequired(VD, CGM.getContext());
   // Create the descriptor for the variable.
   llvm::DIFile *Unit = getOrCreateFile(VD->getLocation());

[PATCH] D69383: [RISCV] Match GCC `-march`/`-mabi` driver defaults

2019-11-02 Thread Kuan Hsu Chen (Zakk) via Phabricator via cfe-commits
khchen added a comment.

LGTM, thanks for the patch!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69383



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


[PATCH] D69585: PerformPendingInstatiations() already in the PCH

2019-11-02 Thread Luboš Luňák via Phabricator via cfe-commits
llunak updated this revision to Diff 227575.
llunak added a comment.

Let's go a different route. This patch fully passes all tests and so should be 
ready to be committed.

It does so by opting out for OpenMP, which can be handled later whenever 
somebody who know about OpenMP looks at it.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69585

Files:
  clang/lib/Sema/Sema.cpp
  clang/test/CodeGenCXX/vla-lambda-capturing.cpp


Index: clang/test/CodeGenCXX/vla-lambda-capturing.cpp
===
--- clang/test/CodeGenCXX/vla-lambda-capturing.cpp
+++ clang/test/CodeGenCXX/vla-lambda-capturing.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 %s -std=c++11 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -std=c++11 -emit-llvm -o - | FileCheck --check-prefixes 
CHECK,CHECK-NOPCH %s
 // RUN: %clang_cc1 %s -std=c++11 -emit-pch -o %t
-// RUN: %clang_cc1 %s -std=c++11 -include-pch %t -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -std=c++11 -include-pch %t -emit-llvm -o - | FileCheck 
--check-prefixes CHECK,CHECK-PCH %s
 
 #ifndef HEADER
 #define HEADER
@@ -111,14 +111,14 @@
 // CHECK: call void @llvm.stackrestore(
 // CHECK: ret void
 
-// CHECK: define linkonce_odr{{.*}} void [[F_INT_LAMBDA]]([[CAP_TYPE2]]*
-// CHECK: [[THIS:%.+]] = load [[CAP_TYPE2]]*, [[CAP_TYPE2]]**
-// CHECK: [[SIZE_REF:%.+]] = getelementptr inbounds [[CAP_TYPE2]], 
[[CAP_TYPE2]]* [[THIS]], i{{.+}} 0, i{{.+}} 0
-// CHECK: [[SIZE:%.+]] = load [[INTPTR_T]], [[INTPTR_T]]* [[SIZE_REF]]
-// CHECK: call i{{.+}}* @llvm.stacksave()
-// CHECK: alloca [[INTPTR_T]], [[INTPTR_T]] [[SIZE]]
-// CHECK: call void @llvm.stackrestore(
-// CHECK: ret void
+// CHECK-NOPCH: define linkonce_odr{{.*}} void [[F_INT_LAMBDA]]([[CAP_TYPE2]]*
+// CHECK-NOPCH: [[THIS:%.+]] = load [[CAP_TYPE2]]*, [[CAP_TYPE2]]**
+// CHECK-NOPCH: [[SIZE_REF:%.+]] = getelementptr inbounds [[CAP_TYPE2]], 
[[CAP_TYPE2]]* [[THIS]], i{{.+}} 0, i{{.+}} 0
+// CHECK-NOPCH: [[SIZE:%.+]] = load [[INTPTR_T]], [[INTPTR_T]]* [[SIZE_REF]]
+// CHECK-NOPCH: call i{{.+}}* @llvm.stacksave()
+// CHECK-NOPCH: alloca [[INTPTR_T]], [[INTPTR_T]] [[SIZE]]
+// CHECK-NOPCH: call void @llvm.stackrestore(
+// CHECK-NOPCH: ret void
 
 // CHECK: define linkonce_odr{{.*}} void [[B_INT_LAMBDA]]([[CAP_TYPE3]]*
 // CHECK: [[SIZE2_REF:%.+]] = getelementptr inbounds [[CAP_TYPE3]], 
[[CAP_TYPE3]]* [[THIS:%.+]], i{{[0-9]+}} 0, i{{[0-9]+}} 1
@@ -168,4 +168,14 @@
 // CHECK: [[MUL:%.+]] = mul {{.*}} i{{[0-9]+}} [[SIZE2]], [[SIZE1]]
 // CHECK: mul {{.*}} i{{[0-9]+}} {{[0-9]+}}, [[MUL]]
 // CHECK: ret void
+
+// CHECK-PCH: define linkonce_odr{{.*}} void [[F_INT_LAMBDA]]([[CAP_TYPE2]]*
+// CHECK-PCH: [[THIS:%.+]] = load [[CAP_TYPE2]]*, [[CAP_TYPE2]]**
+// CHECK-PCH: [[SIZE_REF:%.+]] = getelementptr inbounds [[CAP_TYPE2]], 
[[CAP_TYPE2]]* [[THIS]], i{{.+}} 0, i{{.+}} 0
+// CHECK-PCH: [[SIZE:%.+]] = load [[INTPTR_T]], [[INTPTR_T]]* [[SIZE_REF]]
+// CHECK-PCH: call i{{.+}}* @llvm.stacksave()
+// CHECK-PCH: alloca [[INTPTR_T]], [[INTPTR_T]] [[SIZE]]
+// CHECK-PCH: call void @llvm.stackrestore(
+// CHECK-PCH: ret void
+
 #endif
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -981,6 +981,14 @@
  LateParsedInstantiations.begin(),
  LateParsedInstantiations.end());
 LateParsedInstantiations.clear();
+
+// FIXME: Instantiating implicit templates already in the PCH breaks some
+// OpenMP-specific code paths, see https://reviews.llvm.org/D69585 .
+if (!LangOpts.OpenMP) {
+  llvm::TimeTraceScope TimeScope("PerformPendingInstantiations",
+ StringRef(""));
+  PerformPendingInstantiations();
+}
   }
 
   DiagnoseUnterminatedPragmaPack();


Index: clang/test/CodeGenCXX/vla-lambda-capturing.cpp
===
--- clang/test/CodeGenCXX/vla-lambda-capturing.cpp
+++ clang/test/CodeGenCXX/vla-lambda-capturing.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 %s -std=c++11 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -std=c++11 -emit-llvm -o - | FileCheck --check-prefixes CHECK,CHECK-NOPCH %s
 // RUN: %clang_cc1 %s -std=c++11 -emit-pch -o %t
-// RUN: %clang_cc1 %s -std=c++11 -include-pch %t -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -std=c++11 -include-pch %t -emit-llvm -o - | FileCheck --check-prefixes CHECK,CHECK-PCH %s
 
 #ifndef HEADER
 #define HEADER
@@ -111,14 +111,14 @@
 // CHECK: call void @llvm.stackrestore(
 // CHECK: ret void
 
-// CHECK: define linkonce_odr{{.*}} void [[F_INT_LAMBDA]]([[CAP_TYPE2]]*
-// CHECK: [[THIS:%.+]] = load [[CAP_TYPE2]]*, [[CAP_TYPE2]]**
-// CHECK: [[SIZE_REF:%.+]] = getelementptr inbounds [[CAP_TYPE2]], [[CAP_TYPE2]]* [[THIS]], i{{.+}} 0, i{{.+}} 0
-// CHECK: [[SIZE:%.+]] = load [[INTPTR_T]], 

[PATCH] D68854: [X86] add mayRaiseFPException flag and FPCW registers for X87 instructions

2019-11-02 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

@LiuChen3 @craig.topper This has broken EXPENSIVE_CHECKS builds, please can you 
take a look? 
http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-ubuntu/builds/184/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68854



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


Zorg migration to GitHub/monorepo - Done

2019-11-02 Thread Galina Kistanova via cfe-commits
Hello everyone,

Zorg migration to GitHub/monorepo is complete.

I have removed the following builders from the production build bot:

* clang-atom-d525-fedora-rel - fails to checkout from github
* clang-x64-ninja-win7 - fails to checkout from github
* polly-amd64-linux - missing git
* llvm-hexagon-elf - does not support github

The rest of the builders are working well. The whole production build
bot is back to normal.

Thank you for your patience and understanding.
Please let me know if you see any issue with the build bot.

Thanks

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