[clang] 2497d5a - Define _GNU_SOURCE for arm baremetal in C++ mode.

2022-11-03 Thread Manoj Gupta via cfe-commits

Author: Manoj Gupta
Date: 2022-11-03T13:58:47-07:00
New Revision: 2497d5aa7716a664c4f73df1980b026c906c7522

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

LOG: Define _GNU_SOURCE for arm baremetal in C++ mode.

This matches other C++ drivers e.g. Linux that define
_GNU_SOURCE. This lets clang compiler more code by default
without explicitly passing _GNU_SOURCE on command line.

Reviewed By: MaskRay

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp
index f2db186aac4cb..c38849058e13d 100644
--- a/clang/lib/Basic/Targets/ARM.cpp
+++ b/clang/lib/Basic/Targets/ARM.cpp
@@ -705,8 +705,11 @@ void ARMTargetInfo::getTargetDefines(const LangOptions 
,
   // For bare-metal none-eabi.
   if (getTriple().getOS() == llvm::Triple::UnknownOS &&
   (getTriple().getEnvironment() == llvm::Triple::EABI ||
-   getTriple().getEnvironment() == llvm::Triple::EABIHF))
+   getTriple().getEnvironment() == llvm::Triple::EABIHF)) {
 Builder.defineMacro("__ELF__");
+if (Opts.CPlusPlus)
+  Builder.defineMacro("_GNU_SOURCE");
+  }
 
   // Target properties.
   Builder.defineMacro("__REGISTER_PREFIX__", "");

diff  --git a/clang/test/Preprocessor/init-arm.c 
b/clang/test/Preprocessor/init-arm.c
index e317ffa67393d..a55d0d63a79b3 100644
--- a/clang/test/Preprocessor/init-arm.c
+++ b/clang/test/Preprocessor/init-arm.c
@@ -1450,3 +1450,8 @@
 
 // THUMB-MINGW:#define __ARM_DWARF_EH__ 1
 
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=thumbv6m-none-unknown-eabi < 
/dev/null | FileCheck -match-full-lines -check-prefix Thumbv6m-elf %s
+// Thumbv6m-elf: #define __ELF__ 1
+
+// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding 
-triple=thumbv6m-none-unknown-eabi < /dev/null | FileCheck -match-full-lines 
-check-prefix Thumbv6m-cxx %s
+// Thumbv6m-cxx: #define _GNU_SOURCE 1



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


[clang] 5e5d214 - BareMetal: detect usr/include/c++/v1 path in sysroot

2022-10-07 Thread Manoj Gupta via cfe-commits

Author: Manoj Gupta
Date: 2022-10-07T21:25:18-07:00
New Revision: 5e5d21462d1ea7dbaa13bcd9bcf0156cee45b97c

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

LOG: BareMetal: detect usr/include/c++/v1 path in sysroot

Currently baremetal driver adds /include/c++/v1
for libc++ headers. However on ChromeOS, all include files
are inside /usr/include. So add
/usr/include/c++/v1 if it exists in baremetal driver.

Reviewed By: MaskRay

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/BareMetal.cpp
clang/test/Driver/baremetal.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 7b4b5a35205f..135843463b00 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -217,12 +217,21 @@ void BareMetal::AddClangCXXStdlibIncludeArgs(const 
ArgList ,
   DriverArgs.hasArg(options::OPT_nostdincxx))
 return;
 
+  const Driver  = getDriver();
   std::string SysRoot(computeSysRoot());
   if (SysRoot.empty())
 return;
 
   switch (GetCXXStdlibType(DriverArgs)) {
   case ToolChain::CST_Libcxx: {
+// First check sysroot/usr/include/c++/v1 if it exists.
+SmallString<128> TargetDir(SysRoot);
+llvm::sys::path::append(TargetDir, "usr", "include", "c++", "v1");
+if (D.getVFS().exists(TargetDir)) {
+  addSystemInclude(DriverArgs, CC1Args, TargetDir.str());
+  break;
+}
+// Add generic path if nothing else succeeded so far.
 SmallString<128> Dir(SysRoot);
 llvm::sys::path::append(Dir, "include", "c++", "v1");
 addSystemInclude(DriverArgs, CC1Args, Dir.str());
@@ -234,9 +243,8 @@ void BareMetal::AddClangCXXStdlibIncludeArgs(const ArgList 
,
 std::error_code EC;
 Generic_GCC::GCCVersion Version = {"", -1, -1, -1, "", "", ""};
 // Walk the subdirs, and find the one with the newest gcc version:
-for (llvm::vfs::directory_iterator
- LI = getDriver().getVFS().dir_begin(Dir.str(), EC),
- LE;
+for (llvm::vfs::directory_iterator LI = D.getVFS().dir_begin(Dir.str(), 
EC),
+   LE;
  !EC && LI != LE; LI = LI.increment(EC)) {
   StringRef VersionText = llvm::sys::path::filename(LI->path());
   auto CandidateVersion = Generic_GCC::GCCVersion::Parse(VersionText);

diff  --git a/clang/test/Driver/baremetal.cpp b/clang/test/Driver/baremetal.cpp
index aded91915609..b5fc45586908 100644
--- a/clang/test/Driver/baremetal.cpp
+++ b/clang/test/Driver/baremetal.cpp
@@ -77,6 +77,22 @@
 // CHECK-V6M-NDL-SAME: 
"-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib"
 // CHECK-V6M-NDL-SAME: "-L[[RESOURCE_DIR]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
 
+// RUN: rm -rf %T/baremetal_cxx_sysroot
+// RUN: mkdir -p %T/baremetal_cxx_sysroot/usr/include/c++/v1
+// RUN: %clangxx %s -### 2>&1 \
+// RUN: --target=armv6m-none-eabi \
+// RUN: --sysroot=%T/baremetal_cxx_sysroot \
+// RUN: -stdlib=libc++ \
+// RUN:   | FileCheck --check-prefix=CHECK-V6M-LIBCXX-USR %s
+// CHECK-V6M-LIBCXX-USR: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-V6M-LIBCXX-USR-NOT: "-internal-isystem" 
"{{[^"]+}}baremetal_cxx_sysroot{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}{{[^v].*}}"
+// CHECK-V6M-LIBCXX-USR-SAME: "-internal-isystem" 
"{{[^"]+}}baremetal_cxx_sysroot{{[/\\]+}}usr{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
+// CHECK-V6M-LIBCXX-USR: "{{[^"]*}}-Bstatic"
+// CHECK-V6M-LIBCXX-USR-SAME: 
"-L{{[^"]*}}{{[/\\]+}}baremetal_cxx_sysroot{{[/\\]+}}lib"
+// CHECK-V6M-LIBCXX-USR-SAME: 
"-L[[RESOURCE_DIR]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-LIBCXX-USR-SAME: "-lc++" "-lc++abi" "-lunwind"
+// CHECK-V6M-LIBCXX-USR-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
+
 // RUN: %clangxx --target=arm-none-eabi -v 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-THREAD-MODEL
 // CHECK-THREAD-MODEL: Thread model: posix



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


[clang] 06fc5a7 - Driver: Refactor and support per target dirs in baremetal

2022-08-10 Thread Manoj Gupta via cfe-commits

Author: Manoj Gupta
Date: 2022-08-10T09:13:30-07:00
New Revision: 06fc5a7714621324b121fb3ee03ac15eb018cf99

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

LOG: Driver: Refactor and support per target dirs in baremetal

Refactor baremetal driver code to reduce the bespoke
additions and base class overrides.
This lets us use the per target runtimes like other clang
targets. E.g. clang -target armv7m-cros-none-eabi will now
be able to use the runtimes installed at
/lib/armv7m-cros-none-eabi instead of the hardcoded
path /lib/baremetal.
The older code paths should still continue to work as before if
/lib/ does not exist.

Reviewed By: MaskRay, barannikov88

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

Added: 

clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/lib/armv7m-vendor-none-eabi/libclang_rt.builtins.a

Modified: 
clang/include/clang/Driver/ToolChain.h
clang/lib/Driver/ToolChain.cpp
clang/lib/Driver/ToolChains/BareMetal.cpp
clang/lib/Driver/ToolChains/BareMetal.h
clang/test/Driver/baremetal.cpp
clang/test/Driver/print-libgcc-file-name-clangrt.c

Removed: 




