[PATCH] D30015: [OpenMP] Add arch-specific directory to search path

2017-02-16 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 88662.
pirama added a comment.

Changed the name of the utility that builds the arch-specific directory.


https://reviews.llvm.org/D30015

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChain.cpp
  lib/Driver/Tools.cpp
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/aarch64/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/arm/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/i686/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64/.keep
  test/Driver/openmp-arch-dir.c

Index: test/Driver/openmp-arch-dir.c
===
--- /dev/null
+++ test/Driver/openmp-arch-dir.c
@@ -0,0 +1,57 @@
+// Test that the driver adds an arch-specific subdirectory in
+// {RESOURCE_DIR}/lib/linux to the search path.  This allows multilib toolchains
+// to package libomp.so for multiple architectures.
+
+// Directory resource_dir_with_arch_subdir is setup only for Linux
+// REQUIRES: linux
+//
+// RUN: %clang %s -### 2>&1 -fopenmp -target i686-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR \
+// RUN:   --check-prefix=CHECK-LOMP %s
+//
+// RUN: %clang %s -### 2>&1 -fopenmp -target i686-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR \
+// RUN:   --check-prefix=CHECK-LOMP %s
+//
+// RUN: %clang %s -### 2>&1 -fopenmp -target x86_64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR \
+// RUN:   --check-prefix=CHECK-LOMP %s
+//
+// RUN: %clang %s -### 2>&1 -fopenmp -target x86_64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR \
+// RUN:   --check-prefix=CHECK-LOMP %s
+//
+// RUN: %clang %s -### 2>&1 -fopenmp -target arm-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR \
+// RUN:   --check-prefix=CHECK-LOMP %s
+//
+// RUN: %clang %s -### 2>&1 -fopenmp -target arm-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR \
+// RUN:   --check-prefix=CHECK-LOMP %s
+//
+// RUN: %clang %s -### 2>&1 -fopenmp -target aarch64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR \
+// RUN:   --check-prefix=CHECK-LOMP %s
+//
+// RUN: %clang %s -### 2>&1 -fopenmp -target aarch64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR \
+// RUN:   --check-prefix=CHECK-LOMP %s
+//
+// Check correctness when -fopenmp is omitted
+// RUN: %clang %s -### 2>&1 -target arm-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR \
+// RUN:   --check-prefix=CHECK-NO-LOMP %s
+//
+// CHECK-ARCHDIR: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux
+// CHECK-NO-ARCHDIR-NOT: -L{{.*}}Inputs/resource_dir
+// CHECK-LOMP: -lomp
+// CHECK-NO-LOMP-NOT: -lomp
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3260,6 +3260,12 @@
 options::OPT_fno_openmp, false))
 return;
 
+  // Add /lib// to the linker search path if it
+  // exists.
+  std::string CandidateLibPath = TC.getArchSpecificLibPath();
+  if (llvm::sys::fs::is_directory(CandidateLibPath))
+CmdArgs.push_back(Args.MakeArgString("-L" + CandidateLibPath));
+
   switch (TC.getDriver().getOpenMPRuntime(Args)) {
   case Driver::OMPRT_OMP:
 CmdArgs.push_back("-lomp");
@@ -10316,6 +10322,12 @@
 // FIXME: Does this really make sense for all GNU toolchains?
 WantPthread = true;
 
+// Add /lib// to the linker search path if it
+// exists.
+std::string CandidateLibPath = ToolChain.getArchSpecificLibPath();
+if (llvm::sys::fs::is_directory(CandidateLibPath))
+  CmdArgs.push_back(Args.MakeArgString("-L" + CandidateLibPath));
+
 // Also link the particular OpenMP runtimes.
 switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
 case Driver::OMPRT_OMP:
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -320,6 +320,14 @@
   return Args.MakeArgString(getCompilerRT(Args, Component, Shared));
 }
 
+const std::string ToolChain::getArchSpecificLibPath() const {
+  SmallString<128> Path(getDriver().ResourceDir);
+  StringRef OSLibName = getTriple().isOSFreeBSD() ? "freebsd" : getOS();
+  

[PATCH] D30015: [OpenMP] Add arch-specific directory to search path

2017-02-16 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 88663.
pirama added a comment.

Use getArchTypeName() instead of getArchName().


https://reviews.llvm.org/D30015

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChain.cpp
  lib/Driver/Tools.cpp
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/aarch64/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/arm/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/i386/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64/.keep
  test/Driver/openmp-arch-dir.c

Index: test/Driver/openmp-arch-dir.c
===
--- /dev/null
+++ test/Driver/openmp-arch-dir.c
@@ -0,0 +1,57 @@
+// Test that the driver adds an arch-specific subdirectory in
+// {RESOURCE_DIR}/lib/linux to the search path.  This allows multilib toolchains
+// to package libomp.so for multiple architectures.
+
+// Directory resource_dir_with_arch_subdir is setup only for Linux
+// REQUIRES: linux
+//
+// RUN: %clang %s -### 2>&1 -fopenmp -target i686-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR \
+// RUN:   --check-prefix=CHECK-LOMP %s
+//
+// RUN: %clang %s -### 2>&1 -fopenmp -target i686-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR \
+// RUN:   --check-prefix=CHECK-LOMP %s
+//
+// RUN: %clang %s -### 2>&1 -fopenmp -target x86_64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR \
+// RUN:   --check-prefix=CHECK-LOMP %s
+//
+// RUN: %clang %s -### 2>&1 -fopenmp -target x86_64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR \
+// RUN:   --check-prefix=CHECK-LOMP %s
+//
+// RUN: %clang %s -### 2>&1 -fopenmp -target arm-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR \
+// RUN:   --check-prefix=CHECK-LOMP %s
+//
+// RUN: %clang %s -### 2>&1 -fopenmp -target arm-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR \
+// RUN:   --check-prefix=CHECK-LOMP %s
+//
+// RUN: %clang %s -### 2>&1 -fopenmp -target aarch64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR \
+// RUN:   --check-prefix=CHECK-LOMP %s
+//
+// RUN: %clang %s -### 2>&1 -fopenmp -target aarch64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR \
+// RUN:   --check-prefix=CHECK-LOMP %s
+//
+// Check correctness when -fopenmp is omitted
+// RUN: %clang %s -### 2>&1 -target arm-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR \
+// RUN:   --check-prefix=CHECK-NO-LOMP %s
+//
+// CHECK-ARCHDIR: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux
+// CHECK-NO-ARCHDIR-NOT: -L{{.*}}Inputs/resource_dir
+// CHECK-LOMP: -lomp
+// CHECK-NO-LOMP-NOT: -lomp
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3260,6 +3260,12 @@
 options::OPT_fno_openmp, false))
 return;
 
+  // Add /lib// to the linker search path if it
+  // exists.
+  std::string CandidateLibPath = TC.getArchSpecificLibPath();
+  if (llvm::sys::fs::is_directory(CandidateLibPath))
+CmdArgs.push_back(Args.MakeArgString("-L" + CandidateLibPath));
+
   switch (TC.getDriver().getOpenMPRuntime(Args)) {
   case Driver::OMPRT_OMP:
 CmdArgs.push_back("-lomp");
@@ -10316,6 +10322,12 @@
 // FIXME: Does this really make sense for all GNU toolchains?
 WantPthread = true;
 
+// Add /lib// to the linker search path if it
+// exists.
+std::string CandidateLibPath = ToolChain.getArchSpecificLibPath();
+if (llvm::sys::fs::is_directory(CandidateLibPath))
+  CmdArgs.push_back(Args.MakeArgString("-L" + CandidateLibPath));
+
 // Also link the particular OpenMP runtimes.
 switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
 case Driver::OMPRT_OMP:
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -320,6 +320,14 @@
   return Args.MakeArgString(getCompilerRT(Args, Component, Shared));
 }
 
+const std::string ToolChain::getArchSpecificLibPath() const {
+  SmallString<128> Path(getDriver().ResourceDir);
+  StringRef OSLibName = getTriple().isOSFreeBSD() ? "freebsd" : getOS();
+  llvm::sys::path::append(Path, "lib", 

[PATCH] D30015: [OpenMP] Add arch-specific directory to search path

2017-02-15 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a comment.

In https://reviews.llvm.org/D30015#678243, @Hahnfeld wrote:

> Why is this only for OpenMP? I imagine this should be done for **all** 
> runtime libraries


The other runtime libraries have the arch included in the library's name and 
the driver links the correct file.  cbergstrom preferred to look in an 
arch-specific directory rather 
(http://lists.llvm.org/pipermail/openmp-dev/2017-February/001659.html).  It 
makes sense for OpenMP because other toolchains may assume the standard library 
name (libomp.so).


https://reviews.llvm.org/D30015



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


[PATCH] D30015: Add arch-specific directory to search path

2017-02-17 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a comment.

I believe I've addressed all open issues, but this patch has changed a lot 
since Dan marked it accepted.  @Hahnfeld or @mgorny:  Can one of you give a 
LGTM if you are satisfied?


https://reviews.llvm.org/D30015



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


[PATCH] D30087: [Driver] Unify linking of OpenMP runtime

2017-02-17 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added inline comments.



Comment at: lib/Driver/Tools.cpp:8683
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs))
-addOpenMPRuntime(CmdArgs, getToolChain(), Args);
+addOpenMPRuntime(CmdArgs, getToolChain(), Args, JA);
 

`addOpenMPRuntime` would add `-lomptarget` even for this call if JA satisfies 
the newly added check.  That's a deviation from exisiting behavior.  Am I 
missing some invariant here where `JobAction`s along this path don't have an 
offloading action?


https://reviews.llvm.org/D30087



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


[PATCH] D30015: [OpenMP] Add arch-specific directory to search path

2017-02-16 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 88799.
pirama added a comment.

Stricter tests.


https://reviews.llvm.org/D30015

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChain.cpp
  lib/Driver/Tools.cpp
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/aarch64/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/arm/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/i386/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64/.keep
  test/Driver/arch-specific-libdir-rpath.c
  test/Driver/arch-specific-libdir.c
  test/lit.cfg

Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -392,6 +392,10 @@
 if config.host_triple == config.target_triple:
 config.available_features.add("native")
 
+# Test Driver/arch-specific-libdir-rpath.c is restricted to x86_64-linux
+if re.match(r'^x86_64.*-linux', config.target_triple):
+config.available_features.add("x86_64-linux")
+
 # Case-insensitive file system
 def is_filesystem_case_insensitive():
 handle, path = tempfile.mkstemp(prefix='case-test', dir=config.test_exec_root)
Index: test/Driver/arch-specific-libdir.c
===
--- /dev/null
+++ test/Driver/arch-specific-libdir.c
@@ -0,0 +1,52 @@
+// Test that the driver adds an arch-specific subdirectory in
+// {RESOURCE_DIR}/lib/linux to the search path.
+//
+// RUN: %clang %s -### 2>&1 -target i386-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR-i386 %s
+//
+// RUN: %clang %s -### 2>&1 -target i386-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target i686-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR-i386 %s
+//
+// RUN: %clang %s -### 2>&1 -target i686-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target x86_64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR-x86_64 %s
+//
+// RUN: %clang %s -### 2>&1 -target x86_64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target arm-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR-arm %s
+//
+// RUN: %clang %s -### 2>&1 -target arm-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target aarch64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR-aarch64 %s
+//
+// RUN: %clang %s -### 2>&1 -target aarch64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+//
+// CHECK-ARCHDIR-i386: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux/i386
+// CHECK-ARCHDIR-x86_64: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64
+// CHECK-ARCHDIR-arm: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux/arm
+// CHECK-ARCHDIR-aarch64: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux/aarch64
+//
+// Have a stricter check for no-archdir - that the driver doesn't add any
+// subdirectory from the provided resource directory.
+// CHECK-NO-ARCHDIR-NOT: -L{{.*}}Inputs/resource_dir
Index: test/Driver/arch-specific-libdir-rpath.c
===
--- /dev/null
+++ test/Driver/arch-specific-libdir-rpath.c
@@ -0,0 +1,20 @@
+// Test that the driver adds an arch-specific subdirectory in
+// {RESOURCE_DIR}/lib/linux to the linker search path and to '-rpath' for native
+// compilations.
+//
+// -rpath only gets added during native compilation.  To keep the test simple,
+// just test for x86_64-linux native compilation.
+// REQUIRES: x86_64-linux
+//
+// RUN: %clang %s -### 2>&1 \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+//
+// CHECK-ARCHDIR: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux{{.*}} "-rpath" {{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux
+// CHECK-NO-ARCHDIR-NOT: -L{{.*}}Inputs/resource_dir
+// CHECK-NO-ARCHDIR-NOT: "-rpath" {{.*}}/Inputs/resource_dir
Index: lib/Driver/Tools.cpp

[PATCH] D30015: [OpenMP] Add arch-specific directory to search path

2017-02-16 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added inline comments.



Comment at: test/Driver/arch-specific-libdir-rpath.c:6
+// -rpath only gets added during native compilation
+// REQUIRES: native
+//

pirama wrote:
> I feel this test is fragile.  Any idea how to further restrict and require 
> that the default target triple has linux and one of i386, x86_64, arm, 
> aarch64?
> 
> I could create sub-dirs for all archs returned by Triple::getArchTypeName 
> (llvm/lib/Support/Triple.cpp) but it seems overkill.
I've restricted the test to just x86_64-linux.


https://reviews.llvm.org/D30015



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


[PATCH] D30015: Add arch-specific directory to search path

2017-02-17 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a reviewer: rnk.
pirama added a subscriber: rnk.
pirama added a comment.

@rnk: This patch was to address discussion in 
http://lists.llvm.org/pipermail/openmp-dev/2017-February/001659.html but now 
also addresses 
http://lists.llvm.org/pipermail/cfe-dev/2017-January/052512.html.  Can you take 
a look?


https://reviews.llvm.org/D30015



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


[PATCH] D30015: Add arch-specific directory to search path

2017-02-17 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added inline comments.



Comment at: test/Driver/arch-specific-libdir-rpath.c:18
+//
+// CHECK-ARCHDIR: 
-L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux{{.*}} "-rpath" 
{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux
+// CHECK-NO-ARCHDIR-NOT: -L{{.*}}Inputs/resource_dir

mgorny wrote:
> pirama wrote:
> > Hahnfeld wrote:
> > > Can you split that into two lines? Then it won't fail if there is some 
> > > argument added in between
> > Splitting into two lines makes FileCheck eagerly match the arch-subdir and 
> > -rpath into the {{.*}} next to the "-L".  This causes the check for -rpath 
> > to fail.
> > 
> > The test accepts intermediate arguments because of the wildcard right after 
> > the -L...Inputs/...
> Please do not rely on implicit assumptions like that. One day someone may 
> decide to 'fix' the wildcard not to match whitespace, and make the wrong 
> assumption about order. If for anything, splitting in two would make this 
> more readable.
Do you have any suggestions?  Right now, if I split it into two lines, the 
second check fails due to the eager regex match.


https://reviews.llvm.org/D30015



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


[PATCH] D30015: Add arch-specific directory to search path

2017-02-17 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added inline comments.



Comment at: test/Driver/arch-specific-libdir-rpath.c:18
+//
+// CHECK-ARCHDIR: 
-L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux{{.*}} "-rpath" 
{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux
+// CHECK-NO-ARCHDIR-NOT: -L{{.*}}Inputs/resource_dir

Hahnfeld wrote:
> Can you split that into two lines? Then it won't fail if there is some 
> argument added in between
Splitting into two lines makes FileCheck eagerly match the arch-subdir and 
-rpath into the {{.*}} next to the "-L".  This causes the check for -rpath to 
fail.

The test accepts intermediate arguments because of the wildcard right after the 
-L...Inputs/...


https://reviews.llvm.org/D30015



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


[PATCH] D30015: [OpenMP] Add arch-specific directory to search path

2017-02-16 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a subscriber: openmp-commits.
pirama marked an inline comment as done.
pirama added inline comments.



Comment at: lib/Driver/Tools.cpp:3267
+  if (llvm::sys::fs::is_directory(CandidateLibPath))
+CmdArgs.push_back(Args.MakeArgString("-L" + CandidateLibPath));
+

mgorny wrote:
> Don't you also need rpath for it? Or is this purely for static runtime?
I am doing this for a cross-compiling toolchain (Android NDK) where the actual 
rpath is not valid at runtime.  The runtime is packaged with the application 
and made available to the loader behind the scenes.

That said, I don't think providing an rpath doesn't hurt.  I'll wait for input 
from @cbergstrom and OpenMP folks to see if this'd be useful.


https://reviews.llvm.org/D30015



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


[PATCH] D30015: [OpenMP] Add arch-specific directory to search path

2017-02-16 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a comment.

I am fine to do this more generally, but not sure of the scope.  Should this be 
always added or only if a runtime (sanitizer or openmp or xray) is requested?


https://reviews.llvm.org/D30015



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


[PATCH] D30015: [OpenMP] Add arch-specific directory to search path

2017-02-16 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 88768.
pirama added a comment.

- Arch-subdir is now always added to -L
- It is added to -rpath during native compilation.
- Tests have been updated


https://reviews.llvm.org/D30015

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChain.cpp
  lib/Driver/Tools.cpp
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/aarch64/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/arm/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/i386/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64/.keep
  test/Driver/arch-specific-libdir-rpath.c
  test/Driver/arch-specific-libdir.c

Index: test/Driver/arch-specific-libdir.c
===
--- /dev/null
+++ test/Driver/arch-specific-libdir.c
@@ -0,0 +1,38 @@
+// Test that the driver adds an arch-specific subdirectory in
+// {RESOURCE_DIR}/lib/linux to the search path.
+//
+// RUN: %clang %s -### 2>&1 -target i686-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target i686-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target x86_64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target x86_64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target arm-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target arm-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target aarch64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target aarch64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+//
+// CHECK-ARCHDIR: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux
+// CHECK-NO-ARCHDIR-NOT: -L{{.*}}Inputs/resource_dir
Index: test/Driver/arch-specific-libdir-rpath.c
===
--- /dev/null
+++ test/Driver/arch-specific-libdir-rpath.c
@@ -0,0 +1,19 @@
+// Test that the driver adds an arch-specific subdirectory in
+// {RESOURCE_DIR}/lib/linux to the linker search path and to '-rpath' for native
+// compilations.
+//
+// -rpath only gets added during native compilation
+// REQUIRES: native
+//
+// RUN: %clang %s -### 2>&1 \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+//
+// CHECK-ARCHDIR: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux{{.*}} "-rpath" {{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux
+// CHECK-NO-ARCHDIR-NOT: -L{{.*}}Inputs/resource_dir
+// CHECK-NO-ARCHDIR-NOT: "-rpath" {{.*}}/Inputs/resource_dir
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -14,6 +14,7 @@
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/ObjCRuntime.h"
 #include "clang/Basic/Version.h"
+#include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Config/config.h"
 #include "clang/Driver/Action.h"
 #include "clang/Driver/Compilation.h"
@@ -276,8 +277,18 @@
 
   // LIBRARY_PATH - included following the user specified library paths.
   //and only supported on native toolchains.
-  if (!TC.isCrossCompiling())
+  if (!TC.isCrossCompiling()) {
 addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");
+
+// If we are not cross-compling, add '-rpath' with architecture-specific
+// library path so libraries lined from this path can be automatically
+// found.
+std::string CandidateRPath = TC.getArchSpecificLibPath();
+if (D.getVFS().exists(CandidateRPath)) {
+  CmdArgs.push_back("-rpath");
+  CmdArgs.push_back(Args.MakeArgString(CandidateRPath.c_str()));
+}
+  }
 }
 
 /// Add OpenMP linker script arguments at the end of the argument list so that
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -10,6 +10,7 @@
 #include "clang/Driver/ToolChain.h"
 #include "Tools.h"
 #include 

[PATCH] D30015: [OpenMP] Add arch-specific directory to search path

2017-02-16 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added inline comments.



Comment at: test/Driver/arch-specific-libdir-rpath.c:6
+// -rpath only gets added during native compilation
+// REQUIRES: native
+//

I feel this test is fragile.  Any idea how to further restrict and require that 
the default target triple has linux and one of i386, x86_64, arm, aarch64?

I could create sub-dirs for all archs returned by Triple::getArchTypeName 
(llvm/lib/Support/Triple.cpp) but it seems overkill.


https://reviews.llvm.org/D30015



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


[PATCH] D30015: [OpenMP] Add arch-specific directory to search path

2017-02-17 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 88864.
pirama added a comment.

Fix typo.


https://reviews.llvm.org/D30015

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChain.cpp
  lib/Driver/Tools.cpp
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/aarch64/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/arm/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/i386/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64/.keep
  test/Driver/arch-specific-libdir-rpath.c
  test/Driver/arch-specific-libdir.c
  test/lit.cfg

Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -392,6 +392,10 @@
 if config.host_triple == config.target_triple:
 config.available_features.add("native")
 
+# Test Driver/arch-specific-libdir-rpath.c is restricted to x86_64-linux
+if re.match(r'^x86_64.*-linux', config.target_triple):
+config.available_features.add("x86_64-linux")
+
 # Case-insensitive file system
 def is_filesystem_case_insensitive():
 handle, path = tempfile.mkstemp(prefix='case-test', dir=config.test_exec_root)
Index: test/Driver/arch-specific-libdir.c
===
--- /dev/null
+++ test/Driver/arch-specific-libdir.c
@@ -0,0 +1,52 @@
+// Test that the driver adds an arch-specific subdirectory in
+// {RESOURCE_DIR}/lib/linux to the search path.
+//
+// RUN: %clang %s -### 2>&1 -target i386-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR-i386 %s
+//
+// RUN: %clang %s -### 2>&1 -target i386-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target i686-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR-i386 %s
+//
+// RUN: %clang %s -### 2>&1 -target i686-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target x86_64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR-x86_64 %s
+//
+// RUN: %clang %s -### 2>&1 -target x86_64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target arm-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR-arm %s
+//
+// RUN: %clang %s -### 2>&1 -target arm-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target aarch64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR-aarch64 %s
+//
+// RUN: %clang %s -### 2>&1 -target aarch64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+//
+// CHECK-ARCHDIR-i386: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux/i386
+// CHECK-ARCHDIR-x86_64: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64
+// CHECK-ARCHDIR-arm: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux/arm
+// CHECK-ARCHDIR-aarch64: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux/aarch64
+//
+// Have a stricter check for no-archdir - that the driver doesn't add any
+// subdirectory from the provided resource directory.
+// CHECK-NO-ARCHDIR-NOT: -L{{.*}}Inputs/resource_dir
Index: test/Driver/arch-specific-libdir-rpath.c
===
--- /dev/null
+++ test/Driver/arch-specific-libdir-rpath.c
@@ -0,0 +1,20 @@
+// Test that the driver adds an arch-specific subdirectory in
+// {RESOURCE_DIR}/lib/linux to the linker search path and to '-rpath' for native
+// compilations.
+//
+// -rpath only gets added during native compilation.  To keep the test simple,
+// just test for x86_64-linux native compilation.
+// REQUIRES: x86_64-linux
+//
+// RUN: %clang %s -### 2>&1 \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+//
+// CHECK-ARCHDIR: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux{{.*}} "-rpath" {{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux
+// CHECK-NO-ARCHDIR-NOT: -L{{.*}}Inputs/resource_dir
+// CHECK-NO-ARCHDIR-NOT: "-rpath" {{.*}}/Inputs/resource_dir
Index: lib/Driver/Tools.cpp

[PATCH] D30015: Add arch-specific directory to search path

2017-02-17 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 88865.
pirama marked an inline comment as done.
pirama added a comment.

Add arch name to -rpath test.


https://reviews.llvm.org/D30015

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChain.cpp
  lib/Driver/Tools.cpp
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/aarch64/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/arm/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/i386/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64/.keep
  test/Driver/arch-specific-libdir-rpath.c
  test/Driver/arch-specific-libdir.c
  test/lit.cfg

Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -392,6 +392,10 @@
 if config.host_triple == config.target_triple:
 config.available_features.add("native")
 
+# Test Driver/arch-specific-libdir-rpath.c is restricted to x86_64-linux
+if re.match(r'^x86_64.*-linux', config.target_triple):
+config.available_features.add("x86_64-linux")
+
 # Case-insensitive file system
 def is_filesystem_case_insensitive():
 handle, path = tempfile.mkstemp(prefix='case-test', dir=config.test_exec_root)
Index: test/Driver/arch-specific-libdir.c
===
--- /dev/null
+++ test/Driver/arch-specific-libdir.c
@@ -0,0 +1,52 @@
+// Test that the driver adds an arch-specific subdirectory in
+// {RESOURCE_DIR}/lib/linux to the search path.
+//
+// RUN: %clang %s -### 2>&1 -target i386-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR-i386 %s
+//
+// RUN: %clang %s -### 2>&1 -target i386-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target i686-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR-i386 %s
+//
+// RUN: %clang %s -### 2>&1 -target i686-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target x86_64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR-x86_64 %s
+//
+// RUN: %clang %s -### 2>&1 -target x86_64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target arm-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR-arm %s
+//
+// RUN: %clang %s -### 2>&1 -target arm-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target aarch64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR-aarch64 %s
+//
+// RUN: %clang %s -### 2>&1 -target aarch64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+//
+// CHECK-ARCHDIR-i386: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux/i386
+// CHECK-ARCHDIR-x86_64: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64
+// CHECK-ARCHDIR-arm: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux/arm
+// CHECK-ARCHDIR-aarch64: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux/aarch64
+//
+// Have a stricter check for no-archdir - that the driver doesn't add any
+// subdirectory from the provided resource directory.
+// CHECK-NO-ARCHDIR-NOT: -L{{.*}}Inputs/resource_dir
Index: test/Driver/arch-specific-libdir-rpath.c
===
--- /dev/null
+++ test/Driver/arch-specific-libdir-rpath.c
@@ -0,0 +1,20 @@
+// Test that the driver adds an arch-specific subdirectory in
+// {RESOURCE_DIR}/lib/linux to the linker search path and to '-rpath' for native
+// compilations.
+//
+// -rpath only gets added during native compilation.  To keep the test simple,
+// just test for x86_64-linux native compilation.
+// REQUIRES: x86_64-linux
+//
+// RUN: %clang %s -### 2>&1 \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+//
+// CHECK-ARCHDIR: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64{{.*}} "-rpath" {{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64
+// CHECK-NO-ARCHDIR-NOT: -L{{.*}}Inputs/resource_dir
+// CHECK-NO-ARCHDIR-NOT: "-rpath" {{.*}}/Inputs/resource_dir

[PATCH] D30920: Do not pass -Os and -Oz to the Gold plugin

2017-03-16 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a comment.

In https://reviews.llvm.org/D30920#700741, @mehdi_amini wrote:

> In https://reviews.llvm.org/D30920#700574, @hfinkel wrote:
>
> > In https://reviews.llvm.org/D30920#700557, @mehdi_amini wrote:
> >
> > > In https://reviews.llvm.org/D30920#700433, @tejohnson wrote:
> > >
> > > > In https://reviews.llvm.org/D30920#700133, @pcc wrote:
> > > >
> > > > > In https://reviews.llvm.org/D30920#700077, @tejohnson wrote:
> > > > >
> > > > > > Until everything is converted to using size attributes, it seems 
> > > > > > like a correct fix for the bug is to accept these options in the 
> > > > > > gold-plugin and pass through the LTO API to the PassManagerBuilder.
> > > > >
> > > > >
> > > > > Not necessarily. There is no requirement (from a correctness 
> > > > > perspective) that `-Os` at link time should exactly match the 
> > > > > behaviour of `-Os` at compile time.
> > > >
> > > >
> > > > Sure, but there is certainly a perception that optimization flags 
> > > > affecting the non-LTO pipeline should similarly affect the LTO 
> > > > pipeline. LTO should be transparent to the user, so if -Os behaves one 
> > > > way without LTO, it seems problematic to me if it behaves a different 
> > > > way with LTO.
> > > >
> > > > That being said, agree that the best way to enforce that is to pass the 
> > > > relevant flags through the IR. (On the flip side, if the user passes 
> > > > -O1 to the link step, it does get passed through to the plugin and 
> > > > affects the LTO optimization pipeline...)
> > >
> > >
> > > I agree that I don't like the discrepancy: the driver should *not* drop 
> > > -Os silently if it passes down -O1/-O2/-O3, a warning is the minimum.
> >
> >
> > I don't like the discrepancy either, and I agree that we should be passing 
> > these other flags through the IR as well (even though, in the face of 
> > inlining, there is some ambiguity as to what the flags would mean). That 
> > having been said, I don't see the value in the warning. Forcing users to 
> > endure a warning solely because they use LTO and use -Os or -Oz for all of 
> > their compilation steps, is not friendly.
>
>
> The warning here is only about the *link* step.
>
> > The information has been captured already so there's nothing to warn about. 
> > You might worry about the opposite situation (the user uses only -Os or -Oz 
> > on the link step, but not for the compile steps), and that will have no 
> > effect. That, however, should be the expected behavior (optimization is 
> > associated with compiling, not linking, except perhaps for specifically 
> > called-out exceptions). The fact that our other optimization level don't 
> > work that way is a bug, not a feature, that we should fix instead of 
> > further exposing to our users.
>
> Yes, the issue is only about how the driver accepts Os for the link even 
> though it has no effect 
> (O0/https://reviews.llvm.org/owners/package/1//https://reviews.llvm.org/owners/package/2//https://reviews.llvm.org/owners/package/3/
>  *will* have an effect though).


The driver (accepts, but) ignores Os and other optimization flags for non-lto 
link-only actions.  That it has an effect for LTO is seems to be an 
implementation detail.  Since optimization flags are compiler-only options, and 
Clang already silently (without a warning) ignores these flags during link-only 
invocations, silently transforming them when passing to the plugin seems 
reasonable.


https://reviews.llvm.org/D30920



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


[PATCH] D30947: [Driver] Fix arch-specific-libdir-rpath.c

2017-03-14 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama created this revision.

Fix the test by adding missing -target flags with a 'linux' triple.


https://reviews.llvm.org/D30947

Files:
  test/Driver/arch-specific-libdir-rpath.c


Index: test/Driver/arch-specific-libdir-rpath.c
===
--- test/Driver/arch-specific-libdir-rpath.c
+++ test/Driver/arch-specific-libdir-rpath.c
@@ -59,19 +59,19 @@
 // RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s
 //
 // Add LIBPATH but no RPATH for ubsan (or any other sanitizer)
-// RUN: %clang %s -### 2>&1 -fsanitize=undefined \
+// RUN: %clang %s -### 2>&1 -fsanitize=undefined -target x86_64-linux \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -frtlib-add-rpath \
 // RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s
 //
 // Add LIBPATH but no RPATH if no sanitizer or runtime is specified
-// RUN: %clang %s -### 2>&1 \
+// RUN: %clang %s -### 2>&1 -target x86_64-linux \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -frtlib-add-rpath \
 // RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s
 //
 // Do not add LIBPATH or RPATH if arch-specific subdir doesn't exist
-// RUN: %clang %s -### 2>&1 \
+// RUN: %clang %s -### 2>&1 -target x86_64-linux \
 // RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN: -frtlib-add-rpath \
 // RUN:   | FileCheck --check-prefixes=RESDIR,NO-LIBPATH,NO-RPATH %s


Index: test/Driver/arch-specific-libdir-rpath.c
===
--- test/Driver/arch-specific-libdir-rpath.c
+++ test/Driver/arch-specific-libdir-rpath.c
@@ -59,19 +59,19 @@
 // RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s
 //
 // Add LIBPATH but no RPATH for ubsan (or any other sanitizer)
-// RUN: %clang %s -### 2>&1 -fsanitize=undefined \
+// RUN: %clang %s -### 2>&1 -fsanitize=undefined -target x86_64-linux \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -frtlib-add-rpath \
 // RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s
 //
 // Add LIBPATH but no RPATH if no sanitizer or runtime is specified
-// RUN: %clang %s -### 2>&1 \
+// RUN: %clang %s -### 2>&1 -target x86_64-linux \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -frtlib-add-rpath \
 // RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s
 //
 // Do not add LIBPATH or RPATH if arch-specific subdir doesn't exist
-// RUN: %clang %s -### 2>&1 \
+// RUN: %clang %s -### 2>&1 -target x86_64-linux \
 // RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN: -frtlib-add-rpath \
 // RUN:   | FileCheck --check-prefixes=RESDIR,NO-LIBPATH,NO-RPATH %s
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30947: [Driver] Fix arch-specific-libdir-rpath.c

2017-03-14 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL297754: [Driver] Fix arch-specific-libdir-rpath.c (authored 
by pirama).

Changed prior to commit:
  https://reviews.llvm.org/D30947?vs=91746=91747#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30947

Files:
  cfe/trunk/test/Driver/arch-specific-libdir-rpath.c


Index: cfe/trunk/test/Driver/arch-specific-libdir-rpath.c
===
--- cfe/trunk/test/Driver/arch-specific-libdir-rpath.c
+++ cfe/trunk/test/Driver/arch-specific-libdir-rpath.c
@@ -59,19 +59,19 @@
 // RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s
 //
 // Add LIBPATH but no RPATH for ubsan (or any other sanitizer)
-// RUN: %clang %s -### 2>&1 -fsanitize=undefined \
+// RUN: %clang %s -### 2>&1 -fsanitize=undefined -target x86_64-linux \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -frtlib-add-rpath \
 // RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s
 //
 // Add LIBPATH but no RPATH if no sanitizer or runtime is specified
-// RUN: %clang %s -### 2>&1 \
+// RUN: %clang %s -### 2>&1 -target x86_64-linux \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -frtlib-add-rpath \
 // RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s
 //
 // Do not add LIBPATH or RPATH if arch-specific subdir doesn't exist
-// RUN: %clang %s -### 2>&1 \
+// RUN: %clang %s -### 2>&1 -target x86_64-linux \
 // RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN: -frtlib-add-rpath \
 // RUN:   | FileCheck --check-prefixes=RESDIR,NO-LIBPATH,NO-RPATH %s


Index: cfe/trunk/test/Driver/arch-specific-libdir-rpath.c
===
--- cfe/trunk/test/Driver/arch-specific-libdir-rpath.c
+++ cfe/trunk/test/Driver/arch-specific-libdir-rpath.c
@@ -59,19 +59,19 @@
 // RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s
 //
 // Add LIBPATH but no RPATH for ubsan (or any other sanitizer)
-// RUN: %clang %s -### 2>&1 -fsanitize=undefined \
+// RUN: %clang %s -### 2>&1 -fsanitize=undefined -target x86_64-linux \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -frtlib-add-rpath \
 // RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s
 //
 // Add LIBPATH but no RPATH if no sanitizer or runtime is specified
-// RUN: %clang %s -### 2>&1 \
+// RUN: %clang %s -### 2>&1 -target x86_64-linux \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -frtlib-add-rpath \
 // RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s
 //
 // Do not add LIBPATH or RPATH if arch-specific subdir doesn't exist
-// RUN: %clang %s -### 2>&1 \
+// RUN: %clang %s -### 2>&1 -target x86_64-linux \
 // RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN: -frtlib-add-rpath \
 // RUN:   | FileCheck --check-prefixes=RESDIR,NO-LIBPATH,NO-RPATH %s
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30733: [Driver] Add arch-specific rpath for libc++

2017-03-09 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added inline comments.



Comment at: lib/Driver/ToolChain.cpp:652
+// libc++ may be installed per arch.
+addArchSpecificRPath(*this, Args, CmdArgs);
 break;

`addArchSpecificRPath` is a static function in Tools.cpp and isn't visible here.


https://reviews.llvm.org/D30733



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


[PATCH] D30015: Add arch-specific directory to search path

2017-03-03 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 90532.
pirama edited the summary of this revision.
pirama added a comment.

Fixed comment in test and added a test for -fsanitize=address without 
-shared-libasan.


https://reviews.llvm.org/D30015

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChain.cpp
  lib/Driver/Tools.cpp
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/aarch64/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/arm/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/i386/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64/.keep
  test/Driver/arch-specific-libdir-rpath.c
  test/Driver/arch-specific-libdir.c
  test/lit.cfg

Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -392,6 +392,10 @@
 if config.host_triple == config.target_triple:
 config.available_features.add("native")
 
+# Test Driver/arch-specific-libdir-rpath.c is restricted to x86_64-linux
+if re.match(r'^x86_64.*-linux', config.target_triple):
+config.available_features.add("x86_64-linux")
+
 # Case-insensitive file system
 def is_filesystem_case_insensitive():
 handle, path = tempfile.mkstemp(prefix='case-test', dir=config.test_exec_root)
Index: test/Driver/arch-specific-libdir.c
===
--- /dev/null
+++ test/Driver/arch-specific-libdir.c
@@ -0,0 +1,53 @@
+// Test that the driver adds an arch-specific subdirectory in
+// {RESOURCE_DIR}/lib/linux to the search path.
+//
+// RUN: %clang %s -### 2>&1 -target i386-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefixes=FILEPATH,ARCHDIR-i386 %s
+//
+// RUN: %clang %s -### 2>&1 -target i386-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefixes=FILEPATH,NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target i686-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefixes=FILEPATH,ARCHDIR-i386 %s
+//
+// RUN: %clang %s -### 2>&1 -target i686-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefixes=FILEPATH,NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target x86_64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefixes=FILEPATH,ARCHDIR-x86_64 %s
+//
+// RUN: %clang %s -### 2>&1 -target x86_64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefixes=FILEPATH,NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target arm-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefixes=FILEPATH,ARCHDIR-arm %s
+//
+// RUN: %clang %s -### 2>&1 -target arm-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefixes=FILEPATH,NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target aarch64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefixes=FILEPATH,ARCHDIR-aarch64 %s
+//
+// RUN: %clang %s -### 2>&1 -target aarch64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefixes=FILEPATH,NO-ARCHDIR %s
+//
+//
+// FILEPATH: "-x" "c" "[[FILE_PATH:.*]]/{{.*}}.c"
+// ARCHDIR-i386:-L[[FILE_PATH]]/Inputs/resource_dir_with_arch_subdir/lib/linux/i386
+// ARCHDIR-x86_64:  -L[[FILE_PATH]]/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64
+// ARCHDIR-arm: -L[[FILE_PATH]]/Inputs/resource_dir_with_arch_subdir/lib/linux/arm
+// ARCHDIR-aarch64: -L[[FILE_PATH]]/Inputs/resource_dir_with_arch_subdir/lib/linux/aarch64
+//
+// Have a stricter check for no-archdir - that the driver doesn't add any
+// subdirectory from the provided resource directory.
+// NO-ARCHDIR-NOT: -L[[FILE_PATH]]/Inputs/resource_dir
Index: test/Driver/arch-specific-libdir-rpath.c
===
--- /dev/null
+++ test/Driver/arch-specific-libdir-rpath.c
@@ -0,0 +1,50 @@
+// Test that the driver adds an arch-specific subdirectory in
+// {RESOURCE_DIR}/lib/linux to the linker search path and to '-rpath' for native
+// compilations.
+//
+// -rpath only gets added during native compilation.  To keep the test simple,
+// just test for x86_64-linux native compilation.
+// REQUIRES: x86_64-linux
+//
+// Add LIBPATH but no RPATH for -fsanitizer=address w/o -shared-libasan
+// RUN: %clang %s -### 2>&1 -fsanitize=undefined \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefixes=FILEPATH,LIBPATH,NO-RPATH %s
+//
+// Add LIBPATH, RPATH for -fsanitize=address -shared-libasan
+// RUN: %clang %s -### 2>&1 -target x86_64-linux \
+// RUN: 

[PATCH] D30015: Add arch-specific directory to search path

2017-03-03 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a comment.

Committed.  Thanks for the reviews!


Repository:
  rL LLVM

https://reviews.llvm.org/D30015



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


[PATCH] D30015: Add arch-specific directory to search path

2017-03-03 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama marked an inline comment as done.
pirama added inline comments.



Comment at: lib/Driver/Tools.cpp:2007-2009
+  // In the cross-compilation case, arch-specific library path is likely
+  // unavailable at runtime.
+  if (TC.isCrossCompiling()) return;

rnk wrote:
> This seems like a really poor heuristic for "will the user ship this binary 
> to another computer that doesn't have clang installed in the same location", 
> but the convenience of not having to add clang's unpredictably named resource 
> library directory to LD_LIBRARY_PATH seems worth baking in a possibly-wrong 
> rpath.
This is indeed poor, but a good check that omits rpath when it is definitely 
useless but leave it in case it might be useful.


https://reviews.llvm.org/D30015



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


[PATCH] D30015: Add arch-specific directory to search path

2017-03-03 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296927: Add arch-specific directory to search path (authored 
by pirama).

Changed prior to commit:
  https://reviews.llvm.org/D30015?vs=90532=90545#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30015

Files:
  cfe/trunk/include/clang/Driver/ToolChain.h
  cfe/trunk/lib/Driver/ToolChain.cpp
  cfe/trunk/lib/Driver/Tools.cpp
  
cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/aarch64/.keep
  cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/arm/.keep
  
cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/i386/.keep
  
cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64/.keep
  cfe/trunk/test/Driver/arch-specific-libdir-rpath.c
  cfe/trunk/test/Driver/arch-specific-libdir.c
  cfe/trunk/test/lit.cfg

Index: cfe/trunk/lib/Driver/ToolChain.cpp
===
--- cfe/trunk/lib/Driver/ToolChain.cpp
+++ cfe/trunk/lib/Driver/ToolChain.cpp
@@ -10,6 +10,7 @@
 #include "clang/Driver/ToolChain.h"
 #include "Tools.h"
 #include "clang/Basic/ObjCRuntime.h"
+#include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Config/config.h"
 #include "clang/Driver/Action.h"
 #include "clang/Driver/Driver.h"
@@ -74,6 +75,10 @@
 if (!isThreadModelSupported(A->getValue()))
   D.Diag(diag::err_drv_invalid_thread_model_for_target)
   << A->getValue() << A->getAsString(Args);
+
+  std::string CandidateLibPath = getArchSpecificLibPath();
+  if (getVFS().exists(CandidateLibPath))
+getFilePaths().push_back(CandidateLibPath);
 }
 
 ToolChain::~ToolChain() {
@@ -320,6 +325,14 @@
   return Args.MakeArgString(getCompilerRT(Args, Component, Shared));
 }
 
+std::string ToolChain::getArchSpecificLibPath() const {
+  SmallString<128> Path(getDriver().ResourceDir);
+  StringRef OSLibName = getTriple().isOSFreeBSD() ? "freebsd" : getOS();
+  llvm::sys::path::append(Path, "lib", OSLibName,
+  llvm::Triple::getArchTypeName(getArch()));
+  return Path.str();
+}
+
 bool ToolChain::needsProfileRT(const ArgList ) {
   if (Args.hasFlag(options::OPT_fprofile_arcs, options::OPT_fno_profile_arcs,
false) ||
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -14,6 +14,7 @@
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/ObjCRuntime.h"
 #include "clang/Basic/Version.h"
+#include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Config/config.h"
 #include "clang/Driver/Action.h"
 #include "clang/Driver/Compilation.h"
@@ -238,8 +239,9 @@
 
   // LIBRARY_PATH - included following the user specified library paths.
   //and only supported on native toolchains.
-  if (!TC.isCrossCompiling())
+  if (!TC.isCrossCompiling()) {
 addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");
+  }
 }
 
 /// Add OpenMP linker script arguments at the end of the argument list so that
@@ -2000,6 +2002,19 @@
   }
 }
 