diff  --git a/clang/include/clang/Driver/ToolChain.h 
b/clang/include/clang/Driver/ToolChain.h
index f20ab164531b8..8915c3b804139 100644
--- a/clang/include/clang/Driver/ToolChain.h
+++ b/clang/include/clang/Driver/ToolChain.h
@@ -532,7 +532,7 @@ class ToolChain {
 
   /// Add an additional -fdebug-prefix-map entry.
   virtual std::string GetGlobalDebugPathRemapping() const { return {}; }
-  
+
   // Return the DWARF version to emit, in the absence of arguments
   // to the contrary.
   virtual unsigned GetDefaultDwarfVersion() const { return 5; }
@@ -575,6 +575,9 @@ class ToolChain {
   /// isThreadModelSupported() - Does this target support a thread model?
   virtual bool isThreadModelSupported(const StringRef Model) const;
 
+  /// isBareMetal - Is this a bare metal target.
+  virtual bool isBareMetal() const { return false; }
+
   virtual std::string getMultiarchTriple(const Driver ,
  const llvm::Triple ,
  StringRef SysRoot) const {

diff  --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 7a4319ea680f9..bc86e5be655fe 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -422,6 +422,9 @@ static StringRef getArchNameForCompilerRTLib(const 
ToolChain ,
   const llvm::Triple  = TC.getTriple();
   bool IsWindows = Triple.isOSWindows();
 
+  if (TC.isBareMetal())
+return Triple.getArchName();
+
   if (TC.getArch() == llvm::Triple::arm || TC.getArch() == llvm::Triple::armeb)
 return (arm::getARMFloatABI(TC, Args) == arm::FloatABI::Hard && !IsWindows)
? "armhf"
@@ -459,7 +462,10 @@ StringRef ToolChain::getOSLibName() const {
 
 std::string ToolChain::getCompilerRTPath() const {
   SmallString<128> Path(getDriver().ResourceDir);
-  if (Triple.isOSUnknown()) {
+  if (isBareMetal()) {
+llvm::sys::path::append(Path, "lib", getOSLibName());
+Path += SelectedMultilib.gccSuffix();
+  } else if (Triple.isOSUnknown()) {
 llvm::sys::path::append(Path, "lib");
   } else {
 llvm::sys::path::append(Path, "lib", getOSLibName());

diff  --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 5f1638a159d52..75b06d5e7d0d5 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -92,7 +92,7 @@ static bool findRISCVMultilibs(const Driver ,
 }
 
 BareMetal::BareMetal(const Driver , const llvm::Triple ,
-   const ArgList )
+ const ArgList )
 : ToolChain(D, Triple, Args) {
   getProgramPaths().push_back(getDriver().getInstalledDir());
   if (getDriver().getInstalledDir() != getDriver().Dir)
@@ -173,21 +173,6 @@ Tool *BareMetal::buildLinker() const {
   return new tools::baremetal::Linker(*this);
 }
 
-std::string BareMetal::getCompilerRTPath() const { return getRuntimesDir(); }
-
-std::string BareMetal::buildCompilerRTBasename(const llvm::opt::ArgList &,
-   StringRef, FileType,
-   bool) const {
-  return ("libclang_rt.builtins-" + getTriple().getArchName() + ".a").str();
-}
-
-std::string BareMetal::getRuntimesDir() const {
-  SmallString<128> Dir(getDriver().ResourceDir);
-  llvm::sys::path::append(Dir, "lib", "baremetal");
-  Dir += SelectedMultilib.gccSuffix();
-  return std::string(Dir.str());
-}
-
 std::string BareMetal::computeSysRoot() const {
   if (!getDriver().SysRoot.empty())
 return getDriver().SysRoot + SelectedMultilib.osSuffix();
@@ -226,8 +211,8 @@ void 

[clang] 18432be - [Driver]: fix compiler-rt path when printing libgcc for baremetal

2020-10-14 Thread Manoj Gupta via cfe-commits

Author: Christopher Di Bella
Date: 2020-10-14T10:29:35-07:00
New Revision: 18432bea764863d1c42fd569bd3846673ee4e802

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

LOG: [Driver]: fix compiler-rt path when printing libgcc for baremetal

clang --target arm-none-eabi --print-libgcc-file-name --rtlib=compiler-rt
used to print `/path/to/lib/clang/version/lib/libclang_rt.builtins-arm.a`
but should print 
`/path/to/lib/clang/version/lib/baremetal/libclang_rt.builtins-arm.a`.
Similarly, --target armv7m-none-eabi should print libclang_rt.builtins-armv7m.a
This matches the compiler-rt file name used at link time in the
baremetal driver.

Reviewed By: manojgupta

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

Added: 


Modified: 
clang/include/clang/Driver/ToolChain.h
clang/lib/Driver/ToolChains/BareMetal.cpp
clang/lib/Driver/ToolChains/BareMetal.h
clang/test/Driver/print-libgcc-file-name-clangrt.c

Removed: 




diff  --git a/clang/include/clang/Driver/ToolChain.h 
b/clang/include/clang/Driver/ToolChain.h
index 7495e08fe6e6..4704308f0450 100644
--- a/clang/include/clang/Driver/ToolChain.h
+++ b/clang/include/clang/Driver/ToolChain.h
@@ -419,10 +419,10 @@ class ToolChain {
   getCompilerRTArgString(const llvm::opt::ArgList , StringRef Component,
  FileType Type = ToolChain::FT_Static) const;
 
-  std::string getCompilerRTBasename(const llvm::opt::ArgList ,
-StringRef Component,
-FileType Type = ToolChain::FT_Static,
-bool AddArch = true) const;
+  virtual std::string
+  getCompilerRTBasename(const llvm::opt::ArgList , StringRef Component,
+FileType Type = ToolChain::FT_Static,
+bool AddArch = true) const;
 
   // Returns target specific runtime path if it exists.
   virtual Optional getRuntimePath() const;
@@ -435,7 +435,7 @@ class ToolChain {
   std::string getArchSpecificLibPath() const;
 
   // Returns  part of above.
-  StringRef getOSLibName() const;
+  virtual StringRef getOSLibName() const;
 
   /// needsProfileRT - returns true if instrumentation profile is on.
   static bool needsProfileRT(const llvm::opt::ArgList );

diff  --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 6ed81c1e34a1..9df42061e12c 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -35,8 +35,6 @@ BareMetal::BareMetal(const Driver , const llvm::Triple 
,
 getProgramPaths().push_back(getDriver().Dir);
 }
 
-BareMetal::~BareMetal() {}
-
 /// Is the triple {arm,thumb}-none-none-{eabi,eabihf} ?
 static bool isARMBareMetal(const llvm::Triple ) {
   if (Triple.getArch() != llvm::Triple::arm &&
@@ -64,6 +62,13 @@ Tool *BareMetal::buildLinker() const {
   return new tools::baremetal::Linker(*this);
 }
 
+std::string BareMetal::getCompilerRTPath() const { return getRuntimesDir(); }
+
+std::string BareMetal::getCompilerRTBasename(const llvm::opt::ArgList &,
+ StringRef, FileType, bool) const {
+  return ("libclang_rt.builtins-" + getTriple().getArchName() + ".a").str();
+}
+
 std::string BareMetal::getRuntimesDir() const {
   SmallString<128> Dir(getDriver().ResourceDir);
   llvm::sys::path::append(Dir, "lib", "baremetal");

diff  --git a/clang/lib/Driver/ToolChains/BareMetal.h 
b/clang/lib/Driver/ToolChains/BareMetal.h
index 4c0c739307b1..0be9377134ce 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.h
+++ b/clang/lib/Driver/ToolChains/BareMetal.h
@@ -23,7 +23,7 @@ class LLVM_LIBRARY_VISIBILITY BareMetal : public ToolChain {
 public:
   BareMetal(const Driver , const llvm::Triple ,
 const llvm::opt::ArgList );
-  ~BareMetal() override;
+  ~BareMetal() override = default;
 
   static bool handlesTarget(const llvm::Triple );
 protected:
@@ -37,6 +37,14 @@ class LLVM_LIBRARY_VISIBILITY BareMetal : public ToolChain {
   bool isPICDefaultForced() const override { return false; }
   bool SupportsProfiling() const override { return false; }
 
+  StringRef getOSLibName() const override { return "baremetal"; }
+
+  std::string getCompilerRTPath() const override;
+  std::string getCompilerRTBasename(const llvm::opt::ArgList ,
+StringRef Component,
+FileType Type = ToolChain::FT_Static,
+bool AddArch = true) const override;
+
   RuntimeLibType GetDefaultRuntimeLibType() const override {
 return ToolChain::RLT_CompilerRT;
   }

diff  --git a/clang/test/Driver/print-libgcc-file-name-clangrt.c 
b/clang/test/Driver/print-libgcc-file-name-clangrt.c
index 

r371878 - Reland r371785: Add -Wpoison-system-directories warning

2019-09-13 Thread Manoj Gupta via cfe-commits
Author: manojgupta
Date: Fri Sep 13 11:00:51 2019
New Revision: 371878

URL: http://llvm.org/viewvc/llvm-project?rev=371878=rev
Log:
Reland r371785: Add -Wpoison-system-directories warning

When using clang as a cross-compiler, we should not use system
headers to do the compilation.
This CL adds support of a new warning flag -Wpoison-system-directories which
emits warnings if --sysroot is set and headers from common host system location
are used.
By default the warning is disabled.

The intention of the warning is to catch bad includes which are usually
generated by third party build system not targeting cross-compilation.
Such cases happen in Chrome OS when someone imports a new package or upgrade
one to a newer version from upstream.

This is reland of r371785 with a fix to test file.

Patch by: denik (Denis Nikitin)

Added:
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/lib/
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/lib/.keep
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/include/

cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/include/c++/

cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/include/c++/.keep
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/lib/
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/lib/gcc/

cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/lib/gcc/.keep
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/local/

cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/local/include/

cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/local/include/.keep

cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/local/lib/

cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/local/lib/.keep
cfe/trunk/test/Frontend/warning-poison-system-directories.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
cfe/trunk/lib/Frontend/InitHeaderSearch.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=371878=371877=371878=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Fri Sep 13 11:00:51 
2019
@@ -315,4 +315,9 @@ def err_unknown_analyzer_checker_or_pack
 "no analyzer checkers or packages are associated with '%0'">;
 def note_suggest_disabling_all_checkers : Note<
 "use -analyzer-disable-all-checks to disable all static analyzer 
checkers">;
+
+// Poison system directories.
+def warn_poison_system_directories : Warning <
+  "include location '%0' is unsafe for cross-compilation">,
+  InGroup>, DefaultIgnore;
 }

Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitHeaderSearch.cpp?rev=371878=371877=371878=diff
==
--- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original)
+++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Fri Sep 13 11:00:51 2019
@@ -137,6 +137,13 @@ bool InitHeaderSearch::AddUnmappedPath(c
   SmallString<256> MappedPathStorage;
   StringRef MappedPathStr = Path.toStringRef(MappedPathStorage);
 
+  // If use system headers while cross-compiling, emit the warning.
+  if (HasSysroot && (MappedPathStr.startswith("/usr/include") ||
+ MappedPathStr.startswith("/usr/local/include"))) {
+Headers.getDiags().Report(diag::warn_poison_system_directories)
+<< MappedPathStr;
+  }
+
   // Compute the DirectoryLookup type.
   SrcMgr::CharacteristicKind Type;
   if (Group == Quoted || Group == Angled || Group == IndexHeaderMap) {

Added: cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/lib/.keep
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/lib/.keep?rev=371878=auto
==
(empty)

Added: 
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/include/c++/.keep
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/include/c%2B%2B/.keep?rev=371878=auto
==
(empty)

Added: 
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/lib/gcc/.keep
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/lib/gcc/.keep?rev=371878=auto

r371799 - Revert r371785.

2019-09-12 Thread Manoj Gupta via cfe-commits
Author: manojgupta
Date: Thu Sep 12 17:28:37 2019
New Revision: 371799

URL: http://llvm.org/viewvc/llvm-project?rev=371799=rev
Log:
Revert r371785.

r371785 is causing fails on clang-hexagon-elf buildbots.

Removed:
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/
cfe/trunk/test/Frontend/warning-poison-system-directories.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
cfe/trunk/lib/Frontend/InitHeaderSearch.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=371799=371798=371799=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Thu Sep 12 17:28:37 
2019
@@ -315,9 +315,4 @@ def err_unknown_analyzer_checker_or_pack
 "no analyzer checkers or packages are associated with '%0'">;
 def note_suggest_disabling_all_checkers : Note<
 "use -analyzer-disable-all-checks to disable all static analyzer 
checkers">;
-
-// Poison system directories.
-def warn_poison_system_directories : Warning <
-  "include location '%0' is unsafe for cross-compilation">,
-  InGroup>, DefaultIgnore;
 }

Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitHeaderSearch.cpp?rev=371799=371798=371799=diff
==
--- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original)
+++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Thu Sep 12 17:28:37 2019
@@ -137,13 +137,6 @@ bool InitHeaderSearch::AddUnmappedPath(c
   SmallString<256> MappedPathStorage;
   StringRef MappedPathStr = Path.toStringRef(MappedPathStorage);
 
-  // If use system headers while cross-compiling, emit the warning.
-  if (HasSysroot && (MappedPathStr.startswith("/usr/include") ||
- MappedPathStr.startswith("/usr/local/include"))) {
-Headers.getDiags().Report(diag::warn_poison_system_directories)
-<< MappedPathStr;
-  }
-
   // Compute the DirectoryLookup type.
   SrcMgr::CharacteristicKind Type;
   if (Group == Quoted || Group == Angled || Group == IndexHeaderMap) {

Removed: cfe/trunk/test/Frontend/warning-poison-system-directories.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/warning-poison-system-directories.c?rev=371798=auto
==
--- cfe/trunk/test/Frontend/warning-poison-system-directories.c (original)
+++ cfe/trunk/test/Frontend/warning-poison-system-directories.c (removed)
@@ -1,27 +0,0 @@
-// System directory and sysroot option causes warning.
-// RUN: %clang -Wpoison-system-directories -target x86_64 -I/usr/include 
--sysroot %S/Inputs/sysroot_x86_64_cross_linux_tree -c -o - %s 2> %t.1.stderr
-// RUN: FileCheck -check-prefix=WARN < %t.1.stderr %s
-// RUN: %clang -Wpoison-system-directories -target x86_64 
-cxx-isystem/usr/include --sysroot %S/Inputs/sysroot_x86_64_cross_linux_tree -c 
-o - %s 2> %t.1.stderr
-// RUN: FileCheck -check-prefix=WARN < %t.1.stderr %s
-// RUN: %clang -Wpoison-system-directories -target x86_64 
-iquote/usr/local/include --sysroot %S/Inputs/sysroot_x86_64_cross_linux_tree 
-c -o - %s 2> %t.1.stderr
-// RUN: FileCheck -check-prefix=WARN < %t.1.stderr %s
-// RUN: %clang -Wpoison-system-directories -target x86_64 
-isystem/usr/local/include --sysroot %S/Inputs/sysroot_x86_64_cross_linux_tree 
-c -o - %s 2> %t.1.stderr
-// RUN: FileCheck -check-prefix=WARN < %t.1.stderr %s
-
-// Missing target but included sysroot still causes the warning.
-// RUN: %clang -Wpoison-system-directories -I/usr/include --sysroot 
%S/Inputs/sysroot_x86_64_cross_linux_tree -c -o - %s 2> %t.2.stderr
-// RUN: FileCheck -check-prefix=WARN < %t.2.stderr %s
-
-// With -Werror the warning causes the failure.
-// RUN: not %clang -Werror=poison-system-directories -target x86_64 
-I/usr/include --sysroot %S/Inputs/sysroot_x86_64_cross_linux_tree -c -o - %s 
2> %t.3.stderr
-// RUN: FileCheck -check-prefix=ERROR < %t.3.stderr %s
-
-// Cros target without sysroot causes no warning.
-// RUN: %clang -Wpoison-system-directories -Werror -target x86_64 
-I/usr/include -c -o - %s
-
-// By default the warning is off.
-// RUN: %clang -Werror -target x86_64 -I/usr/include --sysroot 
%S/Inputs/sysroot_x86_64_cross_linux_tree -c -o - %s
-
-// WARN: warning: include location {{[^ ]+}} is unsafe for cross-compilation 
[-Wpoison-system-directories]
-
-// ERROR: error: include location {{[^ ]+}} is unsafe for cross-compilation 
[-Werror,-Wpoison-system-directories]


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


r371785 - Add -Wpoison-system-directories warning

2019-09-12 Thread Manoj Gupta via cfe-commits
Author: manojgupta
Date: Thu Sep 12 15:36:13 2019
New Revision: 371785

URL: http://llvm.org/viewvc/llvm-project?rev=371785=rev
Log:
Add -Wpoison-system-directories warning

When using clang as a cross-compiler, we should not use system
headers to do the compilation.
This CL adds support of a new warning flag -Wpoison-system-directories which
emits warnings if --sysroot is set and headers from common host system location
are used.
By default the warning is disabled.

The intention of the warning is to catch bad includes which are usually
generated by third party build system not targeting cross-compilation.
Such cases happen in Chrome OS when someone imports a new package or upgrade
one to a newer version from upstream.

Patch by: denik (Denis Nikitin)

Added:
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/lib/
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/lib/.keep
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/include/

cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/include/c++/

cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/include/c++/.keep
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/lib/
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/lib/gcc/

cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/lib/gcc/.keep
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/local/

cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/local/include/

cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/local/include/.keep

cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/local/lib/

cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/local/lib/.keep
cfe/trunk/test/Frontend/warning-poison-system-directories.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
cfe/trunk/lib/Frontend/InitHeaderSearch.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=371785=371784=371785=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Thu Sep 12 15:36:13 
2019
@@ -315,4 +315,9 @@ def err_unknown_analyzer_checker_or_pack
 "no analyzer checkers or packages are associated with '%0'">;
 def note_suggest_disabling_all_checkers : Note<
 "use -analyzer-disable-all-checks to disable all static analyzer 
checkers">;
+
+// Poison system directories.
+def warn_poison_system_directories : Warning <
+  "include location '%0' is unsafe for cross-compilation">,
+  InGroup>, DefaultIgnore;
 }

Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitHeaderSearch.cpp?rev=371785=371784=371785=diff
==
--- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original)
+++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Thu Sep 12 15:36:13 2019
@@ -137,6 +137,13 @@ bool InitHeaderSearch::AddUnmappedPath(c
   SmallString<256> MappedPathStorage;
   StringRef MappedPathStr = Path.toStringRef(MappedPathStorage);
 
+  // If use system headers while cross-compiling, emit the warning.
+  if (HasSysroot && (MappedPathStr.startswith("/usr/include") ||
+ MappedPathStr.startswith("/usr/local/include"))) {
+Headers.getDiags().Report(diag::warn_poison_system_directories)
+<< MappedPathStr;
+  }
+
   // Compute the DirectoryLookup type.
   SrcMgr::CharacteristicKind Type;
   if (Group == Quoted || Group == Angled || Group == IndexHeaderMap) {

Added: cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/lib/.keep
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/lib/.keep?rev=371785=auto
==
(empty)

Added: 
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/include/c++/.keep
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/include/c%2B%2B/.keep?rev=371785=auto
==
(empty)

Added: 
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/lib/gcc/.keep
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/lib/gcc/.keep?rev=371785=auto
==
(empty)

Added: 

Re: r337433 - [clang]: Add support for "-fno-delete-null-pointer-checks"

2018-07-23 Thread Manoj Gupta via cfe-commits
Agree,
will try to add separate testcase soon.

Thanks,
Manoj

On Mon, Jul 23, 2018 at 12:39 PM Richard Smith 
wrote:

> Hi Manoj,
>
> Please can you add better test coverage that we don't emit 'nonnull'
> annotations for reference parameters / return values? At the moment, the
> only such test coverage has been added to test files that are testing
> unrelated things, which seems inappropriate. A separate test file that
> tests that we don't emit 'nonnull' annotations when null pointers are
> assumed valid would seem best to me.
>
> Thanks!
>
> On Wed, 18 Jul 2018 at 17:49, Manoj Gupta via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: manojgupta
>> Date: Wed Jul 18 17:44:52 2018
>> New Revision: 337433
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=337433=rev
>> Log:
>> [clang]: Add support for "-fno-delete-null-pointer-checks"
>>
>> Summary:
>> Support for this option is needed for building Linux kernel.
>> This is a very frequently requested feature by kernel developers.
>>
>> More details : https://lkml.org/lkml/2018/4/4/601
>>
>> GCC option description for -fdelete-null-pointer-checks:
>> This Assume that programs cannot safely dereference null pointers,
>> and that no code or data element resides at address zero.
>>
>> -fno-delete-null-pointer-checks is the inverse of this implying that
>> null pointer dereferencing is not undefined.
>>
>> This feature is implemented in as the function attribute
>> "null-pointer-is-valid"="true".
>> This CL only adds the attribute on the function.
>> It also strips "nonnull" attributes from function arguments but
>> keeps the related warnings unchanged.
>>
>> Corresponding LLVM change rL336613 already updated the
>> optimizations to not treat null pointer dereferencing
>> as undefined if the attribute is present.
>>
>> Reviewers: t.p.northover, efriedma, jyknight, chandlerc, rnk, srhines,
>> void, george.burgess.iv
>>
>> Reviewed By: jyknight
>>
>> Subscribers: drinkcat, xbolva00, cfe-commits
>>
>> Differential Revision: https://reviews.llvm.org/D47894
>>
>> Added:
>> cfe/trunk/test/CodeGen/delete-null-pointer-checks.c
>> Modified:
>> cfe/trunk/docs/ClangCommandLineReference.rst
>> cfe/trunk/include/clang/Driver/Options.td
>> cfe/trunk/include/clang/Frontend/CodeGenOptions.def
>> cfe/trunk/lib/CodeGen/CGCall.cpp
>> cfe/trunk/lib/Driver/ToolChains/Clang.cpp
>> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>> cfe/trunk/test/CodeGen/nonnull.c
>> cfe/trunk/test/CodeGen/vla.c
>> cfe/trunk/test/CodeGenCXX/address-space-ref.cpp
>> cfe/trunk/test/CodeGenCXX/constructors.cpp
>> cfe/trunk/test/CodeGenCXX/temporaries.cpp
>> cfe/trunk/test/Driver/clang_f_opts.c
>> cfe/trunk/test/Sema/nonnull.c
>>
>> Modified: cfe/trunk/docs/ClangCommandLineReference.rst
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangCommandLineReference.rst?rev=337433=337432=337433=diff
>>
>> ==
>> --- cfe/trunk/docs/ClangCommandLineReference.rst (original)
>> +++ cfe/trunk/docs/ClangCommandLineReference.rst Wed Jul 18 17:44:52 2018
>> @@ -1543,6 +1543,14 @@ Specifies the largest alignment guarante
>>
>>  Disable implicit builtin knowledge of a specific function
>>
>> +.. option:: -fdelete-null-pointer-checks, -fno-delete-null-pointer-checks
>> +
>> +When enabled, treat null pointer dereference, creation of a reference to
>> null,
>> +or passing a null pointer to a function parameter annotated with the
>> "nonnull"
>> +attribute as undefined behavior. (And, thus the optimizer may assume
>> that any
>> +pointer used in such a way must not have been null and optimize away the
>> +branches accordingly.) On by default.
>> +
>>  .. option:: -fno-elide-type
>>
>>  Do not elide types when printing diagnostics
>>
>> Modified: cfe/trunk/include/clang/Driver/Options.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=337433=337432=337433=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Driver/Options.td (original)
>> +++ cfe/trunk/include/clang/Driver/Options.td Wed Jul 18 17:44:52 2018
>> @@ -1080,6 +1080,13 @@ def frewrite_imports : Flag<["-"], "frew
>>Flags<[

r337433 - [clang]: Add support for "-fno-delete-null-pointer-checks"

2018-07-18 Thread Manoj Gupta via cfe-commits
Author: manojgupta
Date: Wed Jul 18 17:44:52 2018
New Revision: 337433

URL: http://llvm.org/viewvc/llvm-project?rev=337433=rev
Log:
[clang]: Add support for "-fno-delete-null-pointer-checks"

Summary:
Support for this option is needed for building Linux kernel.
This is a very frequently requested feature by kernel developers.

More details : https://lkml.org/lkml/2018/4/4/601

GCC option description for -fdelete-null-pointer-checks:
This Assume that programs cannot safely dereference null pointers,
and that no code or data element resides at address zero.

-fno-delete-null-pointer-checks is the inverse of this implying that
null pointer dereferencing is not undefined.

This feature is implemented in as the function attribute
"null-pointer-is-valid"="true".
This CL only adds the attribute on the function.
It also strips "nonnull" attributes from function arguments but
keeps the related warnings unchanged.

Corresponding LLVM change rL336613 already updated the
optimizations to not treat null pointer dereferencing
as undefined if the attribute is present.

Reviewers: t.p.northover, efriedma, jyknight, chandlerc, rnk, srhines, void, 
george.burgess.iv

Reviewed By: jyknight

Subscribers: drinkcat, xbolva00, cfe-commits

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

Added:
cfe/trunk/test/CodeGen/delete-null-pointer-checks.c
Modified:
cfe/trunk/docs/ClangCommandLineReference.rst
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGen/nonnull.c
cfe/trunk/test/CodeGen/vla.c
cfe/trunk/test/CodeGenCXX/address-space-ref.cpp
cfe/trunk/test/CodeGenCXX/constructors.cpp
cfe/trunk/test/CodeGenCXX/temporaries.cpp
cfe/trunk/test/Driver/clang_f_opts.c
cfe/trunk/test/Sema/nonnull.c

Modified: cfe/trunk/docs/ClangCommandLineReference.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangCommandLineReference.rst?rev=337433=337432=337433=diff
==
--- cfe/trunk/docs/ClangCommandLineReference.rst (original)
+++ cfe/trunk/docs/ClangCommandLineReference.rst Wed Jul 18 17:44:52 2018
@@ -1543,6 +1543,14 @@ Specifies the largest alignment guarante
 
 Disable implicit builtin knowledge of a specific function
 
+.. option:: -fdelete-null-pointer-checks, -fno-delete-null-pointer-checks
+
+When enabled, treat null pointer dereference, creation of a reference to null,
+or passing a null pointer to a function parameter annotated with the "nonnull"
+attribute as undefined behavior. (And, thus the optimizer may assume that any
+pointer used in such a way must not have been null and optimize away the
+branches accordingly.) On by default.
+
 .. option:: -fno-elide-type
 
 Do not elide types when printing diagnostics

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=337433=337432=337433=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Jul 18 17:44:52 2018
@@ -1080,6 +1080,13 @@ def frewrite_imports : Flag<["-"], "frew
   Flags<[CC1Option]>;
 def fno_rewrite_imports : Flag<["-"], "fno-rewrite-imports">, Group;
 
+def fdelete_null_pointer_checks : Flag<["-"],
+  "fdelete-null-pointer-checks">, Group,
+  HelpText<"Treat usage of null pointers as undefined behavior.">;
+def fno_delete_null_pointer_checks : Flag<["-"],
+  "fno-delete-null-pointer-checks">, Group, Flags<[CC1Option]>,
+  HelpText<"Do not treat usage of null pointers as undefined behavior.">;
+
 def frewrite_map_file : Separate<["-"], "frewrite-map-file">,
 Group,
 Flags<[ DriverOption, CC1Option ]>;
@@ -2855,8 +2862,6 @@ defm reorder_blocks : BooleanFFlag<"reor
 defm eliminate_unused_debug_types : 
BooleanFFlag<"eliminate-unused-debug-types">, Group;
 defm branch_count_reg : BooleanFFlag<"branch-count-reg">, 
Group;
 defm default_inline : BooleanFFlag<"default-inline">, 
Group;
-defm delete_null_pointer_checks : BooleanFFlag<"delete-null-pointer-checks">,
-Group;
 defm fat_lto_objects : BooleanFFlag<"fat-lto-objects">, 
Group;
 defm float_store : BooleanFFlag<"float-store">, 
Group;
 defm friend_injection : BooleanFFlag<"friend-injection">, 
Group;

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=337433=337432=337433=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Wed Jul 18 17:44:52 2018
@@ -130,6 +130,7 @@ 

r331928 - Update pragma-attribute-supported-attributes-list.test.

2018-05-09 Thread Manoj Gupta via cfe-commits
Author: manojgupta
Date: Wed May  9 15:05:53 2018
New Revision: 331928

URL: http://llvm.org/viewvc/llvm-project?rev=331928=rev
Log:
Update pragma-attribute-supported-attributes-list.test.

Update the test to include the new attribute NoStackProtector
to fix the build fails.

Modified:
cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test

Modified: cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test?rev=331928=331927=331928=diff
==
--- cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test 
(original)
+++ cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test Wed May 
 9 15:05:53 2018
@@ -2,7 +2,7 @@
 
 // The number of supported attributes should never go down!
 
-// CHECK: #pragma clang attribute supports 68 attributes:
+// CHECK: #pragma clang attribute supports 69 attributes:
 // CHECK-NEXT: AMDGPUFlatWorkGroupSize (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumSGPR (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumVGPR (SubjectMatchRule_function)
@@ -41,6 +41,7 @@
 // CHECK-NEXT: NoSanitize (SubjectMatchRule_function, 
SubjectMatchRule_objc_method, SubjectMatchRule_variable_is_global)
 // CHECK-NEXT: NoSanitizeSpecific (SubjectMatchRule_function, 
SubjectMatchRule_variable_is_global)
 // CHECK-NEXT: NoSplitStack (SubjectMatchRule_function)
+// CHECK-NEXT: NoStackProtector (SubjectMatchRule_function)
 // CHECK-NEXT: NoThrow (SubjectMatchRule_function)
 // CHECK-NEXT: NotTailCalled (SubjectMatchRule_function)
 // CHECK-NEXT: ObjCBoxable (SubjectMatchRule_record)


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


r331925 - [Clang] Implement function attribute no_stack_protector.

2018-05-09 Thread Manoj Gupta via cfe-commits
Author: manojgupta
Date: Wed May  9 14:41:18 2018
New Revision: 331925

URL: http://llvm.org/viewvc/llvm-project?rev=331925=rev
Log:
[Clang] Implement function attribute no_stack_protector.

Summary:
This attribute tells clang to skip this function from stack protector
when -stack-protector option is passed.
GCC option for this is:
__attribute__((__optimize__("no-stack-protector"))) and the
equivalent clang syntax would be: __attribute__((no_stack_protector))

This is used in Linux kernel to selectively disable stack protector
in certain functions.

Reviewers: aaron.ballman, rsmith, rnk, probinson

Reviewed By: aaron.ballman

Subscribers: probinson, srhines, cfe-commits

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

Added:
cfe/trunk/test/Sema/no_stack_protector.c
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/CodeGen/stack-protector.c

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=331925=331924=331925=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Wed May  9 14:41:18 2018
@@ -1495,6 +1495,12 @@ def NotTailCalled : InheritableAttr {
   let Documentation = [NotTailCalledDocs];
 }
 
+def NoStackProtector : InheritableAttr {
+  let Spellings = [Clang<"no_stack_protector">];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [NoStackProtectorDocs];
+}
+
 def NoThrow : InheritableAttr {
   let Spellings = [GCC<"nothrow">, Declspec<"nothrow">];
   let Subjects = SubjectList<[Function]>;

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=331925=331924=331925=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Wed May  9 14:41:18 2018
@@ -2740,6 +2740,28 @@ The syntax of the declare target directi
   }];
 }
 
+def NoStackProtectorDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Clang supports the ``__attribute__((no_stack_protector))`` attribute which 
disables
+the stack protector on the specified function. This attribute is useful for
+selectively disabling the stack protector on some functions when building with
+``-fstack-protector`` compiler option.
+
+For example, it disables the stack protector for the function ``foo`` but 
function
+``bar`` will still be built with the stack protector with the 
``-fstack-protector``
+option.
+
+.. code-block:: c
+
+int __attribute__((no_stack_protector))
+foo (int x); // stack protection will be disabled for foo.
+
+int bar(int y); // bar can be built with the stack protector.
+
+}];
+}
+
 def NotTailCalledDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=331925=331924=331925=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed May  9 14:41:18 2018
@@ -1142,12 +1142,14 @@ void CodeGenModule::SetLLVMFunctionAttri
   if (!hasUnwindExceptions(LangOpts))
 B.addAttribute(llvm::Attribute::NoUnwind);
 
-  if (LangOpts.getStackProtector() == LangOptions::SSPOn)
-B.addAttribute(llvm::Attribute::StackProtect);
-  else if (LangOpts.getStackProtector() == LangOptions::SSPStrong)
-B.addAttribute(llvm::Attribute::StackProtectStrong);
-  else if (LangOpts.getStackProtector() == LangOptions::SSPReq)
-B.addAttribute(llvm::Attribute::StackProtectReq);
+  if (!D || !D->hasAttr()) {
+if (LangOpts.getStackProtector() == LangOptions::SSPOn)
+  B.addAttribute(llvm::Attribute::StackProtect);
+else if (LangOpts.getStackProtector() == LangOptions::SSPStrong)
+  B.addAttribute(llvm::Attribute::StackProtectStrong);
+else if (LangOpts.getStackProtector() == LangOptions::SSPReq)
+  B.addAttribute(llvm::Attribute::StackProtectReq);
+  }
 
   if (!D) {
 // If we don't have a declaration to control inlining, the function isn't

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=331925=331924=331925=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Wed May  9 14:41:18 2018
@@ -6230,6 +6230,10 @@ static void ProcessDeclAttribute(Sema 
   case AttributeList::AT_NoInstrumentFunction: // Interacts with -pg.
 

r329512 - [Driver] Update GCC libraries detection logic for Gentoo.

2018-04-07 Thread Manoj Gupta via cfe-commits
Author: manojgupta
Date: Sat Apr  7 12:59:58 2018
New Revision: 329512

URL: http://llvm.org/viewvc/llvm-project?rev=329512=rev
Log:
[Driver] Update GCC libraries detection logic for Gentoo.

Summary:
1. Find GCC's LDPATH from the actual GCC config file.
2. Avoid picking libraries from a similar named tuple if the exact
   tuple is installed.

Reviewers: mgorny, chandlerc, thakis, rnk

Reviewed By: mgorny, rnk

Subscribers: cfe-commits, mgorny

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

Added:
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/etc/
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/etc/env.d/
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/etc/env.d/gcc/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/etc/env.d/gcc/config-x86_64-pc-linux-gnu

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/etc/env.d/gcc/x86_64-pc-linux-gnu-4.9.3
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/etc/gentoo-release
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/include/
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/include/.keep
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/32/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/32/crtbegin.o

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/crtbegin.o

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/include/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/include/g++-v4.9.3/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/include/g++-v4.9.3/.keep

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/x32/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/x32/crtbegin.o

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/32/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/32/crtbegin.o

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/crtbegin.o

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/g++-v5.4.0/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/g++-v5.4.0/.keep

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/x32/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/x32/crtbegin.o

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/x86_64-pc-linux-gnu/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/x86_64-pc-linux-gnu/lib/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/x86_64-pc-linux-gnu/lib/.keep
Modified:
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
cfe/trunk/lib/Driver/ToolChains/Gnu.h
cfe/trunk/test/Driver/linux-header-search.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=329512=329511=329512=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Sat Apr  7 12:59:58 2018
@@ -1676,18 +1676,21 @@ void Generic_GCC::GCCInstallationDetecto
   // in /usr. This avoids accidentally enforcing the system GCC version
   // when using a custom toolchain.
   if (GCCToolchainDir == "" || GCCToolchainDir == D.SysRoot + "/usr") {
-for (StringRef CandidateTriple : ExtraTripleAliases) {
-  if (ScanGentooGccConfig(TargetTriple, Args, CandidateTriple))
-return;
-}
-for (StringRef CandidateTriple : CandidateTripleAliases) {
-  if (ScanGentooGccConfig(TargetTriple, Args, CandidateTriple))
-return;
-}
-for (StringRef CandidateTriple : CandidateBiarchTripleAliases) {
-  if (ScanGentooGccConfig(TargetTriple, 

Re: r329300 - Disable -fmerge-all-constants as default.

2018-04-06 Thread Manoj Gupta via cfe-commits
Sure, will update.

Thanks,
Manoj

On Fri, Apr 6, 2018 at 4:56 AM Nico Weber <tha...@chromium.org> wrote:

> This should probably get a release notes entry. Can you write one?
>
> On Thu, Apr 5, 2018 at 11:29 AM, Manoj Gupta via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: manojgupta
>> Date: Thu Apr  5 08:29:52 2018
>> New Revision: 329300
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=329300=rev
>> Log:
>> Disable -fmerge-all-constants as default.
>>
>> Summary:
>> "-fmerge-all-constants" is a non-conforming optimization and should not
>> be the default. It is also causing miscompiles when building Linux
>> Kernel (https://lkml.org/lkml/2018/3/20/872).
>>
>> Fixes PR18538.
>>
>> Reviewers: rjmccall, rsmith, chandlerc
>>
>> Reviewed By: rsmith, chandlerc
>>
>> Subscribers: srhines, cfe-commits
>>
>> Differential Revision: https://reviews.llvm.org/D45289
>>
>> Modified:
>> cfe/trunk/include/clang/Driver/Options.td
>> cfe/trunk/lib/AST/ExprConstant.cpp
>> cfe/trunk/lib/Driver/ToolChains/Clang.cpp
>> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>> cfe/trunk/test/CodeGen/array-init.c
>> cfe/trunk/test/CodeGen/decl.c
>> cfe/trunk/test/CodeGenCXX/const-init-cxx11.cpp
>> cfe/trunk/test/CodeGenCXX/cxx0x-initializer-references.cpp
>> cfe/trunk/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
>> cfe/trunk/test/CodeGenObjCXX/arc-cxx11-init-list.mm
>> cfe/trunk/test/Driver/clang_f_opts.c
>>
>> Modified: cfe/trunk/include/clang/Driver/Options.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=329300=329299=329300=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Driver/Options.td (original)
>> +++ cfe/trunk/include/clang/Driver/Options.td Thu Apr  5 08:29:52 2018
>> @@ -1133,7 +1133,8 @@ def fthinlto_index_EQ : Joined<["-"], "f
>>HelpText<"Perform ThinLTO importing using provided function summary
>> index">;
>>  def fmacro_backtrace_limit_EQ : Joined<["-"], "fmacro-backtrace-limit=">,
>>  Group, Flags<[DriverOption,
>> CoreOption]>;
>> -def fmerge_all_constants : Flag<["-"], "fmerge-all-constants">,
>> Group;
>> +def fmerge_all_constants : Flag<["-"], "fmerge-all-constants">,
>> Group,
>> +  Flags<[CC1Option]>, HelpText<"Allow merging of constants">;
>>  def fmessage_length_EQ : Joined<["-"], "fmessage-length=">,
>> Group;
>>  def fms_extensions : Flag<["-"], "fms-extensions">, Group,
>> Flags<[CC1Option, CoreOption]>,
>>HelpText<"Accept some non-standard constructs supported by the
>> Microsoft compiler">;
>> @@ -1282,7 +1283,7 @@ def fveclib : Joined<["-"], "fveclib=">,
>>  def fno_lax_vector_conversions : Flag<["-"],
>> "fno-lax-vector-conversions">, Group,
>>HelpText<"Disallow implicit conversions between vectors with a
>> different number of elements or different element types">,
>> Flags<[CC1Option]>;
>>  def fno_merge_all_constants : Flag<["-"], "fno-merge-all-constants">,
>> Group,
>> -Flags<[CC1Option]>, HelpText<"Disallow merging of constants">;
>> +  HelpText<"Disallow merging of constants">;
>>  def fno_modules : Flag <["-"], "fno-modules">, Group,
>>Flags<[DriverOption]>;
>>  def fno_implicit_module_maps : Flag <["-"], "fno-implicit-module-maps">,
>> Group,
>>
>> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=329300=329299=329300=diff
>>
>> ==
>> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
>> +++ cfe/trunk/lib/AST/ExprConstant.cpp Thu Apr  5 08:29:52 2018
>> @@ -8596,9 +8596,6 @@ bool IntExprEvaluator::VisitBinaryOperat
>>  (LHSValue.Base && isZeroSized(RHSValue)))
>>return Error(E);
>>  // Pointers with different bases cannot represent the same
>> object.
>> -// (Note that clang defaults to -fmerge

Re: r329300 - Disable -fmerge-all-constants as default.

2018-04-05 Thread Manoj Gupta via cfe-commits
Thanks Richard,

I was wondering how a Clang change can break the Backend tests given that
the tests are all pre-checked IR files.

Failing Tests (7):
LLVM :: CodeGen/Mips/Fast-ISel/fastalloca.ll
LLVM :: CodeGen/Mips/Fast-ISel/fastcc-miss.ll
LLVM :: CodeGen/Mips/Fast-ISel/memtest1.ll
LLVM :: CodeGen/Mips/Fast-ISel/mul1.ll
LLVM :: CodeGen/Mips/Fast-ISel/sel1.ll
LLVM :: CodeGen/Mips/call-optimization.ll
LLVM :: DebugInfo/Mips/delay-slot.ll

On Thu, Apr 5, 2018 at 2:45 PM Richard Smith <rich...@metafoo.co.uk> wrote:

> MipsFastISel::fastLowerArguments looks very broken and is likely the
> culprit here:
>
>   const ArrayRef GPR32ArgRegs = {Mips::A0, Mips::A1, Mips::A2,
> Mips::A3};
>   const ArrayRef FGR32ArgRegs = {Mips::F12, Mips::F14};
>   const ArrayRef AFGR64ArgRegs = {Mips::D6, Mips::D7};
>
> These are dangling ArrayRefs referring to already-destroyed temporaries.
>
> On 5 April 2018 at 14:40, Galina Kistanova via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Hello Manoj,
>>
>> Looks like this commit broke tests at couple of our builders:
>> r329300
>> http://lab.llvm.org:8011/builders/clang-with-thin-lto-ubuntu/builds/9600
>>
>> Few tests failed:
>> . . .
>> Failing Tests (7):
>> LLVM :: CodeGen/Mips/Fast-ISel/fastalloca.ll
>> LLVM :: CodeGen/Mips/Fast-ISel/fastcc-miss.ll
>> LLVM :: CodeGen/Mips/Fast-ISel/memtest1.ll
>> LLVM :: CodeGen/Mips/Fast-ISel/mul1.ll
>> LLVM :: CodeGen/Mips/Fast-ISel/sel1.ll
>> LLVM :: CodeGen/Mips/call-optimization.ll
>> LLVM :: DebugInfo/Mips/delay-slot.ll
>>
>> Previous revision:
>> http://lab.llvm.org:8011/builders/clang-with-thin-lto-ubuntu/builds/9602
>>
>> Also another builder is affected:
>> http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu
>>
>> Both builders were red and did not send notifications.
>>
>> Please have a look?
>>
>> Thanks
>>
>> Galina
>>
>> On Thu, Apr 5, 2018 at 8:29 AM, Manoj Gupta via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: manojgupta
>>> Date: Thu Apr  5 08:29:52 2018
>>> New Revision: 329300
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=329300=rev
>>> Log:
>>> Disable -fmerge-all-constants as default.
>>>
>>> Summary:
>>> "-fmerge-all-constants" is a non-conforming optimization and should not
>>> be the default. It is also causing miscompiles when building Linux
>>> Kernel (https://lkml.org/lkml/2018/3/20/872).
>>>
>>> Fixes PR18538.
>>>
>>> Reviewers: rjmccall, rsmith, chandlerc
>>>
>>> Reviewed By: rsmith, chandlerc
>>>
>>> Subscribers: srhines, cfe-commits
>>>
>>> Differential Revision: https://reviews.llvm.org/D45289
>>>
>>> Modified:
>>> cfe/trunk/include/clang/Driver/Options.td
>>> cfe/trunk/lib/AST/ExprConstant.cpp
>>> cfe/trunk/lib/Driver/ToolChains/Clang.cpp
>>> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>>> cfe/trunk/test/CodeGen/array-init.c
>>> cfe/trunk/test/CodeGen/decl.c
>>> cfe/trunk/test/CodeGenCXX/const-init-cxx11.cpp
>>> cfe/trunk/test/CodeGenCXX/cxx0x-initializer-references.cpp
>>> cfe/trunk/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
>>> cfe/trunk/test/CodeGenObjCXX/arc-cxx11-init-list.mm
>>> cfe/trunk/test/Driver/clang_f_opts.c
>>>
>>> Modified: cfe/trunk/include/clang/Driver/Options.td
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=329300=329299=329300=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/Driver/Options.td (original)
>>> +++ cfe/trunk/include/clang/Driver/Options.td Thu Apr  5 08:29:52 2018
>>> @@ -1133,7 +1133,8 @@ def fthinlto_index_EQ : Joined<["-"], "f
>>>HelpText<"Perform ThinLTO importing using provided function summary
>>> index">;
>>>  def fmacro_backtrace_limit_EQ : Joined<["-"],
>>> "fmacro-backtrace-limit=">,
>>>  Group, Flags<[DriverOption,
>>> CoreOption]>;
>>> -def fmerge_all_constants : Flag<["-"], "fmerge-all-constants">,
>>> Group;
>>> +def fmerge_all_constants : Flag<["-"], "fmerge-all-cons

r329300 - Disable -fmerge-all-constants as default.

2018-04-05 Thread Manoj Gupta via cfe-commits
Author: manojgupta
Date: Thu Apr  5 08:29:52 2018
New Revision: 329300

URL: http://llvm.org/viewvc/llvm-project?rev=329300=rev
Log:
Disable -fmerge-all-constants as default.

Summary:
"-fmerge-all-constants" is a non-conforming optimization and should not
be the default. It is also causing miscompiles when building Linux
Kernel (https://lkml.org/lkml/2018/3/20/872).

Fixes PR18538.

Reviewers: rjmccall, rsmith, chandlerc

Reviewed By: rsmith, chandlerc

Subscribers: srhines, cfe-commits

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

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGen/array-init.c
cfe/trunk/test/CodeGen/decl.c
cfe/trunk/test/CodeGenCXX/const-init-cxx11.cpp
cfe/trunk/test/CodeGenCXX/cxx0x-initializer-references.cpp
cfe/trunk/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
cfe/trunk/test/CodeGenObjCXX/arc-cxx11-init-list.mm
cfe/trunk/test/Driver/clang_f_opts.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=329300=329299=329300=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Apr  5 08:29:52 2018
@@ -1133,7 +1133,8 @@ def fthinlto_index_EQ : Joined<["-"], "f
   HelpText<"Perform ThinLTO importing using provided function summary index">;
 def fmacro_backtrace_limit_EQ : Joined<["-"], "fmacro-backtrace-limit=">,
 Group, Flags<[DriverOption, 
CoreOption]>;
-def fmerge_all_constants : Flag<["-"], "fmerge-all-constants">, Group;
+def fmerge_all_constants : Flag<["-"], "fmerge-all-constants">, Group,
+  Flags<[CC1Option]>, HelpText<"Allow merging of constants">;
 def fmessage_length_EQ : Joined<["-"], "fmessage-length=">, Group;
 def fms_extensions : Flag<["-"], "fms-extensions">, Group, 
Flags<[CC1Option, CoreOption]>,
   HelpText<"Accept some non-standard constructs supported by the Microsoft 
compiler">;
@@ -1282,7 +1283,7 @@ def fveclib : Joined<["-"], "fveclib=">,
 def fno_lax_vector_conversions : Flag<["-"], "fno-lax-vector-conversions">, 
Group,
   HelpText<"Disallow implicit conversions between vectors with a different 
number of elements or different element types">, Flags<[CC1Option]>;
 def fno_merge_all_constants : Flag<["-"], "fno-merge-all-constants">, 
Group,
-Flags<[CC1Option]>, HelpText<"Disallow merging of constants">;
+  HelpText<"Disallow merging of constants">;
 def fno_modules : Flag <["-"], "fno-modules">, Group,
   Flags<[DriverOption]>;
 def fno_implicit_module_maps : Flag <["-"], "fno-implicit-module-maps">, 
Group,

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=329300=329299=329300=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Thu Apr  5 08:29:52 2018
@@ -8596,9 +8596,6 @@ bool IntExprEvaluator::VisitBinaryOperat
 (LHSValue.Base && isZeroSized(RHSValue)))
   return Error(E);
 // Pointers with different bases cannot represent the same object.
-// (Note that clang defaults to -fmerge-all-constants, which can
-// lead to inconsistent results for comparisons involving the address
-// of a constant; this generally doesn't matter in practice.)
 return Success(E->getOpcode() == BO_NE, E);
   }
 

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=329300=329299=329300=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Thu Apr  5 08:29:52 2018
@@ -3361,9 +3361,9 @@ void Clang::ConstructJob(Compilation ,
 
   Args.AddLastArg(CmdArgs, options::OPT_fveclib);
 
-  if (!Args.hasFlag(options::OPT_fmerge_all_constants,
-options::OPT_fno_merge_all_constants))
-CmdArgs.push_back("-fno-merge-all-constants");
+  if (Args.hasFlag(options::OPT_fmerge_all_constants,
+   options::OPT_fno_merge_all_constants, false))
+CmdArgs.push_back("-fmerge-all-constants");
 
   // LLVM Code Generator Options.
 

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=329300=329299=329300=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu Apr  5 08:29:52 2018
@@ -605,7 

r328829 - [AArch64]: Add support for parsing rN registers.

2018-03-29 Thread Manoj Gupta via cfe-commits
Author: manojgupta
Date: Thu Mar 29 14:11:15 2018
New Revision: 328829

URL: http://llvm.org/viewvc/llvm-project?rev=328829=rev
Log:
[AArch64]: Add support for parsing rN registers.

Summary:
Allow rN registers to be simply parsed as correspoing xN registers.
The "register ... asm("rN")" is an command to the
compiler's register allocator, not an operand to any individual assembly
instruction. GCC documents this syntax as "...the name of the register
that should be used."

This is needed to support the changes in Linux kernel (see
https://lkml.org/lkml/2018/3/1/268 )

Note: This will add support only for the limited use case of
register ... asm("rN"). Any other uses that make rN leak into assembly
are not supported.

Reviewers: kristof.beyls, rengolin, peter.smith, t.p.northover

Reviewed By: peter.smith

Subscribers: javed.absar, eraman, cfe-commits, srhines

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

Modified:
cfe/trunk/lib/Basic/Targets/AArch64.cpp
cfe/trunk/test/CodeGen/aarch64-inline-asm.c

Modified: cfe/trunk/lib/Basic/Targets/AArch64.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AArch64.cpp?rev=328829=328828=328829=diff
==
--- cfe/trunk/lib/Basic/Targets/AArch64.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/AArch64.cpp Thu Mar 29 14:11:15 2018
@@ -308,7 +308,40 @@ ArrayRef AArch64TargetInfo
 }
 
 const TargetInfo::GCCRegAlias AArch64TargetInfo::GCCRegAliases[] = {
-{{"w31"}, "wsp"}, {{"x29"}, "fp"}, {{"x30"}, "lr"}, {{"x31"}, "sp"},
+{{"w31"}, "wsp"},
+{{"x31"}, "sp"},
+// GCC rN registers are aliases of xN registers.
+{{"r0"}, "x0"},
+{{"r1"}, "x1"},
+{{"r2"}, "x2"},
+{{"r3"}, "x3"},
+{{"r4"}, "x4"},
+{{"r5"}, "x5"},
+{{"r6"}, "x6"},
+{{"r7"}, "x7"},
+{{"r8"}, "x8"},
+{{"r9"}, "x9"},
+{{"r10"}, "x10"},
+{{"r11"}, "x11"},
+{{"r12"}, "x12"},
+{{"r13"}, "x13"},
+{{"r14"}, "x14"},
+{{"r15"}, "x15"},
+{{"r16"}, "x16"},
+{{"r17"}, "x17"},
+{{"r18"}, "x18"},
+{{"r19"}, "x19"},
+{{"r20"}, "x20"},
+{{"r21"}, "x21"},
+{{"r22"}, "x22"},
+{{"r23"}, "x23"},
+{{"r24"}, "x24"},
+{{"r25"}, "x25"},
+{{"r26"}, "x26"},
+{{"r27"}, "x27"},
+{{"r28"}, "x28"},
+{{"r29", "x29"}, "fp"},
+{{"r30", "x30"}, "lr"},
 // The S/D/Q and W/X registers overlap, but aren't really aliases; we
 // don't want to substitute one of these for a different-sized one.
 };

Modified: cfe/trunk/test/CodeGen/aarch64-inline-asm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-inline-asm.c?rev=328829=328828=328829=diff
==
--- cfe/trunk/test/CodeGen/aarch64-inline-asm.c (original)
+++ cfe/trunk/test/CodeGen/aarch64-inline-asm.c Thu Mar 29 14:11:15 2018
@@ -54,3 +54,23 @@ void test_constraint_Q(void) {
 asm("ldxr %0, %1" : "=r"(val) : "Q"(var));
 // CHECK: call i32 asm "ldxr $0, $1", "=r,*Q"(i64* @var)
 }
+
+void test_gcc_registers(void) {
+register unsigned long reg0 asm("r0") = 0;
+register unsigned long reg1 asm("r1") = 1;
+register unsigned int  reg29 asm("r29") = 2;
+register unsigned int  reg30 asm("r30") = 3;
+
+// Test remapping register names in register ... asm("rN") statments.
+// rN register operands in these two inline assembly lines
+// should get renamed to valid AArch64 registers.
+asm volatile("hvc #0" : : "r" (reg0), "r" (reg1));
+// CHECK: call void asm sideeffect "hvc #0", "{x0},{x1}"
+asm volatile("hvc #0" : : "r" (reg29), "r" (reg30));
+// CHECK: call void asm sideeffect "hvc #0", "{fp},{lr}"
+
+// rN registers when used without register ... asm("rN") syntax
+// should not be remapped.
+asm volatile("mov r0, r1\n");
+// CHECK: call void asm sideeffect "mov r0, r1\0A", ""()
+}


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


r326639 - Do not generate calls to fentry with __attribute__((no_instrument_function))

2018-03-02 Thread Manoj Gupta via cfe-commits
Author: manojgupta
Date: Fri Mar  2 15:52:44 2018
New Revision: 326639

URL: http://llvm.org/viewvc/llvm-project?rev=326639=rev
Log:
Do not generate calls to fentry with __attribute__((no_instrument_function))

Summary:
Currently only calls to mcount were suppressed with
no_instrument_function attribute.
Linux kernel requires that calls to fentry should also not be
generated.
This is an extended fix for PR PR33515.

Reviewers: hfinkel, rengolin, srhines, rnk, rsmith, rjmccall, hans

Reviewed By: rjmccall

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/test/CodeGen/fentry.c

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=326639=326638=326639=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Fri Mar  2 15:52:44 2018
@@ -1016,10 +1016,12 @@ void CodeGenFunction::StartFunction(Glob
   // The attribute "counting-function" is set to mcount function name which is
   // architecture dependent.
   if (CGM.getCodeGenOpts().InstrumentForProfiling) {
-if (CGM.getCodeGenOpts().CallFEntry)
-  Fn->addFnAttr("fentry-call", "true");
-else {
-  if (!CurFuncDecl || !CurFuncDecl->hasAttr()) {
+// Calls to fentry/mcount should not be generated if function has
+// the no_instrument_function attribute.
+if (!CurFuncDecl || !CurFuncDecl->hasAttr()) {
+  if (CGM.getCodeGenOpts().CallFEntry)
+Fn->addFnAttr("fentry-call", "true");
+  else {
 Fn->addFnAttr("instrument-function-entry-inlined",
   getTarget().getMCountName());
   }

Modified: cfe/trunk/test/CodeGen/fentry.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/fentry.c?rev=326639=326638=326639=diff
==
--- cfe/trunk/test/CodeGen/fentry.c (original)
+++ cfe/trunk/test/CodeGen/fentry.c Fri Mar  2 15:52:44 2018
@@ -7,5 +7,12 @@ int foo(void) {
   return 0;
 }
 
-//CHECK: attributes #{{[0-9]+}} = { {{.*}}"fentry-call"="true"{{.*}} }
-//NOPG-NOT: attributes #{{[0-9]+}} = { {{.*}}"fentry-call"{{.*}} }
+int __attribute__((no_instrument_function)) no_instrument(void) {
+  return foo();
+}
+
+//CHECK: attributes #0 = { {{.*}}"fentry-call"="true"{{.*}} }
+//CHECK: attributes #1 = { {{.*}} }
+//CHECK-NOT: attributes #1 = { {{.*}}"fentry-call"="true"{{.*}} }
+//NOPG-NOT: attributes #0 = { {{.*}}"fentry-call"{{.*}} }
+//NOPG-NOT: attributes #1 = { {{.*}}"fentry-call"{{.*}} }


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


r305728 - [Clang] Handle interaction of -pg and no_instrument_function attribute.

2017-06-19 Thread Manoj Gupta via cfe-commits
Author: manojgupta
Date: Mon Jun 19 13:45:03 2017
New Revision: 305728

URL: http://llvm.org/viewvc/llvm-project?rev=305728=rev
Log:
[Clang] Handle interaction of -pg and no_instrument_function attribute.

Summary:
Disable generation of counting-function attribute if no_instrument_function
attribute is present in function.
Interaction between -pg and no_instrument_function is the desired behavior
and matches gcc as well.
This is required for fixing a crash in Linux kernel when function tracing
is enabled.

Fixes PR33515.

Reviewers: hfinkel, rengolin, srhines, hans

Reviewed By: hfinkel

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/test/CodeGen/mcount.c

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=305728=305727=305728=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Mon Jun 19 13:45:03 2017
@@ -887,8 +887,10 @@ void CodeGenFunction::StartFunction(Glob
   if (CGM.getCodeGenOpts().InstrumentForProfiling) {
 if (CGM.getCodeGenOpts().CallFEntry)
   Fn->addFnAttr("fentry-call", "true");
-else
-  Fn->addFnAttr("counting-function", getTarget().getMCountName());
+else {
+  if (!CurFuncDecl || !CurFuncDecl->hasAttr())
+Fn->addFnAttr("counting-function", getTarget().getMCountName());
+}
   }
 
   if (RetTy->isVoidType()) {

Modified: cfe/trunk/test/CodeGen/mcount.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/mcount.c?rev=305728=305727=305728=diff
==
--- cfe/trunk/test/CodeGen/mcount.c (original)
+++ cfe/trunk/test/CodeGen/mcount.c Mon Jun 19 13:45:03 2017
@@ -1,18 +1,18 @@
 // RUN: %clang_cc1 -pg -triple i386-unknown-unknown -emit-llvm -o - %s | 
FileCheck %s
 // RUN: %clang_cc1 -pg -triple i386-unknown-unknown -emit-llvm -O2 -o - %s | 
FileCheck %s
-// RUN: %clang_cc1 -pg -triple powerpc-unknown-gnu-linux -emit-llvm -o - %s | 
FileCheck -check-prefix=CHECK-PREFIXED %s
-// RUN: %clang_cc1 -pg -triple powerpc64-unknown-gnu-linux -emit-llvm -o - %s 
| FileCheck -check-prefix=CHECK-PREFIXED %s
-// RUN: %clang_cc1 -pg -triple powerpc64le-unknown-gnu-linux -emit-llvm -o - 
%s | FileCheck -check-prefix=CHECK-PREFIXED %s
-// RUN: %clang_cc1 -pg -triple i386-netbsd -emit-llvm -o - %s | FileCheck 
-check-prefix=CHECK-PREFIXED %s
-// RUN: %clang_cc1 -pg -triple x86_64-netbsd -emit-llvm -o - %s | FileCheck 
-check-prefix=CHECK-PREFIXED %s
-// RUN: %clang_cc1 -pg -triple arm-netbsd-eabi -emit-llvm -o - %s | FileCheck 
-check-prefix=CHECK-PREFIXED %s
-// RUN: %clang_cc1 -pg -triple aarch64-netbsd -emit-llvm -o - %s | FileCheck 
-check-prefix=CHECK-PREFIXED %s
-// RUN: %clang_cc1 -pg -triple mips-netbsd -emit-llvm -o - %s | FileCheck 
-check-prefix=CHECK-PREFIXED %s
-// RUN: %clang_cc1 -pg -triple powerpc-netbsd -emit-llvm -o - %s | FileCheck 
-check-prefix=CHECK-PREFIXED %s
-// RUN: %clang_cc1 -pg -triple powerpc64-netbsd -emit-llvm -o - %s | FileCheck 
-check-prefix=CHECK-PREFIXED %s
-// RUN: %clang_cc1 -pg -triple powerpc64le-netbsd -emit-llvm -o - %s | 
FileCheck -check-prefix=CHECK-PREFIXED %s
-// RUN: %clang_cc1 -pg -triple sparc-netbsd -emit-llvm -o - %s | FileCheck 
-check-prefix=CHECK-PREFIXED %s
-// RUN: %clang_cc1 -pg -triple sparc64-netbsd -emit-llvm -o - %s | FileCheck 
-check-prefix=CHECK-PREFIXED %s
+// RUN: %clang_cc1 -pg -triple powerpc-unknown-gnu-linux -emit-llvm -o - %s | 
FileCheck -check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
+// RUN: %clang_cc1 -pg -triple powerpc64-unknown-gnu-linux -emit-llvm -o - %s 
| FileCheck -check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
+// RUN: %clang_cc1 -pg -triple powerpc64le-unknown-gnu-linux -emit-llvm -o - 
%s | FileCheck -check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
+// RUN: %clang_cc1 -pg -triple i386-netbsd -emit-llvm -o - %s | FileCheck 
-check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
+// RUN: %clang_cc1 -pg -triple x86_64-netbsd -emit-llvm -o - %s | FileCheck 
-check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
+// RUN: %clang_cc1 -pg -triple arm-netbsd-eabi -emit-llvm -o - %s | FileCheck 
-check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
+// RUN: %clang_cc1 -pg -triple aarch64-netbsd -emit-llvm -o - %s | FileCheck 
-check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
+// RUN: %clang_cc1 -pg -triple mips-netbsd -emit-llvm -o - %s | FileCheck 
-check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
+// RUN: %clang_cc1 -pg -triple powerpc-netbsd -emit-llvm -o - %s | FileCheck 
-check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
+// RUN: %clang_cc1 -pg -triple powerpc64-netbsd -emit-llvm -o - %s | FileCheck 
-check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
+// RUN: %clang_cc1 -pg -triple powerpc64le-netbsd -emit-llvm -o - %s | 
FileCheck 

[libunwind] r303206 - [libunwind] Fix executable stack directive on Linux.

2017-05-16 Thread Manoj Gupta via cfe-commits
Author: manojgupta
Date: Tue May 16 15:18:57 2017
New Revision: 303206

URL: http://llvm.org/viewvc/llvm-project?rev=303206=rev
Log:
[libunwind] Fix executable stack directive on Linux.

Summary:
Disable executable stack on Linux. Also remove redundant Android check
as it is covered by Android.

Reviewers: phosek, compnerd, rs, rmaprath, EricWF, krytarowski

Reviewed By: krytarowski

Subscribers: srhines, llvm-commits, krytarowski

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

Modified:
libunwind/trunk/src/assembly.h

Modified: libunwind/trunk/src/assembly.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/assembly.h?rev=303206=303205=303206=diff
==
--- libunwind/trunk/src/assembly.h (original)
+++ libunwind/trunk/src/assembly.h Tue May 16 15:18:57 2017
@@ -47,8 +47,8 @@
 #define SYMBOL_IS_FUNC(name) .type name,@function
 #endif
 
-#if defined(__GNU__) || defined(__ANDROID__) || defined(__FreeBSD__) || \
-defined(__Fuchsia__)
+#if defined(__GNU__) || defined(__FreeBSD__) || defined(__Fuchsia__) || \
+defined(__linux__)
 #define NO_EXEC_STACK_DIRECTIVE .section .note.GNU-stack,"",%progbits
 #else
 #define NO_EXEC_STACK_DIRECTIVE


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


r300571 - [AArch64][clang] Pass cpu/arch information to assembler for AArch64.

2017-04-18 Thread Manoj Gupta via cfe-commits
Author: manojgupta
Date: Tue Apr 18 12:36:10 2017
New Revision: 300571

URL: http://llvm.org/viewvc/llvm-project?rev=300571=rev
Log:
[AArch64][clang] Pass cpu/arch information to assembler for AArch64.

Summary:
Pass Cpu/Arch options to assembler for AArch64 with no-integrated-as.
This fixes PR20019.

Reviewers: richard.barton.arm, kristof.beyls, rengolin

Reviewed By: rengolin

Subscribers: srhines, pirama, aemerson, rengolin, cfe-commits

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
cfe/trunk/test/Driver/linux-as.c

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=300571=300570=300571=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Tue Apr 18 12:36:10 2017
@@ -770,6 +770,12 @@ void tools::gnutools::Assembler::Constru
 Args.AddLastArg(CmdArgs, options::OPT_mfpu_EQ);
 break;
   }
+  case llvm::Triple::aarch64:
+  case llvm::Triple::aarch64_be: {
+Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
+Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+break;
+  }
   case llvm::Triple::mips:
   case llvm::Triple::mipsel:
   case llvm::Triple::mips64:

Modified: cfe/trunk/test/Driver/linux-as.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/linux-as.c?rev=300571=300570=300571=diff
==
--- cfe/trunk/test/Driver/linux-as.c (original)
+++ cfe/trunk/test/Driver/linux-as.c Tue Apr 18 12:36:10 2017
@@ -100,6 +100,33 @@
 // RUN:   | FileCheck -check-prefix=CHECK-ARM-HARDFP %s
 // CHECK-ARM-HARDFP: as{{(.exe)?}}" "-mfloat-abi=hard"
 //
+// RUN: %clang -target aarch64-linux-gnu -mcpu=cortex-a53 -### \
+// RUN:   -no-integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ARM64-MCPU %s
+// CHECK-ARM64-MCPU: as{{(.exe)?}}" "-mcpu=cortex-a53"
+//
+// RUN: %clang -target aarch64-linux-gnu -march=armv8-a -### \
+// RUN:   -no-integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ARM64-MARCH %s
+// CHECK-ARM64-MARCH: as{{(.exe)?}}" "-march=armv8-a"
+//
+// RUN: %clang -target aarch64-linux-gnu -mcpu=cortex-a53 -march=armv8-a -### \
+// RUN:   -no-integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ARM64-ALL %s
+// CHECK-ARM64-ALL: as{{(.exe)?}}" "-march=armv8-a" "-mcpu=cortex-a53"
+//
+// RUN: %clang -target aarch64_be-linux-gnu -mcpu=cortex-a53 -### \
+// RUN:   -no-integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ARM64-MCPU %s
+//
+// RUN: %clang -target aarch64_be-linux-gnu -march=armv8-a -### \
+// RUN:   -no-integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ARM64-MARCH %s
+//
+// RUN: %clang -target aarch64_be-linux-gnu -mcpu=cortex-a53 -march=armv8-a 
-### \
+// RUN:   -no-integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ARM64-ALL %s
+//
 // RUN: %clang -target ppc-linux -mcpu=invalid-cpu -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-PPC-NO-MCPU %s


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


r300570 - Testing commit access.

2017-04-18 Thread Manoj Gupta via cfe-commits
Author: manojgupta
Date: Tue Apr 18 12:34:46 2017
New Revision: 300570

URL: http://llvm.org/viewvc/llvm-project?rev=300570=rev
Log:
Testing commit access.

Summary: Test commit access.

Reviewers: gbiv, george.burgess.iv

Reviewed By: george.burgess.iv

Subscribers: cfe-commits

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

Modified:
cfe/trunk/unittests/Driver/ToolChainTest.cpp

Modified: cfe/trunk/unittests/Driver/ToolChainTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Driver/ToolChainTest.cpp?rev=300570=300569=300570=diff
==
--- cfe/trunk/unittests/Driver/ToolChainTest.cpp (original)
+++ cfe/trunk/unittests/Driver/ToolChainTest.cpp Tue Apr 18 12:34:46 2017
@@ -142,4 +142,4 @@ TEST(ToolChainTest, DefaultDriverMode) {
   EXPECT_TRUE(CLDriver.IsCLMode());
 }
 
-} // end anonymous namespace
+} // end anonymous namespace.


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