+static void addArchSpecificRPath(const ToolChain , const ArgList ,
+ ArgStringList ) {
+  // In the cross-compilation case, arch-specific library path is likely
+  // unavailable at runtime.
+  if (TC.isCrossCompiling()) return;
+
+  std::string CandidateRPath = TC.getArchSpecificLibPath();
+  if (TC.getVFS().exists(CandidateRPath)) {
+CmdArgs.push_back("-rpath");
+CmdArgs.push_back(Args.MakeArgString(CandidateRPath.c_str()));
+  }
+}
+
 static void addOpenMPRuntime(ArgStringList , const ToolChain ,
   const ArgList ) {
   if (!Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
@@ -2020,6 +2035,8 @@
 // Already diagnosed.
 break;
   }
+
+  addArchSpecificRPath(TC, Args, CmdArgs);
 }
 
 static void addSanitizerRuntime(const ToolChain , const ArgList ,
@@ -2030,6 +2047,10 @@
   if (IsWhole) CmdArgs.push_back("-whole-archive");
   CmdArgs.push_back(TC.getCompilerRTArgString(Args, Sanitizer, IsShared));
   if (IsWhole) CmdArgs.push_back("-no-whole-archive");
+
+  if (IsShared) {
+addArchSpecificRPath(TC, Args, CmdArgs);
+  }
 }
 
 // Tries to use a file with the list of dynamic symbols that need to be exported
@@ -9002,6 +9023,8 @@
 }
 if (JA.isHostOffloading(Action::OFK_OpenMP))
   CmdArgs.push_back("-lomptarget");
+
+addArchSpecificRPath(ToolChain, Args, CmdArgs);
   }
 
   AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
Index: cfe/trunk/include/clang/Driver/ToolChain.h
===
--- cfe/trunk/include/clang/Driver/ToolChain.h
+++ cfe/trunk/include/clang/Driver/ToolChain.h
@@ -299,6 +299,11 @@
   const char *getCompilerRTArgString(const llvm::opt::ArgList ,
  StringRef Component,
 

[PATCH] D30700: [Driver] Always add arch-specific-subdir to -rpath

2017-03-13 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 91633.
pirama added a comment.

- Rebase
- Added command line flag and updated tests.


https://reviews.llvm.org/D30700

Files:
  lib/Driver/ToolChains/CommonArgs.cpp
  test/Driver/arch-specific-libdir-rpath.c
  test/Driver/arch-specific-libdir.c
  test/lit.cfg

Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -397,10 +397,6 @@
 if config.host_triple == config.target_triple:
 config.available_features.add("native")
 
-# Test Driver/arch-specific-libdir-rpath.c is restricted to x86_64-linux
-if re.match(r'^x86_64.*-linux', config.target_triple):
-config.available_features.add("x86_64-linux")
-
 # Case-insensitive file system
 def is_filesystem_case_insensitive():
 handle, path = tempfile.mkstemp(prefix='case-test', dir=config.test_exec_root)
Index: test/Driver/arch-specific-libdir.c
===
--- test/Driver/arch-specific-libdir.c
+++ test/Driver/arch-specific-libdir.c
@@ -1,8 +1,6 @@
 // Test that the driver adds an arch-specific subdirectory in
 // {RESOURCE_DIR}/lib/linux to the search path.
 //
-// REQUIRES: linux
-//
 // RUN: %clang %s -### 2>&1 -target i386-unknown-linux \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN:   | FileCheck --check-prefixes=FILEPATH,ARCHDIR-i386 %s
Index: test/Driver/arch-specific-libdir-rpath.c
===
--- test/Driver/arch-specific-libdir-rpath.c
+++ test/Driver/arch-specific-libdir-rpath.c
@@ -1,50 +1,53 @@
 // Test that the driver adds an arch-specific subdirectory in
-// {RESOURCE_DIR}/lib/linux to the linker search path and to '-rpath' for native
-// compilations.
-//
-// -rpath only gets added during native compilation.  To keep the test simple,
-// just test for x86_64-linux native compilation.
-// REQUIRES: x86_64-linux
+// {RESOURCE_DIR}/lib/linux to the linker search path and to '-rpath'
 //
 // Add LIBPATH but no RPATH for -fsanitizer=address w/o -shared-libasan
-// RUN: %clang %s -### 2>&1 -fsanitize=undefined \
+// RUN: %clang %s -### 2>&1 -target x86_64-linux -fsanitize=undefined \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
-// RUN:   | FileCheck --check-prefixes=FILEPATH,LIBPATH,NO-RPATH %s
+// RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s
 //
 // Add LIBPATH, RPATH for -fsanitize=address -shared-libasan
 // RUN: %clang %s -### 2>&1 -target x86_64-linux \
 // RUN: -fsanitize=address -shared-libasan \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
-// RUN:   | FileCheck --check-prefixes=FILEPATH,LIBPATH,RPATH %s
+// RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s
+//
+// Add LIBPATH, RPATH for -fsanitize=address -shared-libasan on aarch64
+// RUN: %clang %s -### 2>&1 -target aarch64-linux \
+// RUN: -fsanitize=address -shared-libasan \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-AArch64,RPATH-AArch64 %s
 //
 // Add LIBPATH, RPATH with -fsanitize=address for Android
 // RUN: %clang %s -### 2>&1 -target x86_64-linux-android -fsanitize=address \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
-// RUN:   | FileCheck --check-prefixes=FILEPATH,LIBPATH,RPATH %s
+// RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s
 //
 // Add LIBPATH, RPATH for OpenMP
-// RUN: %clang %s -### 2>&1 -fopenmp \
+// RUN: %clang %s -### 2>&1 -target x86_64-linux -fopenmp \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
-// RUN:   | FileCheck --check-prefixes=FILEPATH,LIBPATH,RPATH %s
+// RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s
 //
 // Add LIBPATH but no RPATH for ubsan (or any other sanitizer)
 // RUN: %clang %s -### 2>&1 -fsanitize=undefined \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
-// RUN:   | FileCheck --check-prefixes=FILEPATH,LIBPATH,NO-RPATH %s
+// RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s
 //
 // Add LIBPATH but no RPATH if no sanitizer or runtime is specified
 // RUN: %clang %s -### 2>&1 \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
-// RUN:   | FileCheck --check-prefixes=FILEPATH,LIBPATH,NO-RPATH %s
+// RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s
 //
 // Do not add LIBPATH or RPATH if arch-specific subdir doesn't exist
 // RUN: %clang %s -### 2>&1 \
 // RUN: -resource-dir=%S/Inputs/resource_dir \
-// RUN:   | FileCheck --check-prefixes=FILEPATH,NO-LIBPATH,NO-RPATH %s
+// RUN:   | FileCheck --check-prefixes=RESDIR,NO-LIBPATH,NO-RPATH %s
 //
 //
-// FILEPATH: "-x" "c" "[[FILE_PATH:.*]]/{{.*}}.c"
-// LIBPATH: -L[[FILE_PATH]]/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64
-// RPATH: "-rpath" 

[PATCH] D30733: [Driver] Add arch-specific rpath for libc++

2017-03-13 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added inline comments.



Comment at: lib/Driver/ToolChain.cpp:652
+// libc++ may be installed per arch.
+addArchSpecificRPath(*this, Args, CmdArgs);
 break;

Hahnfeld wrote:
> pirama wrote:
> > `addArchSpecificRPath` is a static function in Tools.cpp and isn't visible 
> > here.
> No, it's not since recent refactoring. I do compile test my changes usually 
> ;-)
My bad.  I'd have found about it if I actually sync to ToT more often than once 
a week.


https://reviews.llvm.org/D30733



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


[PATCH] D30920: Do not pass -Os and -Oz to the Gold plugin

2017-03-13 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama created this revision.
Herald added a subscriber: mehdi_amini.

Address PR32155: Skip passing -Os and -Oz to the Gold plugin using
-plugin-opt.


https://reviews.llvm.org/D30920

Files:
  lib/Driver/ToolChains/CommonArgs.cpp
  test/Driver/gold-lto.c


Index: test/Driver/gold-lto.c
===
--- test/Driver/gold-lto.c
+++ test/Driver/gold-lto.c
@@ -26,3 +26,9 @@
 // RUN: %clang -target i686-linux-android -### %t.o -flto 2>&1 \
 // RUN: | FileCheck %s --check-prefix=CHECK-X86-ANDROID
 // CHECK-X86-ANDROID: "-plugin" "{{.*}}/LLVMgold.so"
+//
+// Test that -Os and -Oz are not passed to the plugin
+// RUN: %clang -### %t.o -flto -Os 2>&1 \
+// RUN: | FileCheck %s --implicit-check-not "-plugin-opt=Os"
+// RUN: %clang -### %t.o -flto -Os 2>&1 \
+// RUN: | FileCheck %s --implicit-check-not "-plugin-opt=Oz"
Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -366,12 +366,17 @@
   if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
 StringRef OOpt;
 if (A->getOption().matches(options::OPT_O4) ||
-A->getOption().matches(options::OPT_Ofast))
+A->getOption().matches(options::OPT_Ofast)) {
   OOpt = "3";
-else if (A->getOption().matches(options::OPT_O))
-  OOpt = A->getValue();
-else if (A->getOption().matches(options::OPT_O0))
+} else if (A->getOption().matches(options::OPT_O)) {
+  StringRef OptLevel = A->getValue();
+  // Do not pass optimization levels pertaining to code size to the plugin.
+  // They are captured by corresponding function attributes.
+  if (!OptLevel.equals("s") && !OptLevel.equals("z"))
+OOpt = OptLevel;
+} else if (A->getOption().matches(options::OPT_O0)) {
   OOpt = "0";
+}
 if (!OOpt.empty())
   CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=O") + OOpt));
   }


Index: test/Driver/gold-lto.c
===
--- test/Driver/gold-lto.c
+++ test/Driver/gold-lto.c
@@ -26,3 +26,9 @@
 // RUN: %clang -target i686-linux-android -### %t.o -flto 2>&1 \
 // RUN: | FileCheck %s --check-prefix=CHECK-X86-ANDROID
 // CHECK-X86-ANDROID: "-plugin" "{{.*}}/LLVMgold.so"
+//
+// Test that -Os and -Oz are not passed to the plugin
+// RUN: %clang -### %t.o -flto -Os 2>&1 \
+// RUN: | FileCheck %s --implicit-check-not "-plugin-opt=Os"
+// RUN: %clang -### %t.o -flto -Os 2>&1 \
+// RUN: | FileCheck %s --implicit-check-not "-plugin-opt=Oz"
Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -366,12 +366,17 @@
   if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
 StringRef OOpt;
 if (A->getOption().matches(options::OPT_O4) ||
-A->getOption().matches(options::OPT_Ofast))
+A->getOption().matches(options::OPT_Ofast)) {
   OOpt = "3";
-else if (A->getOption().matches(options::OPT_O))
-  OOpt = A->getValue();
-else if (A->getOption().matches(options::OPT_O0))
+} else if (A->getOption().matches(options::OPT_O)) {
+  StringRef OptLevel = A->getValue();
+  // Do not pass optimization levels pertaining to code size to the plugin.
+  // They are captured by corresponding function attributes.
+  if (!OptLevel.equals("s") && !OptLevel.equals("z"))
+OOpt = OptLevel;
+} else if (A->getOption().matches(options::OPT_O0)) {
   OOpt = "0";
+}
 if (!OOpt.empty())
   CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=O") + OOpt));
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30700: [Driver] Always add arch-specific-subdir to -rpath

2017-03-13 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 91635.
pirama added a comment.

*Actually* add the command line flags.


https://reviews.llvm.org/D30700

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/CommonArgs.cpp
  test/Driver/arch-specific-libdir-rpath.c
  test/Driver/arch-specific-libdir.c
  test/lit.cfg

Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -397,10 +397,6 @@
 if config.host_triple == config.target_triple:
 config.available_features.add("native")
 
-# Test Driver/arch-specific-libdir-rpath.c is restricted to x86_64-linux
-if re.match(r'^x86_64.*-linux', config.target_triple):
-config.available_features.add("x86_64-linux")
-
 # Case-insensitive file system
 def is_filesystem_case_insensitive():
 handle, path = tempfile.mkstemp(prefix='case-test', dir=config.test_exec_root)
Index: test/Driver/arch-specific-libdir.c
===
--- test/Driver/arch-specific-libdir.c
+++ test/Driver/arch-specific-libdir.c
@@ -1,8 +1,6 @@
 // Test that the driver adds an arch-specific subdirectory in
 // {RESOURCE_DIR}/lib/linux to the search path.
 //
-// REQUIRES: linux
-//
 // RUN: %clang %s -### 2>&1 -target i386-unknown-linux \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN:   | FileCheck --check-prefixes=FILEPATH,ARCHDIR-i386 %s
Index: test/Driver/arch-specific-libdir-rpath.c
===
--- test/Driver/arch-specific-libdir-rpath.c
+++ test/Driver/arch-specific-libdir-rpath.c
@@ -1,50 +1,85 @@
 // Test that the driver adds an arch-specific subdirectory in
-// {RESOURCE_DIR}/lib/linux to the linker search path and to '-rpath' for native
-// compilations.
+// {RESOURCE_DIR}/lib/linux to the linker search path and to '-rpath'
 //
-// -rpath only gets added during native compilation.  To keep the test simple,
-// just test for x86_64-linux native compilation.
-// REQUIRES: x86_64-linux
+// Test the default behavior when neither -frtlib-add-rpath nor
+// -fno-rtlib-add-rpath is specified, which is to skip -rpath
+// RUN: %clang %s -### 2>&1 -target x86_64-linux \
+// RUN: -fsanitize=address -shared-libasan \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN: -frtlib-add-rpath \
+// RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH-X86_64 %s
+//
+// Test that -rpath is not added under -fno-rtlib-add-rpath even if other
+// conditions are met.
+// RUN: %clang %s -### 2>&1 -target x86_64-linux \
+// RUN: -fsanitize=address -shared-libasan \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN: -frtlib-add-rpath \
+// RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH-X86_64 %s
+//
+// Test that -rpath is added only under the right circumstance even if
+// -frtlib-add-rpath is specified.
 //
 // Add LIBPATH but no RPATH for -fsanitizer=address w/o -shared-libasan
-// RUN: %clang %s -### 2>&1 -fsanitize=undefined \
+// RUN: %clang %s -### 2>&1 -target x86_64-linux -fsanitize=undefined \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN: -frtlib-add-rpath \
+// RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s
+//
+// Add LIBPATH but no RPATH for -fsanitizer=address w/o -shared-libasan
+// RUN: %clang %s -### 2>&1 -target x86_64-linux -fsanitize=undefined \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
-// RUN:   | FileCheck --check-prefixes=FILEPATH,LIBPATH,NO-RPATH %s
+// RUN: -frtlib-add-rpath \
+// RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s
 //
 // Add LIBPATH, RPATH for -fsanitize=address -shared-libasan
 // RUN: %clang %s -### 2>&1 -target x86_64-linux \
 // RUN: -fsanitize=address -shared-libasan \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
-// RUN:   | FileCheck --check-prefixes=FILEPATH,LIBPATH,RPATH %s
+// RUN: -frtlib-add-rpath \
+// RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s
+//
+// Add LIBPATH, RPATH for -fsanitize=address -shared-libasan on aarch64
+// RUN: %clang %s -### 2>&1 -target aarch64-linux \
+// RUN: -fsanitize=address -shared-libasan \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN: -frtlib-add-rpath \
+// RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-AArch64,RPATH-AArch64 %s
 //
 // Add LIBPATH, RPATH with -fsanitize=address for Android
 // RUN: %clang %s -### 2>&1 -target x86_64-linux-android -fsanitize=address \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
-// RUN:   | FileCheck --check-prefixes=FILEPATH,LIBPATH,RPATH %s
+// RUN: -frtlib-add-rpath \
+// RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s
 //
 // Add LIBPATH, RPATH for OpenMP
-// RUN: %clang %s -### 2>&1 -fopenmp \
+// RUN: %clang %s 

[PATCH] D30920: Do not pass -Os and -Oz to the Gold plugin

2017-03-13 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama marked 3 inline comments as done.
pirama added inline comments.



Comment at: lib/Driver/ToolChains/CommonArgs.cpp:369
 if (A->getOption().matches(options::OPT_O4) ||
-A->getOption().matches(options::OPT_Ofast))
+A->getOption().matches(options::OPT_Ofast)) {
   OOpt = "3";

tejohnson wrote:
> Remove added "{"
Done.  I thought having braces consistent across `if` and `else` branches would 
be a consistent coding style but doesn't seem so: clang-format doesn't do this.


https://reviews.llvm.org/D30920



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


[PATCH] D30920: Do not pass -Os and -Oz to the Gold plugin

2017-03-13 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 91671.
pirama added a comment.

Address review comments


https://reviews.llvm.org/D30920

Files:
  lib/Driver/ToolChains/CommonArgs.cpp
  test/Driver/gold-lto.c


Index: test/Driver/gold-lto.c
===
--- test/Driver/gold-lto.c
+++ test/Driver/gold-lto.c
@@ -26,3 +26,9 @@
 // RUN: %clang -target i686-linux-android -### %t.o -flto 2>&1 \
 // RUN: | FileCheck %s --check-prefix=CHECK-X86-ANDROID
 // CHECK-X86-ANDROID: "-plugin" "{{.*}}/LLVMgold.so"
+//
+// Test that -Os and -Oz are not passed to the plugin
+// RUN: %clang -### %t.o -flto -Os 2>&1 \
+// RUN: | FileCheck %s --implicit-check-not "-plugin-opt=Os"
+// RUN: %clang -### %t.o -flto -Oz 2>&1 \
+// RUN: | FileCheck %s --implicit-check-not "-plugin-opt=Oz"
Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -368,9 +368,13 @@
 if (A->getOption().matches(options::OPT_O4) ||
 A->getOption().matches(options::OPT_Ofast))
   OOpt = "3";
-else if (A->getOption().matches(options::OPT_O))
-  OOpt = A->getValue();
-else if (A->getOption().matches(options::OPT_O0))
+else if (A->getOption().matches(options::OPT_O)) {
+  StringRef OptLevel = A->getValue();
+  // Do not pass optimization levels pertaining to code size to the plugin.
+  // They are captured by corresponding function attributes.
+  if (OptLevel != "s" && OptLevel != "z")
+OOpt = OptLevel;
+} else if (A->getOption().matches(options::OPT_O0))
   OOpt = "0";
 if (!OOpt.empty())
   CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=O") + OOpt));


Index: test/Driver/gold-lto.c
===
--- test/Driver/gold-lto.c
+++ test/Driver/gold-lto.c
@@ -26,3 +26,9 @@
 // RUN: %clang -target i686-linux-android -### %t.o -flto 2>&1 \
 // RUN: | FileCheck %s --check-prefix=CHECK-X86-ANDROID
 // CHECK-X86-ANDROID: "-plugin" "{{.*}}/LLVMgold.so"
+//
+// Test that -Os and -Oz are not passed to the plugin
+// RUN: %clang -### %t.o -flto -Os 2>&1 \
+// RUN: | FileCheck %s --implicit-check-not "-plugin-opt=Os"
+// RUN: %clang -### %t.o -flto -Oz 2>&1 \
+// RUN: | FileCheck %s --implicit-check-not "-plugin-opt=Oz"
Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -368,9 +368,13 @@
 if (A->getOption().matches(options::OPT_O4) ||
 A->getOption().matches(options::OPT_Ofast))
   OOpt = "3";
-else if (A->getOption().matches(options::OPT_O))
-  OOpt = A->getValue();
-else if (A->getOption().matches(options::OPT_O0))
+else if (A->getOption().matches(options::OPT_O)) {
+  StringRef OptLevel = A->getValue();
+  // Do not pass optimization levels pertaining to code size to the plugin.
+  // They are captured by corresponding function attributes.
+  if (OptLevel != "s" && OptLevel != "z")
+OOpt = OptLevel;
+} else if (A->getOption().matches(options::OPT_O0))
   OOpt = "0";
 if (!OOpt.empty())
   CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=O") + OOpt));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30700: [Driver] Always add arch-specific-subdir to -rpath

2017-03-14 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 91743.
pirama added a comment.

Update commit message


https://reviews.llvm.org/D30700

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/CommonArgs.cpp
  test/Driver/arch-specific-libdir-rpath.c
  test/Driver/arch-specific-libdir.c
  test/lit.cfg

Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -397,10 +397,6 @@
 if config.host_triple == config.target_triple:
 config.available_features.add("native")
 
-# Test Driver/arch-specific-libdir-rpath.c is restricted to x86_64-linux
-if re.match(r'^x86_64.*-linux', config.target_triple):
-config.available_features.add("x86_64-linux")
-
 # Case-insensitive file system
 def is_filesystem_case_insensitive():
 handle, path = tempfile.mkstemp(prefix='case-test', dir=config.test_exec_root)
Index: test/Driver/arch-specific-libdir.c
===
--- test/Driver/arch-specific-libdir.c
+++ test/Driver/arch-specific-libdir.c
@@ -1,8 +1,6 @@
 // Test that the driver adds an arch-specific subdirectory in
 // {RESOURCE_DIR}/lib/linux to the search path.
 //
-// REQUIRES: linux
-//
 // RUN: %clang %s -### 2>&1 -target i386-unknown-linux \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN:   | FileCheck --check-prefixes=FILEPATH,ARCHDIR-i386 %s
Index: test/Driver/arch-specific-libdir-rpath.c
===
--- test/Driver/arch-specific-libdir-rpath.c
+++ test/Driver/arch-specific-libdir-rpath.c
@@ -1,50 +1,85 @@
 // Test that the driver adds an arch-specific subdirectory in
-// {RESOURCE_DIR}/lib/linux to the linker search path and to '-rpath' for native
-// compilations.
+// {RESOURCE_DIR}/lib/linux to the linker search path and to '-rpath'
 //
-// -rpath only gets added during native compilation.  To keep the test simple,
-// just test for x86_64-linux native compilation.
-// REQUIRES: x86_64-linux
+// Test the default behavior when neither -frtlib-add-rpath nor
+// -fno-rtlib-add-rpath is specified, which is to skip -rpath
+// RUN: %clang %s -### 2>&1 -target x86_64-linux \
+// RUN: -fsanitize=address -shared-libasan \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN: -frtlib-add-rpath \
+// RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH-X86_64 %s
+//
+// Test that -rpath is not added under -fno-rtlib-add-rpath even if other
+// conditions are met.
+// RUN: %clang %s -### 2>&1 -target x86_64-linux \
+// RUN: -fsanitize=address -shared-libasan \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN: -frtlib-add-rpath \
+// RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH-X86_64 %s
+//
+// Test that -rpath is added only under the right circumstance even if
+// -frtlib-add-rpath is specified.
 //
 // Add LIBPATH but no RPATH for -fsanitizer=address w/o -shared-libasan
-// RUN: %clang %s -### 2>&1 -fsanitize=undefined \
+// RUN: %clang %s -### 2>&1 -target x86_64-linux -fsanitize=undefined \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN: -frtlib-add-rpath \
+// RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s
+//
+// Add LIBPATH but no RPATH for -fsanitizer=address w/o -shared-libasan
+// RUN: %clang %s -### 2>&1 -target x86_64-linux -fsanitize=undefined \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
-// RUN:   | FileCheck --check-prefixes=FILEPATH,LIBPATH,NO-RPATH %s
+// RUN: -frtlib-add-rpath \
+// RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s
 //
 // Add LIBPATH, RPATH for -fsanitize=address -shared-libasan
 // RUN: %clang %s -### 2>&1 -target x86_64-linux \
 // RUN: -fsanitize=address -shared-libasan \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
-// RUN:   | FileCheck --check-prefixes=FILEPATH,LIBPATH,RPATH %s
+// RUN: -frtlib-add-rpath \
+// RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s
+//
+// Add LIBPATH, RPATH for -fsanitize=address -shared-libasan on aarch64
+// RUN: %clang %s -### 2>&1 -target aarch64-linux \
+// RUN: -fsanitize=address -shared-libasan \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN: -frtlib-add-rpath \
+// RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-AArch64,RPATH-AArch64 %s
 //
 // Add LIBPATH, RPATH with -fsanitize=address for Android
 // RUN: %clang %s -### 2>&1 -target x86_64-linux-android -fsanitize=address \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
-// RUN:   | FileCheck --check-prefixes=FILEPATH,LIBPATH,RPATH %s
+// RUN: -frtlib-add-rpath \
+// RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s
 //
 // Add LIBPATH, RPATH for OpenMP
-// RUN: %clang %s -### 2>&1 -fopenmp \
+// RUN: %clang %s -### 2>&1 -target 

[PATCH] D30920: Do not pass -Os and -Oz to the Gold plugin

2017-03-14 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 91738.
pirama added a comment.

Explicitly pass -O2 instead of relying on the default opt level.


https://reviews.llvm.org/D30920

Files:
  lib/Driver/ToolChains/CommonArgs.cpp
  test/Driver/gold-lto.c


Index: test/Driver/gold-lto.c
===
--- test/Driver/gold-lto.c
+++ test/Driver/gold-lto.c
@@ -26,3 +26,12 @@
 // RUN: %clang -target i686-linux-android -### %t.o -flto 2>&1 \
 // RUN: | FileCheck %s --check-prefix=CHECK-X86-ANDROID
 // CHECK-X86-ANDROID: "-plugin" "{{.*}}/LLVMgold.so"
+//
+// Test that -Os and -Oz are not passed to the plugin
+// RUN: %clang -### %t.o -flto -Os 2>&1 \
+// RUN: | FileCheck %s --implicit-check-not "-plugin-opt=Os" \
+// RUN:   --check-prefix=CHECK-O2
+// RUN: %clang -### %t.o -flto -Oz 2>&1 \
+// RUN: | FileCheck %s --implicit-check-not "-plugin-opt=Oz" \
+// RUN:   --check-prefix=CHECK-O2
+// CHECK-O2: "-plugin-opt=O2"
Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -368,9 +368,16 @@
 if (A->getOption().matches(options::OPT_O4) ||
 A->getOption().matches(options::OPT_Ofast))
   OOpt = "3";
-else if (A->getOption().matches(options::OPT_O))
-  OOpt = A->getValue();
-else if (A->getOption().matches(options::OPT_O0))
+else if (A->getOption().matches(options::OPT_O)) {
+  StringRef OptLevel = A->getValue();
+  // -Os and -Oz add corresponding attributes to functions.  Just use -O2
+  // for these optimization levels.  Pass other optimization levels through
+  // to the plugin.
+  if (OptLevel == "s" || OptLevel == "z")
+OOpt = "2";
+  else
+OOpt = OptLevel;
+} else if (A->getOption().matches(options::OPT_O0))
   OOpt = "0";
 if (!OOpt.empty())
   CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=O") + OOpt));


Index: test/Driver/gold-lto.c
===
--- test/Driver/gold-lto.c
+++ test/Driver/gold-lto.c
@@ -26,3 +26,12 @@
 // RUN: %clang -target i686-linux-android -### %t.o -flto 2>&1 \
 // RUN: | FileCheck %s --check-prefix=CHECK-X86-ANDROID
 // CHECK-X86-ANDROID: "-plugin" "{{.*}}/LLVMgold.so"
+//
+// Test that -Os and -Oz are not passed to the plugin
+// RUN: %clang -### %t.o -flto -Os 2>&1 \
+// RUN: | FileCheck %s --implicit-check-not "-plugin-opt=Os" \
+// RUN:   --check-prefix=CHECK-O2
+// RUN: %clang -### %t.o -flto -Oz 2>&1 \
+// RUN: | FileCheck %s --implicit-check-not "-plugin-opt=Oz" \
+// RUN:   --check-prefix=CHECK-O2
+// CHECK-O2: "-plugin-opt=O2"
Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -368,9 +368,16 @@
 if (A->getOption().matches(options::OPT_O4) ||
 A->getOption().matches(options::OPT_Ofast))
   OOpt = "3";
-else if (A->getOption().matches(options::OPT_O))
-  OOpt = A->getValue();
-else if (A->getOption().matches(options::OPT_O0))
+else if (A->getOption().matches(options::OPT_O)) {
+  StringRef OptLevel = A->getValue();
+  // -Os and -Oz add corresponding attributes to functions.  Just use -O2
+  // for these optimization levels.  Pass other optimization levels through
+  // to the plugin.
+  if (OptLevel == "s" || OptLevel == "z")
+OOpt = "2";
+  else
+OOpt = OptLevel;
+} else if (A->getOption().matches(options::OPT_O0))
   OOpt = "0";
 if (!OOpt.empty())
   CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=O") + OOpt));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30700: [Driver] Add flag to request arch-specific-subdir in -rpath

2017-03-14 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL297751: [Driver] Add flag to request arch-specific-subdir in 
-rpath (authored by pirama).

Changed prior to commit:
  https://reviews.llvm.org/D30700?vs=91743=91744#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30700

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
  cfe/trunk/test/Driver/arch-specific-libdir-rpath.c
  cfe/trunk/test/Driver/arch-specific-libdir.c
  cfe/trunk/test/lit.cfg

Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -2098,6 +2098,10 @@
 def rpath : Separate<["-"], "rpath">, Flags<[LinkerInput]>, Group;
 def rtlib_EQ : Joined<["-", "--"], "rtlib=">,
   HelpText<"Compiler runtime library to use">;
+def frtlib_add_rpath: Flag<["-"], "frtlib-add-rpath">, Flags<[NoArgumentUnused]>,
+  HelpText<"Add -rpath with architecture-specific resource directory to the linker flags">;
+def fno_rtlib_add_rpath: Flag<["-"], "fno-rtlib-add-rpath">, Flags<[NoArgumentUnused]>,
+  HelpText<"Do not add -rpath with architecture-specific resource directory to the linker flags">;
 def r : Flag<["-"], "r">, Flags<[LinkerInput,NoArgumentUnused]>,
 Group;
 def save_temps_EQ : Joined<["-", "--"], "save-temps=">, Flags<[DriverOption]>,
Index: cfe/trunk/test/Driver/arch-specific-libdir.c
===
--- cfe/trunk/test/Driver/arch-specific-libdir.c
+++ cfe/trunk/test/Driver/arch-specific-libdir.c
@@ -1,8 +1,6 @@
 // Test that the driver adds an arch-specific subdirectory in
 // {RESOURCE_DIR}/lib/linux to the search path.
 //
-// REQUIRES: linux
-//
 // RUN: %clang %s -### 2>&1 -target i386-unknown-linux \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN:   | FileCheck --check-prefixes=FILEPATH,ARCHDIR-i386 %s
Index: cfe/trunk/test/Driver/arch-specific-libdir-rpath.c
===
--- cfe/trunk/test/Driver/arch-specific-libdir-rpath.c
+++ cfe/trunk/test/Driver/arch-specific-libdir-rpath.c
@@ -1,50 +1,85 @@
 // Test that the driver adds an arch-specific subdirectory in
-// {RESOURCE_DIR}/lib/linux to the linker search path and to '-rpath' for native
-// compilations.
+// {RESOURCE_DIR}/lib/linux to the linker search path and to '-rpath'
 //
-// -rpath only gets added during native compilation.  To keep the test simple,
-// just test for x86_64-linux native compilation.
-// REQUIRES: x86_64-linux
+// Test the default behavior when neither -frtlib-add-rpath nor
+// -fno-rtlib-add-rpath is specified, which is to skip -rpath
+// RUN: %clang %s -### 2>&1 -target x86_64-linux \
+// RUN: -fsanitize=address -shared-libasan \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN: -frtlib-add-rpath \
+// RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH-X86_64 %s
+//
+// Test that -rpath is not added under -fno-rtlib-add-rpath even if other
+// conditions are met.
+// RUN: %clang %s -### 2>&1 -target x86_64-linux \
+// RUN: -fsanitize=address -shared-libasan \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN: -frtlib-add-rpath \
+// RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH-X86_64 %s
+//
+// Test that -rpath is added only under the right circumstance even if
+// -frtlib-add-rpath is specified.
 //
 // Add LIBPATH but no RPATH for -fsanitizer=address w/o -shared-libasan
-// RUN: %clang %s -### 2>&1 -fsanitize=undefined \
+// RUN: %clang %s -### 2>&1 -target x86_64-linux -fsanitize=undefined \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN: -frtlib-add-rpath \
+// RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s
+//
+// Add LIBPATH but no RPATH for -fsanitizer=address w/o -shared-libasan
+// RUN: %clang %s -### 2>&1 -target x86_64-linux -fsanitize=undefined \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
-// RUN:   | FileCheck --check-prefixes=FILEPATH,LIBPATH,NO-RPATH %s
+// RUN: -frtlib-add-rpath \
+// RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s
 //
 // Add LIBPATH, RPATH for -fsanitize=address -shared-libasan
 // RUN: %clang %s -### 2>&1 -target x86_64-linux \
 // RUN: -fsanitize=address -shared-libasan \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
-// RUN:   | FileCheck --check-prefixes=FILEPATH,LIBPATH,RPATH %s
+// RUN: -frtlib-add-rpath \
+// RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s
+//
+// Add LIBPATH, RPATH for -fsanitize=address -shared-libasan on aarch64
+// RUN: %clang %s -### 2>&1 -target aarch64-linux \
+// RUN: -fsanitize=address -shared-libasan \
+// RUN: 

[PATCH] D30700: [Driver] Always add arch-specific-subdir to -rpath

2017-03-07 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama created this revision.

This patch unconditionally adds -rpath of the arch-specific subdirectory
in resource directory (instead of doing so only during native
compilation).

This patch also re-enables test arch-specific-libdir.c which was
silently unsupported because of the REQUIRES tag 'linux'.


https://reviews.llvm.org/D30700

Files:
  lib/Driver/Tools.cpp
  test/Driver/arch-specific-libdir-rpath.c
  test/Driver/arch-specific-libdir.c
  test/lit.cfg

Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -397,10 +397,6 @@
 if config.host_triple == config.target_triple:
 config.available_features.add("native")
 
-# Test Driver/arch-specific-libdir-rpath.c is restricted to x86_64-linux
-if re.match(r'^x86_64.*-linux', config.target_triple):
-config.available_features.add("x86_64-linux")
-
 # Case-insensitive file system
 def is_filesystem_case_insensitive():
 handle, path = tempfile.mkstemp(prefix='case-test', dir=config.test_exec_root)
Index: test/Driver/arch-specific-libdir.c
===
--- test/Driver/arch-specific-libdir.c
+++ test/Driver/arch-specific-libdir.c
@@ -1,8 +1,6 @@
 // Test that the driver adds an arch-specific subdirectory in
 // {RESOURCE_DIR}/lib/linux to the search path.
 //
-// REQUIRES: linux
-//
 // RUN: %clang %s -### 2>&1 -target i386-unknown-linux \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN:   | FileCheck --check-prefixes=FILEPATH,ARCHDIR-i386 %s
Index: test/Driver/arch-specific-libdir-rpath.c
===
--- test/Driver/arch-specific-libdir-rpath.c
+++ test/Driver/arch-specific-libdir-rpath.c
@@ -1,50 +1,53 @@
 // Test that the driver adds an arch-specific subdirectory in
-// {RESOURCE_DIR}/lib/linux to the linker search path and to '-rpath' for native
-// compilations.
-//
-// -rpath only gets added during native compilation.  To keep the test simple,
-// just test for x86_64-linux native compilation.
-// REQUIRES: x86_64-linux
+// {RESOURCE_DIR}/lib/linux to the linker search path and to '-rpath'
 //
 // Add LIBPATH but no RPATH for -fsanitizer=address w/o -shared-libasan
-// RUN: %clang %s -### 2>&1 -fsanitize=undefined \
+// RUN: %clang %s -### 2>&1 -target x86_64-linux -fsanitize=undefined \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
-// RUN:   | FileCheck --check-prefixes=FILEPATH,LIBPATH,NO-RPATH %s
+// RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s
 //
 // Add LIBPATH, RPATH for -fsanitize=address -shared-libasan
 // RUN: %clang %s -### 2>&1 -target x86_64-linux \
 // RUN: -fsanitize=address -shared-libasan \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
-// RUN:   | FileCheck --check-prefixes=FILEPATH,LIBPATH,RPATH %s
+// RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s
+//
+// Add LIBPATH, RPATH for -fsanitize=address -shared-libasan on aarch64
+// RUN: %clang %s -### 2>&1 -target aarch64-linux \
+// RUN: -fsanitize=address -shared-libasan \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-AArch64,RPATH-AArch64 %s
 //
 // Add LIBPATH, RPATH with -fsanitize=address for Android
 // RUN: %clang %s -### 2>&1 -target x86_64-linux-android -fsanitize=address \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
-// RUN:   | FileCheck --check-prefixes=FILEPATH,LIBPATH,RPATH %s
+// RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s
 //
 // Add LIBPATH, RPATH for OpenMP
-// RUN: %clang %s -### 2>&1 -fopenmp \
+// RUN: %clang %s -### 2>&1 -target x86_64-linux -fopenmp \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
-// RUN:   | FileCheck --check-prefixes=FILEPATH,LIBPATH,RPATH %s
+// RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s
 //
 // Add LIBPATH but no RPATH for ubsan (or any other sanitizer)
 // RUN: %clang %s -### 2>&1 -fsanitize=undefined \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
-// RUN:   | FileCheck --check-prefixes=FILEPATH,LIBPATH,NO-RPATH %s
+// RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s
 //
 // Add LIBPATH but no RPATH if no sanitizer or runtime is specified
 // RUN: %clang %s -### 2>&1 \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
-// RUN:   | FileCheck --check-prefixes=FILEPATH,LIBPATH,NO-RPATH %s
+// RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s
 //
 // Do not add LIBPATH or RPATH if arch-specific subdir doesn't exist
 // RUN: %clang %s -### 2>&1 \
 // RUN: -resource-dir=%S/Inputs/resource_dir \
-// RUN:   | FileCheck --check-prefixes=FILEPATH,NO-LIBPATH,NO-RPATH %s
+// RUN:   | FileCheck --check-prefixes=RESDIR,NO-LIBPATH,NO-RPATH %s
 //
 //
-// FILEPATH: 

[PATCH] D30015: Add arch-specific directory to search path

2017-03-02 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama marked 2 inline comments as done.
pirama added inline comments.



Comment at: lib/Driver/Tools.cpp:289
+  CmdArgs.push_back("-rpath");
+  CmdArgs.push_back(Args.MakeArgString(CandidateRPath.c_str()));
+}

rnk wrote:
> We shouldn't add rpath to every binary linked by clang. We should only add 
> rpath when we know the user is linking against a shared library provided by 
> clang. See for example the way the darwin toolchain handles this in 
> Toolchains.cpp.
> 
> Right now most libraries provided by clang are static, so there hasn't been 
> much need to add rpath, but if we add more shared libraries (xray, 
> sanitizers, profiling, etc), then I think we'll want to do this along with 
> adding an option to suppress the implicit addition of rpath.
PTAL.



Comment at: test/Driver/arch-specific-libdir-rpath.c:18
+//
+// CHECK-ARCHDIR: 
-L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux{{.*}} "-rpath" 
{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux
+// CHECK-NO-ARCHDIR-NOT: -L{{.*}}Inputs/resource_dir

pirama wrote:
> mgorny wrote:
> > pirama wrote:
> > > Hahnfeld wrote:
> > > > Can you split that into two lines? Then it won't fail if there is some 
> > > > argument added in between
> > > Splitting into two lines makes FileCheck eagerly match the arch-subdir 
> > > and -rpath into the {{.*}} next to the "-L".  This causes the check for 
> > > -rpath to fail.
> > > 
> > > The test accepts intermediate arguments because of the wildcard right 
> > > after the -L...Inputs/...
> > Please do not rely on implicit assumptions like that. One day someone may 
> > decide to 'fix' the wildcard not to match whitespace, and make the wrong 
> > assumption about order. If for anything, splitting in two would make this 
> > more readable.
> Do you have any suggestions?  Right now, if I split it into two lines, the 
> second check fails due to the eager regex match.
Done.  I was able to get the exact path from the -cc1 invocation and use it to 
remove the wildcards.


https://reviews.llvm.org/D30015



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


[PATCH] D30015: Add arch-specific directory to search path

2017-03-02 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 90373.
pirama added a comment.

Add -rpath only when a runtime is included as a shared library.  And, cleanup 
tests.


https://reviews.llvm.org/D30015

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChain.cpp
  lib/Driver/Tools.cpp
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/aarch64/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/arm/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/i386/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64/.keep
  test/Driver/arch-specific-libdir-rpath.c
  test/Driver/arch-specific-libdir.c
  test/lit.cfg

Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -392,6 +392,10 @@
 if config.host_triple == config.target_triple:
 config.available_features.add("native")
 
+# Test Driver/arch-specific-libdir-rpath.c is restricted to x86_64-linux
+if re.match(r'^x86_64.*-linux', config.target_triple):
+config.available_features.add("x86_64-linux")
+
 # Case-insensitive file system
 def is_filesystem_case_insensitive():
 handle, path = tempfile.mkstemp(prefix='case-test', dir=config.test_exec_root)
Index: test/Driver/arch-specific-libdir.c
===
--- /dev/null
+++ test/Driver/arch-specific-libdir.c
@@ -0,0 +1,53 @@
+// Test that the driver adds an arch-specific subdirectory in
+// {RESOURCE_DIR}/lib/linux to the search path.
+//
+// RUN: %clang %s -### 2>&1 -target i386-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefixes=FILEPATH,ARCHDIR-i386 %s
+//
+// RUN: %clang %s -### 2>&1 -target i386-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefixes=FILEPATH,NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target i686-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefixes=FILEPATH,ARCHDIR-i386 %s
+//
+// RUN: %clang %s -### 2>&1 -target i686-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefixes=FILEPATH,NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target x86_64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefixes=FILEPATH,ARCHDIR-x86_64 %s
+//
+// RUN: %clang %s -### 2>&1 -target x86_64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefixes=FILEPATH,NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target arm-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefixes=FILEPATH,ARCHDIR-arm %s
+//
+// RUN: %clang %s -### 2>&1 -target arm-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefixes=FILEPATH,NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target aarch64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefixes=FILEPATH,ARCHDIR-aarch64 %s
+//
+// RUN: %clang %s -### 2>&1 -target aarch64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefixes=FILEPATH,NO-ARCHDIR %s
+//
+//
+// FILEPATH: "-x" "c" "[[FILE_PATH:.*]]/{{.*}}.c"
+// ARCHDIR-i386:-L[[FILE_PATH]]/Inputs/resource_dir_with_arch_subdir/lib/linux/i386
+// ARCHDIR-x86_64:  -L[[FILE_PATH]]/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64
+// ARCHDIR-arm: -L[[FILE_PATH]]/Inputs/resource_dir_with_arch_subdir/lib/linux/arm
+// ARCHDIR-aarch64: -L[[FILE_PATH]]/Inputs/resource_dir_with_arch_subdir/lib/linux/aarch64
+//
+// Have a stricter check for no-archdir - that the driver doesn't add any
+// subdirectory from the provided resource directory.
+// NO-ARCHDIR-NOT: -L[[FILE_PATH]]/Inputs/resource_dir
Index: test/Driver/arch-specific-libdir-rpath.c
===
--- /dev/null
+++ test/Driver/arch-specific-libdir-rpath.c
@@ -0,0 +1,45 @@
+// Test that the driver adds an arch-specific subdirectory in
+// {RESOURCE_DIR}/lib/linux to the linker search path and to '-rpath' for native
+// compilations.
+//
+// -rpath only gets added during native compilation.  To keep the test simple,
+// just test for x86_64-linux native compilation.
+// REQUIRES: x86_64-linux
+//
+// Add LIBPATH but no RPATH for -fsanitize=address
+// RUN: %clang %s -### 2>&1 -target x86_64-linux \
+// RUN: -fsanitize=address -shared-libasan \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefixes=FILEPATH,LIBPATH,RPATH %s
+//
+// Add LIBPATH, RPATH with -fsanitize=address for Android
+// RUN: %clang %s -### 2>&1 -target x86_64-linux-android -fsanitize=address \
+// RUN: 

[PATCH] D30700: [Driver] Always add arch-specific-subdir to -rpath

2017-03-07 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a comment.

In https://reviews.llvm.org/D30700#694511, @rnk wrote:

> I was thinking `-f[no-]compiler-rt-rpath` or something, but openmp is not 
> part of compiler-rt. Name recommendations welcome. \


Maybe `-f[no-]rtlib-add-rpath`?

> We might also want to reconsider the default setting.

I also feel defaulting to not adding rpath makes sense.


https://reviews.llvm.org/D30700



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


[PATCH] D30920: Do not pass -Os and -Oz to the Gold plugin

2017-04-03 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a comment.

From the discussion, it seems it is theoretically feasible to make optimization 
for speed a function-level attribute as well.  After looking at the 
PassMangerBuilder for this bug, I think that'll make the optimization passes 
cleaner by keeping the passes and their behavior at various levels in one place.

Circling back to the issue at hand, what is the best way to handle Os and Oz at 
the lto stage?  I think we left off with @mehdi_amini's comment that the driver 
should emit a warning when dropping the Os/Oz.


https://reviews.llvm.org/D30920



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


[PATCH] D33561: [CMake] Add Android toolchain CMake cache files.

2017-07-18 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added inline comments.



Comment at: cmake/caches/Android-stage2.cmake:37
+  set(RUNTIMES_${target}-linux-android_COMPILER_RT_INCLUDE_TESTS OFF CACHE 
BOOL "")
+  set(RUNTIMES_${target}-linux-android_LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
+  set(RUNTIMES_${target}-linux-android_LLVM_ENABLE_THREADS OFF CACHE BOOL "")

jroelofs wrote:
> pirama wrote:
> > Should we initialize it to LLVM_ENABLE_ASSERTIONS rather than defaulting to 
> > ON?  So assertions can be enabled/disabled for all targets with just one 
> > switch (and then over-ride with per-target flags, if necessary).
> No. Absolutely not. Whether or not the bits of the toolchain that run on the 
> host have assertions should be *completely* independent of whether the target 
> bits do or don't. Do not conflate the host with the target.
Maybe I wasn't clear.  I suggest that we don't set 
RUNTIMES_${target}_LLVM_ENABLE_ASSERTIONS to ON here and rather initialize it 
based on another flag.  I was incorrect to suggest we reuse 
LLVM_ENABLE_ASSERTIONS.  We should rather have something like 
ANDROID_RUNTIMES_ENABLE_ASSERTIONS.

The motivation is to reduce the number of additional flags/switches, under the 
assumption that assert-enabled or assert-disabled builds of the runtimes are 
generated simultaneously.

To generate assert-enabled builds, the invocation would be:

```
$ cmake ... -DANDROID_RUNTIMES_ENABLE_ASSERTIONS=ON

```
instead of

```
$ cmake ... -DRUNTIMES_armv7-linux-android_LLVM_ENABLE_ASSERTIONS=ON 
-DRUNTIMES-aarch64-linux-android_LLVM_ENABLE_ASSERTIONS=ON ...

```
If I understand CMake correctly, we can still enable assertions only for a 
particular target by:

```
$ cmake ...  -DANDROID_RUNTIMES_ENABLE_ASSERTIONS=OFF 
-DRUNTIMES-aarch64-linux-android_LLVM_ENABLE_ASSERTIONS=ON
```


https://reviews.llvm.org/D33561



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


[PATCH] D33561: [CMake] Add Android toolchain CMake cache files.

2017-07-18 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added inline comments.



Comment at: cmake/caches/Android-stage2.cmake:27
+  set(RUNTIMES_${target}-linux-android_CMAKE_ASM_FLAGS 
${ANDROID_${target}_C_FLAGS} CACHE PATH "")
+  set(RUNTIMES_${target}-linux-android_CMAKE_BUILD_TYPE RELEASE CACHE STRING 
"")
+  set(RUNTIMES_${target}-linux-android_CMAKE_C_FLAGS 
${ANDROID_${target}_C_FLAGS} CACHE PATH "")

Same comment as ASSERTIONS below.



Comment at: cmake/caches/Android-stage2.cmake:37
+  set(RUNTIMES_${target}-linux-android_COMPILER_RT_INCLUDE_TESTS OFF CACHE 
BOOL "")
+  set(RUNTIMES_${target}-linux-android_LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
+  set(RUNTIMES_${target}-linux-android_LLVM_ENABLE_THREADS OFF CACHE BOOL "")

Should we initialize it to LLVM_ENABLE_ASSERTIONS rather than defaulting to ON? 
 So assertions can be enabled/disabled for all targets with just one switch 
(and then over-ride with per-target flags, if necessary).


https://reviews.llvm.org/D33561



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


[PATCH] D37302: [Headers] Define *_HAS_SUBNORM for FLT, DBL, LDBL

2017-09-15 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a comment.

In https://reviews.llvm.org/D37302#871794, @joerg wrote:

> So what about targets that don't support subnormals? I'm moderately sure ARM 
> falls into this category given the right phase of the moon.


Clang defines `__FLT_HAS_DENORM__` and friends unconditionally, so I thought we 
could do this for `FLT_HAS_SUBNORM` as well, considering that gcc did the same. 
 But that might be misleading because gcc's float.h was just for the target of 
that particular gcc build.

Am I right to understand that `__FLT_HAS_DENORM__` signifies *compiler* support 
for denorms as opposed to support on the *platforms* supported?  If so, it 
might support our alternative consideration of defining these macros in the 
bionic/libc headers for Android (and rely on the include_next similar to 
Windows and Darwin).


https://reviews.llvm.org/D37302



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


[PATCH] D37302: [Headers] Define *_HAS_SUBNORM for FLT, DBL, LDBL

2017-09-13 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a comment.

Ping


https://reviews.llvm.org/D37302



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


[PATCH] D37302: [Headers] Define *_HAS_SUBNORM for FLT, DBL, LDBL

2017-09-14 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a comment.

@bruno Any suggestion on how to update test/Headers/float-darwin,c* so make it 
check the include_next?  I am unable to find the darwin-specific float.h inside 
an XCode installation directory.

- Oops, my earlier comment had the wrong test name


https://reviews.llvm.org/D37302



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


[PATCH] D37302: [Headers] Define *_HAS_SUBNORM for FLT, DBL, LDBL

2017-09-06 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a comment.

Ping...


https://reviews.llvm.org/D37302



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


[PATCH] D40476: Switch kryo to use -mcpu=cortex-a57 when invoking the assembler

2017-11-27 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 124410.
pirama added a comment.

Address review comments.


https://reviews.llvm.org/D40476

Files:
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/as-mcpu.c


Index: test/Driver/as-mcpu.c
===
--- /dev/null
+++ test/Driver/as-mcpu.c
@@ -0,0 +1,10 @@
+// == Check that krait is substituted by cortex-a15 when 
invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=krait -### -c %s -v -fno-integrated-as 
2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A15 %s
+// CHECK-CORTEX-A15: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a15
+
+// == Check that kryo is substituted by cortex-a57 when 
invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=kryo -### -c %s -v -fno-integrated-as 
2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=kryo -### -c %s -v 
-fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// CHECK-CORTEX-A57: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a57
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -653,22 +653,36 @@
 
 Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
 
-// FIXME: remove krait check when GNU tools support krait cpu
-// for now replace it with -mcpu=cortex-a15 to avoid a lower
-// march from being picked in the absence of a cpu flag.
+// FIXME: remove krait and kryo checks when GNU tools support them.  For 
now
+// use -mcpu=cortex-a15 for krait and -mcpu=cortex-a57 for kryo
+// -mcpu=cortex-a57 to avoid a lower march from being picked in the absence
+// of a cpu flag.
 Arg *A;
-if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
-StringRef(A->getValue()).equals_lower("krait"))
-  CmdArgs.push_back("-mcpu=cortex-a15");
-else
-  Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+if ((A= Args.getLastArg(options::OPT_mcpu_EQ))) {
+  StringRef CPUArg(A->getValue());
+  if(CPUArg.equals_lower("krait"))
+CmdArgs.push_back("-mcpu=cortex-a15");
+  else if(CPUArg.equals_lower("kryo"))
+CmdArgs.push_back("-mcpu=cortex-a57");
+  else
+Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+}
 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);
+
+// FIXME: remove kryo check when GNU tools support them.  For now use
+// -mcpu=cortex-a57 to avoid a lower march from being picked in the absence
+// of a cpu flag.
+Arg *A;
+if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
+(StringRef(A->getValue()).equals_lower("kryo")))
+  CmdArgs.push_back("-mcpu=cortex-a57");
+else
+  Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
 break;
   }
   case llvm::Triple::mips:


Index: test/Driver/as-mcpu.c
===
--- /dev/null
+++ test/Driver/as-mcpu.c
@@ -0,0 +1,10 @@
+// == Check that krait is substituted by cortex-a15 when invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=krait -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A15 %s
+// CHECK-CORTEX-A15: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a15
+
+// == Check that kryo is substituted by cortex-a57 when invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=kryo -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=kryo -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// CHECK-CORTEX-A57: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a57
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -653,22 +653,36 @@
 
 Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
 
-// FIXME: remove krait check when GNU tools support krait cpu
-// for now replace it with -mcpu=cortex-a15 to avoid a lower
-// march from being picked in the absence of a cpu flag.
+// FIXME: remove krait and kryo checks when GNU tools support them.  For now
+// use -mcpu=cortex-a15 for krait and -mcpu=cortex-a57 for kryo
+// -mcpu=cortex-a57 to avoid a lower march from being picked in the absence
+// of a cpu flag.
 Arg *A;
-if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
-StringRef(A->getValue()).equals_lower("krait"))
-  CmdArgs.push_back("-mcpu=cortex-a15");
-else
-  Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+if ((A= Args.getLastArg(options::OPT_mcpu_EQ))) {
+  StringRef CPUArg(A->getValue());
+  

[PATCH] D40476: Switch kryo to use -mcpu=cortex-a57 when invoking the assembler

2017-11-27 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 124417.
pirama added a comment.

Normalize falkor and saphira as well.


https://reviews.llvm.org/D40476

Files:
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/as-mcpu.c


Index: test/Driver/as-mcpu.c
===
--- /dev/null
+++ test/Driver/as-mcpu.c
@@ -0,0 +1,17 @@
+// == Check that krait is substituted by cortex-a15 when 
invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=krait -### -c %s -v -fno-integrated-as 
2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A15 %s
+// CHECK-CORTEX-A15: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a15
+
+// == Check that kryo is substituted by cortex-a57 when 
invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=kryo -### -c %s -v -fno-integrated-as 
2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=kryo -### -c %s -v 
-fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+
+// RUN: %clang -target arm-linux -mcpu=falkor -### -c %s -v -fno-integrated-as 
2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=falkor -### -c %s -v 
-fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+
+// RUN: %clang -target arm-linux -mcpu=saphira -### -c %s -v 
-fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=saphira -### -c %s -v 
-fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+
+// CHECK-CORTEX-A57: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a57
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -42,6 +42,24 @@
  !O.hasFlag(options::DriverOption) && !O.hasFlag(options::LinkerInput);
 }
 
+// Switch CPU names not recognized by GNU assembler to a close CPU that it does
+// recognize, instead of a lower march from being picked in the absence of a 
cpu
+// flag.
+static void normalizeCPUNamesForAssembler(const ArgList ,
+  ArgStringList ) {
+  if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
+StringRef CPUArg(A->getValue());
+if (CPUArg.equals_lower("krait"))
+  CmdArgs.push_back("-mcpu=cortex-a15");
+else if(CPUArg.equals_lower("kryo") ||
+CPUArg.equals_lower("falkor") ||
+CPUArg.equals_lower("saphira"))
+  CmdArgs.push_back("-mcpu=cortex-a57");
+else
+  Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+  }
+}
+
 void tools::gcc::Common::ConstructJob(Compilation , const JobAction ,
   const InputInfo ,
   const InputInfoList ,
@@ -652,23 +670,16 @@
 }
 
 Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
+normalizeCPUNamesForAssembler(Args, CmdArgs);
 
-// FIXME: remove krait check when GNU tools support krait cpu
-// for now replace it with -mcpu=cortex-a15 to avoid a lower
-// march from being picked in the absence of a cpu flag.
-Arg *A;
-if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
-StringRef(A->getValue()).equals_lower("krait"))
-  CmdArgs.push_back("-mcpu=cortex-a15");
-else
-  Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
 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);
+normalizeCPUNamesForAssembler(Args, CmdArgs);
+
 break;
   }
   case llvm::Triple::mips:


Index: test/Driver/as-mcpu.c
===
--- /dev/null
+++ test/Driver/as-mcpu.c
@@ -0,0 +1,17 @@
+// == Check that krait is substituted by cortex-a15 when invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=krait -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A15 %s
+// CHECK-CORTEX-A15: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a15
+
+// == Check that kryo is substituted by cortex-a57 when invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=kryo -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=kryo -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+
+// RUN: %clang -target arm-linux -mcpu=falkor -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=falkor -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+
+// RUN: %clang -target arm-linux -mcpu=saphira -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux 

[PATCH] D40476: Switch kryo to use -mcpu=cortex-a57 when invoking the assembler

2017-11-27 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 124415.
pirama added a comment.

Sink 'Arg *' declaration.


https://reviews.llvm.org/D40476

Files:
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/as-mcpu.c


Index: test/Driver/as-mcpu.c
===
--- /dev/null
+++ test/Driver/as-mcpu.c
@@ -0,0 +1,10 @@
+// == Check that krait is substituted by cortex-a15 when 
invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=krait -### -c %s -v -fno-integrated-as 
2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A15 %s
+// CHECK-CORTEX-A15: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a15
+
+// == Check that kryo is substituted by cortex-a57 when 
invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=kryo -### -c %s -v -fno-integrated-as 
2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=kryo -### -c %s -v 
-fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// CHECK-CORTEX-A57: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a57
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -653,22 +653,35 @@
 
 Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
 
-// FIXME: remove krait check when GNU tools support krait cpu
-// for now replace it with -mcpu=cortex-a15 to avoid a lower
-// march from being picked in the absence of a cpu flag.
-Arg *A;
-if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
-StringRef(A->getValue()).equals_lower("krait"))
-  CmdArgs.push_back("-mcpu=cortex-a15");
-else
-  Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+// FIXME: remove krait and kryo checks when GNU tools support them.  For 
now
+// use -mcpu=cortex-a15 for krait and -mcpu=cortex-a57 for kryo
+// -mcpu=cortex-a57 to avoid a lower march from being picked in the absence
+// of a cpu flag.
+if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
+  StringRef CPUArg(A->getValue());
+  if(CPUArg.equals_lower("krait"))
+CmdArgs.push_back("-mcpu=cortex-a15");
+  else if(CPUArg.equals_lower("kryo"))
+CmdArgs.push_back("-mcpu=cortex-a57");
+  else
+Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+}
 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);
+
+// FIXME: remove kryo check when GNU tools support them.  For now use
+// -mcpu=cortex-a57 to avoid a lower march from being picked in the absence
+// of a cpu flag.
+Arg *A;
+if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
+(StringRef(A->getValue()).equals_lower("kryo")))
+  CmdArgs.push_back("-mcpu=cortex-a57");
+else
+  Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
 break;
   }
   case llvm::Triple::mips:


Index: test/Driver/as-mcpu.c
===
--- /dev/null
+++ test/Driver/as-mcpu.c
@@ -0,0 +1,10 @@
+// == Check that krait is substituted by cortex-a15 when invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=krait -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A15 %s
+// CHECK-CORTEX-A15: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a15
+
+// == Check that kryo is substituted by cortex-a57 when invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=kryo -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=kryo -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// CHECK-CORTEX-A57: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a57
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -653,22 +653,35 @@
 
 Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
 
-// FIXME: remove krait check when GNU tools support krait cpu
-// for now replace it with -mcpu=cortex-a15 to avoid a lower
-// march from being picked in the absence of a cpu flag.
-Arg *A;
-if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
-StringRef(A->getValue()).equals_lower("krait"))
-  CmdArgs.push_back("-mcpu=cortex-a15");
-else
-  Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+// FIXME: remove krait and kryo checks when GNU tools support them.  For now
+// use -mcpu=cortex-a15 for krait and -mcpu=cortex-a57 for kryo
+// -mcpu=cortex-a57 to avoid a lower march from being picked in the absence
+// of a cpu flag.
+if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
+  StringRef CPUArg(A->getValue());
+  

[PATCH] D40476: Switch kryo to use -mcpu=cortex-a57 when invoking the assembler

2017-11-27 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL319077: Switch CPU names not recognized by GNU assembler 
(authored by pirama).

Repository:
  rL LLVM

https://reviews.llvm.org/D40476

Files:
  cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
  cfe/trunk/test/Driver/as-mcpu.c


Index: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
@@ -42,6 +42,24 @@
  !O.hasFlag(options::DriverOption) && !O.hasFlag(options::LinkerInput);
 }
 
+// Switch CPU names not recognized by GNU assembler to a close CPU that it does
+// recognize, instead of a lower march from being picked in the absence of a 
cpu
+// flag.
+static void normalizeCPUNamesForAssembler(const ArgList ,
+  ArgStringList ) {
+  if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
+StringRef CPUArg(A->getValue());
+if (CPUArg.equals_lower("krait"))
+  CmdArgs.push_back("-mcpu=cortex-a15");
+else if(CPUArg.equals_lower("kryo") ||
+CPUArg.equals_lower("falkor") ||
+CPUArg.equals_lower("saphira"))
+  CmdArgs.push_back("-mcpu=cortex-a57");
+else
+  Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+  }
+}
+
 void tools::gcc::Common::ConstructJob(Compilation , const JobAction ,
   const InputInfo ,
   const InputInfoList ,
@@ -652,23 +670,16 @@
 }
 
 Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
+normalizeCPUNamesForAssembler(Args, CmdArgs);
 
-// FIXME: remove krait check when GNU tools support krait cpu
-// for now replace it with -mcpu=cortex-a15 to avoid a lower
-// march from being picked in the absence of a cpu flag.
-Arg *A;
-if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
-StringRef(A->getValue()).equals_lower("krait"))
-  CmdArgs.push_back("-mcpu=cortex-a15");
-else
-  Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
 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);
+normalizeCPUNamesForAssembler(Args, CmdArgs);
+
 break;
   }
   case llvm::Triple::mips:
Index: cfe/trunk/test/Driver/as-mcpu.c
===
--- cfe/trunk/test/Driver/as-mcpu.c
+++ cfe/trunk/test/Driver/as-mcpu.c
@@ -0,0 +1,17 @@
+// == Check that krait is substituted by cortex-a15 when 
invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=krait -### -c %s -v -fno-integrated-as 
2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A15 %s
+// CHECK-CORTEX-A15: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a15
+
+// == Check that kryo is substituted by cortex-a57 when 
invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=kryo -### -c %s -v -fno-integrated-as 
2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=kryo -### -c %s -v 
-fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+
+// RUN: %clang -target arm-linux -mcpu=falkor -### -c %s -v -fno-integrated-as 
2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=falkor -### -c %s -v 
-fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+
+// RUN: %clang -target arm-linux -mcpu=saphira -### -c %s -v 
-fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=saphira -### -c %s -v 
-fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+
+// CHECK-CORTEX-A57: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a57


Index: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
@@ -42,6 +42,24 @@
  !O.hasFlag(options::DriverOption) && !O.hasFlag(options::LinkerInput);
 }
 
+// Switch CPU names not recognized by GNU assembler to a close CPU that it does
+// recognize, instead of a lower march from being picked in the absence of a cpu
+// flag.
+static void normalizeCPUNamesForAssembler(const ArgList ,
+  ArgStringList ) {
+  if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
+StringRef CPUArg(A->getValue());
+if (CPUArg.equals_lower("krait"))
+  CmdArgs.push_back("-mcpu=cortex-a15");
+else if(CPUArg.equals_lower("kryo") ||
+CPUArg.equals_lower("falkor") ||
+CPUArg.equals_lower("saphira"))
+  CmdArgs.push_back("-mcpu=cortex-a57");
+else
+  Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+  }
+}
+
 void 

[PATCH] D37302: [Headers] Define *_HAS_SUBNORM for FLT, DBL, LDBL

2017-11-26 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 124313.
pirama added a comment.

- Switch kryo to use -mcpu=cortex-a57 when invoking the assembler


https://reviews.llvm.org/D37302

Files:
  lib/Driver/ToolChains/Gnu.cpp
  lib/Headers/float.h
  test/Driver/as-mcpu.c
  test/Headers/float.c

Index: test/Headers/float.c
===
--- test/Headers/float.c
+++ test/Headers/float.c
@@ -61,6 +61,21 @@
 #if ((FLT_DECIMAL_DIG > DBL_DECIMAL_DIG) || (DBL_DECIMAL_DIG > LDBL_DECIMAL_DIG))
 #error "Mandatory macros {FLT,DBL,LDBL}_DECIMAL_DIG are invalid."
 #endif
+#ifndef FLT_HAS_SUBNORM
+#error "Mandatory macro FLT_HAS_SUBNORM is missing."
+#elif FLT_HAS_SUBNORM != __FLT_HAS_DENORM__
+#error "Mandatory macro FLT_HAS_SUBNORM is invalid."
+#endif
+#ifndef LDBL_HAS_SUBNORM
+#error "Mandatory macro LDBL_HAS_SUBNORM is missing."
+#elif LDBL_HAS_SUBNORM != __LDBL_HAS_DENORM__
+#error "Mandatory macro LDBL_HAS_SUBNORM is invalid."
+#endif
+#ifndef DBL_HAS_SUBNORM
+#error "Mandatory macro DBL_HAS_SUBNORM is missing."
+#elif DBL_HAS_SUBNORM != __DBL_HAS_DENORM__
+#error "Mandatory macro DBL_HAS_SUBNORM is invalid."
+#endif
 #else
 #ifdef FLT_DECIMAL_DIG
 #error "Macro FLT_DECIMAL_DIG should not be defined."
@@ -71,6 +86,15 @@
 #ifdef LDBL_DECIMAL_DIG
 #error "Macro LDBL_DECIMAL_DIG should not be defined."
 #endif
+#ifdef FLT_HAS_SUBNORM
+#error "Macro FLT_HAS_SUBNORM should not be defined."
+#endif
+#ifdef DBL_HAS_SUBNORM
+#error "Macro DBL_HAS_SUBNORM should not be defined."
+#endif
+#ifdef LDBL_HAS_SUBNORM
+#error "Macro LDBL_HAS_SUBNORM should not be defined."
+#endif
 #endif
 
 
Index: test/Driver/as-mcpu.c
===
--- /dev/null
+++ test/Driver/as-mcpu.c
@@ -0,0 +1,10 @@
+// == Check that krait is substituted by cortex-15 when invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=krait -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A15 %s
+// CHECK-CORTEX-A15: bin/as{{.*}}-mcpu=cortex-a15
+
+// == Check that kryo is substituted by cortex-57 when invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=kryo -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=kryo -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// CHECK-CORTEX-A57: bin/as{{.*}}-mcpu=cortex-a57
Index: lib/Headers/float.h
===
--- lib/Headers/float.h
+++ lib/Headers/float.h
@@ -85,6 +85,9 @@
 #undef FLT_DECIMAL_DIG
 #undef DBL_DECIMAL_DIG
 #undef LDBL_DECIMAL_DIG
+#undef FLT_HAS_SUBNORM
+#undef DBL_HAS_SUBNORM
+#undef LDBL_HAS_SUBNORM
 #  endif
 #endif
 
@@ -141,6 +144,9 @@
 #  define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
 #  define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
 #  define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
+#  define FLT_HAS_SUBNORM __FLT_HAS_DENORM__
+#  define DBL_HAS_SUBNORM __DBL_HAS_DENORM__
+#  define LDBL_HAS_SUBNORM __LDBL_HAS_DENORM__
 #endif
 
 #ifdef __STDC_WANT_IEC_60559_TYPES_EXT__
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -653,22 +653,35 @@
 
 Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
 
-// FIXME: remove krait check when GNU tools support krait cpu
-// for now replace it with -mcpu=cortex-a15 to avoid a lower
-// march from being picked in the absence of a cpu flag.
-Arg *A;
-if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
-StringRef(A->getValue()).equals_lower("krait"))
-  CmdArgs.push_back("-mcpu=cortex-a15");
-else
-  Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+// FIXME: remove krait and kryo checks when GNU tools support them.  For now
+// use -mcpu=cortex-a15 for krait and -mcpu=cortex-a57 for kryo
+// -mcpu=cortex-a57 to avoid a lower march from being picked in the absence
+// of a cpu flag.
+Arg *A = Args.getLastArg(options::OPT_mcpu_EQ);
+if (A) {
+  if(StringRef(A->getValue()).equals_lower("krait"))
+CmdArgs.push_back("-mcpu=cortex-a15");
+  else if(StringRef(A->getValue()).equals_lower("kryo"))
+CmdArgs.push_back("-mcpu=cortex-a57");
+  else
+Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+}
 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);
+
+// FIXME: remove kryo check when GNU tools support them.  For now use
+// 

[PATCH] D40476: Switch kryo to use -mcpu=cortex-a57 when invoking the assembler

2017-11-26 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 124318.
pirama added a comment.

Few refactorings.


https://reviews.llvm.org/D40476

Files:
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/as-mcpu.c


Index: test/Driver/as-mcpu.c
===
--- /dev/null
+++ test/Driver/as-mcpu.c
@@ -0,0 +1,10 @@
+// == Check that krait is substituted by cortex-15 when 
invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=krait -### -c %s -v -fno-integrated-as 
2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A15 %s
+// CHECK-CORTEX-A15: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a15
+
+// == Check that kryo is substituted by cortex-57 when invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=kryo -### -c %s -v -fno-integrated-as 
2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=kryo -### -c %s -v 
-fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// CHECK-CORTEX-A57: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a57
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -653,22 +653,36 @@
 
 Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
 
-// FIXME: remove krait check when GNU tools support krait cpu
-// for now replace it with -mcpu=cortex-a15 to avoid a lower
-// march from being picked in the absence of a cpu flag.
-Arg *A;
-if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
-StringRef(A->getValue()).equals_lower("krait"))
-  CmdArgs.push_back("-mcpu=cortex-a15");
-else
-  Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+// FIXME: remove krait and kryo checks when GNU tools support them.  For 
now
+// use -mcpu=cortex-a15 for krait and -mcpu=cortex-a57 for kryo
+// -mcpu=cortex-a57 to avoid a lower march from being picked in the absence
+// of a cpu flag.
+Arg *A = Args.getLastArg(options::OPT_mcpu_EQ);
+if (A) {
+  StringRef CPUArg(A->getValue());
+  if(CPUArg.equals_lower("krait"))
+CmdArgs.push_back("-mcpu=cortex-a15");
+  else if(CPUArg.equals_lower("kryo"))
+CmdArgs.push_back("-mcpu=cortex-a57");
+  else
+Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+}
 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);
+
+// FIXME: remove kryo check when GNU tools support them.  For now use
+// -mcpu=cortex-a57 to avoid a lower march from being picked in the absence
+// of a cpu flag.
+Arg *A;
+if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
+(StringRef(A->getValue()).equals_lower("kryo")))
+  CmdArgs.push_back("-mcpu=cortex-a57");
+else
+  Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
 break;
   }
   case llvm::Triple::mips:


Index: test/Driver/as-mcpu.c
===
--- /dev/null
+++ test/Driver/as-mcpu.c
@@ -0,0 +1,10 @@
+// == Check that krait is substituted by cortex-15 when invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=krait -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A15 %s
+// CHECK-CORTEX-A15: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a15
+
+// == Check that kryo is substituted by cortex-57 when invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=kryo -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=kryo -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// CHECK-CORTEX-A57: as{{(.exe)?}}" "{{.*}}-mcpu=cortex-a57
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -653,22 +653,36 @@
 
 Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
 
-// FIXME: remove krait check when GNU tools support krait cpu
-// for now replace it with -mcpu=cortex-a15 to avoid a lower
-// march from being picked in the absence of a cpu flag.
-Arg *A;
-if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
-StringRef(A->getValue()).equals_lower("krait"))
-  CmdArgs.push_back("-mcpu=cortex-a15");
-else
-  Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+// FIXME: remove krait and kryo checks when GNU tools support them.  For now
+// use -mcpu=cortex-a15 for krait and -mcpu=cortex-a57 for kryo
+// -mcpu=cortex-a57 to avoid a lower march from being picked in the absence
+// of a cpu flag.
+Arg *A = Args.getLastArg(options::OPT_mcpu_EQ);
+if (A) {
+  StringRef CPUArg(A->getValue());
+  

[PATCH] D37302: [Headers] Define *_HAS_SUBNORM for FLT, DBL, LDBL

2017-11-26 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 124315.
pirama added a comment.

Actually revert


https://reviews.llvm.org/D37302

Files:
  lib/Headers/float.h
  test/Headers/float.c


Index: test/Headers/float.c
===
--- test/Headers/float.c
+++ test/Headers/float.c
@@ -61,6 +61,21 @@
 #if ((FLT_DECIMAL_DIG > DBL_DECIMAL_DIG) || (DBL_DECIMAL_DIG > 
LDBL_DECIMAL_DIG))
 #error "Mandatory macros {FLT,DBL,LDBL}_DECIMAL_DIG are invalid."
 #endif
+#ifndef FLT_HAS_SUBNORM
+#error "Mandatory macro FLT_HAS_SUBNORM is missing."
+#elif FLT_HAS_SUBNORM != __FLT_HAS_DENORM__
+#error "Mandatory macro FLT_HAS_SUBNORM is invalid."
+#endif
+#ifndef LDBL_HAS_SUBNORM
+#error "Mandatory macro LDBL_HAS_SUBNORM is missing."
+#elif LDBL_HAS_SUBNORM != __LDBL_HAS_DENORM__
+#error "Mandatory macro LDBL_HAS_SUBNORM is invalid."
+#endif
+#ifndef DBL_HAS_SUBNORM
+#error "Mandatory macro DBL_HAS_SUBNORM is missing."
+#elif DBL_HAS_SUBNORM != __DBL_HAS_DENORM__
+#error "Mandatory macro DBL_HAS_SUBNORM is invalid."
+#endif
 #else
 #ifdef FLT_DECIMAL_DIG
 #error "Macro FLT_DECIMAL_DIG should not be defined."
@@ -71,6 +86,15 @@
 #ifdef LDBL_DECIMAL_DIG
 #error "Macro LDBL_DECIMAL_DIG should not be defined."
 #endif
+#ifdef FLT_HAS_SUBNORM
+#error "Macro FLT_HAS_SUBNORM should not be defined."
+#endif
+#ifdef DBL_HAS_SUBNORM
+#error "Macro DBL_HAS_SUBNORM should not be defined."
+#endif
+#ifdef LDBL_HAS_SUBNORM
+#error "Macro LDBL_HAS_SUBNORM should not be defined."
+#endif
 #endif
 
 
Index: lib/Headers/float.h
===
--- lib/Headers/float.h
+++ lib/Headers/float.h
@@ -85,6 +85,9 @@
 #undef FLT_DECIMAL_DIG
 #undef DBL_DECIMAL_DIG
 #undef LDBL_DECIMAL_DIG
+#undef FLT_HAS_SUBNORM
+#undef DBL_HAS_SUBNORM
+#undef LDBL_HAS_SUBNORM
 #  endif
 #endif
 
@@ -141,6 +144,9 @@
 #  define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
 #  define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
 #  define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
+#  define FLT_HAS_SUBNORM __FLT_HAS_DENORM__
+#  define DBL_HAS_SUBNORM __DBL_HAS_DENORM__
+#  define LDBL_HAS_SUBNORM __LDBL_HAS_DENORM__
 #endif
 
 #ifdef __STDC_WANT_IEC_60559_TYPES_EXT__


Index: test/Headers/float.c
===
--- test/Headers/float.c
+++ test/Headers/float.c
@@ -61,6 +61,21 @@
 #if ((FLT_DECIMAL_DIG > DBL_DECIMAL_DIG) || (DBL_DECIMAL_DIG > LDBL_DECIMAL_DIG))
 #error "Mandatory macros {FLT,DBL,LDBL}_DECIMAL_DIG are invalid."
 #endif
+#ifndef FLT_HAS_SUBNORM
+#error "Mandatory macro FLT_HAS_SUBNORM is missing."
+#elif FLT_HAS_SUBNORM != __FLT_HAS_DENORM__
+#error "Mandatory macro FLT_HAS_SUBNORM is invalid."
+#endif
+#ifndef LDBL_HAS_SUBNORM
+#error "Mandatory macro LDBL_HAS_SUBNORM is missing."
+#elif LDBL_HAS_SUBNORM != __LDBL_HAS_DENORM__
+#error "Mandatory macro LDBL_HAS_SUBNORM is invalid."
+#endif
+#ifndef DBL_HAS_SUBNORM
+#error "Mandatory macro DBL_HAS_SUBNORM is missing."
+#elif DBL_HAS_SUBNORM != __DBL_HAS_DENORM__
+#error "Mandatory macro DBL_HAS_SUBNORM is invalid."
+#endif
 #else
 #ifdef FLT_DECIMAL_DIG
 #error "Macro FLT_DECIMAL_DIG should not be defined."
@@ -71,6 +86,15 @@
 #ifdef LDBL_DECIMAL_DIG
 #error "Macro LDBL_DECIMAL_DIG should not be defined."
 #endif
+#ifdef FLT_HAS_SUBNORM
+#error "Macro FLT_HAS_SUBNORM should not be defined."
+#endif
+#ifdef DBL_HAS_SUBNORM
+#error "Macro DBL_HAS_SUBNORM should not be defined."
+#endif
+#ifdef LDBL_HAS_SUBNORM
+#error "Macro LDBL_HAS_SUBNORM should not be defined."
+#endif
 #endif
 
 
Index: lib/Headers/float.h
===
--- lib/Headers/float.h
+++ lib/Headers/float.h
@@ -85,6 +85,9 @@
 #undef FLT_DECIMAL_DIG
 #undef DBL_DECIMAL_DIG
 #undef LDBL_DECIMAL_DIG
+#undef FLT_HAS_SUBNORM
+#undef DBL_HAS_SUBNORM
+#undef LDBL_HAS_SUBNORM
 #  endif
 #endif
 
@@ -141,6 +144,9 @@
 #  define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
 #  define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
 #  define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
+#  define FLT_HAS_SUBNORM __FLT_HAS_DENORM__
+#  define DBL_HAS_SUBNORM __DBL_HAS_DENORM__
+#  define LDBL_HAS_SUBNORM __LDBL_HAS_DENORM__
 #endif
 
 #ifdef __STDC_WANT_IEC_60559_TYPES_EXT__
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37302: [Headers] Define *_HAS_SUBNORM for FLT, DBL, LDBL

2017-11-26 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 124314.
pirama added a comment.

Revert to previous patch after accidental update


https://reviews.llvm.org/D37302

Files:
  lib/Driver/ToolChains/Gnu.cpp
  lib/Headers/float.h
  test/Driver/as-mcpu.c
  test/Headers/float.c

Index: test/Headers/float.c
===
--- test/Headers/float.c
+++ test/Headers/float.c
@@ -61,6 +61,21 @@
 #if ((FLT_DECIMAL_DIG > DBL_DECIMAL_DIG) || (DBL_DECIMAL_DIG > LDBL_DECIMAL_DIG))
 #error "Mandatory macros {FLT,DBL,LDBL}_DECIMAL_DIG are invalid."
 #endif
+#ifndef FLT_HAS_SUBNORM
+#error "Mandatory macro FLT_HAS_SUBNORM is missing."
+#elif FLT_HAS_SUBNORM != __FLT_HAS_DENORM__
+#error "Mandatory macro FLT_HAS_SUBNORM is invalid."
+#endif
+#ifndef LDBL_HAS_SUBNORM
+#error "Mandatory macro LDBL_HAS_SUBNORM is missing."
+#elif LDBL_HAS_SUBNORM != __LDBL_HAS_DENORM__
+#error "Mandatory macro LDBL_HAS_SUBNORM is invalid."
+#endif
+#ifndef DBL_HAS_SUBNORM
+#error "Mandatory macro DBL_HAS_SUBNORM is missing."
+#elif DBL_HAS_SUBNORM != __DBL_HAS_DENORM__
+#error "Mandatory macro DBL_HAS_SUBNORM is invalid."
+#endif
 #else
 #ifdef FLT_DECIMAL_DIG
 #error "Macro FLT_DECIMAL_DIG should not be defined."
@@ -71,6 +86,15 @@
 #ifdef LDBL_DECIMAL_DIG
 #error "Macro LDBL_DECIMAL_DIG should not be defined."
 #endif
+#ifdef FLT_HAS_SUBNORM
+#error "Macro FLT_HAS_SUBNORM should not be defined."
+#endif
+#ifdef DBL_HAS_SUBNORM
+#error "Macro DBL_HAS_SUBNORM should not be defined."
+#endif
+#ifdef LDBL_HAS_SUBNORM
+#error "Macro LDBL_HAS_SUBNORM should not be defined."
+#endif
 #endif
 
 
Index: test/Driver/as-mcpu.c
===
--- /dev/null
+++ test/Driver/as-mcpu.c
@@ -0,0 +1,10 @@
+// == Check that krait is substituted by cortex-15 when invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=krait -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A15 %s
+// CHECK-CORTEX-A15: bin/as{{.*}}-mcpu=cortex-a15
+
+// == Check that kryo is substituted by cortex-57 when invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=kryo -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=kryo -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// CHECK-CORTEX-A57: bin/as{{.*}}-mcpu=cortex-a57
Index: lib/Headers/float.h
===
--- lib/Headers/float.h
+++ lib/Headers/float.h
@@ -85,6 +85,9 @@
 #undef FLT_DECIMAL_DIG
 #undef DBL_DECIMAL_DIG
 #undef LDBL_DECIMAL_DIG
+#undef FLT_HAS_SUBNORM
+#undef DBL_HAS_SUBNORM
+#undef LDBL_HAS_SUBNORM
 #  endif
 #endif
 
@@ -141,6 +144,9 @@
 #  define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
 #  define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
 #  define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
+#  define FLT_HAS_SUBNORM __FLT_HAS_DENORM__
+#  define DBL_HAS_SUBNORM __DBL_HAS_DENORM__
+#  define LDBL_HAS_SUBNORM __LDBL_HAS_DENORM__
 #endif
 
 #ifdef __STDC_WANT_IEC_60559_TYPES_EXT__
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -653,22 +653,35 @@
 
 Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
 
-// FIXME: remove krait check when GNU tools support krait cpu
-// for now replace it with -mcpu=cortex-a15 to avoid a lower
-// march from being picked in the absence of a cpu flag.
-Arg *A;
-if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
-StringRef(A->getValue()).equals_lower("krait"))
-  CmdArgs.push_back("-mcpu=cortex-a15");
-else
-  Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+// FIXME: remove krait and kryo checks when GNU tools support them.  For now
+// use -mcpu=cortex-a15 for krait and -mcpu=cortex-a57 for kryo
+// -mcpu=cortex-a57 to avoid a lower march from being picked in the absence
+// of a cpu flag.
+Arg *A = Args.getLastArg(options::OPT_mcpu_EQ);
+if (A) {
+  if(StringRef(A->getValue()).equals_lower("krait"))
+CmdArgs.push_back("-mcpu=cortex-a15");
+  else if(StringRef(A->getValue()).equals_lower("kryo"))
+CmdArgs.push_back("-mcpu=cortex-a57");
+  else
+Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+}
 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);
+
+// FIXME: remove kryo check when GNU tools support them.  For now use
+// -mcpu=cortex-a57 to 

[PATCH] D40476: Switch kryo to use -mcpu=cortex-a57 when invoking the assembler

2017-11-26 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama created this revision.

Using -no-integrated-as causes -mcpu=kryo to fail since GNU assembler
doesn't recognize kryo.  Cortex-a57 is the closest CPU to kryo that the
assembler does recognize.  So we should switch the assembler to use
that instead.


https://reviews.llvm.org/D40476

Files:
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/as-mcpu.c


Index: test/Driver/as-mcpu.c
===
--- /dev/null
+++ test/Driver/as-mcpu.c
@@ -0,0 +1,10 @@
+// == Check that krait is substituted by cortex-15 when 
invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=krait -### -c %s -v -fno-integrated-as 
2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A15 %s
+// CHECK-CORTEX-A15: bin/as{{.*}}-mcpu=cortex-a15
+
+// == Check that kryo is substituted by cortex-57 when invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=kryo -### -c %s -v -fno-integrated-as 
2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=kryo -### -c %s -v 
-fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// CHECK-CORTEX-A57: bin/as{{.*}}-mcpu=cortex-a57
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -653,22 +653,35 @@
 
 Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
 
-// FIXME: remove krait check when GNU tools support krait cpu
-// for now replace it with -mcpu=cortex-a15 to avoid a lower
-// march from being picked in the absence of a cpu flag.
-Arg *A;
-if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
-StringRef(A->getValue()).equals_lower("krait"))
-  CmdArgs.push_back("-mcpu=cortex-a15");
-else
-  Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+// FIXME: remove krait and kryo checks when GNU tools support them.  For 
now
+// use -mcpu=cortex-a15 for krait and -mcpu=cortex-a57 for kryo
+// -mcpu=cortex-a57 to avoid a lower march from being picked in the absence
+// of a cpu flag.
+Arg *A = Args.getLastArg(options::OPT_mcpu_EQ);
+if (A) {
+  if(StringRef(A->getValue()).equals_lower("krait"))
+CmdArgs.push_back("-mcpu=cortex-a15");
+  else if(StringRef(A->getValue()).equals_lower("kryo"))
+CmdArgs.push_back("-mcpu=cortex-a57");
+  else
+Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+}
 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);
+
+// FIXME: remove kryo check when GNU tools support them.  For now use
+// -mcpu=cortex-a57 to avoid a lower march from being picked in the absence
+// of a cpu flag.
+Arg *A;
+if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
+(StringRef(A->getValue()).equals_lower("kryo")))
+  CmdArgs.push_back("-mcpu=cortex-a57");
+else
+  Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
 break;
   }
   case llvm::Triple::mips:


Index: test/Driver/as-mcpu.c
===
--- /dev/null
+++ test/Driver/as-mcpu.c
@@ -0,0 +1,10 @@
+// == Check that krait is substituted by cortex-15 when invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=krait -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A15 %s
+// CHECK-CORTEX-A15: bin/as{{.*}}-mcpu=cortex-a15
+
+// == Check that kryo is substituted by cortex-57 when invoking
+// the assembler
+// RUN: %clang -target arm-linux -mcpu=kryo -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// RUN: %clang -target aarch64-linux -mcpu=kryo -### -c %s -v -fno-integrated-as 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A57 %s
+// CHECK-CORTEX-A57: bin/as{{.*}}-mcpu=cortex-a57
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -653,22 +653,35 @@
 
 Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
 
-// FIXME: remove krait check when GNU tools support krait cpu
-// for now replace it with -mcpu=cortex-a15 to avoid a lower
-// march from being picked in the absence of a cpu flag.
-Arg *A;
-if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
-StringRef(A->getValue()).equals_lower("krait"))
-  CmdArgs.push_back("-mcpu=cortex-a15");
-else
-  Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
+// FIXME: remove krait and kryo checks when GNU tools support them.  For now
+// use -mcpu=cortex-a15 for krait and -mcpu=cortex-a57 for kryo
+// -mcpu=cortex-a57 to avoid a lower march from being picked in the absence
+// of a 

[PATCH] D48749: [Win32] Overload ==, != for locale_t and long long

2018-07-02 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCXX336141: [Win32] Overload ==, != for locale_t and long long 
(authored by pirama, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D48749?vs=153411=153778#toc

Repository:
  rCXX libc++

https://reviews.llvm.org/D48749

Files:
  include/support/win32/locale_win32.h


Index: include/support/win32/locale_win32.h
===
--- include/support/win32/locale_win32.h
+++ include/support/win32/locale_win32.h
@@ -46,6 +46,10 @@
 return __left.__locale == nullptr && __right == 0;
 }
 
+friend bool operator==(const locale_t& __left, long long __right) {
+return __left.__locale == nullptr && __right == 0;
+}
+
 friend bool operator==(const locale_t& __left, std::nullptr_t) {
 return __left.__locale == nullptr;
 }
@@ -66,6 +70,10 @@
 return !(__left == __right);
 }
 
+friend bool operator!=(const locale_t& __left, long long __right) {
+return !(__left == __right);
+}
+
 friend bool operator!=(const locale_t& __left, std::nullptr_t __right) {
 return !(__left == __right);
 }


Index: include/support/win32/locale_win32.h
===
--- include/support/win32/locale_win32.h
+++ include/support/win32/locale_win32.h
@@ -46,6 +46,10 @@
 return __left.__locale == nullptr && __right == 0;
 }
 
+friend bool operator==(const locale_t& __left, long long __right) {
+return __left.__locale == nullptr && __right == 0;
+}
+
 friend bool operator==(const locale_t& __left, std::nullptr_t) {
 return __left.__locale == nullptr;
 }
@@ -66,6 +70,10 @@
 return !(__left == __right);
 }
 
+friend bool operator!=(const locale_t& __left, long long __right) {
+return !(__left == __right);
+}
+
 friend bool operator!=(const locale_t& __left, std::nullptr_t __right) {
 return !(__left == __right);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50199: [MinGW] Predefine UNICODE if -municode is specified during compilation

2018-08-02 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a comment.

In https://reviews.llvm.org/D50199#1186164, @rnk wrote:

> Does this do anything other than -DUNICODE? Maybe just translate it at the 
> driver level and skip the -cc1 flag?


It seems odd to include predefined macros at the driver, which AFAIK is just a 
bridge to the frontend's command-line interface.  OTOH, there is other 
precedence for doing this - during clang-cl's argument processing.  So I don't 
have a strong opinion here.


https://reviews.llvm.org/D50199



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


[PATCH] D50112: [Android] Increase default new alignment for Android

2018-07-31 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama created this revision.
pirama added a reviewer: rsmith.

Android's memory allocators also guarantee 8-byte alignment for 32-bit
architectures and 16-byte alignment for 64-bit.


Repository:
  rC Clang

https://reviews.llvm.org/D50112

Files:
  lib/Basic/TargetInfo.cpp
  test/Preprocessor/init.c


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -9019,7 +9019,7 @@
 // ANDROID:#define __ANDROID__ 1
 //
 // RUN: %clang_cc1 -x c++ -triple i686-linux-android -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix I386-ANDROID-CXX %s
-// I386-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 4U
+// I386-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8U
 //
 // RUN: %clang_cc1 -x c++ -triple x86_64-linux-android -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix X86_64-ANDROID-CXX %s
 // X86_64-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
Index: lib/Basic/TargetInfo.cpp
===
--- lib/Basic/TargetInfo.cpp
+++ lib/Basic/TargetInfo.cpp
@@ -63,8 +63,9 @@
   MinGlobalAlign = 0;
   // From the glibc documentation, on GNU systems, malloc guarantees 16-byte
   // alignment on 64-bit systems and 8-byte alignment on 32-bit systems. See
-  // https://www.gnu.org/software/libc/manual/html_node/Malloc-Examples.html
-  if (T.isGNUEnvironment() || T.isWindowsMSVCEnvironment())
+  // https://www.gnu.org/software/libc/manual/html_node/Malloc-Examples.html.
+  // This alignment guarantee also applies to Windows and Android.
+  if (T.isGNUEnvironment() || T.isWindowsMSVCEnvironment() || T.isAndroid())
 NewAlign = Triple.isArch64Bit() ? 128 : Triple.isArch32Bit() ? 64 : 0;
   else
 NewAlign = 0; // Infer from basic type alignment.


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -9019,7 +9019,7 @@
 // ANDROID:#define __ANDROID__ 1
 //
 // RUN: %clang_cc1 -x c++ -triple i686-linux-android -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix I386-ANDROID-CXX %s
-// I386-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 4U
+// I386-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8U
 //
 // RUN: %clang_cc1 -x c++ -triple x86_64-linux-android -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix X86_64-ANDROID-CXX %s
 // X86_64-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
Index: lib/Basic/TargetInfo.cpp
===
--- lib/Basic/TargetInfo.cpp
+++ lib/Basic/TargetInfo.cpp
@@ -63,8 +63,9 @@
   MinGlobalAlign = 0;
   // From the glibc documentation, on GNU systems, malloc guarantees 16-byte
   // alignment on 64-bit systems and 8-byte alignment on 32-bit systems. See
-  // https://www.gnu.org/software/libc/manual/html_node/Malloc-Examples.html
-  if (T.isGNUEnvironment() || T.isWindowsMSVCEnvironment())
+  // https://www.gnu.org/software/libc/manual/html_node/Malloc-Examples.html.
+  // This alignment guarantee also applies to Windows and Android.
+  if (T.isGNUEnvironment() || T.isWindowsMSVCEnvironment() || T.isAndroid())
 NewAlign = Triple.isArch64Bit() ? 128 : Triple.isArch32Bit() ? 64 : 0;
   else
 NewAlign = 0; // Infer from basic type alignment.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50112: [Android] Increase default new alignment for Android

2018-08-01 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC338603: [Android] Increase default new alignment for Android 
(authored by pirama, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50112?vs=158402=158574#toc

Repository:
  rC Clang

https://reviews.llvm.org/D50112

Files:
  lib/Basic/TargetInfo.cpp
  test/Preprocessor/init.c


Index: lib/Basic/TargetInfo.cpp
===
--- lib/Basic/TargetInfo.cpp
+++ lib/Basic/TargetInfo.cpp
@@ -63,8 +63,9 @@
   MinGlobalAlign = 0;
   // From the glibc documentation, on GNU systems, malloc guarantees 16-byte
   // alignment on 64-bit systems and 8-byte alignment on 32-bit systems. See
-  // https://www.gnu.org/software/libc/manual/html_node/Malloc-Examples.html
-  if (T.isGNUEnvironment() || T.isWindowsMSVCEnvironment())
+  // https://www.gnu.org/software/libc/manual/html_node/Malloc-Examples.html.
+  // This alignment guarantee also applies to Windows and Android.
+  if (T.isGNUEnvironment() || T.isWindowsMSVCEnvironment() || T.isAndroid())
 NewAlign = Triple.isArch64Bit() ? 128 : Triple.isArch32Bit() ? 64 : 0;
   else
 NewAlign = 0; // Infer from basic type alignment.
Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -9019,7 +9019,7 @@
 // ANDROID:#define __ANDROID__ 1
 //
 // RUN: %clang_cc1 -x c++ -triple i686-linux-android -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix I386-ANDROID-CXX %s
-// I386-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 4U
+// I386-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8U
 //
 // RUN: %clang_cc1 -x c++ -triple x86_64-linux-android -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix X86_64-ANDROID-CXX %s
 // X86_64-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL


Index: lib/Basic/TargetInfo.cpp
===
--- lib/Basic/TargetInfo.cpp
+++ lib/Basic/TargetInfo.cpp
@@ -63,8 +63,9 @@
   MinGlobalAlign = 0;
   // From the glibc documentation, on GNU systems, malloc guarantees 16-byte
   // alignment on 64-bit systems and 8-byte alignment on 32-bit systems. See
-  // https://www.gnu.org/software/libc/manual/html_node/Malloc-Examples.html
-  if (T.isGNUEnvironment() || T.isWindowsMSVCEnvironment())
+  // https://www.gnu.org/software/libc/manual/html_node/Malloc-Examples.html.
+  // This alignment guarantee also applies to Windows and Android.
+  if (T.isGNUEnvironment() || T.isWindowsMSVCEnvironment() || T.isAndroid())
 NewAlign = Triple.isArch64Bit() ? 128 : Triple.isArch32Bit() ? 64 : 0;
   else
 NewAlign = 0; // Infer from basic type alignment.
Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -9019,7 +9019,7 @@
 // ANDROID:#define __ANDROID__ 1
 //
 // RUN: %clang_cc1 -x c++ -triple i686-linux-android -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix I386-ANDROID-CXX %s
-// I386-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 4U
+// I386-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8U
 //
 // RUN: %clang_cc1 -x c++ -triple x86_64-linux-android -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix X86_64-ANDROID-CXX %s
 // X86_64-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50467: [SEMA] add more -Wfloat-conversion to compound assigment analysis

2018-08-08 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added inline comments.



Comment at: lib/Sema/SemaChecking.cpp:10411
+->getAs();
+  if (!ResultBT || !(RBT && RBT->isFloatingPoint())) return;
+

Add a comment explaining this conditional as well?  

> Return if source and target types are unavailable or if source is not a 
> floating point.

With the comment, it might be cleaner to read if you expand the negation: 
`!ResultBT || !RBT || !RBT->isFloatingPoint()`


Repository:
  rC Clang

https://reviews.llvm.org/D50467



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


[PATCH] D37302: [Headers] Define *_HAS_SUBNORM for FLT, DBL, LDBL

2018-08-08 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC339284: [Headers] Define *_HAS_SUBNORM for FLT, DBL, LDBL 
(authored by pirama, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D37302?vs=159330=159778#toc

Repository:
  rC Clang

https://reviews.llvm.org/D37302

Files:
  lib/Headers/float.h
  test/Headers/float.c


Index: lib/Headers/float.h
===
--- lib/Headers/float.h
+++ lib/Headers/float.h
@@ -85,6 +85,9 @@
 #undef FLT_DECIMAL_DIG
 #undef DBL_DECIMAL_DIG
 #undef LDBL_DECIMAL_DIG
+#undef FLT_HAS_SUBNORM
+#undef DBL_HAS_SUBNORM
+#undef LDBL_HAS_SUBNORM
 #  endif
 #endif
 
@@ -141,6 +144,9 @@
 #  define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
 #  define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
 #  define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
+#  define FLT_HAS_SUBNORM __FLT_HAS_DENORM__
+#  define DBL_HAS_SUBNORM __DBL_HAS_DENORM__
+#  define LDBL_HAS_SUBNORM __LDBL_HAS_DENORM__
 #endif
 
 #ifdef __STDC_WANT_IEC_60559_TYPES_EXT__
Index: test/Headers/float.c
===
--- test/Headers/float.c
+++ test/Headers/float.c
@@ -61,6 +61,21 @@
 #if ((FLT_DECIMAL_DIG > DBL_DECIMAL_DIG) || (DBL_DECIMAL_DIG > 
LDBL_DECIMAL_DIG))
 #error "Mandatory macros {FLT,DBL,LDBL}_DECIMAL_DIG are invalid."
 #endif
+#ifndef FLT_HAS_SUBNORM
+#error "Mandatory macro FLT_HAS_SUBNORM is missing."
+#elif FLT_HAS_SUBNORM != __FLT_HAS_DENORM__
+#error "Mandatory macro FLT_HAS_SUBNORM is invalid."
+#endif
+#ifndef LDBL_HAS_SUBNORM
+#error "Mandatory macro LDBL_HAS_SUBNORM is missing."
+#elif LDBL_HAS_SUBNORM != __LDBL_HAS_DENORM__
+#error "Mandatory macro LDBL_HAS_SUBNORM is invalid."
+#endif
+#ifndef DBL_HAS_SUBNORM
+#error "Mandatory macro DBL_HAS_SUBNORM is missing."
+#elif DBL_HAS_SUBNORM != __DBL_HAS_DENORM__
+#error "Mandatory macro DBL_HAS_SUBNORM is invalid."
+#endif
 #else
 #ifdef FLT_DECIMAL_DIG
 #error "Macro FLT_DECIMAL_DIG should not be defined."
@@ -71,6 +86,15 @@
 #ifdef LDBL_DECIMAL_DIG
 #error "Macro LDBL_DECIMAL_DIG should not be defined."
 #endif
+#ifdef FLT_HAS_SUBNORM
+#error "Macro FLT_HAS_SUBNORM should not be defined."
+#endif
+#ifdef DBL_HAS_SUBNORM
+#error "Macro DBL_HAS_SUBNORM should not be defined."
+#endif
+#ifdef LDBL_HAS_SUBNORM
+#error "Macro LDBL_HAS_SUBNORM should not be defined."
+#endif
 #endif
 
 


Index: lib/Headers/float.h
===
--- lib/Headers/float.h
+++ lib/Headers/float.h
@@ -85,6 +85,9 @@
 #undef FLT_DECIMAL_DIG
 #undef DBL_DECIMAL_DIG
 #undef LDBL_DECIMAL_DIG
+#undef FLT_HAS_SUBNORM
+#undef DBL_HAS_SUBNORM
+#undef LDBL_HAS_SUBNORM
 #  endif
 #endif
 
@@ -141,6 +144,9 @@
 #  define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
 #  define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
 #  define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
+#  define FLT_HAS_SUBNORM __FLT_HAS_DENORM__
+#  define DBL_HAS_SUBNORM __DBL_HAS_DENORM__
+#  define LDBL_HAS_SUBNORM __LDBL_HAS_DENORM__
 #endif
 
 #ifdef __STDC_WANT_IEC_60559_TYPES_EXT__
Index: test/Headers/float.c
===
--- test/Headers/float.c
+++ test/Headers/float.c
@@ -61,6 +61,21 @@
 #if ((FLT_DECIMAL_DIG > DBL_DECIMAL_DIG) || (DBL_DECIMAL_DIG > LDBL_DECIMAL_DIG))
 #error "Mandatory macros {FLT,DBL,LDBL}_DECIMAL_DIG are invalid."
 #endif
+#ifndef FLT_HAS_SUBNORM
+#error "Mandatory macro FLT_HAS_SUBNORM is missing."
+#elif FLT_HAS_SUBNORM != __FLT_HAS_DENORM__
+#error "Mandatory macro FLT_HAS_SUBNORM is invalid."
+#endif
+#ifndef LDBL_HAS_SUBNORM
+#error "Mandatory macro LDBL_HAS_SUBNORM is missing."
+#elif LDBL_HAS_SUBNORM != __LDBL_HAS_DENORM__
+#error "Mandatory macro LDBL_HAS_SUBNORM is invalid."
+#endif
+#ifndef DBL_HAS_SUBNORM
+#error "Mandatory macro DBL_HAS_SUBNORM is missing."
+#elif DBL_HAS_SUBNORM != __DBL_HAS_DENORM__
+#error "Mandatory macro DBL_HAS_SUBNORM is invalid."
+#endif
 #else
 #ifdef FLT_DECIMAL_DIG
 #error "Macro FLT_DECIMAL_DIG should not be defined."
@@ -71,6 +86,15 @@
 #ifdef LDBL_DECIMAL_DIG
 #error "Macro LDBL_DECIMAL_DIG should not be defined."
 #endif
+#ifdef FLT_HAS_SUBNORM
+#error "Macro FLT_HAS_SUBNORM should not be defined."
+#endif
+#ifdef DBL_HAS_SUBNORM
+#error "Macro DBL_HAS_SUBNORM should not be defined."
+#endif
+#ifdef LDBL_HAS_SUBNORM
+#error "Macro LDBL_HAS_SUBNORM should not be defined."
+#endif
 #endif
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D50359: Add a new library, libclang-cxx

2018-08-06 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama created this revision.
Herald added a subscriber: mgorny.

The current libclang.so exports only the symbols required for the stable
C api.  This is opposed to libLLVM.so, which exports all the symbols
from the LLVM libraries, including those from the C++ API.  This patch
adds libclang-cxx.so that is similar to libLLVM.so and exports all
symbols from the clang libraries.  The motivation for this library is to
be used by Clang tools that use Clang's C++ api.  They no longer need to
link against the individual static libraries.


Repository:
  rC Clang

https://reviews.llvm.org/D50359

Files:
  CMakeLists.txt
  tools/CMakeLists.txt
  tools/libclang-cxx/CMakeLists.txt

Index: tools/libclang-cxx/CMakeLists.txt
===
--- /dev/null
+++ tools/libclang-cxx/CMakeLists.txt
@@ -0,0 +1,74 @@
+set(LIBS
+  clangBasic
+  clangCodeGen
+  clangDriver
+  clangFrontend
+  clangFrontendTool
+)
+
+if (CLANG_ENABLE_ARCMT)
+  list(APPEND LIBS clangARCMigrate)
+endif ()
+
+if (TARGET clangTidyPlugin)
+  add_definitions(-DCLANG_TOOL_EXTRA_BUILD)
+  list(APPEND LIBS clangTidyPlugin)
+  list(APPEND LIBS clangIncludeFixerPlugin)
+  if(LLVM_ENABLE_MODULES)
+list(APPEND LLVM_COMPILE_FLAGS "-fmodules-ignore-macro=CLANG_TOOL_EXTRA_BUILD")
+  endif()
+endif ()
+
+find_library(DL_LIBRARY_PATH dl)
+if (DL_LIBRARY_PATH)
+  list(APPEND LIBS dl)
+endif()
+
+if( LLVM_ENABLE_PIC )
+  set(ENABLE_SHARED SHARED)
+endif()
+
+if(NOT LLVM_ENABLE_PIC AND NOT WIN32)
+  set(ENABLE_STATIC STATIC)
+endif()
+
+if(WIN32)
+  set(output_name "libclang_cxx")
+else()
+  set(output_name "clang_cxx")
+endif()
+
+set(LIBS -Wl,--whole-archive ${LIBS} -Wl,--no-whole-archive)
+
+add_clang_library(libclang_cxx ${ENABLE_SHARED} ${ENABLE_STATIC}
+  OUTPUT_NAME ${output_name}
+
+  LINK_LIBS
+  ${LIBS}
+  )
+
+if(ENABLE_SHARED)
+  if(WIN32)
+set_target_properties(libclang_cxx
+  PROPERTIES
+  VERSION ${LIBCLANG_LIBRARY_VERSION}
+  DEFINE_SYMBOL _CINDEX_LIB_)
+  elseif(APPLE)
+  set(LIBCLANG_CXX_LINK_FLAGS " -Wl,-compatibility_version -Wl,1")
+  set(LIBCLANG_CXX_LINK_FLAGS "${LIBCLANG_CXX_LINK_FLAGS} -Wl,-current_version -Wl,${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}")
+
+set_property(TARGET libclang_cxx APPEND_STRING PROPERTY
+LINK_FLAGS ${LIBCLANG_CXX_LINK_FLAGS})
+  else()
+set_target_properties(libclang_cxx
+  PROPERTIES
+  VERSION ${LIBCLANG_LIBRARY_VERSION}
+  DEFINE_SYMBOL _CINDEX_LIB_)
+# FIXME: _CINDEX_LIB_ affects dllexport/dllimport on Win32.
+if(LLVM_ENABLE_MODULES AND NOT WIN32)
+  target_compile_options(libclang_cxx PRIVATE
+"-fmodules-ignore-macro=_CINDEX_LIB_"
+)
+endif()
+  endif()
+endif()
Index: tools/CMakeLists.txt
===
--- tools/CMakeLists.txt
+++ tools/CMakeLists.txt
@@ -35,3 +35,4 @@
 
 # libclang may require clang-tidy in clang-tools-extra.
 add_clang_subdirectory(libclang)
+add_clang_subdirectory(libclang-cxx)
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -431,7 +431,7 @@
 "Major version number that will be appended to the clang executable name")
 set(LIBCLANG_LIBRARY_VERSION
 "${CLANG_VERSION_MAJOR}" CACHE STRING
-"Major version number that will be appended to the libclang library")
+"Major version number that will be appended to the libclang, libclang_cxx libraries")
 mark_as_advanced(CLANG_EXECUTABLE_VERSION LIBCLANG_LIBRARY_VERSION)
 
 option(CLANG_INCLUDE_TESTS
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50359: Add a new library, libclang-cxx

2018-08-06 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a comment.

This implements the new library proposed in 
http://lists.llvm.org/pipermail/cfe-dev/2018-August/058736.html.


Repository:
  rC Clang

https://reviews.llvm.org/D50359



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


[PATCH] D50683: [Android] Set NewAlign for 64-bit Android to 8 bytes

2018-08-13 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama created this revision.
pirama added reviewers: rsmith, srhines.

Android uses jemalloc allocator, which returns 8-byte-aligned pointers for
allocations smaller than 8 bytes for 64-bit architectures.  Set NewAlign
conservatively to 8 bytes.


Repository:
  rC Clang

https://reviews.llvm.org/D50683

Files:
  lib/Basic/TargetInfo.cpp
  test/Preprocessor/init.c


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -9022,7 +9022,10 @@
 // I386-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8U
 //
 // RUN: %clang_cc1 -x c++ -triple x86_64-linux-android -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix X86_64-ANDROID-CXX %s
-// X86_64-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
+// X86_64-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8UL
+//
+// RUN: %clang_cc1 -x c++ -triple aarch64-linux-android -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix AARCH64-ANDROID-CXX %s
+// AARCH64-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8UL
 //
 // RUN: %clang_cc1 -triple arm-linux-androideabi20 -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix ANDROID20 %s
 // ANDROID20:#define __ANDROID_API__ 20
Index: lib/Basic/TargetInfo.cpp
===
--- lib/Basic/TargetInfo.cpp
+++ lib/Basic/TargetInfo.cpp
@@ -64,10 +64,13 @@
   // From the glibc documentation, on GNU systems, malloc guarantees 16-byte
   // alignment on 64-bit systems and 8-byte alignment on 32-bit systems. See
   // https://www.gnu.org/software/libc/manual/html_node/Malloc-Examples.html.
-  // This alignment guarantee also applies to Windows and Android.
-  if (T.isGNUEnvironment() || T.isWindowsMSVCEnvironment() || T.isAndroid())
+  // This alignment guarantee also applies to Windows.
+  if (T.isGNUEnvironment() || T.isWindowsMSVCEnvironment())
 NewAlign = Triple.isArch64Bit() ? 128 : Triple.isArch32Bit() ? 64 : 0;
-  else
+  else if (T.isAndroid()) {
+// For 64-bit Android, alignment is 8 bytes for allocations <= 8 bytes.
+NewAlign = (Triple.isArch64Bit() || Triple.isArch32Bit()) ? 64 : 0;
+  } else
 NewAlign = 0; // Infer from basic type alignment.
   HalfWidth = 16;
   HalfAlign = 16;


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -9022,7 +9022,10 @@
 // I386-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8U
 //
 // RUN: %clang_cc1 -x c++ -triple x86_64-linux-android -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix X86_64-ANDROID-CXX %s
-// X86_64-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
+// X86_64-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8UL
+//
+// RUN: %clang_cc1 -x c++ -triple aarch64-linux-android -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix AARCH64-ANDROID-CXX %s
+// AARCH64-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8UL
 //
 // RUN: %clang_cc1 -triple arm-linux-androideabi20 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix ANDROID20 %s
 // ANDROID20:#define __ANDROID_API__ 20
Index: lib/Basic/TargetInfo.cpp
===
--- lib/Basic/TargetInfo.cpp
+++ lib/Basic/TargetInfo.cpp
@@ -64,10 +64,13 @@
   // From the glibc documentation, on GNU systems, malloc guarantees 16-byte
   // alignment on 64-bit systems and 8-byte alignment on 32-bit systems. See
   // https://www.gnu.org/software/libc/manual/html_node/Malloc-Examples.html.
-  // This alignment guarantee also applies to Windows and Android.
-  if (T.isGNUEnvironment() || T.isWindowsMSVCEnvironment() || T.isAndroid())
+  // This alignment guarantee also applies to Windows.
+  if (T.isGNUEnvironment() || T.isWindowsMSVCEnvironment())
 NewAlign = Triple.isArch64Bit() ? 128 : Triple.isArch32Bit() ? 64 : 0;
-  else
+  else if (T.isAndroid()) {
+// For 64-bit Android, alignment is 8 bytes for allocations <= 8 bytes.
+NewAlign = (Triple.isArch64Bit() || Triple.isArch32Bit()) ? 64 : 0;
+  } else
 NewAlign = 0; // Infer from basic type alignment.
   HalfWidth = 16;
   HalfAlign = 16;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37302: [Headers] Define *_HAS_SUBNORM for FLT, DBL, LDBL

2018-08-06 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a comment.

Sorry this fell of my radar.  I've rebased the patch.

Since this has been inactive for a while, lets wait for a couple of days to see 
if there are any other comments.  If there are no objections, I'll submit this 
on Wednesday.


Repository:
  rC Clang

https://reviews.llvm.org/D37302



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


[PATCH] D37302: [Headers] Define *_HAS_SUBNORM for FLT, DBL, LDBL

2018-08-06 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 159330.
pirama added a comment.

Rebase


Repository:
  rC Clang

https://reviews.llvm.org/D37302

Files:
  lib/Headers/float.h
  test/Headers/float.c


Index: test/Headers/float.c
===
--- test/Headers/float.c
+++ test/Headers/float.c
@@ -61,6 +61,21 @@
 #if ((FLT_DECIMAL_DIG > DBL_DECIMAL_DIG) || (DBL_DECIMAL_DIG > 
LDBL_DECIMAL_DIG))
 #error "Mandatory macros {FLT,DBL,LDBL}_DECIMAL_DIG are invalid."
 #endif
+#ifndef FLT_HAS_SUBNORM
+#error "Mandatory macro FLT_HAS_SUBNORM is missing."
+#elif FLT_HAS_SUBNORM != __FLT_HAS_DENORM__
+#error "Mandatory macro FLT_HAS_SUBNORM is invalid."
+#endif
+#ifndef LDBL_HAS_SUBNORM
+#error "Mandatory macro LDBL_HAS_SUBNORM is missing."
+#elif LDBL_HAS_SUBNORM != __LDBL_HAS_DENORM__
+#error "Mandatory macro LDBL_HAS_SUBNORM is invalid."
+#endif
+#ifndef DBL_HAS_SUBNORM
+#error "Mandatory macro DBL_HAS_SUBNORM is missing."
+#elif DBL_HAS_SUBNORM != __DBL_HAS_DENORM__
+#error "Mandatory macro DBL_HAS_SUBNORM is invalid."
+#endif
 #else
 #ifdef FLT_DECIMAL_DIG
 #error "Macro FLT_DECIMAL_DIG should not be defined."
@@ -71,6 +86,15 @@
 #ifdef LDBL_DECIMAL_DIG
 #error "Macro LDBL_DECIMAL_DIG should not be defined."
 #endif
+#ifdef FLT_HAS_SUBNORM
+#error "Macro FLT_HAS_SUBNORM should not be defined."
+#endif
+#ifdef DBL_HAS_SUBNORM
+#error "Macro DBL_HAS_SUBNORM should not be defined."
+#endif
+#ifdef LDBL_HAS_SUBNORM
+#error "Macro LDBL_HAS_SUBNORM should not be defined."
+#endif
 #endif
 
 
Index: lib/Headers/float.h
===
--- lib/Headers/float.h
+++ lib/Headers/float.h
@@ -85,6 +85,9 @@
 #undef FLT_DECIMAL_DIG
 #undef DBL_DECIMAL_DIG
 #undef LDBL_DECIMAL_DIG
+#undef FLT_HAS_SUBNORM
+#undef DBL_HAS_SUBNORM
+#undef LDBL_HAS_SUBNORM
 #  endif
 #endif
 
@@ -141,6 +144,9 @@
 #  define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
 #  define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
 #  define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
+#  define FLT_HAS_SUBNORM __FLT_HAS_DENORM__
+#  define DBL_HAS_SUBNORM __DBL_HAS_DENORM__
+#  define LDBL_HAS_SUBNORM __LDBL_HAS_DENORM__
 #endif
 
 #ifdef __STDC_WANT_IEC_60559_TYPES_EXT__


Index: test/Headers/float.c
===
--- test/Headers/float.c
+++ test/Headers/float.c
@@ -61,6 +61,21 @@
 #if ((FLT_DECIMAL_DIG > DBL_DECIMAL_DIG) || (DBL_DECIMAL_DIG > LDBL_DECIMAL_DIG))
 #error "Mandatory macros {FLT,DBL,LDBL}_DECIMAL_DIG are invalid."
 #endif
+#ifndef FLT_HAS_SUBNORM
+#error "Mandatory macro FLT_HAS_SUBNORM is missing."
+#elif FLT_HAS_SUBNORM != __FLT_HAS_DENORM__
+#error "Mandatory macro FLT_HAS_SUBNORM is invalid."
+#endif
+#ifndef LDBL_HAS_SUBNORM
+#error "Mandatory macro LDBL_HAS_SUBNORM is missing."
+#elif LDBL_HAS_SUBNORM != __LDBL_HAS_DENORM__
+#error "Mandatory macro LDBL_HAS_SUBNORM is invalid."
+#endif
+#ifndef DBL_HAS_SUBNORM
+#error "Mandatory macro DBL_HAS_SUBNORM is missing."
+#elif DBL_HAS_SUBNORM != __DBL_HAS_DENORM__
+#error "Mandatory macro DBL_HAS_SUBNORM is invalid."
+#endif
 #else
 #ifdef FLT_DECIMAL_DIG
 #error "Macro FLT_DECIMAL_DIG should not be defined."
@@ -71,6 +86,15 @@
 #ifdef LDBL_DECIMAL_DIG
 #error "Macro LDBL_DECIMAL_DIG should not be defined."
 #endif
+#ifdef FLT_HAS_SUBNORM
+#error "Macro FLT_HAS_SUBNORM should not be defined."
+#endif
+#ifdef DBL_HAS_SUBNORM
+#error "Macro DBL_HAS_SUBNORM should not be defined."
+#endif
+#ifdef LDBL_HAS_SUBNORM
+#error "Macro LDBL_HAS_SUBNORM should not be defined."
+#endif
 #endif
 
 
Index: lib/Headers/float.h
===
--- lib/Headers/float.h
+++ lib/Headers/float.h
@@ -85,6 +85,9 @@
 #undef FLT_DECIMAL_DIG
 #undef DBL_DECIMAL_DIG
 #undef LDBL_DECIMAL_DIG
+#undef FLT_HAS_SUBNORM
+#undef DBL_HAS_SUBNORM
+#undef LDBL_HAS_SUBNORM
 #  endif
 #endif
 
@@ -141,6 +144,9 @@
 #  define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
 #  define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
 #  define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
+#  define FLT_HAS_SUBNORM __FLT_HAS_DENORM__
+#  define DBL_HAS_SUBNORM __DBL_HAS_DENORM__
+#  define LDBL_HAS_SUBNORM __LDBL_HAS_DENORM__
 #endif
 
 #ifdef __STDC_WANT_IEC_60559_TYPES_EXT__
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50683: [Android] Set NewAlign for 64-bit Android to 8 bytes

2018-08-20 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama abandoned this revision.
pirama added a comment.

Thanks for the clarification Richard and Eli.  I agree that leaving the status 
quo will match the intent of the macro.  I'll abandon this.


Repository:
  rC Clang

https://reviews.llvm.org/D50683



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


[PATCH] D51068: [Android] Default to -fno-math-errno

2018-08-21 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama created this revision.
pirama added reviewers: srhines, enh.

Android's libm does not set errno.


Repository:
  rC Clang

https://reviews.llvm.org/D51068

Files:
  lib/Driver/ToolChains/Linux.cpp
  lib/Driver/ToolChains/Linux.h
  test/Driver/fast-math.c


Index: test/Driver/fast-math.c
===
--- test/Driver/fast-math.c
+++ test/Driver/fast-math.c
@@ -95,6 +95,8 @@
 // RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
 // RUN: %clang -### -target x86_64-fuchsia -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
+// RUN: %clang -### -target x86_64-linux-android -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
 //
 // Check that -ffast-math disables -fmath-errno, and -fno-fast-math merely
 // preserves the target default. Also check various flag set operations between
Index: lib/Driver/ToolChains/Linux.h
===
--- lib/Driver/ToolChains/Linux.h
+++ lib/Driver/ToolChains/Linux.h
@@ -38,6 +38,7 @@
   void AddIAMCUIncludeArgs(const llvm::opt::ArgList ,
llvm::opt::ArgStringList ) const override;
   bool isPIEDefault() const override;
+  bool IsMathErrnoDefault() const override;
   SanitizerMask getSupportedSanitizers() const override;
   void addProfileRTLibs(const llvm::opt::ArgList ,
 llvm::opt::ArgStringList ) const override;
Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -907,6 +907,12 @@
   getTriple().isMusl() || getSanitizerArgs().requiresPIE();
 }
 
+bool Linux::IsMathErrnoDefault() const {
+  if (getTriple().isAndroid())
+return false;
+  return Generic_ELF::IsMathErrnoDefault();
+}
+
 SanitizerMask Linux::getSupportedSanitizers() const {
   const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;
   const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;


Index: test/Driver/fast-math.c
===
--- test/Driver/fast-math.c
+++ test/Driver/fast-math.c
@@ -95,6 +95,8 @@
 // RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
 // RUN: %clang -### -target x86_64-fuchsia -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
+// RUN: %clang -### -target x86_64-linux-android -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
 //
 // Check that -ffast-math disables -fmath-errno, and -fno-fast-math merely
 // preserves the target default. Also check various flag set operations between
Index: lib/Driver/ToolChains/Linux.h
===
--- lib/Driver/ToolChains/Linux.h
+++ lib/Driver/ToolChains/Linux.h
@@ -38,6 +38,7 @@
   void AddIAMCUIncludeArgs(const llvm::opt::ArgList ,
llvm::opt::ArgStringList ) const override;
   bool isPIEDefault() const override;
+  bool IsMathErrnoDefault() const override;
   SanitizerMask getSupportedSanitizers() const override;
   void addProfileRTLibs(const llvm::opt::ArgList ,
 llvm::opt::ArgStringList ) const override;
Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -907,6 +907,12 @@
   getTriple().isMusl() || getSanitizerArgs().requiresPIE();
 }
 
+bool Linux::IsMathErrnoDefault() const {
+  if (getTriple().isAndroid())
+return false;
+  return Generic_ELF::IsMathErrnoDefault();
+}
+
 SanitizerMask Linux::getSupportedSanitizers() const {
   const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;
   const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51068: [Android] Default to -fno-math-errno

2018-08-21 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added inline comments.



Comment at: lib/Driver/ToolChains/Linux.cpp:913
+return false;
+  return Generic_ELF::IsMathErrnoDefault();
+}

I tried to be defensive here in case the default changes in the future.  I can 
simplify to just return true here if that'd be simpler.


Repository:
  rC Clang

https://reviews.llvm.org/D51068



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


[PATCH] D51068: [Android] Default to -fno-math-errno

2018-08-22 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL340424: [Android] Default to -fno-math-errno (authored by 
pirama, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D51068

Files:
  cfe/trunk/lib/Driver/ToolChains/Linux.cpp
  cfe/trunk/lib/Driver/ToolChains/Linux.h
  cfe/trunk/test/Driver/fast-math.c


Index: cfe/trunk/test/Driver/fast-math.c
===
--- cfe/trunk/test/Driver/fast-math.c
+++ cfe/trunk/test/Driver/fast-math.c
@@ -95,6 +95,8 @@
 // RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
 // RUN: %clang -### -target x86_64-fuchsia -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
+// RUN: %clang -### -target x86_64-linux-android -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
 //
 // Check that -ffast-math disables -fmath-errno, and -fno-fast-math merely
 // preserves the target default. Also check various flag set operations between
Index: cfe/trunk/lib/Driver/ToolChains/Linux.h
===
--- cfe/trunk/lib/Driver/ToolChains/Linux.h
+++ cfe/trunk/lib/Driver/ToolChains/Linux.h
@@ -38,6 +38,7 @@
   void AddIAMCUIncludeArgs(const llvm::opt::ArgList ,
llvm::opt::ArgStringList ) const override;
   bool isPIEDefault() const override;
+  bool IsMathErrnoDefault() const override;
   SanitizerMask getSupportedSanitizers() const override;
   void addProfileRTLibs(const llvm::opt::ArgList ,
 llvm::opt::ArgStringList ) const override;
Index: cfe/trunk/lib/Driver/ToolChains/Linux.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Linux.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Linux.cpp
@@ -907,6 +907,12 @@
   getTriple().isMusl() || getSanitizerArgs().requiresPIE();
 }
 
+bool Linux::IsMathErrnoDefault() const {
+  if (getTriple().isAndroid())
+return false;
+  return Generic_ELF::IsMathErrnoDefault();
+}
+
 SanitizerMask Linux::getSupportedSanitizers() const {
   const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;
   const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;


Index: cfe/trunk/test/Driver/fast-math.c
===
--- cfe/trunk/test/Driver/fast-math.c
+++ cfe/trunk/test/Driver/fast-math.c
@@ -95,6 +95,8 @@
 // RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
 // RUN: %clang -### -target x86_64-fuchsia -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
+// RUN: %clang -### -target x86_64-linux-android -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
 //
 // Check that -ffast-math disables -fmath-errno, and -fno-fast-math merely
 // preserves the target default. Also check various flag set operations between
Index: cfe/trunk/lib/Driver/ToolChains/Linux.h
===
--- cfe/trunk/lib/Driver/ToolChains/Linux.h
+++ cfe/trunk/lib/Driver/ToolChains/Linux.h
@@ -38,6 +38,7 @@
   void AddIAMCUIncludeArgs(const llvm::opt::ArgList ,
llvm::opt::ArgStringList ) const override;
   bool isPIEDefault() const override;
+  bool IsMathErrnoDefault() const override;
   SanitizerMask getSupportedSanitizers() const override;
   void addProfileRTLibs(const llvm::opt::ArgList ,
 llvm::opt::ArgStringList ) const override;
Index: cfe/trunk/lib/Driver/ToolChains/Linux.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Linux.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Linux.cpp
@@ -907,6 +907,12 @@
   getTriple().isMusl() || getSanitizerArgs().requiresPIE();
 }
 
+bool Linux::IsMathErrnoDefault() const {
+  if (getTriple().isAndroid())
+return false;
+  return Generic_ELF::IsMathErrnoDefault();
+}
+
 SanitizerMask Linux::getSupportedSanitizers() const {
   const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;
   const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D48743: Make pthread's __libcpp_get_tls declaration consistent

2018-07-20 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a comment.

Ping...


Repository:
  rCXX libc++

https://reviews.llvm.org/D48743



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


[PATCH] D48742: Set _LIBCPP_TLS_DESTRUCTOR_CC convention to run_dtors

2018-07-20 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a comment.

Ping...


Repository:
  rCXXA libc++abi

https://reviews.llvm.org/D48742



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


[PATCH] D44852: [CodeGen] Mark fma as const for Android

2018-03-26 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL328552: [CodeGen] Mark fma as const for Android (authored by 
pirama, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D44852

Files:
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/CodeGen/math-builtins.c


Index: cfe/trunk/test/CodeGen/math-builtins.c
===
--- cfe/trunk/test/CodeGen/math-builtins.c
+++ cfe/trunk/test/CodeGen/math-builtins.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm
  %s | FileCheck %s -check-prefix=NO__ERRNO
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm 
-fmath-errno %s | FileCheck %s -check-prefix=HAS_ERRNO
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown-gnu -w -S -o - -emit-llvm 
-fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_GNU
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown-android -w -S -o - 
-emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_ANDROID
 // RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -w -S -o - -emit-llvm 
-fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_WIN
 
 // Test attributes and codegen of math builtins.
@@ -296,6 +297,10 @@
 // HAS_ERRNO_GNU: declare float @llvm.fma.f32(float, float, float) 
[[READNONE_INTRINSIC]]
 // HAS_ERRNO_GNU: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) 
[[READNONE_INTRINSIC]]
 
+// HAS_ERRNO_ANDROID: declare double @llvm.fma.f64(double, double, double) 
[[READNONE_INTRINSIC:#[0-9]+]]
+// HAS_ERRNO_ANDROID: declare float @llvm.fma.f32(float, float, float) 
[[READNONE_INTRINSIC]]
+// HAS_ERRNO_ANDROID: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, 
x86_fp80) [[READNONE_INTRINSIC]]
+
 // HAS_ERRNO_WIN: declare double @llvm.fma.f64(double, double, double) 
[[READNONE_INTRINSIC:#[0-9]+]]
 // HAS_ERRNO_WIN: declare float @llvm.fma.f32(float, float, float) 
[[READNONE_INTRINSIC]]
 // Long double is just double on win, so no f80 use/declaration.
@@ -582,5 +587,6 @@
 // HAS_ERRNO: attributes [[READNONE]] = { {{.*}}readnone{{.*}} }
 
 // HAS_ERRNO_GNU: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} }
+// HAS_ERRNO_ANDROID: attributes [[READNONE_INTRINSIC]] = { 
{{.*}}readnone{{.*}} }
 // HAS_ERRNO_WIN: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} }
 
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -13116,11 +13116,11 @@
 Context.BuiltinInfo.isConstWithoutErrno(BuiltinID))
   FD->addAttr(ConstAttr::CreateImplicit(Context, FD->getLocation()));
 
-// We make "fma" on GNU or Windows const because we know it does not set
+// We make "fma" on some platforms const because we know it does not set
 // errno in those environments even though it could set errno based on the
 // C standard.
 const llvm::Triple  = Context.getTargetInfo().getTriple();
-if ((Trip.isGNUEnvironment() || Trip.isOSMSVCRT()) &&
+if ((Trip.isGNUEnvironment() || Trip.isAndroid() || Trip.isOSMSVCRT()) &&
 !FD->hasAttr()) {
   switch (BuiltinID) {
   case Builtin::BI__builtin_fma:


Index: cfe/trunk/test/CodeGen/math-builtins.c
===
--- cfe/trunk/test/CodeGen/math-builtins.c
+++ cfe/trunk/test/CodeGen/math-builtins.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm  %s | FileCheck %s -check-prefix=NO__ERRNO
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s -check-prefix=HAS_ERRNO
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown-gnu -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_GNU
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown-android -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_ANDROID
 // RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_WIN
 
 // Test attributes and codegen of math builtins.
@@ -296,6 +297,10 @@
 // HAS_ERRNO_GNU: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]]
 // HAS_ERRNO_GNU: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
 
+// HAS_ERRNO_ANDROID: declare double @llvm.fma.f64(double, double, double) [[READNONE_INTRINSIC:#[0-9]+]]
+// HAS_ERRNO_ANDROID: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]]
+// HAS_ERRNO_ANDROID: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
+
 // HAS_ERRNO_WIN: declare double @llvm.fma.f64(double, double, double) [[READNONE_INTRINSIC:#[0-9]+]]
 // HAS_ERRNO_WIN: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]]
 // Long double is just double on 

[PATCH] D44852: [CodeGen] Mark fma as const for Android

2018-03-26 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a comment.

Thanks for the reviews!


Repository:
  rL LLVM

https://reviews.llvm.org/D44852



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


[PATCH] D44852: [CodeGen] Mark fma as const for Android

2018-03-26 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 139798.
pirama added a comment.

Fix comment.


Repository:
  rC Clang

https://reviews.llvm.org/D44852

Files:
  lib/Sema/SemaDecl.cpp
  test/CodeGen/math-builtins.c


Index: test/CodeGen/math-builtins.c
===
--- test/CodeGen/math-builtins.c
+++ test/CodeGen/math-builtins.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm
  %s | FileCheck %s -check-prefix=NO__ERRNO
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm 
-fmath-errno %s | FileCheck %s -check-prefix=HAS_ERRNO
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown-gnu -w -S -o - -emit-llvm 
-fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_GNU
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown-android -w -S -o - 
-emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_ANDROID
 // RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -w -S -o - -emit-llvm 
-fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_WIN
 
 // Test attributes and codegen of math builtins.
@@ -296,6 +297,10 @@
 // HAS_ERRNO_GNU: declare float @llvm.fma.f32(float, float, float) 
[[READNONE_INTRINSIC]]
 // HAS_ERRNO_GNU: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) 
[[READNONE_INTRINSIC]]
 
+// HAS_ERRNO_ANDROID: declare double @llvm.fma.f64(double, double, double) 
[[READNONE_INTRINSIC:#[0-9]+]]
+// HAS_ERRNO_ANDROID: declare float @llvm.fma.f32(float, float, float) 
[[READNONE_INTRINSIC]]
+// HAS_ERRNO_ANDROID: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, 
x86_fp80) [[READNONE_INTRINSIC]]
+
 // HAS_ERRNO_WIN: declare double @llvm.fma.f64(double, double, double) 
[[READNONE_INTRINSIC:#[0-9]+]]
 // HAS_ERRNO_WIN: declare float @llvm.fma.f32(float, float, float) 
[[READNONE_INTRINSIC]]
 // Long double is just double on win, so no f80 use/declaration.
@@ -582,5 +587,6 @@
 // HAS_ERRNO: attributes [[READNONE]] = { {{.*}}readnone{{.*}} }
 
 // HAS_ERRNO_GNU: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} }
+// HAS_ERRNO_ANDROID: attributes [[READNONE_INTRINSIC]] = { 
{{.*}}readnone{{.*}} }
 // HAS_ERRNO_WIN: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} }
 
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -13105,11 +13105,11 @@
 Context.BuiltinInfo.isConstWithoutErrno(BuiltinID))
   FD->addAttr(ConstAttr::CreateImplicit(Context, FD->getLocation()));
 
-// We make "fma" on GNU or Windows const because we know it does not set
+// We make "fma" on some platforms const because we know it does not set
 // errno in those environments even though it could set errno based on the
 // C standard.
 const llvm::Triple  = Context.getTargetInfo().getTriple();
-if ((Trip.isGNUEnvironment() || Trip.isOSMSVCRT()) &&
+if ((Trip.isGNUEnvironment() || Trip.isAndroid() || Trip.isOSMSVCRT()) &&
 !FD->hasAttr()) {
   switch (BuiltinID) {
   case Builtin::BI__builtin_fma:


Index: test/CodeGen/math-builtins.c
===
--- test/CodeGen/math-builtins.c
+++ test/CodeGen/math-builtins.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm  %s | FileCheck %s -check-prefix=NO__ERRNO
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s -check-prefix=HAS_ERRNO
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown-gnu -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_GNU
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown-android -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_ANDROID
 // RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_WIN
 
 // Test attributes and codegen of math builtins.
@@ -296,6 +297,10 @@
 // HAS_ERRNO_GNU: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]]
 // HAS_ERRNO_GNU: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
 
+// HAS_ERRNO_ANDROID: declare double @llvm.fma.f64(double, double, double) [[READNONE_INTRINSIC:#[0-9]+]]
+// HAS_ERRNO_ANDROID: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]]
+// HAS_ERRNO_ANDROID: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
+
 // HAS_ERRNO_WIN: declare double @llvm.fma.f64(double, double, double) [[READNONE_INTRINSIC:#[0-9]+]]
 // HAS_ERRNO_WIN: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]]
 // Long double is just double on win, so no f80 use/declaration.
@@ -582,5 +587,6 @@
 // HAS_ERRNO: attributes [[READNONE]] = { {{.*}}readnone{{.*}} }
 
 // HAS_ERRNO_GNU: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} }
+// 

[PATCH] D45145: [Driver] Wire up the -f[no-]rtlib-add-rpath flag and tests

2018-04-02 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a comment.

Hi Petr, thanks for the fix (I dropped the ball on this one :( ).  Instead of 
duplicating the checks, does it make sense to fold check into 
addArchSpecificRPath and rename it to 'addArchSpecificRPathIfRequested' or 
something similar?


Repository:
  rC Clang

https://reviews.llvm.org/D45145



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


[PATCH] D44852: [CodeGen] Mark fma as const for Android

2018-03-23 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama created this revision.
pirama added reviewers: spatel, efriedma, srhines, chh, enh.
Herald added a subscriber: cfe-commits.

r318093 sets fma, fmaf, fmal as const for Gnu and MSVC.  Android also
does not set errno for these functions.  So mark these const for
Android.


Repository:
  rC Clang

https://reviews.llvm.org/D44852

Files:
  lib/Sema/SemaDecl.cpp
  test/CodeGen/math-builtins.c


Index: test/CodeGen/math-builtins.c
===
--- test/CodeGen/math-builtins.c
+++ test/CodeGen/math-builtins.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm
  %s | FileCheck %s -check-prefix=NO__ERRNO
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm 
-fmath-errno %s | FileCheck %s -check-prefix=HAS_ERRNO
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown-gnu -w -S -o - -emit-llvm 
-fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_GNU
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown-android -w -S -o - 
-emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_ANDROID
 // RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -w -S -o - -emit-llvm 
-fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_WIN
 
 // Test attributes and codegen of math builtins.
@@ -296,6 +297,10 @@
 // HAS_ERRNO_GNU: declare float @llvm.fma.f32(float, float, float) 
[[READNONE_INTRINSIC]]
 // HAS_ERRNO_GNU: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) 
[[READNONE_INTRINSIC]]
 
+// HAS_ERRNO_ANDROID: declare double @llvm.fma.f64(double, double, double) 
[[READNONE_INTRINSIC:#[0-9]+]]
+// HAS_ERRNO_ANDROID: declare float @llvm.fma.f32(float, float, float) 
[[READNONE_INTRINSIC]]
+// HAS_ERRNO_ANDROID: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, 
x86_fp80) [[READNONE_INTRINSIC]]
+
 // HAS_ERRNO_WIN: declare double @llvm.fma.f64(double, double, double) 
[[READNONE_INTRINSIC:#[0-9]+]]
 // HAS_ERRNO_WIN: declare float @llvm.fma.f32(float, float, float) 
[[READNONE_INTRINSIC]]
 // Long double is just double on win, so no f80 use/declaration.
@@ -582,5 +587,6 @@
 // HAS_ERRNO: attributes [[READNONE]] = { {{.*}}readnone{{.*}} }
 
 // HAS_ERRNO_GNU: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} }
+// HAS_ERRNO_ANDROID: attributes [[READNONE_INTRINSIC]] = { 
{{.*}}readnone{{.*}} }
 // HAS_ERRNO_WIN: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} }
 
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -13109,7 +13109,7 @@
 // errno in those environments even though it could set errno based on the
 // C standard.
 const llvm::Triple  = Context.getTargetInfo().getTriple();
-if ((Trip.isGNUEnvironment() || Trip.isOSMSVCRT()) &&
+if ((Trip.isGNUEnvironment() || Trip.isAndroid() || Trip.isOSMSVCRT()) &&
 !FD->hasAttr()) {
   switch (BuiltinID) {
   case Builtin::BI__builtin_fma:


Index: test/CodeGen/math-builtins.c
===
--- test/CodeGen/math-builtins.c
+++ test/CodeGen/math-builtins.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm  %s | FileCheck %s -check-prefix=NO__ERRNO
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s -check-prefix=HAS_ERRNO
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown-gnu -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_GNU
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown-android -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_ANDROID
 // RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_WIN
 
 // Test attributes and codegen of math builtins.
@@ -296,6 +297,10 @@
 // HAS_ERRNO_GNU: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]]
 // HAS_ERRNO_GNU: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
 
+// HAS_ERRNO_ANDROID: declare double @llvm.fma.f64(double, double, double) [[READNONE_INTRINSIC:#[0-9]+]]
+// HAS_ERRNO_ANDROID: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]]
+// HAS_ERRNO_ANDROID: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
+
 // HAS_ERRNO_WIN: declare double @llvm.fma.f64(double, double, double) [[READNONE_INTRINSIC:#[0-9]+]]
 // HAS_ERRNO_WIN: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]]
 // Long double is just double on win, so no f80 use/declaration.
@@ -582,5 +587,6 @@
 // HAS_ERRNO: attributes [[READNONE]] = { {{.*}}readnone{{.*}} }
 
 // HAS_ERRNO_GNU: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} }
+// HAS_ERRNO_ANDROID: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} }
 // HAS_ERRNO_WIN: 

[PATCH] D37302: [Headers] Define *_HAS_SUBNORM for FLT, DBL, LDBL

2018-03-23 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 139667.
pirama added a comment.

- [CodeGen] Mark fma as const for Android


Repository:
  rC Clang

https://reviews.llvm.org/D37302

Files:
  lib/Headers/float.h
  lib/Sema/SemaDecl.cpp
  test/CodeGen/math-builtins.c
  test/Headers/float.c

Index: test/Headers/float.c
===
--- test/Headers/float.c
+++ test/Headers/float.c
@@ -61,6 +61,21 @@
 #if ((FLT_DECIMAL_DIG > DBL_DECIMAL_DIG) || (DBL_DECIMAL_DIG > LDBL_DECIMAL_DIG))
 #error "Mandatory macros {FLT,DBL,LDBL}_DECIMAL_DIG are invalid."
 #endif
+#ifndef FLT_HAS_SUBNORM
+#error "Mandatory macro FLT_HAS_SUBNORM is missing."
+#elif FLT_HAS_SUBNORM != __FLT_HAS_DENORM__
+#error "Mandatory macro FLT_HAS_SUBNORM is invalid."
+#endif
+#ifndef LDBL_HAS_SUBNORM
+#error "Mandatory macro LDBL_HAS_SUBNORM is missing."
+#elif LDBL_HAS_SUBNORM != __LDBL_HAS_DENORM__
+#error "Mandatory macro LDBL_HAS_SUBNORM is invalid."
+#endif
+#ifndef DBL_HAS_SUBNORM
+#error "Mandatory macro DBL_HAS_SUBNORM is missing."
+#elif DBL_HAS_SUBNORM != __DBL_HAS_DENORM__
+#error "Mandatory macro DBL_HAS_SUBNORM is invalid."
+#endif
 #else
 #ifdef FLT_DECIMAL_DIG
 #error "Macro FLT_DECIMAL_DIG should not be defined."
@@ -71,6 +86,15 @@
 #ifdef LDBL_DECIMAL_DIG
 #error "Macro LDBL_DECIMAL_DIG should not be defined."
 #endif
+#ifdef FLT_HAS_SUBNORM
+#error "Macro FLT_HAS_SUBNORM should not be defined."
+#endif
+#ifdef DBL_HAS_SUBNORM
+#error "Macro DBL_HAS_SUBNORM should not be defined."
+#endif
+#ifdef LDBL_HAS_SUBNORM
+#error "Macro LDBL_HAS_SUBNORM should not be defined."
+#endif
 #endif
 
 
Index: test/CodeGen/math-builtins.c
===
--- test/CodeGen/math-builtins.c
+++ test/CodeGen/math-builtins.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm  %s | FileCheck %s -check-prefix=NO__ERRNO
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s -check-prefix=HAS_ERRNO
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown-gnu -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_GNU
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown-android -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_ANDROID
 // RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_WIN
 
 // Test attributes and codegen of math builtins.
@@ -296,6 +297,10 @@
 // HAS_ERRNO_GNU: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]]
 // HAS_ERRNO_GNU: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
 
+// HAS_ERRNO_ANDROID: declare double @llvm.fma.f64(double, double, double) [[READNONE_INTRINSIC:#[0-9]+]]
+// HAS_ERRNO_ANDROID: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]]
+// HAS_ERRNO_ANDROID: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
+
 // HAS_ERRNO_WIN: declare double @llvm.fma.f64(double, double, double) [[READNONE_INTRINSIC:#[0-9]+]]
 // HAS_ERRNO_WIN: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]]
 // Long double is just double on win, so no f80 use/declaration.
@@ -582,5 +587,6 @@
 // HAS_ERRNO: attributes [[READNONE]] = { {{.*}}readnone{{.*}} }
 
 // HAS_ERRNO_GNU: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} }
+// HAS_ERRNO_ANDROID: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} }
 // HAS_ERRNO_WIN: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} }
 
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -13109,7 +13109,7 @@
 // errno in those environments even though it could set errno based on the
 // C standard.
 const llvm::Triple  = Context.getTargetInfo().getTriple();
-if ((Trip.isGNUEnvironment() || Trip.isOSMSVCRT()) &&
+if ((Trip.isGNUEnvironment() || Trip.isAndroid() || Trip.isOSMSVCRT()) &&
 !FD->hasAttr()) {
   switch (BuiltinID) {
   case Builtin::BI__builtin_fma:
Index: lib/Headers/float.h
===
--- lib/Headers/float.h
+++ lib/Headers/float.h
@@ -85,6 +85,9 @@
 #undef FLT_DECIMAL_DIG
 #undef DBL_DECIMAL_DIG
 #undef LDBL_DECIMAL_DIG
+#undef FLT_HAS_SUBNORM
+#undef DBL_HAS_SUBNORM
+#undef LDBL_HAS_SUBNORM
 #  endif
 #endif
 
@@ -141,6 +144,9 @@
 #  define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
 #  define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
 #  define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
+#  define FLT_HAS_SUBNORM __FLT_HAS_DENORM__
+#  define 

[PATCH] D37302: [Headers] Define *_HAS_SUBNORM for FLT, DBL, LDBL

2018-03-23 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 139670.
pirama added a comment.

Remove unexpected change from another patch.


Repository:
  rC Clang

https://reviews.llvm.org/D37302

Files:
  lib/Headers/float.h
  test/Headers/float.c


Index: test/Headers/float.c
===
--- test/Headers/float.c
+++ test/Headers/float.c
@@ -61,6 +61,21 @@
 #if ((FLT_DECIMAL_DIG > DBL_DECIMAL_DIG) || (DBL_DECIMAL_DIG > 
LDBL_DECIMAL_DIG))
 #error "Mandatory macros {FLT,DBL,LDBL}_DECIMAL_DIG are invalid."
 #endif
+#ifndef FLT_HAS_SUBNORM
+#error "Mandatory macro FLT_HAS_SUBNORM is missing."
+#elif FLT_HAS_SUBNORM != __FLT_HAS_DENORM__
+#error "Mandatory macro FLT_HAS_SUBNORM is invalid."
+#endif
+#ifndef LDBL_HAS_SUBNORM
+#error "Mandatory macro LDBL_HAS_SUBNORM is missing."
+#elif LDBL_HAS_SUBNORM != __LDBL_HAS_DENORM__
+#error "Mandatory macro LDBL_HAS_SUBNORM is invalid."
+#endif
+#ifndef DBL_HAS_SUBNORM
+#error "Mandatory macro DBL_HAS_SUBNORM is missing."
+#elif DBL_HAS_SUBNORM != __DBL_HAS_DENORM__
+#error "Mandatory macro DBL_HAS_SUBNORM is invalid."
+#endif
 #else
 #ifdef FLT_DECIMAL_DIG
 #error "Macro FLT_DECIMAL_DIG should not be defined."
@@ -71,6 +86,15 @@
 #ifdef LDBL_DECIMAL_DIG
 #error "Macro LDBL_DECIMAL_DIG should not be defined."
 #endif
+#ifdef FLT_HAS_SUBNORM
+#error "Macro FLT_HAS_SUBNORM should not be defined."
+#endif
+#ifdef DBL_HAS_SUBNORM
+#error "Macro DBL_HAS_SUBNORM should not be defined."
+#endif
+#ifdef LDBL_HAS_SUBNORM
+#error "Macro LDBL_HAS_SUBNORM should not be defined."
+#endif
 #endif
 
 
Index: lib/Headers/float.h
===
--- lib/Headers/float.h
+++ lib/Headers/float.h
@@ -85,6 +85,9 @@
 #undef FLT_DECIMAL_DIG
 #undef DBL_DECIMAL_DIG
 #undef LDBL_DECIMAL_DIG
+#undef FLT_HAS_SUBNORM
+#undef DBL_HAS_SUBNORM
+#undef LDBL_HAS_SUBNORM
 #  endif
 #endif
 
@@ -141,6 +144,9 @@
 #  define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
 #  define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
 #  define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
+#  define FLT_HAS_SUBNORM __FLT_HAS_DENORM__
+#  define DBL_HAS_SUBNORM __DBL_HAS_DENORM__
+#  define LDBL_HAS_SUBNORM __LDBL_HAS_DENORM__
 #endif
 
 #ifdef __STDC_WANT_IEC_60559_TYPES_EXT__


Index: test/Headers/float.c
===
--- test/Headers/float.c
+++ test/Headers/float.c
@@ -61,6 +61,21 @@
 #if ((FLT_DECIMAL_DIG > DBL_DECIMAL_DIG) || (DBL_DECIMAL_DIG > LDBL_DECIMAL_DIG))
 #error "Mandatory macros {FLT,DBL,LDBL}_DECIMAL_DIG are invalid."
 #endif
+#ifndef FLT_HAS_SUBNORM
+#error "Mandatory macro FLT_HAS_SUBNORM is missing."
+#elif FLT_HAS_SUBNORM != __FLT_HAS_DENORM__
+#error "Mandatory macro FLT_HAS_SUBNORM is invalid."
+#endif
+#ifndef LDBL_HAS_SUBNORM
+#error "Mandatory macro LDBL_HAS_SUBNORM is missing."
+#elif LDBL_HAS_SUBNORM != __LDBL_HAS_DENORM__
+#error "Mandatory macro LDBL_HAS_SUBNORM is invalid."
+#endif
+#ifndef DBL_HAS_SUBNORM
+#error "Mandatory macro DBL_HAS_SUBNORM is missing."
+#elif DBL_HAS_SUBNORM != __DBL_HAS_DENORM__
+#error "Mandatory macro DBL_HAS_SUBNORM is invalid."
+#endif
 #else
 #ifdef FLT_DECIMAL_DIG
 #error "Macro FLT_DECIMAL_DIG should not be defined."
@@ -71,6 +86,15 @@
 #ifdef LDBL_DECIMAL_DIG
 #error "Macro LDBL_DECIMAL_DIG should not be defined."
 #endif
+#ifdef FLT_HAS_SUBNORM
+#error "Macro FLT_HAS_SUBNORM should not be defined."
+#endif
+#ifdef DBL_HAS_SUBNORM
+#error "Macro DBL_HAS_SUBNORM should not be defined."
+#endif
+#ifdef LDBL_HAS_SUBNORM
+#error "Macro LDBL_HAS_SUBNORM should not be defined."
+#endif
 #endif
 
 
Index: lib/Headers/float.h
===
--- lib/Headers/float.h
+++ lib/Headers/float.h
@@ -85,6 +85,9 @@
 #undef FLT_DECIMAL_DIG
 #undef DBL_DECIMAL_DIG
 #undef LDBL_DECIMAL_DIG
+#undef FLT_HAS_SUBNORM
+#undef DBL_HAS_SUBNORM
+#undef LDBL_HAS_SUBNORM
 #  endif
 #endif
 
@@ -141,6 +144,9 @@
 #  define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
 #  define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
 #  define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
+#  define FLT_HAS_SUBNORM __FLT_HAS_DENORM__
+#  define DBL_HAS_SUBNORM __DBL_HAS_DENORM__
+#  define LDBL_HAS_SUBNORM __LDBL_HAS_DENORM__
 #endif
 
 #ifdef __STDC_WANT_IEC_60559_TYPES_EXT__
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37302: [Headers] Define *_HAS_SUBNORM for FLT, DBL, LDBL

2018-03-23 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 139666.
pirama added a comment.

- [CodeGen] Mark fma as const for Android


Repository:
  rC Clang

https://reviews.llvm.org/D37302

Files:
  lib/Headers/float.h
  lib/Sema/SemaDecl.cpp
  test/CodeGen/math-builtins.c
  test/Headers/float.c

Index: test/Headers/float.c
===
--- test/Headers/float.c
+++ test/Headers/float.c
@@ -61,6 +61,21 @@
 #if ((FLT_DECIMAL_DIG > DBL_DECIMAL_DIG) || (DBL_DECIMAL_DIG > LDBL_DECIMAL_DIG))
 #error "Mandatory macros {FLT,DBL,LDBL}_DECIMAL_DIG are invalid."
 #endif
+#ifndef FLT_HAS_SUBNORM
+#error "Mandatory macro FLT_HAS_SUBNORM is missing."
+#elif FLT_HAS_SUBNORM != __FLT_HAS_DENORM__
+#error "Mandatory macro FLT_HAS_SUBNORM is invalid."
+#endif
+#ifndef LDBL_HAS_SUBNORM
+#error "Mandatory macro LDBL_HAS_SUBNORM is missing."
+#elif LDBL_HAS_SUBNORM != __LDBL_HAS_DENORM__
+#error "Mandatory macro LDBL_HAS_SUBNORM is invalid."
+#endif
+#ifndef DBL_HAS_SUBNORM
+#error "Mandatory macro DBL_HAS_SUBNORM is missing."
+#elif DBL_HAS_SUBNORM != __DBL_HAS_DENORM__
+#error "Mandatory macro DBL_HAS_SUBNORM is invalid."
+#endif
 #else
 #ifdef FLT_DECIMAL_DIG
 #error "Macro FLT_DECIMAL_DIG should not be defined."
@@ -71,6 +86,15 @@
 #ifdef LDBL_DECIMAL_DIG
 #error "Macro LDBL_DECIMAL_DIG should not be defined."
 #endif
+#ifdef FLT_HAS_SUBNORM
+#error "Macro FLT_HAS_SUBNORM should not be defined."
+#endif
+#ifdef DBL_HAS_SUBNORM
+#error "Macro DBL_HAS_SUBNORM should not be defined."
+#endif
+#ifdef LDBL_HAS_SUBNORM
+#error "Macro LDBL_HAS_SUBNORM should not be defined."
+#endif
 #endif
 
 
Index: test/CodeGen/math-builtins.c
===
--- test/CodeGen/math-builtins.c
+++ test/CodeGen/math-builtins.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm  %s | FileCheck %s -check-prefix=NO__ERRNO
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s -check-prefix=HAS_ERRNO
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown-gnu -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_GNU
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown-android -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_ANDROID
 // RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_WIN
 
 // Test attributes and codegen of math builtins.
@@ -296,6 +297,10 @@
 // HAS_ERRNO_GNU: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]]
 // HAS_ERRNO_GNU: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
 
+// HAS_ERRNO_ANDROID: declare double @llvm.fma.f64(double, double, double) [[READNONE_INTRINSIC:#[0-9]+]]
+// HAS_ERRNO_ANDROID: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]]
+// HAS_ERRNO_ANDROID: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
+
 // HAS_ERRNO_WIN: declare double @llvm.fma.f64(double, double, double) [[READNONE_INTRINSIC:#[0-9]+]]
 // HAS_ERRNO_WIN: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]]
 // Long double is just double on win, so no f80 use/declaration.
@@ -582,5 +587,6 @@
 // HAS_ERRNO: attributes [[READNONE]] = { {{.*}}readnone{{.*}} }
 
 // HAS_ERRNO_GNU: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} }
+// HAS_ERRNO_ANDROID: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} }
 // HAS_ERRNO_WIN: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} }
 
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -13109,7 +13109,7 @@
 // errno in those environments even though it could set errno based on the
 // C standard.
 const llvm::Triple  = Context.getTargetInfo().getTriple();
-if ((Trip.isGNUEnvironment() || Trip.isOSMSVCRT()) &&
+if ((Trip.isGNUEnvironment() || Trip.isAndroid() || Trip.isOSMSVCRT()) &&
 !FD->hasAttr()) {
   switch (BuiltinID) {
   case Builtin::BI__builtin_fma:
Index: lib/Headers/float.h
===
--- lib/Headers/float.h
+++ lib/Headers/float.h
@@ -85,6 +85,9 @@
 #undef FLT_DECIMAL_DIG
 #undef DBL_DECIMAL_DIG
 #undef LDBL_DECIMAL_DIG
+#undef FLT_HAS_SUBNORM
+#undef DBL_HAS_SUBNORM
+#undef LDBL_HAS_SUBNORM
 #  endif
 #endif
 
@@ -141,6 +144,9 @@
 #  define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
 #  define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
 #  define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
+#  define FLT_HAS_SUBNORM __FLT_HAS_DENORM__
+#  define 

[PATCH] D48731: Configure ELAST for MinGW

2018-06-28 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama created this revision.
pirama added reviewers: compnerd, srhines, danalbert, mstorsjo.
Herald added subscribers: cfe-commits, ldionne, christof.

Use _LIBCPP_MSVCRT_LIKE while configuring ELAST, so MinGW gets the same
configuration as MSVC.


Repository:
  rCXX libc++

https://reviews.llvm.org/D48731

Files:
  src/include/config_elast.h


Index: src/include/config_elast.h
===
--- src/include/config_elast.h
+++ src/include/config_elast.h
@@ -12,7 +12,7 @@
 
 #include <__config>
 
-#if defined(_LIBCPP_MSVCRT)
+#if defined(_LIBCPP_MSVCRT_LIKE)
 #include 
 #else
 #include 
@@ -30,7 +30,7 @@
 // No _LIBCPP_ELAST needed on Apple
 #elif defined(__sun__)
 #define _LIBCPP_ELAST ESTALE
-#elif defined(_LIBCPP_MSVCRT)
+#elif defined(_LIBCPP_MSVCRT_LIKE)
 #define _LIBCPP_ELAST (_sys_nerr - 1)
 #else
 // Warn here so that the person doing the libcxx port has an easier time:


Index: src/include/config_elast.h
===
--- src/include/config_elast.h
+++ src/include/config_elast.h
@@ -12,7 +12,7 @@
 
 #include <__config>
 
-#if defined(_LIBCPP_MSVCRT)
+#if defined(_LIBCPP_MSVCRT_LIKE)
 #include 
 #else
 #include 
@@ -30,7 +30,7 @@
 // No _LIBCPP_ELAST needed on Apple
 #elif defined(__sun__)
 #define _LIBCPP_ELAST ESTALE
-#elif defined(_LIBCPP_MSVCRT)
+#elif defined(_LIBCPP_MSVCRT_LIKE)
 #define _LIBCPP_ELAST (_sys_nerr - 1)
 #else
 // Warn here so that the person doing the libcxx port has an easier time:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D48749: [Win32] Overload ==, != for locale_t and long long

2018-06-28 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama created this revision.
pirama added reviewers: mstorsjo, EricWF, srhines, danalbert.
Herald added subscribers: ldionne, christof.

_is_chartype_l (needed for isxdigit_l) in MinGW compares locale_t and NULL.
NULL is 'long long' for 64-bit, and this results in ambiguous overloads when
compiled with Clang.  Define a concrete overload for the operators to fix the
ambiguity.


Repository:
  rCXX libc++

https://reviews.llvm.org/D48749

Files:
  include/support/win32/locale_win32.h


Index: include/support/win32/locale_win32.h
===
--- include/support/win32/locale_win32.h
+++ include/support/win32/locale_win32.h
@@ -46,6 +46,10 @@
 return __left.__locale == nullptr && __right == 0;
 }
 
+friend bool operator==(const locale_t& __left, long long __right) {
+return __left.__locale == nullptr && __right == 0;
+}
+
 friend bool operator==(const locale_t& __left, std::nullptr_t) {
 return __left.__locale == nullptr;
 }
@@ -66,6 +70,10 @@
 return !(__left == __right);
 }
 
+friend bool operator!=(const locale_t& __left, long long __right) {
+return !(__left == __right);
+}
+
 friend bool operator!=(const locale_t& __left, std::nullptr_t __right) {
 return !(__left == __right);
 }


Index: include/support/win32/locale_win32.h
===
--- include/support/win32/locale_win32.h
+++ include/support/win32/locale_win32.h
@@ -46,6 +46,10 @@
 return __left.__locale == nullptr && __right == 0;
 }
 
+friend bool operator==(const locale_t& __left, long long __right) {
+return __left.__locale == nullptr && __right == 0;
+}
+
 friend bool operator==(const locale_t& __left, std::nullptr_t) {
 return __left.__locale == nullptr;
 }
@@ -66,6 +70,10 @@
 return !(__left == __right);
 }
 
+friend bool operator!=(const locale_t& __left, long long __right) {
+return !(__left == __right);
+}
+
 friend bool operator!=(const locale_t& __left, std::nullptr_t __right) {
 return !(__left == __right);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D48742: Set _LIBCPP_TLS_DESTRUCTOR_CC convention to run_dtors

2018-06-28 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama created this revision.
pirama added reviewers: EricWF, srhines, danalbert.
Herald added subscribers: ldionne, christof.

This function is passed as the __at_exit parameter to
__libcpp_tls_create.  This parameter is marked with the
_LIBCPP_TLS_DESTRUCTOR_CC attribute.  The macro is empty for pthread,
and set to __stdcall for other threading models.  __stdcall is in turn
emptry for most cases.  That's likely why this doesn't fail now.

The one exception is Windows on i686 with the Win32 threading API, where
the stdcall calling convention is used.


Repository:
  rCXXA libc++abi

https://reviews.llvm.org/D48742

Files:
  src/cxa_thread_atexit.cpp


Index: src/cxa_thread_atexit.cpp
===
--- src/cxa_thread_atexit.cpp
+++ src/cxa_thread_atexit.cpp
@@ -68,7 +68,7 @@
   // Used to trigger destructors on thread exit; value is ignored
   std::__libcpp_tls_key dtors_key;
 
-  void run_dtors(void*) {
+  void _LIBCPP_TLS_DESTRUCTOR_CC run_dtors(void*) {
 while (auto head = dtors) {
   dtors = head->next;
   head->dtor(head->obj);


Index: src/cxa_thread_atexit.cpp
===
--- src/cxa_thread_atexit.cpp
+++ src/cxa_thread_atexit.cpp
@@ -68,7 +68,7 @@
   // Used to trigger destructors on thread exit; value is ignored
   std::__libcpp_tls_key dtors_key;
 
-  void run_dtors(void*) {
+  void _LIBCPP_TLS_DESTRUCTOR_CC run_dtors(void*) {
 while (auto head = dtors) {
   dtors = head->next;
   head->dtor(head->obj);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D48743: Make pthread's __libcpp_get_tls declaration consistent

2018-06-28 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama created this revision.
pirama added reviewers: EricWF, srhines, danalbert.
Herald added subscribers: ldionne, christof.

Add the _LIBCPP_TLS_DESTRUCTOR_CC attribute to the __at_exit parameter
for the pthread definition of __libcpp_get_tls.  This makes it
consistent with the rest (the non-pthread declaration in
include/__threading_support, and calls in include/thread and
srcsrc/support/win32/thread_win32.cpp).

This has NFC because _LIBCPP_TLS_DESTRUCTOR_CC is empty when pthread is
available.


Repository:
  rCXX libc++

https://reviews.llvm.org/D48743

Files:
  include/__threading_support


Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -376,7 +376,8 @@
 }
 
 // Thread local storage
-int __libcpp_tls_create(__libcpp_tls_key *__key, void (*__at_exit)(void *))
+int __libcpp_tls_create(__libcpp_tls_key *__key,
+void (_LIBCPP_TLS_DESTRUCTOR_CC* __at_exit)(void *))
 {
   return pthread_key_create(__key, __at_exit);
 }


Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -376,7 +376,8 @@
 }
 
 // Thread local storage
-int __libcpp_tls_create(__libcpp_tls_key *__key, void (*__at_exit)(void *))
+int __libcpp_tls_create(__libcpp_tls_key *__key,
+void (_LIBCPP_TLS_DESTRUCTOR_CC* __at_exit)(void *))
 {
   return pthread_key_create(__key, __at_exit);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D48731: Configure ELAST for MinGW

2018-06-28 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCXX335916: Configure ELAST for MinGW (authored by pirama, 
committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D48731?vs=153352=153381#toc

Repository:
  rCXX libc++

https://reviews.llvm.org/D48731

Files:
  src/include/config_elast.h


Index: src/include/config_elast.h
===
--- src/include/config_elast.h
+++ src/include/config_elast.h
@@ -12,7 +12,7 @@
 
 #include <__config>
 
-#if defined(_LIBCPP_MSVCRT)
+#if defined(_LIBCPP_MSVCRT_LIKE)
 #include 
 #else
 #include 
@@ -30,7 +30,7 @@
 // No _LIBCPP_ELAST needed on Apple
 #elif defined(__sun__)
 #define _LIBCPP_ELAST ESTALE
-#elif defined(_LIBCPP_MSVCRT)
+#elif defined(_LIBCPP_MSVCRT_LIKE)
 #define _LIBCPP_ELAST (_sys_nerr - 1)
 #else
 // Warn here so that the person doing the libcxx port has an easier time:


Index: src/include/config_elast.h
===
--- src/include/config_elast.h
+++ src/include/config_elast.h
@@ -12,7 +12,7 @@
 
 #include <__config>
 
-#if defined(_LIBCPP_MSVCRT)
+#if defined(_LIBCPP_MSVCRT_LIKE)
 #include 
 #else
 #include 
@@ -30,7 +30,7 @@
 // No _LIBCPP_ELAST needed on Apple
 #elif defined(__sun__)
 #define _LIBCPP_ELAST ESTALE
-#elif defined(_LIBCPP_MSVCRT)
+#elif defined(_LIBCPP_MSVCRT_LIKE)
 #define _LIBCPP_ELAST (_sys_nerr - 1)
 #else
 // Warn here so that the person doing the libcxx port has an easier time:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53850: Declares __cpu_model as hidden symbol

2018-10-29 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama edited reviewers, added: echristo, craig.topper; removed: pirama.
pirama added subscribers: srhines, pirama, cfe-commits.
pirama added a comment.

Adding reviewers suggested by 'arc cover'.


https://reviews.llvm.org/D53850



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


[PATCH] D48742: Set _LIBCPP_TLS_DESTRUCTOR_CC convention to run_dtors

2018-09-21 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama abandoned this revision.
pirama added a comment.
Herald added subscribers: libcxx-commits, jfb.

This file is not built for WIN32.


Repository:
  rCXXA libc++abi

https://reviews.llvm.org/D48742



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


[PATCH] D52368: [libc++abi] is_strcmp parameter to is_equal is unused for WIN32

2018-09-21 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 166527.
pirama added a comment.

Simplify patch.


Repository:
  rCXXA libc++abi

https://reviews.llvm.org/D52368

Files:
  src/private_typeinfo.cpp


Index: src/private_typeinfo.cpp
===
--- src/private_typeinfo.cpp
+++ src/private_typeinfo.cpp
@@ -64,6 +64,7 @@
 return x == y;
 return strcmp(x->name(), y->name()) == 0;
 #else
+(void) use_strcmp;
 return (x == y) || (strcmp(x->name(), y->name()) == 0);
 #endif
 }


Index: src/private_typeinfo.cpp
===
--- src/private_typeinfo.cpp
+++ src/private_typeinfo.cpp
@@ -64,6 +64,7 @@
 return x == y;
 return strcmp(x->name(), y->name()) == 0;
 #else
+(void) use_strcmp;
 return (x == y) || (strcmp(x->name(), y->name()) == 0);
 #endif
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52368: [libc++abi] is_strcmp parameter to is_equal is unused for WIN32

2018-09-21 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL342764: [libc++abi] is_strcmp parameter to is_equal is 
unused for WIN32 (authored by pirama, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D52368

Files:
  libcxxabi/trunk/src/private_typeinfo.cpp


Index: libcxxabi/trunk/src/private_typeinfo.cpp
===
--- libcxxabi/trunk/src/private_typeinfo.cpp
+++ libcxxabi/trunk/src/private_typeinfo.cpp
@@ -64,6 +64,7 @@
 return x == y;
 return strcmp(x->name(), y->name()) == 0;
 #else
+(void) use_strcmp;
 return (x == y) || (strcmp(x->name(), y->name()) == 0);
 #endif
 }


Index: libcxxabi/trunk/src/private_typeinfo.cpp
===
--- libcxxabi/trunk/src/private_typeinfo.cpp
+++ libcxxabi/trunk/src/private_typeinfo.cpp
@@ -64,6 +64,7 @@
 return x == y;
 return strcmp(x->name(), y->name()) == 0;
 #else
+(void) use_strcmp;
 return (x == y) || (strcmp(x->name(), y->name()) == 0);
 #endif
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52368: [libc++abi] is_strcmp parameter to is_equal is unused for WIN32

2018-09-21 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama created this revision.
pirama added reviewers: EricWF, srhines, mstorsjo.
Herald added subscribers: libcxx-commits, ldionne, christof.

Mark it as unused to avoid -Wunused-parameter.


Repository:
  rCXXA libc++abi

https://reviews.llvm.org/D52368

Files:
  src/private_typeinfo.cpp


Index: src/private_typeinfo.cpp
===
--- src/private_typeinfo.cpp
+++ src/private_typeinfo.cpp
@@ -51,13 +51,17 @@
 // Defining _LIBCXX_DYNAMIC_FALLBACK does not help since can_catch() calls 
 // is_equal() with use_strcmp=false so the string names are not compared.
 
+#define _UNUSED_IN_WIN32
 #ifdef _WIN32
 #include 
+#define _UNUSED_IN_WIN32 __attribute__((unused))
 #endif
 
 static inline
 bool
-is_equal(const std::type_info* x, const std::type_info* y, bool use_strcmp)
+is_equal(const std::type_info* x,
+ const std::type_info* y,
+ _UNUSED_IN_WIN32 bool use_strcmp)
 {
 #ifndef _WIN32
 if (!use_strcmp)


Index: src/private_typeinfo.cpp
===
--- src/private_typeinfo.cpp
+++ src/private_typeinfo.cpp
@@ -51,13 +51,17 @@
 // Defining _LIBCXX_DYNAMIC_FALLBACK does not help since can_catch() calls 
 // is_equal() with use_strcmp=false so the string names are not compared.
 
+#define _UNUSED_IN_WIN32
 #ifdef _WIN32
 #include 
+#define _UNUSED_IN_WIN32 __attribute__((unused))
 #endif
 
 static inline
 bool
-is_equal(const std::type_info* x, const std::type_info* y, bool use_strcmp)
+is_equal(const std::type_info* x,
+ const std::type_info* y,
+ _UNUSED_IN_WIN32 bool use_strcmp)
 {
 #ifndef _WIN32
 if (!use_strcmp)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50359: Add a new library, libclang-cxx

2018-09-12 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a comment.

As I mentioned in the discussion, we decided to carry build rules for the 
proposed library in downstream.  I've updated this to make it more general, and 
will leave it open in case there's more interest to revive it in the future.


Repository:
  rC Clang

https://reviews.llvm.org/D50359



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


[PATCH] D50359: Add a new library, libclang-cxx

2018-09-12 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 165118.
pirama added a comment.
Herald added a subscriber: fedor.sergeev.

Add empty source file to silence CMake warning.
Support more platforms, similar to libLLVM.so


Repository:
  rC Clang

https://reviews.llvm.org/D50359

Files:
  CMakeLists.txt
  tools/CMakeLists.txt
  tools/libclang-cxx/CMakeLists.txt
  tools/libclang-cxx/libclang_cxx.cpp

Index: tools/libclang-cxx/libclang_cxx.cpp
===
--- /dev/null
+++ tools/libclang-cxx/libclang_cxx.cpp
@@ -0,0 +1,8 @@
+//===- libclang_cxx.cpp - libclang_cxx Shared Library ---===//
+//===--===//
+//
+// This file is empty and serves only the purpose of making CMake happy because
+// you can't define a target with no sources.
+//
+//===--===//
+
Index: tools/libclang-cxx/CMakeLists.txt
===
--- /dev/null
+++ tools/libclang-cxx/CMakeLists.txt
@@ -0,0 +1,87 @@
+set(SOURCES
+  libclang_cxx.cpp
+  )
+
+set(LIBS
+  clangBasic
+  clangCodeGen
+  clangDriver
+  clangFrontend
+  clangFrontendTool
+)
+
+if (CLANG_ENABLE_ARCMT)
+  list(APPEND LIBS clangARCMigrate)
+endif ()
+
+if (TARGET clangTidyPlugin)
+  add_definitions(-DCLANG_TOOL_EXTRA_BUILD)
+  list(APPEND LIBS clangTidyPlugin)
+  list(APPEND LIBS clangIncludeFixerPlugin)
+  if(LLVM_ENABLE_MODULES)
+list(APPEND LLVM_COMPILE_FLAGS "-fmodules-ignore-macro=CLANG_TOOL_EXTRA_BUILD")
+  endif()
+endif ()
+
+find_library(DL_LIBRARY_PATH dl)
+if (DL_LIBRARY_PATH)
+  list(APPEND LIBS dl)
+endif()
+
+if( LLVM_ENABLE_PIC )
+  set(ENABLE_SHARED SHARED)
+endif()
+
+if(NOT LLVM_ENABLE_PIC AND NOT WIN32)
+  set(ENABLE_STATIC STATIC)
+endif()
+
+if(WIN32)
+  set(output_name "libclang_cxx")
+else()
+  set(output_name "clang_cxx")
+endif()
+
+if(("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") OR (MINGW) OR (HAIKU)
+OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD")
+OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "OpenBSD")
+OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "Fuchsia")
+OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "DragonFly")
+OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")) # FIXME: It should be "GNU ld for elf"
+  set(LIBS -Wl,--whole-archive ${LIBS} -Wl,--no-whole-archive)
+elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
+  set(LIBS -Wl,-all_load ${LIBS})
+endif()
+
+add_clang_library(libclang_cxx ${ENABLE_SHARED} ${ENABLE_STATIC}
+  OUTPUT_NAME ${output_name}
+  ${SOURCES}
+  LINK_LIBS
+  ${LIBS}
+  )
+
+if(ENABLE_SHARED)
+  if(WIN32)
+set_target_properties(libclang_cxx
+  PROPERTIES
+  VERSION ${LIBCLANG_LIBRARY_VERSION}
+  DEFINE_SYMBOL _CINDEX_LIB_)
+  elseif(APPLE)
+  set(LIBCLANG_CXX_LINK_FLAGS " -Wl,-compatibility_version -Wl,1")
+  set(LIBCLANG_CXX_LINK_FLAGS "${LIBCLANG_CXX_LINK_FLAGS} -Wl,-current_version -Wl,${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}")
+
+set_property(TARGET libclang_cxx APPEND_STRING PROPERTY
+LINK_FLAGS ${LIBCLANG_CXX_LINK_FLAGS})
+  else()
+set_target_properties(libclang_cxx
+  PROPERTIES
+  VERSION ${LIBCLANG_LIBRARY_VERSION}
+  DEFINE_SYMBOL _CINDEX_LIB_)
+# FIXME: _CINDEX_LIB_ affects dllexport/dllimport on Win32.
+if(LLVM_ENABLE_MODULES AND NOT WIN32)
+  target_compile_options(libclang_cxx PRIVATE
+"-fmodules-ignore-macro=_CINDEX_LIB_"
+)
+endif()
+  endif()
+endif()
Index: tools/CMakeLists.txt
===
--- tools/CMakeLists.txt
+++ tools/CMakeLists.txt
@@ -35,3 +35,4 @@
 
 # libclang may require clang-tidy in clang-tools-extra.
 add_clang_subdirectory(libclang)
+add_clang_subdirectory(libclang-cxx)
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -422,7 +422,7 @@
 "Major version number that will be appended to the clang executable name")
 set(LIBCLANG_LIBRARY_VERSION
 "${CLANG_VERSION_MAJOR}" CACHE STRING
-"Major version number that will be appended to the libclang library")
+"Major version number that will be appended to the libclang, libclang_cxx libraries")
 mark_as_advanced(CLANG_EXECUTABLE_VERSION LIBCLANG_LIBRARY_VERSION)
 
 option(CLANG_INCLUDE_TESTS
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55856: [Driver] Also obey -nostdlib++ when rewriting -lstdc++.

2018-12-18 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added inline comments.



Comment at: test/Driver/nostdlibxx.cpp:14
+// RUN: %clangxx -target i686-pc-linux-gnu -### \
+// RUN: -nostdlib++ -stdlib=libc++ -lstdc++%s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-RESERVED-LIB-REWRITE < %t %s

Missing space here?


Repository:
  rC Clang

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

https://reviews.llvm.org/D55856



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


[PATCH] D55856: [Driver] Also obey -nostdlib++ when rewriting -lstdc++.

2018-12-18 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama accepted this revision.
pirama added inline comments.
This revision is now accepted and ready to land.



Comment at: test/Driver/nostdlibxx.cpp:14
+// RUN: %clangxx -target i686-pc-linux-gnu -### \
+// RUN: -nostdlib++ -stdlib=libc++ -lstdc++%s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-RESERVED-LIB-REWRITE < %t %s

pirama wrote:
> Missing space here?
Between -lstdc++ and the %s.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55856



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


[PATCH] D53343: [Driver] Default Android toolchains to noexecstack.

2019-03-27 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama accepted this revision.
pirama added inline comments.
This revision is now accepted and ready to land.
Herald added a project: clang.



Comment at: include/clang/Driver/ToolChain.h:393
 
+  /// Test whether this toolchaind defaults to non-executable stacks.
+  virtual bool isNoExecStackDefault() const;

typo: toolchain


Repository:
  rC Clang

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

https://reviews.llvm.org/D53343



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


[PATCH] D63889: Check possible warnings on global initializers for reachability

2019-07-01 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added inline comments.



Comment at: clang/include/clang/Sema/AnalysisBasedWarnings.h:111
+void emitPossiblyUnreachableDiags(Sema , AnalysisDeclContext ,
+SmallVector PossiblyUnreachableDiags);
+

Fix indentation.



Comment at: clang/lib/Sema/AnalysisBasedWarnings.cpp:2007
+static void flushDiagnostics(Sema ,
+SmallVector PossiblyUnreachableDiags) 
{
+  for (const auto  : PossiblyUnreachableDiags)

Should `PossiblyUnreachableDiags` be const?

Also, fix indentation.



Comment at: clang/lib/Sema/AnalysisBasedWarnings.cpp:2015
+
+  if (!PossiblyUnreachableDiags.empty()) {
+bool analyzed = false;

How about returning early if `PossiblyUnreachableDiags` here is empty?  That'll 
avoid putting the entire logic of this function in the `true` branch.



Comment at: clang/lib/Sema/AnalysisBasedWarnings.cpp:2031
+  CFGReverseBlockReachabilityAnalysis *cra =
+  AC.getCFGReachablityAnalysis();
+  // FIXME: We should be able to assert that block is non-null, but

`getCFGReachablityAnalysis` has a typo.  It's missing an 'i'.  Consider fixing 
this in a separate patch.



Comment at: clang/lib/Sema/AnalysisBasedWarnings.cpp:2051
+
+if (!analyzed)
+  flushDiagnostics(S, PossiblyUnreachableDiags);

Rewrite this as the `else` clause for `if (AC.getCFG())`?  In the current 
structure, it's not immediately clear that `flushDiagnostics` is called iff 
`AC.getCFG()` fails to return a valid CFG.

Upon further reading, this seems to be refactored from another function below 
so it probably makes sense to leave it as-is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63889



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


[PATCH] D67200: Add -static-openmp driver option

2019-09-05 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 218959.
pirama added a comment.
Herald added a subscriber: emaste.

Supported this flag for NetBSD and FreeBSD as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67200

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/NetBSD.cpp
  clang/test/Driver/fopenmp.c

Index: clang/test/Driver/fopenmp.c
===
--- clang/test/Driver/fopenmp.c
+++ clang/test/Driver/fopenmp.c
@@ -31,6 +31,10 @@
 // RUN: %clang -target x86_64-linux-gnu -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-GOMP --check-prefix=CHECK-LD-GOMP-RT
 // RUN: %clang -target x86_64-linux-gnu -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-IOMP5
 //
+// RUN: %clang -target x86_64-linux-gnu -fopenmp=libomp -static-openmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-OMP
+// RUN: %clang -target x86_64-linux-gnu -fopenmp=libgomp -static-openmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-GOMP --check-prefix=CHECK-LD-STATIC-GOMP-RT
+// RUN: %clang -target x86_64-linux-gnu -fopenmp=libiomp5 -static-openmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-IOMP5
+//
 // RUN: %clang -nostdlib -target x86_64-linux-gnu -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-OMP
 // RUN: %clang -nostdlib -target x86_64-linux-gnu -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-GOMP
 // RUN: %clang -nostdlib -target x86_64-linux-gnu -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-IOMP5
@@ -47,6 +51,10 @@
 // RUN: %clang -target x86_64-freebsd -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-GOMP --check-prefix=CHECK-LD-GOMP-NO-RT
 // RUN: %clang -target x86_64-freebsd -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-IOMP5
 //
+// RUN: %clang -target x86_64-freebsd -fopenmp=libomp -static-openmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-OMP
+// RUN: %clang -target x86_64-freebsd -fopenmp=libgomp -static-openmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-GOMP --check-prefix=CHECK-LD-STATIC-GOMP-NO-RT
+// RUN: %clang -target x86_64-freebsd -fopenmp=libiomp5 -static-openmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-IOMP5
+//
 // RUN: %clang -nostdlib -target x86_64-freebsd -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-OMP
 // RUN: %clang -nostdlib -target x86_64-freebsd -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-GOMP
 // RUN: %clang -nostdlib -target x86_64-freebsd -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-IOMP5
@@ -55,6 +63,10 @@
 // RUN: %clang -target x86_64-netbsd -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-GOMP --check-prefix=CHECK-LD-GOMP-NO-RT
 // RUN: %clang -target x86_64-netbsd -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-IOMP5
 //
+// RUN: %clang -target x86_64-netbsd -fopenmp=libomp -static-openmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-OMP
+// RUN: %clang -target x86_64-netbsd -fopenmp=libgomp -static-openmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-GOMP --check-prefix=CHECK-LD-STATIC-GOMP-NO-RT
+// RUN: %clang -target x86_64-netbsd -fopenmp=libiomp5 -static-openmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-IOMP5
+//
 // RUN: %clang -nostdlib -target x86_64-netbsd -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-OMP
 // RUN: %clang -nostdlib -target x86_64-netbsd -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-GOMP
 // RUN: %clang -nostdlib -target x86_64-netbsd -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-IOMP5
@@ -93,6 +105,17 @@
 // CHECK-NO-IOMP5MD: "{{.*}}ld{{(.exe)?}}"
 // CHECK-NO-IOMP5MD-NOT: "-liomp5md"
 //
+// CHECK-LD-STATIC-OMP: "{{.*}}ld{{(.exe)?}}"
+// CHECK-LD-STATIC-OMP: "-Bstatic" "-lomp" "-Bdynamic"
+//
+// CHECK-LD-STATIC-GOMP: "{{.*}}ld{{(.exe)?}}"
+// CHECK-LD-STATIC-GOMP: "-Bstatic" "-lgomp" "-Bdynamic"
+// CHECK-LD-STATIC-GOMP-RT: "-lrt"
+// CHECK-LD-STATIC-NO-GOMP-RT-NOT: "-lrt"
+//
+// CHECK-LD-STATIC-IOMP5: "{{.*}}ld{{(.exe)?}}"
+// CHECK-LD-STATIC-IOMP5: "-Bstatic" "-liomp5" "-Bdynamic"
+//
 // We'd like to check that the default is sane, but until we have the ability
 // to *always* semantically analyze OpenMP without always generating runtime
 // calls (in the event of an unsupported runtime), we don't have a good way to
Index: 

[PATCH] D67200: Add -static-openmp driver option

2019-09-05 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 219004.
pirama added a comment.

Change parameter name.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67200

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/NetBSD.cpp
  clang/test/Driver/fopenmp.c

Index: clang/test/Driver/fopenmp.c
===
--- clang/test/Driver/fopenmp.c
+++ clang/test/Driver/fopenmp.c
@@ -31,6 +31,10 @@
 // RUN: %clang -target x86_64-linux-gnu -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-GOMP --check-prefix=CHECK-LD-GOMP-RT
 // RUN: %clang -target x86_64-linux-gnu -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-IOMP5
 //
+// RUN: %clang -target x86_64-linux-gnu -fopenmp=libomp -static-openmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-OMP
+// RUN: %clang -target x86_64-linux-gnu -fopenmp=libgomp -static-openmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-GOMP --check-prefix=CHECK-LD-STATIC-GOMP-RT
+// RUN: %clang -target x86_64-linux-gnu -fopenmp=libiomp5 -static-openmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-IOMP5
+//
 // RUN: %clang -nostdlib -target x86_64-linux-gnu -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-OMP
 // RUN: %clang -nostdlib -target x86_64-linux-gnu -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-GOMP
 // RUN: %clang -nostdlib -target x86_64-linux-gnu -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-IOMP5
@@ -47,6 +51,10 @@
 // RUN: %clang -target x86_64-freebsd -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-GOMP --check-prefix=CHECK-LD-GOMP-NO-RT
 // RUN: %clang -target x86_64-freebsd -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-IOMP5
 //
+// RUN: %clang -target x86_64-freebsd -fopenmp=libomp -static-openmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-OMP
+// RUN: %clang -target x86_64-freebsd -fopenmp=libgomp -static-openmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-GOMP --check-prefix=CHECK-LD-STATIC-GOMP-NO-RT
+// RUN: %clang -target x86_64-freebsd -fopenmp=libiomp5 -static-openmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-IOMP5
+//
 // RUN: %clang -nostdlib -target x86_64-freebsd -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-OMP
 // RUN: %clang -nostdlib -target x86_64-freebsd -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-GOMP
 // RUN: %clang -nostdlib -target x86_64-freebsd -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-IOMP5
@@ -55,6 +63,10 @@
 // RUN: %clang -target x86_64-netbsd -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-GOMP --check-prefix=CHECK-LD-GOMP-NO-RT
 // RUN: %clang -target x86_64-netbsd -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-IOMP5
 //
+// RUN: %clang -target x86_64-netbsd -fopenmp=libomp -static-openmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-OMP
+// RUN: %clang -target x86_64-netbsd -fopenmp=libgomp -static-openmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-GOMP --check-prefix=CHECK-LD-STATIC-GOMP-NO-RT
+// RUN: %clang -target x86_64-netbsd -fopenmp=libiomp5 -static-openmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-IOMP5
+//
 // RUN: %clang -nostdlib -target x86_64-netbsd -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-OMP
 // RUN: %clang -nostdlib -target x86_64-netbsd -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-GOMP
 // RUN: %clang -nostdlib -target x86_64-netbsd -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-IOMP5
@@ -93,6 +105,17 @@
 // CHECK-NO-IOMP5MD: "{{.*}}ld{{(.exe)?}}"
 // CHECK-NO-IOMP5MD-NOT: "-liomp5md"
 //
+// CHECK-LD-STATIC-OMP: "{{.*}}ld{{(.exe)?}}"
+// CHECK-LD-STATIC-OMP: "-Bstatic" "-lomp" "-Bdynamic"
+//
+// CHECK-LD-STATIC-GOMP: "{{.*}}ld{{(.exe)?}}"
+// CHECK-LD-STATIC-GOMP: "-Bstatic" "-lgomp" "-Bdynamic"
+// CHECK-LD-STATIC-GOMP-RT: "-lrt"
+// CHECK-LD-STATIC-NO-GOMP-RT-NOT: "-lrt"
+//
+// CHECK-LD-STATIC-IOMP5: "{{.*}}ld{{(.exe)?}}"
+// CHECK-LD-STATIC-IOMP5: "-Bstatic" "-liomp5" "-Bdynamic"
+//
 // We'd like to check that the default is sane, but until we have the ability
 // to *always* semantically analyze OpenMP without always generating runtime
 // calls (in the event of an unsupported runtime), we don't have a good way to
Index: clang/lib/Driver/ToolChains/NetBSD.cpp

[PATCH] D53238: [Driver] Add -static= to unify -static-{libgcc,libstdc++}

2019-09-05 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a comment.

Does this regress from existing behavior for unused arguments?  Currently, 
`-static-libstdc++ -nostdlib` issues an unused argument warning for 
`-static-libstdc++`, while AFAICT `-static=c++stdlib -nostdlib` doesn't.

I'm not exactly sure how/where to issue this warning, though.


Repository:
  rC Clang

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

https://reviews.llvm.org/D53238



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


[PATCH] D67200: Add -static-openmp driver option

2019-09-06 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a comment.

In D67200#1660147 , @srhines wrote:

> Looks really nice. I am sure the NDK developers will be happy to see support 
> for static OpenMP. Do you want to add the public NDK github issue link in the 
> commit message?


Done.

In D67200#1660192 , @MaskRay wrote:

> Edit: Added `-static=` in D53238 . If that 
> is accepted, you may consider `-static=openmp`


Thanks Fangrui!  That change would be very helpful and I'll move to 
`-static=openmp` once it lands.  As for this change, I'll wait over the weekend 
and submit it on Monday to allow everyone a chance to look at it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67200



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


[PATCH] D67200: Add -static-openmp driver option

2019-09-06 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 219182.
pirama added a comment.
Herald added a subscriber: ychen.

Mention NDK issue https://github.com/android-ndk/ndk/issues/1028.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67200

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/NetBSD.cpp
  clang/test/Driver/fopenmp.c

Index: clang/test/Driver/fopenmp.c
===
--- clang/test/Driver/fopenmp.c
+++ clang/test/Driver/fopenmp.c
@@ -31,6 +31,10 @@
 // RUN: %clang -target x86_64-linux-gnu -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-GOMP --check-prefix=CHECK-LD-GOMP-RT
 // RUN: %clang -target x86_64-linux-gnu -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-IOMP5
 //
+// RUN: %clang -target x86_64-linux-gnu -fopenmp=libomp -static-openmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-OMP
+// RUN: %clang -target x86_64-linux-gnu -fopenmp=libgomp -static-openmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-GOMP --check-prefix=CHECK-LD-STATIC-GOMP-RT
+// RUN: %clang -target x86_64-linux-gnu -fopenmp=libiomp5 -static-openmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-IOMP5
+//
 // RUN: %clang -nostdlib -target x86_64-linux-gnu -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-OMP
 // RUN: %clang -nostdlib -target x86_64-linux-gnu -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-GOMP
 // RUN: %clang -nostdlib -target x86_64-linux-gnu -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-IOMP5
@@ -47,6 +51,10 @@
 // RUN: %clang -target x86_64-freebsd -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-GOMP --check-prefix=CHECK-LD-GOMP-NO-RT
 // RUN: %clang -target x86_64-freebsd -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-IOMP5
 //
+// RUN: %clang -target x86_64-freebsd -fopenmp=libomp -static-openmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-OMP
+// RUN: %clang -target x86_64-freebsd -fopenmp=libgomp -static-openmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-GOMP --check-prefix=CHECK-LD-STATIC-GOMP-NO-RT
+// RUN: %clang -target x86_64-freebsd -fopenmp=libiomp5 -static-openmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-IOMP5
+//
 // RUN: %clang -nostdlib -target x86_64-freebsd -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-OMP
 // RUN: %clang -nostdlib -target x86_64-freebsd -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-GOMP
 // RUN: %clang -nostdlib -target x86_64-freebsd -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-IOMP5
@@ -55,6 +63,10 @@
 // RUN: %clang -target x86_64-netbsd -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-GOMP --check-prefix=CHECK-LD-GOMP-NO-RT
 // RUN: %clang -target x86_64-netbsd -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-IOMP5
 //
+// RUN: %clang -target x86_64-netbsd -fopenmp=libomp -static-openmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-OMP
+// RUN: %clang -target x86_64-netbsd -fopenmp=libgomp -static-openmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-GOMP --check-prefix=CHECK-LD-STATIC-GOMP-NO-RT
+// RUN: %clang -target x86_64-netbsd -fopenmp=libiomp5 -static-openmp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-STATIC-IOMP5
+//
 // RUN: %clang -nostdlib -target x86_64-netbsd -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-OMP
 // RUN: %clang -nostdlib -target x86_64-netbsd -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-GOMP
 // RUN: %clang -nostdlib -target x86_64-netbsd -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-IOMP5
@@ -93,6 +105,17 @@
 // CHECK-NO-IOMP5MD: "{{.*}}ld{{(.exe)?}}"
 // CHECK-NO-IOMP5MD-NOT: "-liomp5md"
 //
+// CHECK-LD-STATIC-OMP: "{{.*}}ld{{(.exe)?}}"
+// CHECK-LD-STATIC-OMP: "-Bstatic" "-lomp" "-Bdynamic"
+//
+// CHECK-LD-STATIC-GOMP: "{{.*}}ld{{(.exe)?}}"
+// CHECK-LD-STATIC-GOMP: "-Bstatic" "-lgomp" "-Bdynamic"
+// CHECK-LD-STATIC-GOMP-RT: "-lrt"
+// CHECK-LD-STATIC-NO-GOMP-RT-NOT: "-lrt"
+//
+// CHECK-LD-STATIC-IOMP5: "{{.*}}ld{{(.exe)?}}"
+// CHECK-LD-STATIC-IOMP5: "-Bstatic" "-liomp5" "-Bdynamic"
+//
 // We'd like to check that the default is sane, but until we have the ability
 // to *always* semantically analyze OpenMP without always generating runtime
 // calls (in the event of an unsupported runtime), we don't have a good way to
Index: 

[PATCH] D67200: Add -static-openmp driver option

2019-09-06 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a comment.

I'll update this review addressing @Joerg's reply to cfe-commits:

> Needs testing for the -static interaction?

Thanks @srhines for pointing me to it - I'd only subscribed to cfe-dev and not 
cfe-commits so I'd missed it..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67200



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


  1   2   >