[PATCH] D28213: [Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin

2017-02-03 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

In https://reviews.llvm.org/D28213#665967, @dim wrote:

> I don't think FreeBSD has lock-free 64 bit atomic operations on 32-bit x86.  
> IIRC we already had some trouble before with clang emitting libcalls to 
> `__atomic_fetch_add_8` and friends, which then lead to linking errors.
>
> See https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216745, where this is 
> now occurring with boost.


Could you try to figure out what's the cause for that discrepancy? What's the 
value of `__atomic_always_lock_free(sizeof(long long), 0)` for gcc and clang?


Repository:
  rL LLVM

https://reviews.llvm.org/D28213



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


[PATCH] D29304: [cmake] Hint find_package() to prefer LLVM installed alongside clang

2017-01-31 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL293632: [cmake] Hint find_package() to prefer LLVM installed 
alongside clang (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D29304?vs=86339=86421#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29304

Files:
  cfe/trunk/cmake/modules/CMakeLists.txt
  cfe/trunk/cmake/modules/ClangConfig.cmake.in


Index: cfe/trunk/cmake/modules/ClangConfig.cmake.in
===
--- cfe/trunk/cmake/modules/ClangConfig.cmake.in
+++ cfe/trunk/cmake/modules/ClangConfig.cmake.in
@@ -1,9 +1,10 @@
 # This file allows users to call find_package(Clang) and pick up our targets.
 
-find_package(LLVM REQUIRED CONFIG)
-
 @CLANG_CONFIG_CODE@
 
+find_package(LLVM REQUIRED CONFIG
+ HINTS "@CLANG_CONFIG_LLVM_CMAKE_DIR@")
+
 set(CLANG_EXPORTED_TARGETS "@CLANG_EXPORTS@")
 set(CLANG_CMAKE_DIR "@CLANG_CONFIG_CMAKE_DIR@")
 
Index: cfe/trunk/cmake/modules/CMakeLists.txt
===
--- cfe/trunk/cmake/modules/CMakeLists.txt
+++ cfe/trunk/cmake/modules/CMakeLists.txt
@@ -4,17 +4,23 @@
 set(CLANG_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/clang)
 set(clang_cmake_builddir "${CMAKE_BINARY_DIR}/${CLANG_INSTALL_PACKAGE_DIR}")
 
+# Keep this in sync with llvm/cmake/CMakeLists.txt!
+set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm)
+set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
+
 get_property(CLANG_EXPORTS GLOBAL PROPERTY CLANG_EXPORTS)
 export(TARGETS ${CLANG_EXPORTS} FILE 
${clang_cmake_builddir}/ClangTargets.cmake)
 
 # Generate ClangConfig.cmake for the build tree.
 set(CLANG_CONFIG_CMAKE_DIR "${clang_cmake_builddir}")
+set(CLANG_CONFIG_LLVM_CMAKE_DIR "${llvm_cmake_builddir}")
 set(CLANG_CONFIG_EXPORTS_FILE "${clang_cmake_builddir}/ClangTargets.cmake")
 configure_file(
   ${CMAKE_CURRENT_SOURCE_DIR}/ClangConfig.cmake.in
   ${clang_cmake_builddir}/ClangConfig.cmake
   @ONLY)
 set(CLANG_CONFIG_CMAKE_DIR)
+set(CLANG_CONFIG_LLVM_CMAKE_DIR)
 set(CLANG_CONFIG_EXPORTS_FILE)
 
 # Generate ClangConfig.cmake for the install tree.
@@ -29,6 +35,7 @@
 get_filename_component(CLANG_INSTALL_PREFIX \"\${CLANG_INSTALL_PREFIX}\" 
PATH)")
 endforeach(p)
 set(CLANG_CONFIG_CMAKE_DIR 
"\${CLANG_INSTALL_PREFIX}/${CLANG_INSTALL_PACKAGE_DIR}")
+set(CLANG_CONFIG_LLVM_CMAKE_DIR 
"\${CLANG_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}")
 set(CLANG_CONFIG_EXPORTS_FILE "\${CLANG_CMAKE_DIR}/ClangTargets.cmake")
 configure_file(
   ${CMAKE_CURRENT_SOURCE_DIR}/ClangConfig.cmake.in


Index: cfe/trunk/cmake/modules/ClangConfig.cmake.in
===
--- cfe/trunk/cmake/modules/ClangConfig.cmake.in
+++ cfe/trunk/cmake/modules/ClangConfig.cmake.in
@@ -1,9 +1,10 @@
 # This file allows users to call find_package(Clang) and pick up our targets.
 
-find_package(LLVM REQUIRED CONFIG)
-
 @CLANG_CONFIG_CODE@
 
+find_package(LLVM REQUIRED CONFIG
+ HINTS "@CLANG_CONFIG_LLVM_CMAKE_DIR@")
+
 set(CLANG_EXPORTED_TARGETS "@CLANG_EXPORTS@")
 set(CLANG_CMAKE_DIR "@CLANG_CONFIG_CMAKE_DIR@")
 
Index: cfe/trunk/cmake/modules/CMakeLists.txt
===
--- cfe/trunk/cmake/modules/CMakeLists.txt
+++ cfe/trunk/cmake/modules/CMakeLists.txt
@@ -4,17 +4,23 @@
 set(CLANG_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/clang)
 set(clang_cmake_builddir "${CMAKE_BINARY_DIR}/${CLANG_INSTALL_PACKAGE_DIR}")
 
+# Keep this in sync with llvm/cmake/CMakeLists.txt!
+set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm)
+set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
+
 get_property(CLANG_EXPORTS GLOBAL PROPERTY CLANG_EXPORTS)
 export(TARGETS ${CLANG_EXPORTS} FILE ${clang_cmake_builddir}/ClangTargets.cmake)
 
 # Generate ClangConfig.cmake for the build tree.
 set(CLANG_CONFIG_CMAKE_DIR "${clang_cmake_builddir}")
+set(CLANG_CONFIG_LLVM_CMAKE_DIR "${llvm_cmake_builddir}")
 set(CLANG_CONFIG_EXPORTS_FILE "${clang_cmake_builddir}/ClangTargets.cmake")
 configure_file(
   ${CMAKE_CURRENT_SOURCE_DIR}/ClangConfig.cmake.in
   ${clang_cmake_builddir}/ClangConfig.cmake
   @ONLY)
 set(CLANG_CONFIG_CMAKE_DIR)
+set(CLANG_CONFIG_LLVM_CMAKE_DIR)
 set(CLANG_CONFIG_EXPORTS_FILE)
 
 # Generate ClangConfig.cmake for the install tree.
@@ -29,6 +35,7 @@
 get_filename_component(CLANG_INSTALL_PREFIX \"\${CLANG_INSTALL_PREFIX}\" PATH)")
 endforeach(p)
 set(CLANG_CONFIG_CMAKE_DIR "\${CLANG_INSTALL_PREFIX}/${CLANG_INSTALL_PACKAGE_DIR}")
+set(CLANG_CONFIG_LLVM_CMAKE_DIR "\${CLANG_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}")
 set(CLANG_CONFIG_EXPORTS_FILE "\${CLANG_CMAKE_DIR}/ClangTargets.cmake")
 configure_file(
   ${CMAKE_CURRENT_SOURCE_DIR}/ClangConfig.cmake.in
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D29628: [compiler-rt] [test] Enable the strace_test only if strace is installed

2017-02-07 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
Herald added a subscriber: dberris.

Check whether strace is to be found in PATH, and control the strace_test 
appropriately. This fixes a test failure when strace is not installed.


Repository:
  rL LLVM

https://reviews.llvm.org/D29628

Files:
  test/lsan/TestCases/strace_test.cc
  test/lsan/lit.common.cfg


Index: test/lsan/lit.common.cfg
===
--- test/lsan/lit.common.cfg
+++ test/lsan/lit.common.cfg
@@ -4,6 +4,8 @@
 
 import os
 
+import lit.util
+
 def get_required_attr(config, attr_name):
   attr_value = getattr(config, attr_name, None)
   if attr_value == None:
@@ -29,6 +31,9 @@
   lit_config.fatal("Unknown LSan test mode: %r" % lsan_lit_test_mode)
 config.name += config.name_suffix
 
+if lit.util.which('strace'):
+  config.available_features.add('strace')
+
 clang_cflags = ["-O0", config.target_cflags] + config.debug_info_flags
 clang_cxxflags = config.cxx_mode_flags + clang_cflags
 lsan_incdir = config.test_source_root + "/../"
Index: test/lsan/TestCases/strace_test.cc
===
--- test/lsan/TestCases/strace_test.cc
+++ test/lsan/TestCases/strace_test.cc
@@ -1,4 +1,5 @@
 // Test that lsan reports a proper error when running under strace.
+// REQUIRES: strace
 // RUN: %clangxx_lsan %s -o %t
 // RUN: not strace -o /dev/null %run %t 2>&1 | FileCheck %s
 


Index: test/lsan/lit.common.cfg
===
--- test/lsan/lit.common.cfg
+++ test/lsan/lit.common.cfg
@@ -4,6 +4,8 @@
 
 import os
 
+import lit.util
+
 def get_required_attr(config, attr_name):
   attr_value = getattr(config, attr_name, None)
   if attr_value == None:
@@ -29,6 +31,9 @@
   lit_config.fatal("Unknown LSan test mode: %r" % lsan_lit_test_mode)
 config.name += config.name_suffix
 
+if lit.util.which('strace'):
+  config.available_features.add('strace')
+
 clang_cflags = ["-O0", config.target_cflags] + config.debug_info_flags
 clang_cxxflags = config.cxx_mode_flags + clang_cflags
 lsan_incdir = config.test_source_root + "/../"
Index: test/lsan/TestCases/strace_test.cc
===
--- test/lsan/TestCases/strace_test.cc
+++ test/lsan/TestCases/strace_test.cc
@@ -1,4 +1,5 @@
 // Test that lsan reports a proper error when running under strace.
+// REQUIRES: strace
 // RUN: %clangxx_lsan %s -o %t
 // RUN: not strace -o /dev/null %run %t 2>&1 | FileCheck %s
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29542: [TargetInfo] Adjust x86-32 atomic support to the CPU used

2017-02-05 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 87134.
mgorny edited the summary of this revision.
mgorny added a comment.

Ok, this CUDA fix should be reasonable, i think. It simply assumes i586+ (i.e. 
all inline atomics enabled) for CUDA target builds. I seriously doubt it's 
technically possible that anyone will ever use CUDA on https://reviews.llvm.org/D29542

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/atomic-ops.c
  test/CodeGen/ms-volatile.c
  test/CodeGenCXX/atomicinit.cpp
  test/Sema/atomic-ops.c

Index: test/Sema/atomic-ops.c
===
--- test/Sema/atomic-ops.c
+++ test/Sema/atomic-ops.c
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 %s -verify -ffreestanding -fsyntax-only -triple=i686-linux-gnu -std=c11
+// RUN: %clang_cc1 %s -verify -ffreestanding -fsyntax-only -triple=i686-linux-gnu -target-cpu i686 -std=c11
+// RUN: %clang_cc1 %s -verify -ffreestanding -fsyntax-only -triple=i486-linux-gnu -target-cpu i486 -std=c11
 
 // Basic parsing/Sema tests for __c11_atomic_*
 
@@ -14,22 +15,34 @@
 _Static_assert(__GCC_ATOMIC_SHORT_LOCK_FREE == 2, "");
 _Static_assert(__GCC_ATOMIC_INT_LOCK_FREE == 2, "");
 _Static_assert(__GCC_ATOMIC_LONG_LOCK_FREE == 2, "");
+#if defined(__i486__)
+_Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 1, "");
+#else
 _Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 2, "");
+#endif
 _Static_assert(__GCC_ATOMIC_POINTER_LOCK_FREE == 2, "");
 
 _Static_assert(__c11_atomic_is_lock_free(1), "");
 _Static_assert(__c11_atomic_is_lock_free(2), "");
 _Static_assert(__c11_atomic_is_lock_free(3), ""); // expected-error {{not an integral constant expression}}
 _Static_assert(__c11_atomic_is_lock_free(4), "");
+#if defined(__i486__)
+_Static_assert(__c11_atomic_is_lock_free(8), ""); // expected-error {{not an integral constant expression}}
+#else
 _Static_assert(__c11_atomic_is_lock_free(8), "");
+#endif
 _Static_assert(__c11_atomic_is_lock_free(16), ""); // expected-error {{not an integral constant expression}}
 _Static_assert(__c11_atomic_is_lock_free(17), ""); // expected-error {{not an integral constant expression}}
 
 _Static_assert(__atomic_is_lock_free(1, 0), "");
 _Static_assert(__atomic_is_lock_free(2, 0), "");
 _Static_assert(__atomic_is_lock_free(3, 0), ""); // expected-error {{not an integral constant expression}}
 _Static_assert(__atomic_is_lock_free(4, 0), "");
+#if defined(__i486__)
+_Static_assert(__atomic_is_lock_free(8, 0), ""); // expected-error {{not an integral constant expression}}
+#else
 _Static_assert(__atomic_is_lock_free(8, 0), "");
+#endif
 _Static_assert(__atomic_is_lock_free(16, 0), ""); // expected-error {{not an integral constant expression}}
 _Static_assert(__atomic_is_lock_free(17, 0), ""); // expected-error {{not an integral constant expression}}
 
@@ -56,13 +69,21 @@
 _Static_assert(__atomic_is_lock_free(4, ), "");
 _Static_assert(__atomic_is_lock_free(4, ), "");
 _Static_assert(__atomic_is_lock_free(8, ), ""); // expected-error {{not an integral constant expression}}
+#if defined(__i486__)
+_Static_assert(__atomic_is_lock_free(8, ), ""); // expected-error {{not an integral constant expression}}
+#else
 _Static_assert(__atomic_is_lock_free(8, ), "");
+#endif
 
 _Static_assert(__atomic_always_lock_free(1, 0), "");
 _Static_assert(__atomic_always_lock_free(2, 0), "");
 _Static_assert(!__atomic_always_lock_free(3, 0), "");
 _Static_assert(__atomic_always_lock_free(4, 0), "");
+#if defined(__i486__)
+_Static_assert(!__atomic_always_lock_free(8, 0), "");
+#else
 _Static_assert(__atomic_always_lock_free(8, 0), "");
+#endif
 _Static_assert(!__atomic_always_lock_free(16, 0), "");
 _Static_assert(!__atomic_always_lock_free(17, 0), "");
 
@@ -79,7 +100,11 @@
 _Static_assert(__atomic_always_lock_free(4, ), "");
 _Static_assert(__atomic_always_lock_free(4, ), "");
 _Static_assert(!__atomic_always_lock_free(8, ), "");
+#if defined(__i486__)
+_Static_assert(!__atomic_always_lock_free(8, ), "");
+#else
 _Static_assert(__atomic_always_lock_free(8, ), "");
+#endif
 
 #define _AS1 __attribute__((address_space(1)))
 #define _AS2 __attribute__((address_space(2)))
Index: test/CodeGenCXX/atomicinit.cpp
===
--- test/CodeGenCXX/atomicinit.cpp
+++ test/CodeGenCXX/atomicinit.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -emit-llvm -O1 -o - -triple=i686-apple-darwin9 -std=c++11 | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -O1 -o - -triple=i686-apple-darwin9 -target-cpu i686 -std=c++11 | FileCheck %s
 
 // CHECK-DAG: @PR22043 = local_unnamed_addr global i32 0, align 4
 typedef _Atomic(int) AtomicInt;
Index: test/CodeGen/ms-volatile.c
===
--- test/CodeGen/ms-volatile.c
+++ test/CodeGen/ms-volatile.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple i386-pc-win32 -fms-extensions -emit-llvm -fms-volatile -o - < %s | FileCheck %s
+// RUN: %clang_cc1 -triple i386-pc-win32 -target-cpu i686 -fms-extensions -emit-llvm -fms-volatile 

[PATCH] D29542: [TargetInfo] Adjust x86-32 atomic support to the CPU used

2017-02-06 Thread Michał Górny via Phabricator via cfe-commits
mgorny added inline comments.



Comment at: lib/Basic/Targets.cpp:4244
+} else // allow locked atomics up to 4 bytes
+  MaxAtomicPromoteWidth = 32;
+  }

ahatanak wrote:
> mgorny wrote:
> > dim wrote:
> > > Are you purposefully not setting `MaxAtomicInlineWidth` here?  (It seems 
> > > from `TargetInfo` that the default value is zero.)
> > > 
> > Yes. I've based this on what's done for ARM. Unless I misunderstood 
> > something, this means that on 'plain' i386 there is no inline atomics 
> > support but we still want to do atomics-via-locking up to 32-bit types. I'm 
> > not sure about 32/64 here to match i486.
> If there isn't a test case for plain i386, is it possible to add one (perhaps 
> in test/Sema/atomic-ops.c)?
I could do that. However, @joerg suggested dropping i386 branch entirely, and 
assuming i486+.


https://reviews.llvm.org/D29542



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


[PATCH] D29542: [TargetInfo] Adjust x86-32 atomic support to the CPU used

2017-02-06 Thread Michał Górny via Phabricator via cfe-commits
mgorny added inline comments.



Comment at: lib/Basic/Targets.cpp:1808
+if (HostTriple.getArch() == llvm::Triple::x86)
+  HostTarget->setCPU("i586");
+

jlebar wrote:
> mgorny wrote:
> > jlebar wrote:
> > > Okay, is this still needed now?
> > Yes. I've specifically tested with it commented out, and the CPU gets 
> > initiated to generic (=no inline atomics) then.
> Yes, but is that a bug?  Does that break the test?
> 
> I thought the problem we were trying to solve here was that CUDA host and 
> device builds did not define the same macros.  And I thought that setCPU 
> modified the values for MaxAtomicInlineWidth and MaxAtomicPromoteWidth.  
> Moreover I thought that we called HostTarget->setCPU before calling this 
> function.
> 
> If all of those things are true, I don't see what problem we're solving by 
> calling HostTarget->setCPU("i586") here.
Well, the thing is, we don't call `HostTarget->setCPU()` before this function. 
We just call `AllocateTarget()`, and it does not set the CPU.

Normally the CPU is set in Driver, based on `-march` etc. if provided, with 
fallback to platform-specific defaults. In the case of host-side CUDA build, 
the Driver sets x86-specific CPU. While the defaults differ per platform, for 
all platforms supporting CUDA it's i586+.

Now, for the target-side, the Driver creates NVPTX target, and sets 
NVPTX-specific CPU. The `HostTarget` instance is only created within 
`NVPTXTargetInfo`, and so we need to `setCPU()` explicitly. Since we can 
reliably assume that the host-side will be i586+, we use `i586` here.

So far this didn't matter since all atomic properties were defined statically. 
However, this patch changes them to adjust to the CPU used, and so if the 
`X8632TargetInfo` instance is allocated without an explicit `setCPU()` call, it 
defaults to generic x86 (= no inline atomics available) which is different from 
the host platform default. As a result, different macros are defined and the 
test fails.


https://reviews.llvm.org/D29542



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


[PATCH] D29542: [TargetInfo] Adjust x86-32 atomic support to the CPU used

2017-02-06 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

In https://reviews.llvm.org/D29542#667814, @joerg wrote:

> At this point, I don't think there is any use on pretending that 
> i386-as-default makes sense. So I would request that the i386 case should be 
> made explicit or just dropped, with a preference for the latter.


By the former, do you mean making `CK_Generic` imply i486+ or i586+? What about 
line ~3947 where the same conditions are used to control other definitions? 
Should they be changed too?


https://reviews.llvm.org/D29542



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


[PATCH] D29542: [TargetInfo] Adjust x86-32 atomic support to the CPU used

2017-02-06 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 87311.
mgorny added a comment.

Removed the i386 branch. Now the i486+ are used unconditionally.


https://reviews.llvm.org/D29542

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/atomic-ops.c
  test/CodeGen/ms-volatile.c
  test/CodeGenCXX/atomicinit.cpp
  test/Sema/atomic-ops.c

Index: test/Sema/atomic-ops.c
===
--- test/Sema/atomic-ops.c
+++ test/Sema/atomic-ops.c
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 %s -verify -ffreestanding -fsyntax-only -triple=i686-linux-gnu -std=c11
+// RUN: %clang_cc1 %s -verify -ffreestanding -fsyntax-only -triple=i686-linux-gnu -target-cpu i686 -std=c11
+// RUN: %clang_cc1 %s -verify -ffreestanding -fsyntax-only -triple=i486-linux-gnu -target-cpu i486 -std=c11
 
 // Basic parsing/Sema tests for __c11_atomic_*
 
@@ -14,22 +15,34 @@
 _Static_assert(__GCC_ATOMIC_SHORT_LOCK_FREE == 2, "");
 _Static_assert(__GCC_ATOMIC_INT_LOCK_FREE == 2, "");
 _Static_assert(__GCC_ATOMIC_LONG_LOCK_FREE == 2, "");
+#if defined(__i486__)
+_Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 1, "");
+#else
 _Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 2, "");
+#endif
 _Static_assert(__GCC_ATOMIC_POINTER_LOCK_FREE == 2, "");
 
 _Static_assert(__c11_atomic_is_lock_free(1), "");
 _Static_assert(__c11_atomic_is_lock_free(2), "");
 _Static_assert(__c11_atomic_is_lock_free(3), ""); // expected-error {{not an integral constant expression}}
 _Static_assert(__c11_atomic_is_lock_free(4), "");
+#if defined(__i486__)
+_Static_assert(__c11_atomic_is_lock_free(8), ""); // expected-error {{not an integral constant expression}}
+#else
 _Static_assert(__c11_atomic_is_lock_free(8), "");
+#endif
 _Static_assert(__c11_atomic_is_lock_free(16), ""); // expected-error {{not an integral constant expression}}
 _Static_assert(__c11_atomic_is_lock_free(17), ""); // expected-error {{not an integral constant expression}}
 
 _Static_assert(__atomic_is_lock_free(1, 0), "");
 _Static_assert(__atomic_is_lock_free(2, 0), "");
 _Static_assert(__atomic_is_lock_free(3, 0), ""); // expected-error {{not an integral constant expression}}
 _Static_assert(__atomic_is_lock_free(4, 0), "");
+#if defined(__i486__)
+_Static_assert(__atomic_is_lock_free(8, 0), ""); // expected-error {{not an integral constant expression}}
+#else
 _Static_assert(__atomic_is_lock_free(8, 0), "");
+#endif
 _Static_assert(__atomic_is_lock_free(16, 0), ""); // expected-error {{not an integral constant expression}}
 _Static_assert(__atomic_is_lock_free(17, 0), ""); // expected-error {{not an integral constant expression}}
 
@@ -56,13 +69,21 @@
 _Static_assert(__atomic_is_lock_free(4, ), "");
 _Static_assert(__atomic_is_lock_free(4, ), "");
 _Static_assert(__atomic_is_lock_free(8, ), ""); // expected-error {{not an integral constant expression}}
+#if defined(__i486__)
+_Static_assert(__atomic_is_lock_free(8, ), ""); // expected-error {{not an integral constant expression}}
+#else
 _Static_assert(__atomic_is_lock_free(8, ), "");
+#endif
 
 _Static_assert(__atomic_always_lock_free(1, 0), "");
 _Static_assert(__atomic_always_lock_free(2, 0), "");
 _Static_assert(!__atomic_always_lock_free(3, 0), "");
 _Static_assert(__atomic_always_lock_free(4, 0), "");
+#if defined(__i486__)
+_Static_assert(!__atomic_always_lock_free(8, 0), "");
+#else
 _Static_assert(__atomic_always_lock_free(8, 0), "");
+#endif
 _Static_assert(!__atomic_always_lock_free(16, 0), "");
 _Static_assert(!__atomic_always_lock_free(17, 0), "");
 
@@ -79,7 +100,11 @@
 _Static_assert(__atomic_always_lock_free(4, ), "");
 _Static_assert(__atomic_always_lock_free(4, ), "");
 _Static_assert(!__atomic_always_lock_free(8, ), "");
+#if defined(__i486__)
+_Static_assert(!__atomic_always_lock_free(8, ), "");
+#else
 _Static_assert(__atomic_always_lock_free(8, ), "");
+#endif
 
 #define _AS1 __attribute__((address_space(1)))
 #define _AS2 __attribute__((address_space(2)))
Index: test/CodeGenCXX/atomicinit.cpp
===
--- test/CodeGenCXX/atomicinit.cpp
+++ test/CodeGenCXX/atomicinit.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -emit-llvm -O1 -o - -triple=i686-apple-darwin9 -std=c++11 | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -O1 -o - -triple=i686-apple-darwin9 -target-cpu i686 -std=c++11 | FileCheck %s
 
 // CHECK-DAG: @PR22043 = local_unnamed_addr global i32 0, align 4
 typedef _Atomic(int) AtomicInt;
Index: test/CodeGen/ms-volatile.c
===
--- test/CodeGen/ms-volatile.c
+++ test/CodeGen/ms-volatile.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple i386-pc-win32 -fms-extensions -emit-llvm -fms-volatile -o - < %s | FileCheck %s
+// RUN: %clang_cc1 -triple i386-pc-win32 -target-cpu i686 -fms-extensions -emit-llvm -fms-volatile -o - < %s | FileCheck %s
 struct foo {
   volatile int x;
 };
Index: test/CodeGen/atomic-ops.c
===
--- 

[PATCH] D29628: [compiler-rt] [test] Enable the strace_test only if strace is installed

2017-02-08 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL294425: [test] Enable the strace_test only if strace is 
installed (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D29628?vs=87392=87603#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29628

Files:
  compiler-rt/trunk/test/lsan/TestCases/strace_test.cc
  compiler-rt/trunk/test/lsan/lit.common.cfg


Index: compiler-rt/trunk/test/lsan/TestCases/strace_test.cc
===
--- compiler-rt/trunk/test/lsan/TestCases/strace_test.cc
+++ compiler-rt/trunk/test/lsan/TestCases/strace_test.cc
@@ -1,4 +1,5 @@
 // Test that lsan reports a proper error when running under strace.
+// REQUIRES: strace
 // RUN: %clangxx_lsan %s -o %t
 // RUN: not strace -o /dev/null %run %t 2>&1 | FileCheck %s
 
Index: compiler-rt/trunk/test/lsan/lit.common.cfg
===
--- compiler-rt/trunk/test/lsan/lit.common.cfg
+++ compiler-rt/trunk/test/lsan/lit.common.cfg
@@ -4,6 +4,8 @@
 
 import os
 
+import lit.util
+
 def get_required_attr(config, attr_name):
   attr_value = getattr(config, attr_name, None)
   if attr_value == None:
@@ -29,6 +31,9 @@
   lit_config.fatal("Unknown LSan test mode: %r" % lsan_lit_test_mode)
 config.name += config.name_suffix
 
+if lit.util.which('strace'):
+  config.available_features.add('strace')
+
 clang_cflags = ["-O0", config.target_cflags] + config.debug_info_flags
 clang_cxxflags = config.cxx_mode_flags + clang_cflags
 lsan_incdir = config.test_source_root + "/../"


Index: compiler-rt/trunk/test/lsan/TestCases/strace_test.cc
===
--- compiler-rt/trunk/test/lsan/TestCases/strace_test.cc
+++ compiler-rt/trunk/test/lsan/TestCases/strace_test.cc
@@ -1,4 +1,5 @@
 // Test that lsan reports a proper error when running under strace.
+// REQUIRES: strace
 // RUN: %clangxx_lsan %s -o %t
 // RUN: not strace -o /dev/null %run %t 2>&1 | FileCheck %s
 
Index: compiler-rt/trunk/test/lsan/lit.common.cfg
===
--- compiler-rt/trunk/test/lsan/lit.common.cfg
+++ compiler-rt/trunk/test/lsan/lit.common.cfg
@@ -4,6 +4,8 @@
 
 import os
 
+import lit.util
+
 def get_required_attr(config, attr_name):
   attr_value = getattr(config, attr_name, None)
   if attr_value == None:
@@ -29,6 +31,9 @@
   lit_config.fatal("Unknown LSan test mode: %r" % lsan_lit_test_mode)
 config.name += config.name_suffix
 
+if lit.util.which('strace'):
+  config.available_features.add('strace')
+
 clang_cflags = ["-O0", config.target_cflags] + config.debug_info_flags
 clang_cxxflags = config.cxx_mode_flags + clang_cflags
 lsan_incdir = config.test_source_root + "/../"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29706: [libcxx] [test] Fix hard_link_count test to account for fs with dir nlink==1

2017-02-08 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL294431: [test] Fix hard_link_count test to account for fs 
with dir nlink==1 (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D29706?vs=87613=87618#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29706

Files:
  
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.hard_lk_ct/hard_link_count.pass.cpp


Index: 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.hard_lk_ct/hard_link_count.pass.cpp
===
--- 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.hard_lk_ct/hard_link_count.pass.cpp
+++ 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.hard_lk_ct/hard_link_count.pass.cpp
@@ -57,15 +57,19 @@
 Dir3Expect = 3; // .  ..  file5
 #endif
 TEST_CHECK(hard_link_count(StaticEnv::Dir) == DirExpect ||
-   hard_link_count(StaticEnv::Dir) == DirExpectAlt);
+   hard_link_count(StaticEnv::Dir) == DirExpectAlt ||
+   hard_link_count(StaticEnv::Dir) == 1);
 TEST_CHECK(hard_link_count(StaticEnv::Dir3) == Dir3Expect ||
-   hard_link_count(StaticEnv::Dir3) == Dir3ExpectAlt);
+   hard_link_count(StaticEnv::Dir3) == Dir3ExpectAlt ||
+   hard_link_count(StaticEnv::Dir3) == 1);
 
 std::error_code ec;
 TEST_CHECK(hard_link_count(StaticEnv::Dir, ec) == DirExpect ||
-   hard_link_count(StaticEnv::Dir, ec) == DirExpectAlt);
+   hard_link_count(StaticEnv::Dir, ec) == DirExpectAlt ||
+   hard_link_count(StaticEnv::Dir) == 1);
 TEST_CHECK(hard_link_count(StaticEnv::Dir3, ec) == Dir3Expect ||
-   hard_link_count(StaticEnv::Dir3, ec) == Dir3ExpectAlt);
+   hard_link_count(StaticEnv::Dir3, ec) == Dir3ExpectAlt ||
+   hard_link_count(StaticEnv::Dir3) == 1);
 }
 TEST_CASE(hard_link_count_increments_test)
 {


Index: libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.hard_lk_ct/hard_link_count.pass.cpp
===
--- libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.hard_lk_ct/hard_link_count.pass.cpp
+++ libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.hard_lk_ct/hard_link_count.pass.cpp
@@ -57,15 +57,19 @@
 Dir3Expect = 3; // .  ..  file5
 #endif
 TEST_CHECK(hard_link_count(StaticEnv::Dir) == DirExpect ||
-   hard_link_count(StaticEnv::Dir) == DirExpectAlt);
+   hard_link_count(StaticEnv::Dir) == DirExpectAlt ||
+   hard_link_count(StaticEnv::Dir) == 1);
 TEST_CHECK(hard_link_count(StaticEnv::Dir3) == Dir3Expect ||
-   hard_link_count(StaticEnv::Dir3) == Dir3ExpectAlt);
+   hard_link_count(StaticEnv::Dir3) == Dir3ExpectAlt ||
+   hard_link_count(StaticEnv::Dir3) == 1);
 
 std::error_code ec;
 TEST_CHECK(hard_link_count(StaticEnv::Dir, ec) == DirExpect ||
-   hard_link_count(StaticEnv::Dir, ec) == DirExpectAlt);
+   hard_link_count(StaticEnv::Dir, ec) == DirExpectAlt ||
+   hard_link_count(StaticEnv::Dir) == 1);
 TEST_CHECK(hard_link_count(StaticEnv::Dir3, ec) == Dir3Expect ||
-   hard_link_count(StaticEnv::Dir3, ec) == Dir3ExpectAlt);
+   hard_link_count(StaticEnv::Dir3, ec) == Dir3ExpectAlt ||
+   hard_link_count(StaticEnv::Dir3) == 1);
 }
 TEST_CASE(hard_link_count_increments_test)
 {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29706: [libcxx] [test] Fix hard_link_count test to account for fs with dir nlink==1

2017-02-08 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.

Filesystems are not required to maintain a hard link count consistent
with number of subdirectories. For example, on btrfs all directories
have nlink==1. Account for that in the test.


Repository:
  rL LLVM

https://reviews.llvm.org/D29706

Files:
  
test/std/experimental/filesystem/fs.op.funcs/fs.op.hard_lk_ct/hard_link_count.pass.cpp


Index: 
test/std/experimental/filesystem/fs.op.funcs/fs.op.hard_lk_ct/hard_link_count.pass.cpp
===
--- 
test/std/experimental/filesystem/fs.op.funcs/fs.op.hard_lk_ct/hard_link_count.pass.cpp
+++ 
test/std/experimental/filesystem/fs.op.funcs/fs.op.hard_lk_ct/hard_link_count.pass.cpp
@@ -57,15 +57,19 @@
 Dir3Expect = 3; // .  ..  file5
 #endif
 TEST_CHECK(hard_link_count(StaticEnv::Dir) == DirExpect ||
-   hard_link_count(StaticEnv::Dir) == DirExpectAlt);
+   hard_link_count(StaticEnv::Dir) == DirExpectAlt ||
+   hard_link_count(StaticEnv::Dir) == 1);
 TEST_CHECK(hard_link_count(StaticEnv::Dir3) == Dir3Expect ||
-   hard_link_count(StaticEnv::Dir3) == Dir3ExpectAlt);
+   hard_link_count(StaticEnv::Dir3) == Dir3ExpectAlt ||
+   hard_link_count(StaticEnv::Dir3) == 1);
 
 std::error_code ec;
 TEST_CHECK(hard_link_count(StaticEnv::Dir, ec) == DirExpect ||
-   hard_link_count(StaticEnv::Dir, ec) == DirExpectAlt);
+   hard_link_count(StaticEnv::Dir, ec) == DirExpectAlt ||
+   hard_link_count(StaticEnv::Dir) == 1);
 TEST_CHECK(hard_link_count(StaticEnv::Dir3, ec) == Dir3Expect ||
-   hard_link_count(StaticEnv::Dir3, ec) == Dir3ExpectAlt);
+   hard_link_count(StaticEnv::Dir3, ec) == Dir3ExpectAlt ||
+   hard_link_count(StaticEnv::Dir3) == 1);
 }
 TEST_CASE(hard_link_count_increments_test)
 {


Index: test/std/experimental/filesystem/fs.op.funcs/fs.op.hard_lk_ct/hard_link_count.pass.cpp
===
--- test/std/experimental/filesystem/fs.op.funcs/fs.op.hard_lk_ct/hard_link_count.pass.cpp
+++ test/std/experimental/filesystem/fs.op.funcs/fs.op.hard_lk_ct/hard_link_count.pass.cpp
@@ -57,15 +57,19 @@
 Dir3Expect = 3; // .  ..  file5
 #endif
 TEST_CHECK(hard_link_count(StaticEnv::Dir) == DirExpect ||
-   hard_link_count(StaticEnv::Dir) == DirExpectAlt);
+   hard_link_count(StaticEnv::Dir) == DirExpectAlt ||
+   hard_link_count(StaticEnv::Dir) == 1);
 TEST_CHECK(hard_link_count(StaticEnv::Dir3) == Dir3Expect ||
-   hard_link_count(StaticEnv::Dir3) == Dir3ExpectAlt);
+   hard_link_count(StaticEnv::Dir3) == Dir3ExpectAlt ||
+   hard_link_count(StaticEnv::Dir3) == 1);
 
 std::error_code ec;
 TEST_CHECK(hard_link_count(StaticEnv::Dir, ec) == DirExpect ||
-   hard_link_count(StaticEnv::Dir, ec) == DirExpectAlt);
+   hard_link_count(StaticEnv::Dir, ec) == DirExpectAlt ||
+   hard_link_count(StaticEnv::Dir) == 1);
 TEST_CHECK(hard_link_count(StaticEnv::Dir3, ec) == Dir3Expect ||
-   hard_link_count(StaticEnv::Dir3, ec) == Dir3ExpectAlt);
+   hard_link_count(StaticEnv::Dir3, ec) == Dir3ExpectAlt ||
+   hard_link_count(StaticEnv::Dir3) == 1);
 }
 TEST_CASE(hard_link_count_increments_test)
 {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29708: [compiler-rt] [test] #ifdef new builtin tests for __arm__ platform

2017-02-08 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
Herald added subscribers: dberris, aemerson.

Add an #if that excludes the newly added aeabi* tests on non-ARM
platforms. This is consistent with other ARM tests, and aims to make
running builtin tests easier. Lacking a proper infrastructure to run
tests selectively, it is more convenient if we do not have to implement
directory-platform exclusions and can just rely on tests compiling to
no-op on other platforms.


Repository:
  rL LLVM

https://reviews.llvm.org/D29708

Files:
  test/builtins/Unit/arm/aeabi_idivmod_test.c
  test/builtins/Unit/arm/aeabi_uidivmod_test.c
  test/builtins/Unit/arm/aeabi_uldivmod_test.c

Index: test/builtins/Unit/arm/aeabi_uldivmod_test.c
===
--- test/builtins/Unit/arm/aeabi_uldivmod_test.c
+++ test/builtins/Unit/arm/aeabi_uldivmod_test.c
@@ -14,6 +14,7 @@
 #include "int_lib.h"
 #include 
 
+#if __arm__
 // Based on udivmoddi4_test.c
 
 COMPILER_RT_ABI void /* __value_in_regs */ __aeabi_uldivmod(du_int a, du_int b);
@@ -20637,14 +20638,19 @@
 {0xuLL, 0xFFFEuLL, 0x0001uLL, 0x0001uLL},
 {0xuLL, 0xuLL, 0x0001uLL, 0xuLL}
 };
+#endif
 
 int main()
 {
+#if __arm__
 const unsigned N = sizeof(tests) / sizeof(tests[0]);
 unsigned i;
 for (i = 0; i < N; ++i)
 if (test_aeabi_uldivmod(tests[i][0], tests[i][1], tests[i][2], tests[i][3]))
 return 1;
+#else
+printf("skipped\n");
+#endif
 
 return 0;
 }
Index: test/builtins/Unit/arm/aeabi_uidivmod_test.c
===
--- test/builtins/Unit/arm/aeabi_uidivmod_test.c
+++ test/builtins/Unit/arm/aeabi_uidivmod_test.c
@@ -14,6 +14,7 @@
 #include "int_lib.h"
 #include 
 
+#if __arm__
 // Based on udivmodsi4_test.c
 
 extern du_int __aeabi_uidivmod(su_int a, su_int b);
@@ -38,10 +39,12 @@
 
 return 0;
 }
+#endif
 
 
 int main()
 {
+#if __arm__
 if (test__aeabi_uidivmod(0, 1, 0, 0))
 return 1;
 
@@ -56,6 +59,9 @@
  
  	if (test__aeabi_uidivmod(0x8003, 8, 0x1000, 3))
 return 1;
+#else
+printf("skipped\n");
+#endif
 
 	return 0;
 }
Index: test/builtins/Unit/arm/aeabi_idivmod_test.c
===
--- test/builtins/Unit/arm/aeabi_idivmod_test.c
+++ test/builtins/Unit/arm/aeabi_idivmod_test.c
@@ -14,6 +14,7 @@
 #include "int_lib.h"
 #include 
 
+#if __arm__
 // Based on divmodsi4_test.c
 
 extern du_int __aeabi_idivmod(si_int a, si_int b);
@@ -38,10 +39,12 @@
 
 return 0;
 }
+#endif
 
 
 int main()
 {
+#if __arm__
 if (test__aeabi_idivmod(0, 1, 0, 0))
 return 1;
 if (test__aeabi_idivmod(0, -1, 0, 0))
@@ -69,6 +72,9 @@
 return 1;
 	if (test__aeabi_idivmod(0x8007, 8, 0xf001, -1))
 return 1;
+#else
+printf("skipped\n");
+#endif
 
 return 0;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29708: [compiler-rt] [test] #ifdef new builtin tests for __arm__ platform

2017-02-08 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL294438: [test] #ifdef new builtin tests for __arm__ platform 
(authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D29708?vs=87617=87629#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29708

Files:
  compiler-rt/trunk/test/builtins/Unit/arm/aeabi_idivmod_test.c
  compiler-rt/trunk/test/builtins/Unit/arm/aeabi_uidivmod_test.c
  compiler-rt/trunk/test/builtins/Unit/arm/aeabi_uldivmod_test.c

Index: compiler-rt/trunk/test/builtins/Unit/arm/aeabi_uidivmod_test.c
===
--- compiler-rt/trunk/test/builtins/Unit/arm/aeabi_uidivmod_test.c
+++ compiler-rt/trunk/test/builtins/Unit/arm/aeabi_uidivmod_test.c
@@ -14,6 +14,7 @@
 #include "int_lib.h"
 #include 
 
+#if __arm__
 // Based on udivmodsi4_test.c
 
 extern du_int __aeabi_uidivmod(su_int a, su_int b);
@@ -38,10 +39,12 @@
 
 return 0;
 }
+#endif
 
 
 int main()
 {
+#if __arm__
 if (test__aeabi_uidivmod(0, 1, 0, 0))
 return 1;
 
@@ -56,6 +59,9 @@
  
  	if (test__aeabi_uidivmod(0x8003, 8, 0x1000, 3))
 return 1;
+#else
+printf("skipped\n");
+#endif
 
 	return 0;
 }
Index: compiler-rt/trunk/test/builtins/Unit/arm/aeabi_idivmod_test.c
===
--- compiler-rt/trunk/test/builtins/Unit/arm/aeabi_idivmod_test.c
+++ compiler-rt/trunk/test/builtins/Unit/arm/aeabi_idivmod_test.c
@@ -14,6 +14,7 @@
 #include "int_lib.h"
 #include 
 
+#if __arm__
 // Based on divmodsi4_test.c
 
 extern du_int __aeabi_idivmod(si_int a, si_int b);
@@ -38,10 +39,12 @@
 
 return 0;
 }
+#endif
 
 
 int main()
 {
+#if __arm__
 if (test__aeabi_idivmod(0, 1, 0, 0))
 return 1;
 if (test__aeabi_idivmod(0, -1, 0, 0))
@@ -69,6 +72,9 @@
 return 1;
 	if (test__aeabi_idivmod(0x8007, 8, 0xf001, -1))
 return 1;
+#else
+printf("skipped\n");
+#endif
 
 return 0;
 }
Index: compiler-rt/trunk/test/builtins/Unit/arm/aeabi_uldivmod_test.c
===
--- compiler-rt/trunk/test/builtins/Unit/arm/aeabi_uldivmod_test.c
+++ compiler-rt/trunk/test/builtins/Unit/arm/aeabi_uldivmod_test.c
@@ -14,6 +14,7 @@
 #include "int_lib.h"
 #include 
 
+#if __arm__
 // Based on udivmoddi4_test.c
 
 COMPILER_RT_ABI void /* __value_in_regs */ __aeabi_uldivmod(du_int a, du_int b);
@@ -20637,14 +20638,19 @@
 {0xuLL, 0xFFFEuLL, 0x0001uLL, 0x0001uLL},
 {0xuLL, 0xuLL, 0x0001uLL, 0xuLL}
 };
+#endif
 
 int main()
 {
+#if __arm__
 const unsigned N = sizeof(tests) / sizeof(tests[0]);
 unsigned i;
 for (i = 0; i < N; ++i)
 if (test_aeabi_uldivmod(tests[i][0], tests[i][1], tests[i][2], tests[i][3]))
 return 1;
+#else
+printf("skipped\n");
+#endif
 
 return 0;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28213: [Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin

2017-02-04 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

In https://reviews.llvm.org/D28213#666269, @dim wrote:

> > What's the value of `__atomic_always_lock_free(sizeof(long long), 0)` for 
> > gcc and clang?
>
> For gcc, it is always 0, for clang (I tested 3.4.1 through 4.0.0) it is 
> always 1.  Maybe that was always incorrect on 32-bit FreeBSD, then?


That's what I suspected. Yeah, looks like clang always made the wrong 
assumption and possibly someone just swept it under the carpet.

In https://reviews.llvm.org/D28213#666352, @dim wrote:

> Hmm, I just noticed the following rather disappointing comment in 
> `tools/clang/lib/Basic/Targets.cpp`:
>
>   X86_32TargetInfo(const llvm::Triple , const TargetOptions )
>   : X86TargetInfo(Triple, Opts) {
> [...]
> // x86-32 has atomics up to 8 bytes
> // FIXME: Check that we actually have cmpxchg8b before setting
> // MaxAtomicInlineWidth. (cmpxchg8b is an i586 instruction.)
> MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
>   
>
> So this can never have worked properly for e.g. i486 and i586...


Yep, looks like it. I see that the triple is passed there, so I guess making 
that conditional to `>=i586-*` should be relatively easy. However, I don't know 
how to make it properly respect `-march`.


Repository:
  rL LLVM

https://reviews.llvm.org/D28213



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


[PATCH] D29542: [TargetInfo] Adjust x86-32 atomic support to the CPU used

2017-02-04 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

In https://reviews.llvm.org/D29542#666831, @jlebar wrote:

> > Could someone help me figure out what is the cause and correct solution to 
> > that failure? @jlebar?
>
> You can see in NVPTXTargetInfo that we read properties from the host 
> targetinfo so that we export the same macros.  The problem here seems to be 
> that we're mutating the x86 targetinfo after the nvptx targetinfo reads its 
> properties.
>
> Does that give you enough context to fix the problem?


Thanks. I'll try to find a reasonably sane solution ;-).




Comment at: lib/Basic/Targets.cpp:4244
+} else // allow locked atomics up to 4 bytes
+  MaxAtomicPromoteWidth = 32;
+  }

dim wrote:
> Are you purposefully not setting `MaxAtomicInlineWidth` here?  (It seems from 
> `TargetInfo` that the default value is zero.)
> 
Yes. I've based this on what's done for ARM. Unless I misunderstood something, 
this means that on 'plain' i386 there is no inline atomics support but we still 
want to do atomics-via-locking up to 32-bit types. I'm not sure about 32/64 
here to match i486.



Comment at: lib/Basic/Targets.cpp:4265
 
-// x86-32 has atomics up to 8 bytes
-// FIXME: Check that we actually have cmpxchg8b before setting
-// MaxAtomicInlineWidth. (cmpxchg8b is an i586 instruction.)
-MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
+setAtomic();
   }

dim wrote:
> As far as I can see, in the constructor this call is _always_ made with `CPU` 
> set to `CK_Generic`, i.e. zero.  Therefore, the "allow locked atomics up to 4 
> bytes" path in `setAtomic` is always chosen.  Maybe it is clearer to just 
> initialize `MaxAtomicPromoteWidth` to 32 directly here, instead?
> 
Well, I just copied the idea from ARM. I thought of it more like 'make sure it 
is initialized to some value, possibly update it later when setting CPU'. I'm 
fine either way.


Repository:
  rL LLVM

https://reviews.llvm.org/D29542



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


[PATCH] D29542: [TargetInfo] Adjust x86-32 atomic support to the CPU used

2017-02-04 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
Herald added a subscriber: emaste.

Set the maximum width of atomic operations on x86-32 based on the target
CPU. The 64-bit inline atomics require cmpxchg8b which is an i586
instruction. Other inline atomics require cmpxchg which is an i486
instruction.

This fixes the incorrect value of __GCC_ATOMIC_LLONG_LOCK_FREE
and __atomic_always_lock_free() on FreeBSD where clang defaults to i486
CPU (PR#31864).

TODO: one CUDA test is broken:

  /home/mgorny/llvm/_build/./bin/clang  --cuda-host-only -nocudainc -target 
x86_64-windows-msvc -x cuda -E -dM -o - /dev/null| grep 'define __[^ 
]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC'| grep -v 
'__LDBL\|_LONG_DOUBLE' > 
/home/mgorny/llvm/_build/tools/clang/test/Preprocessor/Output/x86_64-msvc-host-defines-filtered
  /home/mgorny/llvm/_build/./bin/clang  --cuda-device-only -nocudainc 
-nocudalib -target x86_64-windows-msvc -x cuda -E -dM -o - /dev/null| grep 
'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC'| grep -v 
'__LDBL\|_LONG_DOUBLE' > 
/home/mgorny/llvm/_build/tools/clang/test/Preprocessor/Output/x86_64-msvc-device-defines-filtered
  diff 
/home/mgorny/llvm/_build/tools/clang/test/Preprocessor/Output/x86_64-msvc-host-defines-filtered
 
/home/mgorny/llvm/_build/tools/clang/test/Preprocessor/Output/x86_64-msvc-device-defines-filtered
  --
  Exit Code: 1
  
  Command Output (stdout):
  --
  9,17c9,17
  < #define __GCC_ATOMIC_BOOL_LOCK_FREE 2
  < #define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2
  < #define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2
  < #define __GCC_ATOMIC_CHAR_LOCK_FREE 2
  < #define __GCC_ATOMIC_INT_LOCK_FREE 2
  < #define __GCC_ATOMIC_LLONG_LOCK_FREE 2
  < #define __GCC_ATOMIC_LONG_LOCK_FREE 2
  < #define __GCC_ATOMIC_POINTER_LOCK_FREE 2
  < #define __GCC_ATOMIC_SHORT_LOCK_FREE 2
  ---
  > #define __GCC_ATOMIC_BOOL_LOCK_FREE 1
  > #define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 1
  > #define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 1
  > #define __GCC_ATOMIC_CHAR_LOCK_FREE 1
  > #define __GCC_ATOMIC_INT_LOCK_FREE 1
  > #define __GCC_ATOMIC_LLONG_LOCK_FREE 1
  > #define __GCC_ATOMIC_LONG_LOCK_FREE 1
  > #define __GCC_ATOMIC_POINTER_LOCK_FREE 1
  > #define __GCC_ATOMIC_SHORT_LOCK_FREE 1
  19c19
  < #define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2
  ---
  > #define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 1
  
  --

Could someone help me figure out what is the cause and correct solution to that 
failure? @jlebar?


Repository:
  rL LLVM

https://reviews.llvm.org/D29542

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/atomic-ops.c
  test/CodeGen/ms-volatile.c
  test/CodeGenCXX/atomicinit.cpp
  test/Sema/atomic-ops.c

Index: test/Sema/atomic-ops.c
===
--- test/Sema/atomic-ops.c
+++ test/Sema/atomic-ops.c
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 %s -verify -ffreestanding -fsyntax-only -triple=i686-linux-gnu -std=c11
+// RUN: %clang_cc1 %s -verify -ffreestanding -fsyntax-only -triple=i686-linux-gnu -target-cpu i686 -std=c11
+// RUN: %clang_cc1 %s -verify -ffreestanding -fsyntax-only -triple=i486-linux-gnu -target-cpu i486 -std=c11
 
 // Basic parsing/Sema tests for __c11_atomic_*
 
@@ -14,22 +15,34 @@
 _Static_assert(__GCC_ATOMIC_SHORT_LOCK_FREE == 2, "");
 _Static_assert(__GCC_ATOMIC_INT_LOCK_FREE == 2, "");
 _Static_assert(__GCC_ATOMIC_LONG_LOCK_FREE == 2, "");
+#if defined(__i486__)
+_Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 1, "");
+#else
 _Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 2, "");
+#endif
 _Static_assert(__GCC_ATOMIC_POINTER_LOCK_FREE == 2, "");
 
 _Static_assert(__c11_atomic_is_lock_free(1), "");
 _Static_assert(__c11_atomic_is_lock_free(2), "");
 _Static_assert(__c11_atomic_is_lock_free(3), ""); // expected-error {{not an integral constant expression}}
 _Static_assert(__c11_atomic_is_lock_free(4), "");
+#if defined(__i486__)
+_Static_assert(__c11_atomic_is_lock_free(8), ""); // expected-error {{not an integral constant expression}}
+#else
 _Static_assert(__c11_atomic_is_lock_free(8), "");
+#endif
 _Static_assert(__c11_atomic_is_lock_free(16), ""); // expected-error {{not an integral constant expression}}
 _Static_assert(__c11_atomic_is_lock_free(17), ""); // expected-error {{not an integral constant expression}}
 
 _Static_assert(__atomic_is_lock_free(1, 0), "");
 _Static_assert(__atomic_is_lock_free(2, 0), "");
 _Static_assert(__atomic_is_lock_free(3, 0), ""); // expected-error {{not an integral constant expression}}
 _Static_assert(__atomic_is_lock_free(4, 0), "");
+#if defined(__i486__)
+_Static_assert(__atomic_is_lock_free(8, 0), ""); // expected-error {{not an integral constant expression}}
+#else
 _Static_assert(__atomic_is_lock_free(8, 0), "");
+#endif
 _Static_assert(__atomic_is_lock_free(16, 0), ""); // expected-error {{not an integral constant expression}}
 _Static_assert(__atomic_is_lock_free(17, 0), ""); // expected-error {{not an integral constant expression}}
 
@@ -56,13 +69,21 @@
 _Static_assert(__atomic_is_lock_free(4, ), "");
 

[PATCH] D29542: [TargetInfo] Adjust x86-32 atomic support to the CPU used

2017-02-06 Thread Michał Górny via Phabricator via cfe-commits
mgorny added inline comments.



Comment at: lib/Basic/Targets.cpp:1808
+if (HostTriple.getArch() == llvm::Triple::x86)
+  HostTarget->setCPU("i586");
+

jlebar wrote:
> Okay, is this still needed now?
Yes. I've specifically tested with it commented out, and the CPU gets initiated 
to generic (=no inline atomics) then.


https://reviews.llvm.org/D29542



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


[PATCH] D29304: [cmake] Hint find_package() to prefer LLVM installed alongside clang

2017-01-30 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.

Include a path hint for find_package() in ClangConfig.cmake to ensure
that CMake prefers LLVM installed alongside clang over the default
search path.

If two versions of LLVM are installed in the system, and one of them is
in PATH, CMake's find_package() magic prefers the CMake directory
alongside that install by default. Adding a relative hint makes it
possible to prioritize to the install from which find_package() is
called.

If you want to build e.g. LLDB against another install of LLVM, you can
pass LLVM_CONFIG override. In this case, LLDB queries the prefix from
llvm-config and uses the CMake files located there. However, when
including ClangConfig, the implicit find_package() nevertheless prefers
PATH-found LLVM over the one used previously by LLDB, and two versions
of LLVMConfig end up being loaded.

This could be fixed on LLDB end up by explicitly forcing custom package
search location. However, it seems simpler and safer to add a hint to
ClangConfig than to track every usage of ClangConfig.


Repository:
  rL LLVM

https://reviews.llvm.org/D29304

Files:
  cmake/modules/CMakeLists.txt
  cmake/modules/ClangConfig.cmake.in


Index: cmake/modules/ClangConfig.cmake.in
===
--- cmake/modules/ClangConfig.cmake.in
+++ cmake/modules/ClangConfig.cmake.in
@@ -1,9 +1,10 @@
 # This file allows users to call find_package(Clang) and pick up our targets.
 
-find_package(LLVM REQUIRED CONFIG)
-
 @CLANG_CONFIG_CODE@
 
+find_package(LLVM REQUIRED CONFIG
+ HINTS "@CLANG_CONFIG_LLVM_CMAKE_DIR@")
+
 set(CLANG_EXPORTED_TARGETS "@CLANG_EXPORTS@")
 set(CLANG_CMAKE_DIR "@CLANG_CONFIG_CMAKE_DIR@")
 
Index: cmake/modules/CMakeLists.txt
===
--- cmake/modules/CMakeLists.txt
+++ cmake/modules/CMakeLists.txt
@@ -4,17 +4,23 @@
 set(CLANG_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/clang)
 set(clang_cmake_builddir "${CMAKE_BINARY_DIR}/${CLANG_INSTALL_PACKAGE_DIR}")
 
+# Keep this in sync with llvm/cmake/CMakeLists.txt!
+set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm)
+set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
+
 get_property(CLANG_EXPORTS GLOBAL PROPERTY CLANG_EXPORTS)
 export(TARGETS ${CLANG_EXPORTS} FILE 
${clang_cmake_builddir}/ClangTargets.cmake)
 
 # Generate ClangConfig.cmake for the build tree.
 set(CLANG_CONFIG_CMAKE_DIR "${clang_cmake_builddir}")
+set(CLANG_CONFIG_LLVM_CMAKE_DIR "${llvm_cmake_builddir}")
 set(CLANG_CONFIG_EXPORTS_FILE "${clang_cmake_builddir}/ClangTargets.cmake")
 configure_file(
   ${CMAKE_CURRENT_SOURCE_DIR}/ClangConfig.cmake.in
   ${clang_cmake_builddir}/ClangConfig.cmake
   @ONLY)
 set(CLANG_CONFIG_CMAKE_DIR)
+set(CLANG_CONFIG_LLVM_CMAKE_DIR)
 set(CLANG_CONFIG_EXPORTS_FILE)
 
 # Generate ClangConfig.cmake for the install tree.
@@ -29,6 +35,7 @@
 get_filename_component(CLANG_INSTALL_PREFIX \"\${CLANG_INSTALL_PREFIX}\" 
PATH)")
 endforeach(p)
 set(CLANG_CONFIG_CMAKE_DIR 
"\${CLANG_INSTALL_PREFIX}/${CLANG_INSTALL_PACKAGE_DIR}")
+set(CLANG_CONFIG_LLVM_CMAKE_DIR 
"\${CLANG_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}")
 set(CLANG_CONFIG_EXPORTS_FILE "\${CLANG_CMAKE_DIR}/ClangTargets.cmake")
 configure_file(
   ${CMAKE_CURRENT_SOURCE_DIR}/ClangConfig.cmake.in


Index: cmake/modules/ClangConfig.cmake.in
===
--- cmake/modules/ClangConfig.cmake.in
+++ cmake/modules/ClangConfig.cmake.in
@@ -1,9 +1,10 @@
 # This file allows users to call find_package(Clang) and pick up our targets.
 
-find_package(LLVM REQUIRED CONFIG)
-
 @CLANG_CONFIG_CODE@
 
+find_package(LLVM REQUIRED CONFIG
+ HINTS "@CLANG_CONFIG_LLVM_CMAKE_DIR@")
+
 set(CLANG_EXPORTED_TARGETS "@CLANG_EXPORTS@")
 set(CLANG_CMAKE_DIR "@CLANG_CONFIG_CMAKE_DIR@")
 
Index: cmake/modules/CMakeLists.txt
===
--- cmake/modules/CMakeLists.txt
+++ cmake/modules/CMakeLists.txt
@@ -4,17 +4,23 @@
 set(CLANG_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/clang)
 set(clang_cmake_builddir "${CMAKE_BINARY_DIR}/${CLANG_INSTALL_PACKAGE_DIR}")
 
+# Keep this in sync with llvm/cmake/CMakeLists.txt!
+set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm)
+set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
+
 get_property(CLANG_EXPORTS GLOBAL PROPERTY CLANG_EXPORTS)
 export(TARGETS ${CLANG_EXPORTS} FILE ${clang_cmake_builddir}/ClangTargets.cmake)
 
 # Generate ClangConfig.cmake for the build tree.
 set(CLANG_CONFIG_CMAKE_DIR "${clang_cmake_builddir}")
+set(CLANG_CONFIG_LLVM_CMAKE_DIR "${llvm_cmake_builddir}")
 set(CLANG_CONFIG_EXPORTS_FILE "${clang_cmake_builddir}/ClangTargets.cmake")
 configure_file(
   ${CMAKE_CURRENT_SOURCE_DIR}/ClangConfig.cmake.in
   ${clang_cmake_builddir}/ClangConfig.cmake
   @ONLY)
 set(CLANG_CONFIG_CMAKE_DIR)
+set(CLANG_CONFIG_LLVM_CMAKE_DIR)
 

[PATCH] D28529: [test] Port clang tests to canonicalized booleans

2017-01-25 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL293052: [test] Port clang tests to canonicalized booleans 
(authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D28529?vs=83852=85736#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28529

Files:
  cfe/trunk/CMakeLists.txt
  cfe/trunk/test/ARCMT/lit.local.cfg
  cfe/trunk/test/Analysis/lit.local.cfg
  cfe/trunk/test/CMakeLists.txt
  cfe/trunk/test/Rewriter/lit.local.cfg
  cfe/trunk/test/Tooling/lit.local.cfg
  cfe/trunk/test/lit.cfg
  cfe/trunk/test/lit.site.cfg.in

Index: cfe/trunk/test/Analysis/lit.local.cfg
===
--- cfe/trunk/test/Analysis/lit.local.cfg
+++ cfe/trunk/test/Analysis/lit.local.cfg
@@ -1,2 +1,2 @@
-if config.root.clang_staticanalyzer == 0:
+if not config.root.clang_staticanalyzer:
 config.unsupported = True
Index: cfe/trunk/test/ARCMT/lit.local.cfg
===
--- cfe/trunk/test/ARCMT/lit.local.cfg
+++ cfe/trunk/test/ARCMT/lit.local.cfg
@@ -1,2 +1,2 @@
-if config.root.clang_arcmt == 0:
+if not config.root.clang_arcmt:
 config.unsupported = True
Index: cfe/trunk/test/Rewriter/lit.local.cfg
===
--- cfe/trunk/test/Rewriter/lit.local.cfg
+++ cfe/trunk/test/Rewriter/lit.local.cfg
@@ -1,3 +1,3 @@
 # The Objective-C rewriters are currently grouped with ARCMT.
-if config.root.clang_arcmt == 0:
+if not config.root.clang_arcmt:
 config.unsupported = True
Index: cfe/trunk/test/lit.site.cfg.in
===
--- cfe/trunk/test/lit.site.cfg.in
+++ cfe/trunk/test/lit.site.cfg.in
@@ -14,13 +14,13 @@
 config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
-config.have_zlib = "@HAVE_LIBZ@"
-config.clang_arcmt = @ENABLE_CLANG_ARCMT@
+config.have_zlib = @HAVE_LIBZ@
+config.clang_arcmt = @CLANG_ENABLE_ARCMT@
 config.clang_default_cxx_stdlib = "@CLANG_DEFAULT_CXX_STDLIB@"
-config.clang_staticanalyzer = @ENABLE_CLANG_STATIC_ANALYZER@
-config.clang_examples = @ENABLE_CLANG_EXAMPLES@
+config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@
+config.clang_examples = @CLANG_BUILD_EXAMPLES@
 config.enable_shared = @ENABLE_SHARED@
-config.enable_backtrace = "@ENABLE_BACKTRACES@"
+config.enable_backtrace = @ENABLE_BACKTRACES@
 config.host_arch = "@HOST_ARCH@"
 
 # Support substitution of the tools and libs dirs with user parameters. This is
Index: cfe/trunk/test/lit.cfg
===
--- cfe/trunk/test/lit.cfg
+++ cfe/trunk/test/lit.cfg
@@ -202,7 +202,7 @@
 # Plugins (loadable modules)
 # TODO: This should be supplied by Makefile or autoconf.
 if sys.platform in ['win32', 'cygwin']:
-has_plugins = (config.enable_shared == 1)
+has_plugins = config.enable_shared
 else:
 has_plugins = True
 
@@ -353,7 +353,7 @@
 config.available_features.add('default-cxx-stdlib-set')
 
 # Enabled/disabled features
-if config.clang_staticanalyzer != 0:
+if config.clang_staticanalyzer:
 config.available_features.add("staticanalyzer")
 
 # As of 2011.08, crash-recovery tests still do not pass on FreeBSD.
@@ -474,10 +474,10 @@
 else:
 config.available_features.add("not_ubsan")
 
-if config.enable_backtrace == "1":
+if config.enable_backtrace:
 config.available_features.add("backtrace")
 
-if config.have_zlib == "1":
+if config.have_zlib:
 config.available_features.add("zlib")
 else:
 config.available_features.add("nozlib")
Index: cfe/trunk/test/CMakeLists.txt
===
--- cfe/trunk/test/CMakeLists.txt
+++ cfe/trunk/test/CMakeLists.txt
@@ -18,6 +18,12 @@
   endif()
 endif()
 
+llvm_canonicalize_cmake_booleans(
+  CLANG_BUILD_EXAMPLES
+  CLANG_ENABLE_ARCMT
+  CLANG_ENABLE_STATIC_ANALYZER
+  ENABLE_BACKTRACES)
+
 configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
@@ -55,15 +61,15 @@
   )
 endif ()
 
-if (ENABLE_CLANG_EXAMPLES)
+if (CLANG_BUILD_EXAMPLES)
   list(APPEND CLANG_TEST_DEPS
 AnnotateFunctions
 clang-interpreter
 PrintFunctionNames
 )
 endif ()
 
-if (ENABLE_CLANG_STATIC_ANALYZER AND ENABLE_CLANG_EXAMPLES)
+if (CLANG_ENABLE_STATIC_ANALYZER AND CLANG_BUILD_EXAMPLES)
   list(APPEND CLANG_TEST_DEPS
 SampleAnalyzerPlugin
 )
Index: cfe/trunk/test/Tooling/lit.local.cfg
===
--- cfe/trunk/test/Tooling/lit.local.cfg
+++ cfe/trunk/test/Tooling/lit.local.cfg
@@ -1,2 +1,2 @@
-if config.root.clang_staticanalyzer == 0:
+if not config.root.clang_staticanalyzer:
 config.unsupported = True
Index: cfe/trunk/CMakeLists.txt
===
--- 

[PATCH] D25402: [Driver] Pass -lunwind along with compiler-rt when necessary on Linux

2017-01-26 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 85875.
mgorny retitled this revision from "[Driver] Pass -lunwind when using libc++ + 
compiler-rt on Linux" to "[Driver] Pass -lunwind along with compiler-rt when 
necessary on Linux".
mgorny edited the summary of this revision.
mgorny added a comment.
Herald added subscribers: srhines, danalbert.

Here's a v2. It turns out that you also need `-lunwind` when using to link C 
programs with `-static -rtlib=compiler-rt`. I've also disabled the changes for 
Android targets.


https://reviews.llvm.org/D25402

Files:
  lib/Driver/Tools.cpp
  test/Driver/linux-ld.c


Index: test/Driver/linux-ld.c
===
--- test/Driver/linux-ld.c
+++ test/Driver/linux-ld.c
@@ -443,6 +443,34 @@
 // CHECK-BASIC-LIBCXX-C-LINK: "--sysroot=[[SYSROOT]]"
 // CHECK-BASIC-LIBCXX-C-LINK: "-L[[SYSROOT]]/usr/bin/../lib"
 //
+// Test that libc++ combined with compiler-rt includes -lunwind
+// (and no gcc libraries).
+// RUN: %clangxx -no-canonical-prefixes -x c++ %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-unknown-linux-gnu \
+// RUN: -stdlib=libc++ -rtlib=compiler-rt \
+// RUN: -ccc-install-dir %S/Inputs/basic_linux_tree/usr/bin \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/basic_linux_libcxx_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-BASIC-LIBCXX-CLANGRT %s
+// CHECK-BASIC-LIBCXX-CLANGRT: "-lc++"
+// CHECK-BASIC-LIBCXX-CLANGRT: "-lunwind"
+// CHECK-BASIC-LIBCXX-CLANGRT-NOT: "-lgcc_s"
+// CHECK-BASIC-LIBCXX-CLANGRT-NOT: "-lgcc"
+// CHECK-BASIC-LIBCXX-CLANGRT-NOT: "-lgcc_eh"
+//
+// Test that compiler-rt with -static includes -lunwind.
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-unknown-linux-gnu \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: --rtlib=compiler-rt \
+// RUN: -static \
+// RUN:   | FileCheck --check-prefix=CHECK-BASIC-STATIC-CLANGRT %s
+// CHECK-BASIC-STATIC-CLANGRT: "-lunwind"
+// CHECK-BASIC-STATIC-CLANGRT-NOT: "-lgcc_s"
+// CHECK-BASIC-STATIC-CLANGRT-NOT: "-lgcc"
+// CHECK-BASIC-STATIC-CLANGRT-NOT: "-lgcc_eh"
+//
 // Test a very broken version of multiarch that shipped in Ubuntu 11.04.
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: --target=i386-unknown-linux \
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -10220,6 +10220,7 @@
   // The profile runtime also needs access to system libraries.
   getToolChain().addProfileRTLibs(Args, CmdArgs);
 
+  bool NeedsUnwinder = false;
   if (D.CCCIsCXX() &&
   !Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
 bool OnlyLibstdcxxStatic = Args.hasArg(options::OPT_static_libstdcxx) &&
@@ -10230,14 +10231,20 @@
 if (OnlyLibstdcxxStatic)
   CmdArgs.push_back("-Bdynamic");
 CmdArgs.push_back("-lm");
+// C++ always needs some unwinder
+NeedsUnwinder = true;
   }
   // Silence warnings when linking C code with a C++ '-stdlib' argument.
   Args.ClaimAllArgs(options::OPT_stdlib_EQ);
 
   if (!Args.hasArg(options::OPT_nostdlib)) {
 if (!Args.hasArg(options::OPT_nodefaultlibs)) {
-  if (Args.hasArg(options::OPT_static))
+  if (Args.hasArg(options::OPT_static)) {
 CmdArgs.push_back("--start-group");
+// when linking compiler-rt statically, we also need unwinder
+// (note: this is implicit no-op for libgcc builds)
+NeedsUnwinder = true;
+  }
 
   if (NeedsSanitizerDeps)
 linkSanitizerRuntimeDeps(ToolChain, CmdArgs);
@@ -10278,6 +10285,11 @@
   }
 
   AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
+  // if unwinder is needed and we're using compiler-rt we need
+  // to explicitly link -lunwind in (libgcc has its own unwinder)
+  if (NeedsUnwinder && !isAndroid &&
+  ToolChain.GetRuntimeLibType(Args) == ToolChain::RLT_CompilerRT)
+CmdArgs.push_back("-lunwind");
 
   if (WantPthread && !isAndroid)
 CmdArgs.push_back("-lpthread");


Index: test/Driver/linux-ld.c
===
--- test/Driver/linux-ld.c
+++ test/Driver/linux-ld.c
@@ -443,6 +443,34 @@
 // CHECK-BASIC-LIBCXX-C-LINK: "--sysroot=[[SYSROOT]]"
 // CHECK-BASIC-LIBCXX-C-LINK: "-L[[SYSROOT]]/usr/bin/../lib"
 //
+// Test that libc++ combined with compiler-rt includes -lunwind
+// (and no gcc libraries).
+// RUN: %clangxx -no-canonical-prefixes -x c++ %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-unknown-linux-gnu \
+// RUN: -stdlib=libc++ -rtlib=compiler-rt \
+// RUN: -ccc-install-dir %S/Inputs/basic_linux_tree/usr/bin \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/basic_linux_libcxx_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-BASIC-LIBCXX-CLANGRT %s
+// CHECK-BASIC-LIBCXX-CLANGRT: "-lc++"
+// CHECK-BASIC-LIBCXX-CLANGRT: "-lunwind"

[PATCH] D28849: [compiler-rt] [test] Fix page address logic in clear_cache_test

2017-01-21 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL292729: [test] Fix page address logic in clear_cache_test 
(authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D28849?vs=85208=85248#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28849

Files:
  compiler-rt/trunk/test/builtins/Unit/clear_cache_test.c


Index: compiler-rt/trunk/test/builtins/Unit/clear_cache_test.c
===
--- compiler-rt/trunk/test/builtins/Unit/clear_cache_test.c
+++ compiler-rt/trunk/test/builtins/Unit/clear_cache_test.c
@@ -18,9 +18,20 @@
 if (!FlushInstructionCache(GetCurrentProcess(), start, end-start))
 exit(1);
 }
+
+static uintptr_t get_page_size() {
+SYSTEM_INFO si;
+GetSystemInfo();
+return si.dwPageSize;
+}
 #else
+#include 
 #include 
 extern void __clear_cache(void* start, void* end);
+
+static uintptr_t get_page_size() {
+return sysconf(_SC_PAGE_SIZE);
+}
 #endif
 
 
@@ -56,8 +67,9 @@
 int main()
 {
 // make executable the page containing execution_buffer 
-char* start = (char*)((uintptr_t)execution_buffer & (-4095));
-char* end = (char*)((uintptr_t)(_buffer[128+4096]) & (-4095));
+uintptr_t page_size = get_page_size();
+char* start = (char*)((uintptr_t)execution_buffer & (-page_size));
+char* end = (char*)((uintptr_t)(_buffer[128+page_size]) & 
(-page_size));
 #if defined(_WIN32)
 DWORD dummy_oldProt;
 MEMORY_BASIC_INFORMATION b;


Index: compiler-rt/trunk/test/builtins/Unit/clear_cache_test.c
===
--- compiler-rt/trunk/test/builtins/Unit/clear_cache_test.c
+++ compiler-rt/trunk/test/builtins/Unit/clear_cache_test.c
@@ -18,9 +18,20 @@
 if (!FlushInstructionCache(GetCurrentProcess(), start, end-start))
 exit(1);
 }
+
+static uintptr_t get_page_size() {
+SYSTEM_INFO si;
+GetSystemInfo();
+return si.dwPageSize;
+}
 #else
+#include 
 #include 
 extern void __clear_cache(void* start, void* end);
+
+static uintptr_t get_page_size() {
+return sysconf(_SC_PAGE_SIZE);
+}
 #endif
 
 
@@ -56,8 +67,9 @@
 int main()
 {
 // make executable the page containing execution_buffer 
-char* start = (char*)((uintptr_t)execution_buffer & (-4095));
-char* end = (char*)((uintptr_t)(_buffer[128+4096]) & (-4095));
+uintptr_t page_size = get_page_size();
+char* start = (char*)((uintptr_t)execution_buffer & (-page_size));
+char* end = (char*)((uintptr_t)(_buffer[128+page_size]) & (-page_size));
 #if defined(_WIN32)
 DWORD dummy_oldProt;
 MEMORY_BASIC_INFORMATION b;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28849: [compiler-rt] [test] Fix page address logic in clear_cache_test

2017-01-20 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 85208.
mgorny marked an inline comment as done.
mgorny added a comment.

Fixed the missing change. Also created a local variable to avoid calling the 
sysconf three times.


https://reviews.llvm.org/D28849

Files:
  test/builtins/Unit/clear_cache_test.c


Index: test/builtins/Unit/clear_cache_test.c
===
--- test/builtins/Unit/clear_cache_test.c
+++ test/builtins/Unit/clear_cache_test.c
@@ -18,9 +18,20 @@
 if (!FlushInstructionCache(GetCurrentProcess(), start, end-start))
 exit(1);
 }
+
+static uintptr_t get_page_size() {
+SYSTEM_INFO si;
+GetSystemInfo();
+return si.dwPageSize;
+}
 #else
+#include 
 #include 
 extern void __clear_cache(void* start, void* end);
+
+static uintptr_t get_page_size() {
+return sysconf(_SC_PAGE_SIZE);
+}
 #endif
 
 
@@ -56,8 +67,9 @@
 int main()
 {
 // make executable the page containing execution_buffer 
-char* start = (char*)((uintptr_t)execution_buffer & (-4095));
-char* end = (char*)((uintptr_t)(_buffer[128+4096]) & (-4095));
+uintptr_t page_size = get_page_size();
+char* start = (char*)((uintptr_t)execution_buffer & (-page_size));
+char* end = (char*)((uintptr_t)(_buffer[128+page_size]) & 
(-page_size));
 #if defined(_WIN32)
 DWORD dummy_oldProt;
 MEMORY_BASIC_INFORMATION b;


Index: test/builtins/Unit/clear_cache_test.c
===
--- test/builtins/Unit/clear_cache_test.c
+++ test/builtins/Unit/clear_cache_test.c
@@ -18,9 +18,20 @@
 if (!FlushInstructionCache(GetCurrentProcess(), start, end-start))
 exit(1);
 }
+
+static uintptr_t get_page_size() {
+SYSTEM_INFO si;
+GetSystemInfo();
+return si.dwPageSize;
+}
 #else
+#include 
 #include 
 extern void __clear_cache(void* start, void* end);
+
+static uintptr_t get_page_size() {
+return sysconf(_SC_PAGE_SIZE);
+}
 #endif
 
 
@@ -56,8 +67,9 @@
 int main()
 {
 // make executable the page containing execution_buffer 
-char* start = (char*)((uintptr_t)execution_buffer & (-4095));
-char* end = (char*)((uintptr_t)(_buffer[128+4096]) & (-4095));
+uintptr_t page_size = get_page_size();
+char* start = (char*)((uintptr_t)execution_buffer & (-page_size));
+char* end = (char*)((uintptr_t)(_buffer[128+page_size]) & (-page_size));
 #if defined(_WIN32)
 DWORD dummy_oldProt;
 MEMORY_BASIC_INFORMATION b;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30025: [compiler-rt] [builtins] Fix building atomic.c with GCC

2017-02-15 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
Herald added a subscriber: dberris.

Make the use of #pragma redefine_extname and appropriate renames of
builtins conditional to using clang. GCC used not to support it outside
Solaris and currently seems to be very restrictive on applying it.
In other words, it does not work for me with GCC 5.4.0 and the built
libraries use the 'internal' names.

On the other hand, GCC does not have any restrictions on redefining
builtins. So instead of trying to figure out how to make the #pragma
work, it is simpler to make the rename conditional to clang.


Repository:
  rL LLVM

https://reviews.llvm.org/D30025

Files:
  lib/builtins/atomic.c


Index: lib/builtins/atomic.c
===
--- lib/builtins/atomic.c
+++ lib/builtins/atomic.c
@@ -30,12 +30,17 @@
 
 #include "assembly.h"
 
+#ifdef __clang__
 // Clang objects if you redefine a builtin.  This little hack allows us to
 // define a function with the same name as an intrinsic.
-#pragma redefine_extname __atomic_load_c SYMBOL_NAME(__atomic_load)
-#pragma redefine_extname __atomic_store_c SYMBOL_NAME(__atomic_store)
-#pragma redefine_extname __atomic_exchange_c SYMBOL_NAME(__atomic_exchange)
-#pragma redefine_extname __atomic_compare_exchange_c 
SYMBOL_NAME(__atomic_compare_exchange)
+#define ATOMIC_IMPL_SYMBOL(x) x##_c
+#pragma redefine_extname ATOMIC_IMPL_SYMBOL(__atomic_load) 
SYMBOL_NAME(__atomic_load)
+#pragma redefine_extname ATOMIC_IMPL_SYMBOL(__atomic_store) 
SYMBOL_NAME(__atomic_store)
+#pragma redefine_extname ATOMIC_IMPL_SYMBOL(__atomic_exchange) 
SYMBOL_NAME(__atomic_exchange)
+#pragma redefine_extname ATOMIC_IMPL_SYMBOL(__atomic_compare_exchange) 
SYMBOL_NAME(__atomic_compare_exchange)
+#else
+#define ATOMIC_IMPL_SYMBOL(x) SYMBOL_NAME(x)
+#endif
 
 /// Number of locks.  This allocates one page on 32-bit platforms, two on
 /// 64-bit.  This can be specified externally if a different trade between
@@ -159,7 +164,7 @@
 
 /// An atomic load operation.  This is atomic with respect to the source
 /// pointer only.
-void __atomic_load_c(int size, void *src, void *dest, int model) {
+void ATOMIC_IMPL_SYMBOL(__atomic_load)(int size, void *src, void *dest, int 
model) {
 #define LOCK_FREE_ACTION(type) \
 *((type*)dest) = __c11_atomic_load((_Atomic(type)*)src, model);\
 return;
@@ -173,7 +178,7 @@
 
 /// An atomic store operation.  This is atomic with respect to the destination
 /// pointer only.
-void __atomic_store_c(int size, void *dest, void *src, int model) {
+void ATOMIC_IMPL_SYMBOL(__atomic_store)(int size, void *dest, void *src, int 
model) {
 #define LOCK_FREE_ACTION(type) \
 __c11_atomic_store((_Atomic(type)*)dest, *(type*)dest, model);\
 return;
@@ -190,7 +195,7 @@
 /// they  are not, then this stores the current value from *ptr in *expected.
 ///
 /// This function returns 1 if the exchange takes place or 0 if it fails. 
-int __atomic_compare_exchange_c(int size, void *ptr, void *expected,
+int ATOMIC_IMPL_SYMBOL(__atomic_compare_exchange)(int size, void *ptr, void 
*expected,
 void *desired, int success, int failure) {
 #define LOCK_FREE_ACTION(type) \
   return __c11_atomic_compare_exchange_strong((_Atomic(type)*)ptr, 
(type*)expected,\
@@ -211,7 +216,7 @@
 
 /// Performs an atomic exchange operation between two pointers.  This is atomic
 /// with respect to the target address.
-void __atomic_exchange_c(int size, void *ptr, void *val, void *old, int model) 
{
+void ATOMIC_IMPL_SYMBOL(__atomic_exchange)(int size, void *ptr, void *val, 
void *old, int model) {
 #define LOCK_FREE_ACTION(type) \
 *(type*)old = __c11_atomic_exchange((_Atomic(type)*)ptr, *(type*)val,\
 model);\


Index: lib/builtins/atomic.c
===
--- lib/builtins/atomic.c
+++ lib/builtins/atomic.c
@@ -30,12 +30,17 @@
 
 #include "assembly.h"
 
+#ifdef __clang__
 // Clang objects if you redefine a builtin.  This little hack allows us to
 // define a function with the same name as an intrinsic.
-#pragma redefine_extname __atomic_load_c SYMBOL_NAME(__atomic_load)
-#pragma redefine_extname __atomic_store_c SYMBOL_NAME(__atomic_store)
-#pragma redefine_extname __atomic_exchange_c SYMBOL_NAME(__atomic_exchange)
-#pragma redefine_extname __atomic_compare_exchange_c SYMBOL_NAME(__atomic_compare_exchange)
+#define ATOMIC_IMPL_SYMBOL(x) x##_c
+#pragma redefine_extname ATOMIC_IMPL_SYMBOL(__atomic_load) SYMBOL_NAME(__atomic_load)
+#pragma redefine_extname ATOMIC_IMPL_SYMBOL(__atomic_store) SYMBOL_NAME(__atomic_store)
+#pragma redefine_extname ATOMIC_IMPL_SYMBOL(__atomic_exchange) SYMBOL_NAME(__atomic_exchange)
+#pragma redefine_extname ATOMIC_IMPL_SYMBOL(__atomic_compare_exchange) SYMBOL_NAME(__atomic_compare_exchange)
+#else
+#define ATOMIC_IMPL_SYMBOL(x) SYMBOL_NAME(x)
+#endif
 
 /// Number of locks.  This allocates one page on 32-bit platforms, two on
 /// 64-bit.  This can be specified externally if a different trade 

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

2017-02-16 Thread Michał Górny via Phabricator via cfe-commits
mgorny added inline comments.



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

Don't you also need rpath for it? Or is this purely for static runtime?


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 Michał Górny via Phabricator via cfe-commits
mgorny added inline comments.



Comment at: lib/Driver/ToolChain.cpp:327
+  llvm::sys::path::append(Path, "lib", OSLibName,
+  getArchName());
+  return Path.str();

I would suggest using arch type, to avoid e.g. i386/i486/i586 mess. It's really 
hard to clean it up afterwards, see D26796.


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] D30155: [clang-tools-extra] [test] Fix clang library dir in LD_LIBRARY_PATH For stand-alone build

2017-02-19 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added a project: clang-tools-extra.

Prepend the clang library directory (determined using SHLIBDIR, alike
in clang) to the LD_LIBRARY_PATH to ensure that just-built clang
libraries will be used instead of a previous installed version.

When a stand-alone build is performed, LLVM_LIBS_DIR contains the path
to installed LLVM library directory. The same directory frequently
contains a previously installed version of clang. SHLIBDIR, on the other
hand, is always the build-tree directory, and therefore contains
the freshly built clang libraries.

In a non-stand-alone build, both paths will be the same and therefore
including them both will not cause any issues.


Repository:
  rL LLVM

https://reviews.llvm.org/D30155

Files:
  test/Unit/lit.cfg
  test/lit.cfg
  test/lit.site.cfg.in


Index: test/lit.site.cfg.in
===
--- test/lit.site.cfg.in
+++ test/lit.site.cfg.in
@@ -7,6 +7,7 @@
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@"
 config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
+config.clang_libs_dir = "@SHLIBDIR@"
 config.python_executable = "@PYTHON_EXECUTABLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 
Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -99,10 +99,13 @@
 clang_tools_dir, llvm_tools_dir, config.environment['PATH']))
 config.environment['PATH'] = path
 
+clang_libs_dir = getattr(config, 'clang_libs_dir', None)
+if not clang_libs_dir:
+lit_config.fatal('No Clang libs dir set!')
 llvm_libs_dir = getattr(config, 'llvm_libs_dir', None)
 if not llvm_libs_dir:
 lit_config.fatal('No LLVM libs dir set!')
-path = os.path.pathsep.join((llvm_libs_dir,
+path = os.path.pathsep.join((clang_libs_dir, llvm_libs_dir,
  config.environment.get('LD_LIBRARY_PATH','')))
 config.environment['LD_LIBRARY_PATH'] = path
 
Index: test/Unit/lit.cfg
===
--- test/Unit/lit.cfg
+++ test/Unit/lit.cfg
@@ -41,14 +41,17 @@
 shlibpath_var = 'PATH'
 
 # Point the dynamic loader at dynamic libraries in 'lib'.
+shlibdir = getattr(config, 'shlibdir', None)
+if not shlibdir:
+lit_config.fatal('No shlibdir set!')
 llvm_libs_dir = getattr(config, 'llvm_libs_dir', None)
 if not llvm_libs_dir:
 lit_config.fatal('No LLVM libs dir set!')
-shlibpath = os.path.pathsep.join((llvm_libs_dir,
+shlibpath = os.path.pathsep.join((shlibdir, llvm_libs_dir,
  config.environment.get(shlibpath_var,'')))
 
 # Win32 seeks DLLs along %PATH%.
-if sys.platform in ['win32', 'cygwin'] and os.path.isdir(config.shlibdir):
-shlibpath = os.path.pathsep.join((config.shlibdir, shlibpath))
+if sys.platform in ['win32', 'cygwin'] and os.path.isdir(shlibdir):
+shlibpath = os.path.pathsep.join((shlibdir, shlibpath))
 
 config.environment[shlibpath_var] = shlibpath


Index: test/lit.site.cfg.in
===
--- test/lit.site.cfg.in
+++ test/lit.site.cfg.in
@@ -7,6 +7,7 @@
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@"
 config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
+config.clang_libs_dir = "@SHLIBDIR@"
 config.python_executable = "@PYTHON_EXECUTABLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 
Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -99,10 +99,13 @@
 clang_tools_dir, llvm_tools_dir, config.environment['PATH']))
 config.environment['PATH'] = path
 
+clang_libs_dir = getattr(config, 'clang_libs_dir', None)
+if not clang_libs_dir:
+lit_config.fatal('No Clang libs dir set!')
 llvm_libs_dir = getattr(config, 'llvm_libs_dir', None)
 if not llvm_libs_dir:
 lit_config.fatal('No LLVM libs dir set!')
-path = os.path.pathsep.join((llvm_libs_dir,
+path = os.path.pathsep.join((clang_libs_dir, llvm_libs_dir,
  config.environment.get('LD_LIBRARY_PATH','')))
 config.environment['LD_LIBRARY_PATH'] = path
 
Index: test/Unit/lit.cfg
===
--- test/Unit/lit.cfg
+++ test/Unit/lit.cfg
@@ -41,14 +41,17 @@
 shlibpath_var = 'PATH'
 
 # Point the dynamic loader at dynamic libraries in 'lib'.
+shlibdir = getattr(config, 'shlibdir', None)
+if not shlibdir:
+lit_config.fatal('No shlibdir set!')
 llvm_libs_dir = getattr(config, 'llvm_libs_dir', None)
 if not llvm_libs_dir:
 lit_config.fatal('No LLVM libs dir set!')
-shlibpath = os.path.pathsep.join((llvm_libs_dir,
+shlibpath = os.path.pathsep.join((shlibdir, llvm_libs_dir,
  config.environment.get(shlibpath_var,'')))
 
 # Win32 

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

2017-02-16 Thread Michał Górny via Phabricator via cfe-commits
mgorny added inline comments.



Comment at: test/Driver/arch-specific-libdir.c:6
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR %s
+//

Please be more specific in the tests, i.e. check if the correct arch dir is 
selected. Also add a test for i386-* triple, and make sure that both i386-* and 
i686-* give the same result.


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 Michał Górny via Phabricator via cfe-commits
mgorny accepted this revision.
mgorny added a comment.

LGTM modulo the test match split. But please wait for someone who has been 
longer here to confirm.




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:
> 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.


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 Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Thanks. The -L tests look good, -rpath is not perfect but I don't think you can 
improve it without additional changes to the Driver.




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

Hahnfeld wrote:
> pirama wrote:
> > 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.
> Instead of `REQUIRES`, you should probably add `-target x86_64-unknown-linux`
Hmm, I don't see any good solution for this. Looking at the code, the host 
triple is hardcoded, so you'd indeed have to either restrict the test to 
triples matching LLVM_HOST_TRIPLE. Or maybe add a command-line option to 
override the host triple.


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] D29542: [TargetInfo] Adjust x86-32 atomic support to the CPU used

2017-02-23 Thread Michał Górny via Phabricator via cfe-commits
mgorny added inline comments.



Comment at: test/CodeGen/atomic-ops.c:1
-// RUN: %clang_cc1 %s -emit-llvm -o - -ffreestanding -ffake-address-space-map 
-triple=i686-apple-darwin9 | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -ffreestanding -ffake-address-space-map 
-triple=i686-apple-darwin9 -target-cpu i686 | FileCheck %s
 // REQUIRES: x86-registered-target

hans wrote:
> Naive question: why is the i686- part of the triple not sufficient here; why 
> is -target-cpu needed?
It's because triple is not really meaningful on most of the systems (e.g. many 
Linux distros use i386, *BSD use i486), and the default CPU logic is applied in 
the Driver, while cc1 is called directly here.


https://reviews.llvm.org/D29542



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


[PATCH] D30025: [compiler-rt] [builtins] Fix building atomic.c with GCC

2017-02-24 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a reviewer: doug.gregor.
mgorny added a subscriber: doug.gregor.
mgorny added a comment.

If I read the git correctly, the change that forbid defining builtins was 
initially made in https://reviews.llvm.org/rL64639. @doug.gregor, any chance 
you could help us over here? Is clang supposed to unconditionally reject those 
definitions, and are we supposed to always work-around it in compiler-rt, or 
should we consider adding some additional switch to allow them in clang?


Repository:
  rL LLVM

https://reviews.llvm.org/D30025



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


[PATCH] D29851: [clang-tools-extra] [test] Fix test dependencies when using installed tools

2017-02-10 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added a project: clang-tools-extra.

Use the LLVM_UTILS_PROVIDED variable to determine whether test tool
dependencies should be exposed for clang-tools-extra tests. If clang is
being built stand-alone and LLVM test tools (FileCheck, count and not)
are installed, the top-level CMakeLists.txt of clang sets this variable
to indicate that they will not be built as a part of this build,
and therefore no dependencies should be emitted for them. This fixes
the dependency errors when building clang stand-alone with tests
enabled.


Repository:
  rL LLVM

https://reviews.llvm.org/D29851

Files:
  test/CMakeLists.txt


Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -31,9 +31,6 @@
 endif()
 
 set(CLANG_TOOLS_TEST_DEPS
-  # Base line deps.
-  FileCheck count not
-
   # clang-tidy tests require it.
   clang-headers
 
@@ -58,6 +55,13 @@
   ExtraToolsUnitTests
   )
 
+if(NOT LLVM_UTILS_PROVIDED)
+  list(APPEND CLANG_TOOLS_TEST_DEPS
+# Base line deps.
+FileCheck count not
+)
+endif()
+
 add_lit_testsuite(check-clang-tools "Running the Clang extra tools' regression 
tests"
   ${CMAKE_CURRENT_BINARY_DIR}
   DEPENDS ${CLANG_TOOLS_TEST_DEPS}


Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -31,9 +31,6 @@
 endif()
 
 set(CLANG_TOOLS_TEST_DEPS
-  # Base line deps.
-  FileCheck count not
-
   # clang-tidy tests require it.
   clang-headers
 
@@ -58,6 +55,13 @@
   ExtraToolsUnitTests
   )
 
+if(NOT LLVM_UTILS_PROVIDED)
+  list(APPEND CLANG_TOOLS_TEST_DEPS
+# Base line deps.
+FileCheck count not
+)
+endif()
+
 add_lit_testsuite(check-clang-tools "Running the Clang extra tools' regression tests"
   ${CMAKE_CURRENT_BINARY_DIR}
   DEPENDS ${CLANG_TOOLS_TEST_DEPS}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28862: [compiler-rt] [test] Use approximate comparison on float types

2017-02-15 Thread Michał Górny via Phabricator via cfe-commits
mgorny abandoned this revision.
mgorny added a comment.

I've opened http://bugs.llvm.org/show_bug.cgi?id=31964 to track this further. I 
don't really have time to look into it in more detail at the moment.


Repository:
  rL LLVM

https://reviews.llvm.org/D28862



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


[PATCH] D29542: [TargetInfo] Adjust x86-32 atomic support to the CPU used

2017-02-13 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Le gentle ping.


https://reviews.llvm.org/D29542



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


[PATCH] D30025: [compiler-rt] [builtins] Fix building atomic.c with GCC

2017-02-16 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

In https://reviews.llvm.org/D30025#678462, @theraven wrote:

> This code is working around something that's probably a clang bug.  It would 
> be better to fix the clang bug than add more complex workarounds.


Well, clang explicitly rejects those functions as errors, so I would guess it 
does that by design.


Repository:
  rL LLVM

https://reviews.llvm.org/D30025



___
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 Michał Górny via Phabricator via cfe-commits
mgorny added inline comments.



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

pirama wrote:
> 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.
@cbergstrom says: 'let them know that your comments are equivalent (or better) 
than mine'. But yeah, PathScale's adding rpaths for the libraries on our end, 
so this is consistent with what we do.


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] D28849: [compiler-rt] [test] Fix page address logic in clear_cache_test to use binary negation

2017-01-18 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
Herald added a subscriber: dberris.

Fix the logic used to calculate page address in clear_cache_test to use
the binary negation of 4095 rather than arithmetic. The latter gives
incorrect result since:

  -4095 -> 0xf001
  ~4095 -> 0xf000

Alternatively, -4096 could be used to obtain the correct result.
However, considering the confusion caused by this so far I think it's
better to use binary negation explicitly.

The issue went unnoticed so far because the array alignment caused
the last bit not to be set. However, on 32-bit x86 no such alignment is
enforced and the wrong page address caused the test to fail.


Repository:
  rL LLVM

https://reviews.llvm.org/D28849

Files:
  test/builtins/Unit/clear_cache_test.c


Index: test/builtins/Unit/clear_cache_test.c
===
--- test/builtins/Unit/clear_cache_test.c
+++ test/builtins/Unit/clear_cache_test.c
@@ -56,8 +56,8 @@
 int main()
 {
 // make executable the page containing execution_buffer 
-char* start = (char*)((uintptr_t)execution_buffer & (-4095));
-char* end = (char*)((uintptr_t)(_buffer[128+4096]) & (-4095));
+char* start = (char*)((uintptr_t)execution_buffer & (~4095));
+char* end = (char*)((uintptr_t)(_buffer[128+4096]) & (~4095));
 #if defined(_WIN32)
 DWORD dummy_oldProt;
 MEMORY_BASIC_INFORMATION b;


Index: test/builtins/Unit/clear_cache_test.c
===
--- test/builtins/Unit/clear_cache_test.c
+++ test/builtins/Unit/clear_cache_test.c
@@ -56,8 +56,8 @@
 int main()
 {
 // make executable the page containing execution_buffer 
-char* start = (char*)((uintptr_t)execution_buffer & (-4095));
-char* end = (char*)((uintptr_t)(_buffer[128+4096]) & (-4095));
+char* start = (char*)((uintptr_t)execution_buffer & (~4095));
+char* end = (char*)((uintptr_t)(_buffer[128+4096]) & (~4095));
 #if defined(_WIN32)
 DWORD dummy_oldProt;
 MEMORY_BASIC_INFORMATION b;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28849: [compiler-rt] [test] Fix page address logic in clear_cache_test

2017-01-19 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 84947.
mgorny retitled this revision from "[compiler-rt] [test] Fix page address logic 
in clear_cache_test to use binary negation" to "[compiler-rt] [test] Fix page 
address logic in clear_cache_test".
mgorny edited the summary of this revision.
mgorny added a comment.

Updated to use page size logic on POSIX and Windows systems. I haven't tested 
the latter, though.


https://reviews.llvm.org/D28849

Files:
  test/builtins/Unit/clear_cache_test.c


Index: test/builtins/Unit/clear_cache_test.c
===
--- test/builtins/Unit/clear_cache_test.c
+++ test/builtins/Unit/clear_cache_test.c
@@ -18,9 +18,20 @@
 if (!FlushInstructionCache(GetCurrentProcess(), start, end-start))
 exit(1);
 }
+
+static uintptr_t get_page_size() {
+SYSTEM_INFO si;
+GetSystemInfo();
+return si.dwPageSize;
+}
 #else
+#include 
 #include 
 extern void __clear_cache(void* start, void* end);
+
+static uintptr_t get_page_size() {
+return sysconf(_SC_PAGE_SIZE);
+}
 #endif
 
 
@@ -56,8 +67,8 @@
 int main()
 {
 // make executable the page containing execution_buffer 
-char* start = (char*)((uintptr_t)execution_buffer & (-4095));
-char* end = (char*)((uintptr_t)(_buffer[128+4096]) & (-4095));
+char* start = (char*)((uintptr_t)execution_buffer & (-get_page_size()));
+char* end = (char*)((uintptr_t)(_buffer[128+4096]) & 
(-get_page_size()));
 #if defined(_WIN32)
 DWORD dummy_oldProt;
 MEMORY_BASIC_INFORMATION b;


Index: test/builtins/Unit/clear_cache_test.c
===
--- test/builtins/Unit/clear_cache_test.c
+++ test/builtins/Unit/clear_cache_test.c
@@ -18,9 +18,20 @@
 if (!FlushInstructionCache(GetCurrentProcess(), start, end-start))
 exit(1);
 }
+
+static uintptr_t get_page_size() {
+SYSTEM_INFO si;
+GetSystemInfo();
+return si.dwPageSize;
+}
 #else
+#include 
 #include 
 extern void __clear_cache(void* start, void* end);
+
+static uintptr_t get_page_size() {
+return sysconf(_SC_PAGE_SIZE);
+}
 #endif
 
 
@@ -56,8 +67,8 @@
 int main()
 {
 // make executable the page containing execution_buffer 
-char* start = (char*)((uintptr_t)execution_buffer & (-4095));
-char* end = (char*)((uintptr_t)(_buffer[128+4096]) & (-4095));
+char* start = (char*)((uintptr_t)execution_buffer & (-get_page_size()));
+char* end = (char*)((uintptr_t)(_buffer[128+4096]) & (-get_page_size()));
 #if defined(_WIN32)
 DWORD dummy_oldProt;
 MEMORY_BASIC_INFORMATION b;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28862: [compiler-rt] [test] Use approximate comparison on float types

2017-01-19 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Just to be clear, the values also differ per -O0 vs -O2. I'm not sure if we can 
even reliably figure that out.

I've tried to work around the issue by building everything in 387 mode. 
However, in that case muldc3_test has even larger mismatches and didn't really 
want to go figuring that out.


Repository:
  rL LLVM

https://reviews.llvm.org/D28862



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


[PATCH] D28146: [compiler-rt] [test] [builtins] Remove obsolete/UB tests in __fixuns?fdi based

2017-01-17 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL292257: [test] [builtins] Remove obsolete/UB tests in 
__fixuns?fdi based (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D28146?vs=82625=84737#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28146

Files:
  compiler-rt/trunk/test/builtins/Unit/fixunsdfdi_test.c
  compiler-rt/trunk/test/builtins/Unit/fixunssfdi_test.c


Index: compiler-rt/trunk/test/builtins/Unit/fixunsdfdi_test.c
===
--- compiler-rt/trunk/test/builtins/Unit/fixunsdfdi_test.c
+++ compiler-rt/trunk/test/builtins/Unit/fixunsdfdi_test.c
@@ -95,9 +95,6 @@
 if (test__fixunsdfdi(0x1.Ep+62, 0x7800LL))
 return 1;
 
-if (test__fixunsdfdi(0x1.p+64, 0xLL))
-return 1;
-
 #if !TARGET_LIBGCC
 if (test__fixunsdfdi(-0x1.Fp+62, 0))
 return 1;
Index: compiler-rt/trunk/test/builtins/Unit/fixunssfdi_test.c
===
--- compiler-rt/trunk/test/builtins/Unit/fixunssfdi_test.c
+++ compiler-rt/trunk/test/builtins/Unit/fixunssfdi_test.c
@@ -79,8 +79,6 @@
 return 1;
 if (test__fixunssfdi(0x1.00p+63F, 0x8000LL))
 return 1;
-if (test__fixunssfdi(0x1.00p+64F, 0xLL))
-return 1;
 if (test__fixunssfdi(0x1.FEp+62F, 0x7F80LL))
 return 1;
 if (test__fixunssfdi(0x1.FCp+62F, 0x7F00LL))


Index: compiler-rt/trunk/test/builtins/Unit/fixunsdfdi_test.c
===
--- compiler-rt/trunk/test/builtins/Unit/fixunsdfdi_test.c
+++ compiler-rt/trunk/test/builtins/Unit/fixunsdfdi_test.c
@@ -95,9 +95,6 @@
 if (test__fixunsdfdi(0x1.Ep+62, 0x7800LL))
 return 1;
 
-if (test__fixunsdfdi(0x1.p+64, 0xLL))
-return 1;
-
 #if !TARGET_LIBGCC
 if (test__fixunsdfdi(-0x1.Fp+62, 0))
 return 1;
Index: compiler-rt/trunk/test/builtins/Unit/fixunssfdi_test.c
===
--- compiler-rt/trunk/test/builtins/Unit/fixunssfdi_test.c
+++ compiler-rt/trunk/test/builtins/Unit/fixunssfdi_test.c
@@ -79,8 +79,6 @@
 return 1;
 if (test__fixunssfdi(0x1.00p+63F, 0x8000LL))
 return 1;
-if (test__fixunssfdi(0x1.00p+64F, 0xLL))
-return 1;
 if (test__fixunssfdi(0x1.FEp+62F, 0x7F80LL))
 return 1;
 if (test__fixunssfdi(0x1.FCp+62F, 0x7F00LL))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28862: [compiler-rt] [test] Use approximate comparison on float types

2017-01-18 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
Herald added a subscriber: dberris.

Use approximate comparison between the result of __divsc3()
and the canonical value calculated, to allow the possible difference of
1 representable value resulting from optimization.

For example, the value of (0.01+j0.01) / (-0.50-j2.00))
computed the canonical way without specific machine flags is:

  z = -0x1.3bce70p-21 + j0x1.7af7bcp-22

However, if -march=i386 -mfpmath=387 is used, it becomes:

  z = -0x1.3bce72p-21 + j0x1.7af7bcp-22

While this difference is insignificant, it may cause the exact
comparison used in tests to fail. Allowing the difference of one
representable value seems to be a reasonable compromise.


Repository:
  rL LLVM

https://reviews.llvm.org/D28862

Files:
  test/builtins/Unit/divsc3_test.c


Index: test/builtins/Unit/divsc3_test.c
===
--- test/builtins/Unit/divsc3_test.c
+++ test/builtins/Unit/divsc3_test.c
@@ -14,6 +14,7 @@
 #include "int_lib.h"
 #include 
 #include 
+#include 
 #include 
 
 // Returns: the quotient of (a + ib) / (c + id)
@@ -47,6 +48,25 @@
 return non_zero;
 }
 
+// check for equality assuming that both real and imaginary parts
+// can differ by exactly 1 representable value, in order to handle
+// different levels of accuracy on 32-bit x86
+static bool approx_equal(float _Complex a, float _Complex b) {
+if (a != b) {
+float ra = __real__ a;
+float ia = __imag__ a;
+float rb = __real__ b;
+float ib = __imag__ b;
+
+if (ra != rb && nextafterf(ra, rb) != rb)
+return false;
+if (ia != ib && nextafterf(ia, ib) != ib)
+return false;
+}
+
+return true;
+}
+
 int test__divsc3(float a, float b, float c, float d)
 {
 float _Complex r = __divsc3(a, b, c, d);
@@ -100,7 +120,7 @@
 {
 float _Complex z = (a * c + b * d) / (c * c + d * d)
  + (b * c - a * d) / (c * c + d * d) * _Complex_I;
-if (r != z)
+if (!approx_equal(r, z))
 return 1;
 }
 break;


Index: test/builtins/Unit/divsc3_test.c
===
--- test/builtins/Unit/divsc3_test.c
+++ test/builtins/Unit/divsc3_test.c
@@ -14,6 +14,7 @@
 #include "int_lib.h"
 #include 
 #include 
+#include 
 #include 
 
 // Returns: the quotient of (a + ib) / (c + id)
@@ -47,6 +48,25 @@
 return non_zero;
 }
 
+// check for equality assuming that both real and imaginary parts
+// can differ by exactly 1 representable value, in order to handle
+// different levels of accuracy on 32-bit x86
+static bool approx_equal(float _Complex a, float _Complex b) {
+if (a != b) {
+float ra = __real__ a;
+float ia = __imag__ a;
+float rb = __real__ b;
+float ib = __imag__ b;
+
+if (ra != rb && nextafterf(ra, rb) != rb)
+return false;
+if (ia != ib && nextafterf(ia, ib) != ib)
+return false;
+}
+
+return true;
+}
+
 int test__divsc3(float a, float b, float c, float d)
 {
 float _Complex r = __divsc3(a, b, c, d);
@@ -100,7 +120,7 @@
 {
 float _Complex z = (a * c + b * d) / (c * c + d * d)
  + (b * c - a * d) / (c * c + d * d) * _Complex_I;
-if (r != z)
+if (!approx_equal(r, z))
 return 1;
 }
 break;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26887: [Driver] Fix finding multilib gcc install on Gentoo (with gcc-config)

2016-11-28 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Ping.


https://reviews.llvm.org/D26887



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


[PATCH] D25686: [Driver] Support "hardfloat" vendor triples used by Gentoo

2016-11-28 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Second ping. @hfinkel, could you suggest me how to proceed with this?


https://reviews.llvm.org/D25686



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


[PATCH] D26764: [compiler-rt] [cmake] Remove i686 target that is duplicate to i386

2016-11-28 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Ping.


https://reviews.llvm.org/D26764



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


[PATCH] D26796: [Driver] Use arch type to find compiler-rt libraries (on Linux)

2016-11-28 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Ping.


https://reviews.llvm.org/D26796



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


[PATCH] D25949: [Driver] Refactor distro detection & classification as a separate API

2016-11-28 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL288060: [Driver] Refactor distro detection & classification 
as a separate API (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D25949?vs=78462=79442#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25949

Files:
  cfe/trunk/include/clang/Driver/Distro.h
  cfe/trunk/lib/Driver/CMakeLists.txt
  cfe/trunk/lib/Driver/Distro.cpp
  cfe/trunk/lib/Driver/ToolChains.cpp

Index: cfe/trunk/include/clang/Driver/Distro.h
===
--- cfe/trunk/include/clang/Driver/Distro.h
+++ cfe/trunk/include/clang/Driver/Distro.h
@@ -0,0 +1,122 @@
+//===--- Distro.h - Linux distribution detection support *- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_DRIVER_DISTRO_H
+#define LLVM_CLANG_DRIVER_DISTRO_H
+
+#include "clang/Basic/VirtualFileSystem.h"
+
+namespace clang {
+namespace driver {
+
+/// Distro - Helper class for detecting and classifying Linux distributions.
+///
+/// This class encapsulates the clang Linux distribution detection mechanism
+/// as well as helper functions that match the specific (versioned) results
+/// into wider distribution classes.
+class Distro {
+public:
+  enum DistroType {
+// NB: Releases of a particular Linux distro should be kept together
+// in this enum, because some tests are done by integer comparison against
+// the first and last known member in the family, e.g. IsRedHat().
+ArchLinux,
+DebianLenny,
+DebianSqueeze,
+DebianWheezy,
+DebianJessie,
+DebianStretch,
+Exherbo,
+RHEL5,
+RHEL6,
+RHEL7,
+Fedora,
+OpenSUSE,
+UbuntuHardy,
+UbuntuIntrepid,
+UbuntuJaunty,
+UbuntuKarmic,
+UbuntuLucid,
+UbuntuMaverick,
+UbuntuNatty,
+UbuntuOneiric,
+UbuntuPrecise,
+UbuntuQuantal,
+UbuntuRaring,
+UbuntuSaucy,
+UbuntuTrusty,
+UbuntuUtopic,
+UbuntuVivid,
+UbuntuWily,
+UbuntuXenial,
+UbuntuYakkety,
+UbuntuZesty,
+UnknownDistro
+  };
+
+private:
+  /// The distribution, possibly with specific version.
+  DistroType DistroVal;
+
+public:
+  /// @name Constructors
+  /// @{
+
+  /// Default constructor leaves the distribution unknown.
+  Distro() : DistroVal() {}
+
+  /// Constructs a Distro type for specific distribution.
+  Distro(DistroType D) : DistroVal(D) {}
+
+  /// Detects the distribution using specified VFS.
+  explicit Distro(clang::vfs::FileSystem& VFS);
+
+  bool operator==(const Distro ) const {
+return DistroVal == Other.DistroVal;
+  }
+
+  bool operator!=(const Distro ) const {
+return DistroVal != Other.DistroVal;
+  }
+
+  bool operator>=(const Distro ) const {
+return DistroVal >= Other.DistroVal;
+  }
+
+  bool operator<=(const Distro ) const {
+return DistroVal <= Other.DistroVal;
+  }
+
+  /// @}
+  /// @name Convenience Predicates
+  /// @{
+
+  bool IsRedhat() const {
+return DistroVal == Fedora || (DistroVal >= RHEL5 && DistroVal <= RHEL7);
+  }
+
+  bool IsOpenSUSE() const {
+return DistroVal == OpenSUSE;
+  }
+
+  bool IsDebian() const {
+return DistroVal >= DebianLenny && DistroVal <= DebianStretch;
+  }
+
+  bool IsUbuntu() const {
+return DistroVal >= UbuntuHardy && DistroVal <= UbuntuZesty;
+  }
+ 
+  /// @}
+};
+
+} // end namespace driver
+} // end namespace clang
+
+#endif
Index: cfe/trunk/lib/Driver/CMakeLists.txt
===
--- cfe/trunk/lib/Driver/CMakeLists.txt
+++ cfe/trunk/lib/Driver/CMakeLists.txt
@@ -12,6 +12,7 @@
   Action.cpp
   Compilation.cpp
   CrossWindowsToolChain.cpp
+  Distro.cpp
   Driver.cpp
   DriverOptions.cpp
   Job.cpp
Index: cfe/trunk/lib/Driver/Distro.cpp
===
--- cfe/trunk/lib/Driver/Distro.cpp
+++ cfe/trunk/lib/Driver/Distro.cpp
@@ -0,0 +1,131 @@
+//===--- Distro.cpp - Linux distribution detection support --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/Driver/Distro.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/MemoryBuffer.h"
+
+using namespace clang::driver;
+using namespace clang;
+
+static Distro::DistroType DetectDistro(vfs::FileSystem ) {
+  llvm::ErrorOr File =
+  VFS.getBufferForFile("/etc/lsb-release");
+  if (File) {
+

[PATCH] D25869: [Driver] Add unit tests for Distro detection

2016-11-28 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL288062: [Driver] Add unit tests for Distro detection 
(authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D25869?vs=78625=79444#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25869

Files:
  cfe/trunk/unittests/Driver/CMakeLists.txt
  cfe/trunk/unittests/Driver/DistroTest.cpp

Index: cfe/trunk/unittests/Driver/DistroTest.cpp
===
--- cfe/trunk/unittests/Driver/DistroTest.cpp
+++ cfe/trunk/unittests/Driver/DistroTest.cpp
@@ -0,0 +1,305 @@
+//===- unittests/Driver/DistroTest.cpp --- ToolChains tests ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Unit tests for Distro detection.
+//
+//===--===//
+
+#include "clang/Driver/Distro.h"
+#include "clang/Basic/VirtualFileSystem.h"
+#include "llvm/Support/raw_ostream.h"
+#include "gtest/gtest.h"
+using namespace clang;
+using namespace clang::driver;
+
+namespace {
+
+// The tests include all release-related files for each distribution
+// in the VFS, in order to make sure that earlier tests do not
+// accidentally result in incorrect distribution guess.
+
+TEST(DistroTest, DetectUbuntu) {
+  vfs::InMemoryFileSystem UbuntuTrustyFileSystem;
+  // Ubuntu uses Debian Sid version.
+  UbuntuTrustyFileSystem.addFile("/etc/debian_version", 0,
+  llvm::MemoryBuffer::getMemBuffer("jessie/sid\n"));
+  UbuntuTrustyFileSystem.addFile("/etc/lsb-release", 0,
+  llvm::MemoryBuffer::getMemBuffer("DISTRIB_ID=Ubuntu\n"
+   "DISTRIB_RELEASE=14.04\n"
+   "DISTRIB_CODENAME=trusty\n"
+   "DISTRIB_DESCRIPTION=\"Ubuntu 14.04 LTS\"\n"));
+  UbuntuTrustyFileSystem.addFile("/etc/os-release", 0,
+  llvm::MemoryBuffer::getMemBuffer("NAME=\"Ubuntu\"\n"
+   "VERSION=\"14.04, Trusty Tahr\"\n"
+   "ID=ubuntu\n"
+   "ID_LIKE=debian\n"
+   "PRETTY_NAME=\"Ubuntu 14.04 LTS\"\n"
+   "VERSION_ID=\"14.04\"\n"
+   "HOME_URL=\"http://www.ubuntu.com/\"\n;
+   "SUPPORT_URL=\"http://help.ubuntu.com/\"\n;
+   "BUG_REPORT_URL=\"http://bugs.launchpad.net/ubuntu/\"\n;));
+
+  Distro UbuntuTrusty{UbuntuTrustyFileSystem};
+  ASSERT_EQ(Distro(Distro::UbuntuTrusty), UbuntuTrusty);
+  ASSERT_TRUE(UbuntuTrusty.IsUbuntu());
+  ASSERT_FALSE(UbuntuTrusty.IsRedhat());
+  ASSERT_FALSE(UbuntuTrusty.IsOpenSUSE());
+  ASSERT_FALSE(UbuntuTrusty.IsDebian());
+
+  vfs::InMemoryFileSystem UbuntuYakketyFileSystem;
+  UbuntuYakketyFileSystem.addFile("/etc/debian_version", 0,
+  llvm::MemoryBuffer::getMemBuffer("stretch/sid\n"));
+  UbuntuYakketyFileSystem.addFile("/etc/lsb-release", 0,
+  llvm::MemoryBuffer::getMemBuffer("DISTRIB_ID=Ubuntu\n"
+   "DISTRIB_RELEASE=16.10\n"
+   "DISTRIB_CODENAME=yakkety\n"
+   "DISTRIB_DESCRIPTION=\"Ubuntu 16.10\"\n"));
+  UbuntuYakketyFileSystem.addFile("/etc/os-release", 0,
+  llvm::MemoryBuffer::getMemBuffer("NAME=\"Ubuntu\"\n"
+   "VERSION=\"16.10 (Yakkety Yak)\"\n"
+   "ID=ubuntu\n"
+   "ID_LIKE=debian\n"
+   "PRETTY_NAME=\"Ubuntu 16.10\"\n"
+   "VERSION_ID=\"16.10\"\n"
+   "HOME_URL=\"http://www.ubuntu.com/\"\n;
+   "SUPPORT_URL=\"http://help.ubuntu.com/\"\n;
+   "BUG_REPORT_URL=\"http://bugs.launchpad.net/ubuntu/\"\n;
+   "PRIVACY_POLICY_URL=\"http://www.ubuntu.com/legal/terms-and-policies/privacy-policy\"\n;
+   "VERSION_CODENAME=yakkety\n"
+   "UBUNTU_CODENAME=yakkety\n"));
+
+  Distro UbuntuYakkety{UbuntuYakketyFileSystem};
+  ASSERT_EQ(Distro(Distro::UbuntuYakkety), UbuntuYakkety);
+  ASSERT_TRUE(UbuntuYakkety.IsUbuntu());
+  ASSERT_FALSE(UbuntuYakkety.IsRedhat());
+  ASSERT_FALSE(UbuntuYakkety.IsOpenSUSE());
+  ASSERT_FALSE(UbuntuYakkety.IsDebian());
+}
+
+TEST(DistroTest, DetectRedhat) {
+  vfs::InMemoryFileSystem Fedora25FileSystem;
+  Fedora25FileSystem.addFile("/etc/system-release-cpe", 

[PATCH] D26764: [compiler-rt] [cmake] Remove i686 target that is duplicate to i386

2016-11-28 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

In https://reviews.llvm.org/D26764#606638, @beanz wrote:

> Looping in @eugenis, who added i686 support in r218761.
>
> eugenis, since i686 is identical to i386 generating it as a separate target 
> is undesirable. Can you help advise as to how we can better meet your needs 
> and not duplicate an effectively identical target?


I suspect https://reviews.llvm.org/D26796 attempts to solve the same problem.


https://reviews.llvm.org/D26764



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


[PATCH] D25686: [Driver] Improve support for Gentoo arm*-hardfloat-*-*eabi triples

2016-12-06 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

In https://reviews.llvm.org/D25686#614420, @rengolin wrote:

> I think this patch should move to canonicalise the triple as per all the 
> others, in the right place (vendor/environment).
>
> If you find `hardfloat` or on where the vendor should be, and there are no 
> other possible vendors, just append `hf` to the environment and mark the 
> vendor as `unknown`. This works already with `gnueabihf`, `eabihf` and 
> `muslabihf` (doubts about this last one).
>
> What the clang driver accepts is different than what the rest of the compiler 
> should use.


Ok but I think that then clang will not be able to find the gcc directory. Am I 
missing something obvious?


https://reviews.llvm.org/D25686



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


[PATCH] D27812: [test] Extend llvm_shlib_dir fix to unittests

2016-12-15 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: chapuni, gribozavr, ddunbar, beanz.
mgorny added a subscriber: cfe-commits.

Extend the fix from https://reviews.llvm.org/rL286952 to unittests. The fix 
added clang built
library directories (via llvm_shlib_dir) to LD_LIBRARY_PATH.
The previous logic has used llvm_libs_dir only which points to installed
LLVM when doing stand-alone builds.

The patch also removes the redundant win32 code that is no longer
necessary now that shlibdir is used unconditionally.


https://reviews.llvm.org/D27812

Files:
  test/Unit/lit.cfg


Index: test/Unit/lit.cfg
===
--- test/Unit/lit.cfg
+++ test/Unit/lit.cfg
@@ -94,15 +94,16 @@
 elif platform.system() == 'Windows':
 shlibpath_var = 'PATH'
 
+# in stand-alone builds, shlibdir is clang's build tree
+# while llvm_libs_dir is installed LLVM (and possibly older clang)
+llvm_shlib_dir = getattr(config, 'shlibdir', None)
+if not llvm_shlib_dir:
+lit_config.fatal('No shlibdir set!')
 # Point the dynamic loader at dynamic libraries in 'lib'.
 llvm_libs_dir = getattr(config, 'llvm_libs_dir', None)
 if not llvm_libs_dir:
 lit_config.fatal('No LLVM libs dir set!')
-shlibpath = os.path.pathsep.join((llvm_libs_dir,
+shlibpath = os.path.pathsep.join((llvm_shlib_dir, llvm_libs_dir,
  config.environment.get(shlibpath_var,'')))
 
-# Win32 seeks DLLs along %PATH%.
-if sys.platform in ['win32', 'cygwin'] and os.path.isdir(config.shlibdir):
-shlibpath = os.path.pathsep.join((config.shlibdir, shlibpath))
-
 config.environment[shlibpath_var] = shlibpath


Index: test/Unit/lit.cfg
===
--- test/Unit/lit.cfg
+++ test/Unit/lit.cfg
@@ -94,15 +94,16 @@
 elif platform.system() == 'Windows':
 shlibpath_var = 'PATH'
 
+# in stand-alone builds, shlibdir is clang's build tree
+# while llvm_libs_dir is installed LLVM (and possibly older clang)
+llvm_shlib_dir = getattr(config, 'shlibdir', None)
+if not llvm_shlib_dir:
+lit_config.fatal('No shlibdir set!')
 # Point the dynamic loader at dynamic libraries in 'lib'.
 llvm_libs_dir = getattr(config, 'llvm_libs_dir', None)
 if not llvm_libs_dir:
 lit_config.fatal('No LLVM libs dir set!')
-shlibpath = os.path.pathsep.join((llvm_libs_dir,
+shlibpath = os.path.pathsep.join((llvm_shlib_dir, llvm_libs_dir,
  config.environment.get(shlibpath_var,'')))
 
-# Win32 seeks DLLs along %PATH%.
-if sys.platform in ['win32', 'cygwin'] and os.path.isdir(config.shlibdir):
-shlibpath = os.path.pathsep.join((config.shlibdir, shlibpath))
-
 config.environment[shlibpath_var] = shlibpath
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27812: [test] Extend llvm_shlib_dir fix to unittests

2016-12-15 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289865: [test] Extend llvm_shlib_dir fix to unittests 
(authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D27812?vs=81587=81635#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27812

Files:
  cfe/trunk/test/Unit/lit.cfg


Index: cfe/trunk/test/Unit/lit.cfg
===
--- cfe/trunk/test/Unit/lit.cfg
+++ cfe/trunk/test/Unit/lit.cfg
@@ -94,15 +94,16 @@
 elif platform.system() == 'Windows':
 shlibpath_var = 'PATH'
 
+# in stand-alone builds, shlibdir is clang's build tree
+# while llvm_libs_dir is installed LLVM (and possibly older clang)
+llvm_shlib_dir = getattr(config, 'shlibdir', None)
+if not llvm_shlib_dir:
+lit_config.fatal('No shlibdir set!')
 # Point the dynamic loader at dynamic libraries in 'lib'.
 llvm_libs_dir = getattr(config, 'llvm_libs_dir', None)
 if not llvm_libs_dir:
 lit_config.fatal('No LLVM libs dir set!')
-shlibpath = os.path.pathsep.join((llvm_libs_dir,
+shlibpath = os.path.pathsep.join((llvm_shlib_dir, llvm_libs_dir,
  config.environment.get(shlibpath_var,'')))
 
-# Win32 seeks DLLs along %PATH%.
-if sys.platform in ['win32', 'cygwin'] and os.path.isdir(config.shlibdir):
-shlibpath = os.path.pathsep.join((config.shlibdir, shlibpath))
-
 config.environment[shlibpath_var] = shlibpath


Index: cfe/trunk/test/Unit/lit.cfg
===
--- cfe/trunk/test/Unit/lit.cfg
+++ cfe/trunk/test/Unit/lit.cfg
@@ -94,15 +94,16 @@
 elif platform.system() == 'Windows':
 shlibpath_var = 'PATH'
 
+# in stand-alone builds, shlibdir is clang's build tree
+# while llvm_libs_dir is installed LLVM (and possibly older clang)
+llvm_shlib_dir = getattr(config, 'shlibdir', None)
+if not llvm_shlib_dir:
+lit_config.fatal('No shlibdir set!')
 # Point the dynamic loader at dynamic libraries in 'lib'.
 llvm_libs_dir = getattr(config, 'llvm_libs_dir', None)
 if not llvm_libs_dir:
 lit_config.fatal('No LLVM libs dir set!')
-shlibpath = os.path.pathsep.join((llvm_libs_dir,
+shlibpath = os.path.pathsep.join((llvm_shlib_dir, llvm_libs_dir,
  config.environment.get(shlibpath_var,'')))
 
-# Win32 seeks DLLs along %PATH%.
-if sys.platform in ['win32', 'cygwin'] and os.path.isdir(config.shlibdir):
-shlibpath = os.path.pathsep.join((config.shlibdir, shlibpath))
-
 config.environment[shlibpath_var] = shlibpath
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26887: [Driver] Fix finding multilib gcc install on Gentoo (with gcc-config)

2016-12-12 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Thanks for the review. Committed now.


https://reviews.llvm.org/D26887



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


[PATCH] D26887: [Driver] Fix finding multilib gcc install on Gentoo (with gcc-config)

2016-12-12 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289436: [Driver] Fix finding multilib gcc install on Gentoo 
(with gcc-config) (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D26887?vs=78623=81086#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26887

Files:
  cfe/trunk/lib/Driver/ToolChains.cpp
  cfe/trunk/lib/Driver/ToolChains.h
  
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/32/crtbegin.o
  
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/x32/crtbegin.o
  
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/32/crtbegin.o
  
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/x32/crtbegin.o
  cfe/trunk/test/Driver/linux-header-search.cpp
  cfe/trunk/test/Driver/linux-ld.c

Index: cfe/trunk/lib/Driver/ToolChains.h
===
--- cfe/trunk/lib/Driver/ToolChains.h
+++ cfe/trunk/lib/Driver/ToolChains.h
@@ -196,6 +196,11 @@
  SmallVectorImpl ,
  SmallVectorImpl );
 
+bool ScanGCCForMultilibs(const llvm::Triple ,
+ const llvm::opt::ArgList ,
+ StringRef Path,
+ bool NeedsBiarchSuffix = false);
+
 void ScanLibDirForGCCTriple(const llvm::Triple ,
 const llvm::opt::ArgList ,
 const std::string ,
@@ -207,6 +212,11 @@
const std::string ,
StringRef CandidateTriple,
bool NeedsBiarchSuffix = false);
+
+bool ScanGentooGccConfig(const llvm::Triple ,
+ const llvm::opt::ArgList ,
+ StringRef CandidateTriple,
+ bool NeedsBiarchSuffix = false);
   };
 
 protected:
Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -1457,35 +1457,17 @@
   // in /usr. This avoids accidentally enforcing the system GCC version
   // when using a custom toolchain.
   if (GCCToolchainDir == "" || GCCToolchainDir == D.SysRoot + "/usr") {
+for (StringRef CandidateTriple : ExtraTripleAliases) {
+  if (ScanGentooGccConfig(TargetTriple, Args, CandidateTriple))
+return;
+}
 for (StringRef CandidateTriple : CandidateTripleAliases) {
-  llvm::ErrorOr File =
-  D.getVFS().getBufferForFile(D.SysRoot + "/etc/env.d/gcc/config-" +
-  CandidateTriple.str());
-  if (File) {
-SmallVector Lines;
-File.get()->getBuffer().split(Lines, "\n");
-for (StringRef Line : Lines) {
-  // CURRENT=triple-version
-  if (Line.consume_front("CURRENT=")) {
-const std::pair ActiveVersion =
-  Line.rsplit('-');
-// Note: Strictly speaking, we should be reading
-// /etc/env.d/gcc/${CURRENT} now. However, the file doesn't
-// contain anything new or especially useful to us.
-const std::string GentooPath = D.SysRoot + "/usr/lib/gcc/" +
-   ActiveVersion.first.str() + "/" +
-   ActiveVersion.second.str();
-if (D.getVFS().exists(GentooPath + "/crtbegin.o")) {
-  Version = GCCVersion::Parse(ActiveVersion.second);
-  GCCInstallPath = GentooPath;
-  GCCParentLibPath = GentooPath + "/../../..";
-  GCCTriple.setTriple(ActiveVersion.first);
-  IsValid = true;
-  return;
-}
-  }
-}
-  }
+  if (ScanGentooGccConfig(TargetTriple, Args, CandidateTriple))
+return;
+}
+for (StringRef CandidateTriple : CandidateBiarchTripleAliases) {
+  if (ScanGentooGccConfig(TargetTriple, Args, CandidateTriple, true))
+return;
 }
   }
 
@@ -2716,6 +2698,33 @@
   }
 }
 
+bool Generic_GCC::GCCInstallationDetector::ScanGCCForMultilibs(
+const llvm::Triple , const ArgList ,
+StringRef Path, bool NeedsBiarchSuffix) {
+  llvm::Triple::ArchType TargetArch = TargetTriple.getArch();
+  DetectedMultilibs Detected;
+
+  // Android standalone toolchain could have multilibs for ARM and Thumb.
+  // Debian mips multilibs behave more like the rest of the biarch ones,
+  // so handle them there
+  if (isArmOrThumbArch(TargetArch) && TargetTriple.isAndroid()) {
+// It should also work without multilibs in a simplified toolchain.
+findAndroidArmMultilibs(D, 

[PATCH] D25686: [Driver] Improve support for Gentoo arm*-hardfloat-*-*eabi triples

2016-12-12 Thread Michał Górny via Phabricator via cfe-commits
mgorny abandoned this revision.
mgorny added a comment.

I give up. I'm just going to complain to Gentoo ARM people a lot and maybe 
they'll fix their triples.


https://reviews.llvm.org/D25686



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


[PATCH] D25314: [libcxxabi] [cmake] Handle missing LIBUNWIND_* directories gracefully

2017-01-14 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Second ping.


https://reviews.llvm.org/D25314



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


[PATCH] D28529: [test] Port clang tests to canonicalized booleans

2017-01-10 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added a reviewer: beanz.
mgorny added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

Use the new llvm_canonicalize_cmake_booleans() function to canonicalize
booleans for lit tests. Replace the duplicate ENABLE_CLANG* variables
used to hold canonicalized values with in-place canonicalization. Use
implicit logic in Python code to avoid overrelying on exact 0/1 values.


https://reviews.llvm.org/D28529

Files:
  CMakeLists.txt
  test/ARCMT/lit.local.cfg
  test/Analysis/lit.local.cfg
  test/CMakeLists.txt
  test/Rewriter/lit.local.cfg
  test/Tooling/lit.local.cfg
  test/lit.cfg
  test/lit.site.cfg.in

Index: test/lit.site.cfg.in
===
--- test/lit.site.cfg.in
+++ test/lit.site.cfg.in
@@ -14,13 +14,13 @@
 config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
-config.have_zlib = "@HAVE_LIBZ@"
-config.clang_arcmt = @ENABLE_CLANG_ARCMT@
+config.have_zlib = @HAVE_LIBZ@
+config.clang_arcmt = @CLANG_ENABLE_ARCMT@
 config.clang_default_cxx_stdlib = "@CLANG_DEFAULT_CXX_STDLIB@"
-config.clang_staticanalyzer = @ENABLE_CLANG_STATIC_ANALYZER@
-config.clang_examples = @ENABLE_CLANG_EXAMPLES@
+config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@
+config.clang_examples = @CLANG_BUILD_EXAMPLES@
 config.enable_shared = @ENABLE_SHARED@
-config.enable_backtrace = "@ENABLE_BACKTRACES@"
+config.enable_backtrace = @ENABLE_BACKTRACES@
 config.host_arch = "@HOST_ARCH@"
 
 # Support substitution of the tools and libs dirs with user parameters. This is
Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -202,7 +202,7 @@
 # Plugins (loadable modules)
 # TODO: This should be supplied by Makefile or autoconf.
 if sys.platform in ['win32', 'cygwin']:
-has_plugins = (config.enable_shared == 1)
+has_plugins = config.enable_shared
 else:
 has_plugins = True
 
@@ -353,7 +353,7 @@
 config.available_features.add('default-cxx-stdlib-set')
 
 # Enabled/disabled features
-if config.clang_staticanalyzer != 0:
+if config.clang_staticanalyzer:
 config.available_features.add("staticanalyzer")
 
 # As of 2011.08, crash-recovery tests still do not pass on FreeBSD.
@@ -474,10 +474,10 @@
 else:
 config.available_features.add("not_ubsan")
 
-if config.enable_backtrace == "1":
+if config.enable_backtrace:
 config.available_features.add("backtrace")
 
-if config.have_zlib == "1":
+if config.have_zlib:
 config.available_features.add("zlib")
 else:
 config.available_features.add("nozlib")
Index: test/Tooling/lit.local.cfg
===
--- test/Tooling/lit.local.cfg
+++ test/Tooling/lit.local.cfg
@@ -1,2 +1,2 @@
-if config.root.clang_staticanalyzer == 0:
+if not config.root.clang_staticanalyzer:
 config.unsupported = True
Index: test/Rewriter/lit.local.cfg
===
--- test/Rewriter/lit.local.cfg
+++ test/Rewriter/lit.local.cfg
@@ -1,3 +1,3 @@
 # The Objective-C rewriters are currently grouped with ARCMT.
-if config.root.clang_arcmt == 0:
+if not config.root.clang_arcmt:
 config.unsupported = True
Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -18,6 +18,12 @@
   endif()
 endif()
 
+llvm_canonicalize_cmake_booleans(
+  CLANG_BUILD_EXAMPLES
+  CLANG_ENABLE_ARCMT
+  CLANG_ENABLE_STATIC_ANALYZER
+  ENABLE_BACKTRACES)
+
 configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
@@ -55,15 +61,15 @@
   )
 endif ()
 
-if (ENABLE_CLANG_EXAMPLES)
+if (CLANG_BUILD_EXAMPLES)
   list(APPEND CLANG_TEST_DEPS
 AnnotateFunctions
 clang-interpreter
 PrintFunctionNames
 )
 endif ()
 
-if (ENABLE_CLANG_STATIC_ANALYZER AND ENABLE_CLANG_EXAMPLES)
+if (CLANG_ENABLE_STATIC_ANALYZER AND CLANG_BUILD_EXAMPLES)
   list(APPEND CLANG_TEST_DEPS
 SampleAnalyzerPlugin
 )
Index: test/Analysis/lit.local.cfg
===
--- test/Analysis/lit.local.cfg
+++ test/Analysis/lit.local.cfg
@@ -1,2 +1,2 @@
-if config.root.clang_staticanalyzer == 0:
+if not config.root.clang_staticanalyzer:
 config.unsupported = True
Index: test/ARCMT/lit.local.cfg
===
--- test/ARCMT/lit.local.cfg
+++ test/ARCMT/lit.local.cfg
@@ -1,2 +1,2 @@
-if config.root.clang_arcmt == 0:
+if not config.root.clang_arcmt:
 config.unsupported = True
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -364,18 +364,7 @@
   "Build the Clang tools. If OFF, just generate build targets." ON)
 
 option(CLANG_ENABLE_ARCMT "Build ARCMT." 

[PATCH] D26900: [cmake] Obtain LLVM_CMAKE_PATH from llvm-config if available

2017-01-09 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL291495: [cmake] Obtain LLVM_CMAKE_PATH from llvm-config 
(authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D26900?vs=83527=83718#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26900

Files:
  cfe/trunk/CMakeLists.txt


Index: cfe/trunk/CMakeLists.txt
===
--- cfe/trunk/CMakeLists.txt
+++ cfe/trunk/CMakeLists.txt
@@ -16,7 +16,8 @@
   "--libdir"
   "--includedir"
   "--prefix"
-  "--src-root")
+  "--src-root"
+  "--cmakedir")
 execute_process(
   COMMAND ${CONFIG_COMMAND}
   RESULT_VARIABLE HAD_ERROR
@@ -41,6 +42,7 @@
   list(GET CONFIG_OUTPUT 3 INCLUDE_DIR)
   list(GET CONFIG_OUTPUT 4 LLVM_OBJ_ROOT)
   list(GET CONFIG_OUTPUT 5 MAIN_SRC_DIR)
+  list(GET CONFIG_OUTPUT 6 LLVM_CMAKE_PATH)
 
   if(NOT MSVC_IDE)
 set(LLVM_ENABLE_ASSERTIONS ${ENABLE_ASSERTIONS}
@@ -58,7 +60,6 @@
   find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR}
 NO_DEFAULT_PATH)
 
-  set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
   set(LLVMCONFIG_FILE "${LLVM_CMAKE_PATH}/LLVMConfig.cmake")
   if(EXISTS ${LLVMCONFIG_FILE})
 list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}")


Index: cfe/trunk/CMakeLists.txt
===
--- cfe/trunk/CMakeLists.txt
+++ cfe/trunk/CMakeLists.txt
@@ -16,7 +16,8 @@
   "--libdir"
   "--includedir"
   "--prefix"
-  "--src-root")
+  "--src-root"
+  "--cmakedir")
 execute_process(
   COMMAND ${CONFIG_COMMAND}
   RESULT_VARIABLE HAD_ERROR
@@ -41,6 +42,7 @@
   list(GET CONFIG_OUTPUT 3 INCLUDE_DIR)
   list(GET CONFIG_OUTPUT 4 LLVM_OBJ_ROOT)
   list(GET CONFIG_OUTPUT 5 MAIN_SRC_DIR)
+  list(GET CONFIG_OUTPUT 6 LLVM_CMAKE_PATH)
 
   if(NOT MSVC_IDE)
 set(LLVM_ENABLE_ASSERTIONS ${ENABLE_ASSERTIONS}
@@ -58,7 +60,6 @@
   find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR}
 NO_DEFAULT_PATH)
 
-  set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
   set(LLVMCONFIG_FILE "${LLVM_CMAKE_PATH}/LLVMConfig.cmake")
   if(EXISTS ${LLVMCONFIG_FILE})
 list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26900: [cmake] Obtain LLVM_CMAKE_PATH from llvm-config if available

2017-01-09 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

As discussed on IRC, I will commit the unconditional versions for projects that 
require the same version of LLVM (clang, lldb, lld) and the version with 
fallback for others (runtimes).


https://reviews.llvm.org/D26900



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


[PATCH] D28213: [Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin

2017-01-09 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL291477: [Frontend] Correct values of ATOMIC_*_LOCK_FREE to 
match builtin (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D28213?vs=82791=83677#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28213

Files:
  cfe/trunk/lib/Frontend/InitPreprocessor.cpp
  cfe/trunk/test/Sema/atomic-ops.c


Index: cfe/trunk/test/Sema/atomic-ops.c
===
--- cfe/trunk/test/Sema/atomic-ops.c
+++ cfe/trunk/test/Sema/atomic-ops.c
@@ -14,11 +14,7 @@
 _Static_assert(__GCC_ATOMIC_SHORT_LOCK_FREE == 2, "");
 _Static_assert(__GCC_ATOMIC_INT_LOCK_FREE == 2, "");
 _Static_assert(__GCC_ATOMIC_LONG_LOCK_FREE == 2, "");
-#ifdef __i386__
-_Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 1, "");
-#else
 _Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 2, "");
-#endif
 _Static_assert(__GCC_ATOMIC_POINTER_LOCK_FREE == 2, "");
 
 _Static_assert(__c11_atomic_is_lock_free(1), "");
Index: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
===
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp
@@ -286,12 +286,12 @@
 
 /// Get the value the ATOMIC_*_LOCK_FREE macro should have for a type with
 /// the specified properties.
-static const char *getLockFreeValue(unsigned TypeWidth, unsigned TypeAlign,
-unsigned InlineWidth) {
+static const char *getLockFreeValue(unsigned TypeWidth, unsigned InlineWidth) {
   // Fully-aligned, power-of-2 sizes no larger than the inline
   // width will be inlined as lock-free operations.
-  if (TypeWidth == TypeAlign && (TypeWidth & (TypeWidth - 1)) == 0 &&
-  TypeWidth <= InlineWidth)
+  // Note: we do not need to check alignment since _Atomic(T) is always
+  // appropriately-aligned in clang.
+  if ((TypeWidth & (TypeWidth - 1)) == 0 && TypeWidth <= InlineWidth)
 return "2"; // "always lock free"
   // We cannot be certain what operations the lib calls might be
   // able to implement as lock-free on future processors.
@@ -881,7 +881,6 @@
 #define DEFINE_LOCK_FREE_MACRO(TYPE, Type) \
 Builder.defineMacro("__GCC_ATOMIC_" #TYPE "_LOCK_FREE", \
 getLockFreeValue(TI.get##Type##Width(), \
- TI.get##Type##Align(), \
  InlineWidthBits));
 DEFINE_LOCK_FREE_MACRO(BOOL, Bool);
 DEFINE_LOCK_FREE_MACRO(CHAR, Char);
@@ -894,7 +893,6 @@
 DEFINE_LOCK_FREE_MACRO(LLONG, LongLong);
 Builder.defineMacro("__GCC_ATOMIC_POINTER_LOCK_FREE",
 getLockFreeValue(TI.getPointerWidth(0),
- TI.getPointerAlign(0),
  InlineWidthBits));
 #undef DEFINE_LOCK_FREE_MACRO
   }


Index: cfe/trunk/test/Sema/atomic-ops.c
===
--- cfe/trunk/test/Sema/atomic-ops.c
+++ cfe/trunk/test/Sema/atomic-ops.c
@@ -14,11 +14,7 @@
 _Static_assert(__GCC_ATOMIC_SHORT_LOCK_FREE == 2, "");
 _Static_assert(__GCC_ATOMIC_INT_LOCK_FREE == 2, "");
 _Static_assert(__GCC_ATOMIC_LONG_LOCK_FREE == 2, "");
-#ifdef __i386__
-_Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 1, "");
-#else
 _Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 2, "");
-#endif
 _Static_assert(__GCC_ATOMIC_POINTER_LOCK_FREE == 2, "");
 
 _Static_assert(__c11_atomic_is_lock_free(1), "");
Index: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
===
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp
@@ -286,12 +286,12 @@
 
 /// Get the value the ATOMIC_*_LOCK_FREE macro should have for a type with
 /// the specified properties.
-static const char *getLockFreeValue(unsigned TypeWidth, unsigned TypeAlign,
-unsigned InlineWidth) {
+static const char *getLockFreeValue(unsigned TypeWidth, unsigned InlineWidth) {
   // Fully-aligned, power-of-2 sizes no larger than the inline
   // width will be inlined as lock-free operations.
-  if (TypeWidth == TypeAlign && (TypeWidth & (TypeWidth - 1)) == 0 &&
-  TypeWidth <= InlineWidth)
+  // Note: we do not need to check alignment since _Atomic(T) is always
+  // appropriately-aligned in clang.
+  if ((TypeWidth & (TypeWidth - 1)) == 0 && TypeWidth <= InlineWidth)
 return "2"; // "always lock free"
   // We cannot be certain what operations the lib calls might be
   // able to implement as lock-free on future processors.
@@ -881,7 +881,6 @@
 #define DEFINE_LOCK_FREE_MACRO(TYPE, Type) \
 Builder.defineMacro("__GCC_ATOMIC_" #TYPE "_LOCK_FREE", \
 getLockFreeValue(TI.get##Type##Width(), \
- TI.get##Type##Align(), \
  

[PATCH] D25314: [libcxxabi] [cmake] Handle missing LIBUNWIND_* directories gracefully

2017-01-14 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL292018: [cmake] Handle missing LIBUNWIND_* directories 
gracefully (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D25314?vs=73770=84455#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25314

Files:
  libcxxabi/trunk/CMakeLists.txt


Index: libcxxabi/trunk/CMakeLists.txt
===
--- libcxxabi/trunk/CMakeLists.txt
+++ libcxxabi/trunk/CMakeLists.txt
@@ -479,8 +479,12 @@
 set(LIBCXXABI_LIBUNWIND_SOURCES "")
   endif()
 
-  include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}")
-  include_directories("${LIBCXXABI_LIBUNWIND_SOURCES}")
+  if (NOT LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL STREQUAL 
"LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL-NOTFOUND")
+include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}")
+  endif()
+  if (NOT LIBCXXABI_LIBUNWIND_SOURCES STREQUAL "")
+include_directories("${LIBCXXABI_LIBUNWIND_SOURCES}")
+  endif()
 endif()
 
 # Add source code. This also contains all of the logic for deciding linker 
flags


Index: libcxxabi/trunk/CMakeLists.txt
===
--- libcxxabi/trunk/CMakeLists.txt
+++ libcxxabi/trunk/CMakeLists.txt
@@ -479,8 +479,12 @@
 set(LIBCXXABI_LIBUNWIND_SOURCES "")
   endif()
 
-  include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}")
-  include_directories("${LIBCXXABI_LIBUNWIND_SOURCES}")
+  if (NOT LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL STREQUAL "LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL-NOTFOUND")
+include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}")
+  endif()
+  if (NOT LIBCXXABI_LIBUNWIND_SOURCES STREQUAL "")
+include_directories("${LIBCXXABI_LIBUNWIND_SOURCES}")
+  endif()
 endif()
 
 # Add source code. This also contains all of the logic for deciding linker flags
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25686: [Driver] Improve support for Gentoo arm*-hardfloat-*-*eabi triples

2016-12-02 Thread Michał Górny via Phabricator via cfe-commits
mgorny added inline comments.



Comment at: lib/Driver/ToolChains.cpp:1674
   TripleAliases.append(begin(ARMHFTriples), end(ARMHFTriples));
+} else if (TargetTriple.getEnvironment() == llvm::Triple::MuslEABIHF) {
+  TripleAliases.append(begin(ARMHFMuslTriples), end(ARMHFMuslTriples));

rengolin wrote:
> You're not testing this...
Well, I presumed I don't have to test every single possible triple. But sure, I 
can add a test for that.



Comment at: test/Driver/linux-ld.c:1016
+// CHECK-LD-GENTOO-ARMHF: "-dynamic-linker" "/lib/ld-linux-armhf.so.3"
+// CHECK-LD-GENTOO-ARMHF: 
"{{.*}}/usr/lib/gcc/armv7a-hardfloat-linux-gnueabi/4.9.3/crtbegin.o"
+// CHECK-LD-GENTOO-ARMHF: 
"-L[[SYSROOT]]/usr/lib/gcc/armv7a-hardfloat-linux-gnueabi/4.9.3"

rengolin wrote:
> where is 4.9.3 coming from?
It's the version used in the input tree, i.e. the two added files above.


https://reviews.llvm.org/D25686



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


[PATCH] D25686: [Driver] Improve support for Gentoo arm*-hardfloat-*-*eabi triples

2016-12-02 Thread Michał Górny via Phabricator via cfe-commits
mgorny retitled this revision from "[Driver] Support "hardfloat" vendor triples 
used by Gentoo" to "[Driver] Improve support for Gentoo arm*-hardfloat-*-*eabi 
triples".
mgorny updated the summary for this revision.
mgorny added a reviewer: atanasyan.
mgorny updated this revision to Diff 80118.

https://reviews.llvm.org/D25686

Files:
  lib/Driver/ToolChains.cpp
  
test/Driver/Inputs/gentoo_linux_gcc_armhf_tree/usr/armv7a-hardfloat-linux-gnueabi/lib/.keep
  test/Driver/Inputs/gentoo_linux_gcc_armhf_tree/usr/include/.keep
  
test/Driver/Inputs/gentoo_linux_gcc_armhf_tree/usr/lib/gcc/armv7a-hardfloat-linux-gnueabi/4.9.3/crtbegin.o
  
test/Driver/Inputs/gentoo_linux_gcc_armhf_tree/usr/lib/gcc/armv7a-hardfloat-linux-gnueabi/4.9.3/include/g++-v4.9.3/.keep
  test/Driver/linux-ld.c


Index: test/Driver/linux-ld.c
===
--- test/Driver/linux-ld.c
+++ test/Driver/linux-ld.c
@@ -1002,6 +1002,32 @@
 // CHECK-DEBIAN-SPARC64: 
"[[SYSROOT]]/usr/lib/gcc/sparc64-linux-gnu/4.9{{/|}}crtend.o"
 // CHECK-DEBIAN-SPARC64: 
"[[SYSROOT]]/usr/lib/gcc/sparc64-linux-gnu/4.9/../../../sparc64-linux-gnu{{/|}}crtn.o"
 //
+// Check Gentoo Linux with GCC installed using arm*-hardfloat-linux-gnu* 
triples.
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=armv7a-hardfloat-linux-gnueabi --rtlib=platform \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/gentoo_linux_gcc_armhf_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-GENTOO-ARMHF %s
+// CHECK-LD-GENTOO-ARMHF-NOT: warning:
+// CHECK-LD-GENTOO-ARMHF: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-LD-GENTOO-ARMHF: "--eh-frame-hdr"
+// CHECK-LD-GENTOO-ARMHF: "-m" "armelf_linux_eabi"
+// CHECK-LD-GENTOO-ARMHF: "-dynamic-linker" "/lib/ld-linux-armhf.so.3"
+// CHECK-LD-GENTOO-ARMHF: 
"{{.*}}/usr/lib/gcc/armv7a-hardfloat-linux-gnueabi/4.9.3/crtbegin.o"
+// CHECK-LD-GENTOO-ARMHF: 
"-L[[SYSROOT]]/usr/lib/gcc/armv7a-hardfloat-linux-gnueabi/4.9.3"
+// CHECK-LD-GENTOO-ARMHF: 
"-L[[SYSROOT]]/usr/lib/gcc/armv7a-hardfloat-linux-gnueabi/4.9.3/../../../../armv7a-hardfloat-linux-gnueabi/lib"
+// CHECK-LD-GENTOO-ARMHF: 
"-L[[SYSROOT]]/usr/lib/gcc/armv7a-hardfloat-linux-gnueabi/4.9.3/../../.."
+// CHECK-LD-GENTOO-ARMHF: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
+// CHECK-LD-GENTOO-ARMHF: "-lc"
+// CHECK-LD-GENTOO-ARMHF: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
+//
+// Check whether the standard ARM triples can find Gentoo gcc.
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=armv7a-unknown-linux-gnueabihf --rtlib=platform \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/gentoo_linux_gcc_armhf_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-GENTOO-ARMHF %s
+//
 // Test linker invocation on Android.
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: --target=arm-linux-androideabi -rtlib=platform \
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -1557,14 +1557,21 @@
   static const char *const ARMLibDirs[] = {"/lib"};
   static const char *const ARMTriples[] = {"arm-linux-gnueabi",
"arm-linux-androideabi"};
+  // arm*-hardfloat-* triples are used by Gentoo
   static const char *const ARMHFTriples[] = {"arm-linux-gnueabihf",
+ "armv6j-hardfloat-linux-gnueabi",
+ "armv7a-hardfloat-linux-gnueabi",
  "armv7hl-redhat-linux-gnueabi"};
   static const char *const ARMebLibDirs[] = {"/lib"};
   static const char *const ARMebTriples[] = {"armeb-linux-gnueabi",
  "armeb-linux-androideabi"};
   static const char *const ARMebHFTriples[] = {
   "armeb-linux-gnueabihf", "armebv7hl-redhat-linux-gnueabi"};
 
+  static const char *const ARMHFMuslTriples[] = {
+  "armv6j-hardfloat-linux-musleabi",
+  "armv7a-hardfloat-linux-musleabi"};
+
   static const char *const X86_64LibDirs[] = {"/lib64", "/lib"};
   static const char *const X86_64Triples[] = {
   "x86_64-linux-gnu",   "x86_64-unknown-linux-gnu",
@@ -1664,6 +1671,8 @@
 LibDirs.append(begin(ARMLibDirs), end(ARMLibDirs));
 if (TargetTriple.getEnvironment() == llvm::Triple::GNUEABIHF) {
   TripleAliases.append(begin(ARMHFTriples), end(ARMHFTriples));
+} else if (TargetTriple.getEnvironment() == llvm::Triple::MuslEABIHF) {
+  TripleAliases.append(begin(ARMHFMuslTriples), end(ARMHFMuslTriples));
 } else {
   TripleAliases.append(begin(ARMTriples), end(ARMTriples));
 }


Index: test/Driver/linux-ld.c
===
--- test/Driver/linux-ld.c
+++ test/Driver/linux-ld.c
@@ -1002,6 +1002,32 @@
 // 

[PATCH] D25686: [Driver] Improve support for Gentoo arm*-hardfloat-*-*eabi triples

2016-12-02 Thread Michał Górny via Phabricator via cfe-commits
mgorny added inline comments.



Comment at: test/Driver/linux-ld.c:1016
+// CHECK-LD-GENTOO-ARMHF: "-dynamic-linker" "/lib/ld-linux-armhf.so.3"
+// CHECK-LD-GENTOO-ARMHF: 
"{{.*}}/usr/lib/gcc/armv7a-hardfloat-linux-gnueabi/4.9.3/crtbegin.o"
+// CHECK-LD-GENTOO-ARMHF: 
"-L[[SYSROOT]]/usr/lib/gcc/armv7a-hardfloat-linux-gnueabi/4.9.3"

rengolin wrote:
> mgorny wrote:
> > rengolin wrote:
> > > where is 4.9.3 coming from?
> > It's the version used in the input tree, i.e. the two added files above.
> Right, I mean is this "4.9.3" there because the driver "found" it there, or 
> is it generated by the compiler version you have on your machine, and that's 
> why you created the directory with "4.9.3" in it?
> 
> I'm worried that if it's the latter, the test will fail on any machine that 
> doesn't have that compiler version. But I really don't know how it works, so 
> it was an honest question. :)
It's there because Driver founds it in Input directory structure. I don't have 
that version installed locally, if that's what worries you. You could say it's 
intentionally different from my install but I've simply copied the version used 
by other Gentoo tests.


https://reviews.llvm.org/D25686



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


[PATCH] D25686: [Driver] Improve support for Gentoo arm*-hardfloat-*-*eabi triples

2016-12-06 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

How should I proceed, then? Was something along the lines of the earlier diff a 
better idea?


https://reviews.llvm.org/D25686



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


[PATCH] D28304: [compiler-rt] [cmake] Disable appending -msse* flags implicitly

2017-01-05 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

In https://reviews.llvm.org/D28304#636669, @dvyukov wrote:

> User -march flag won't help as runtime is prebuilt.


I meant the flag used by the compiler vendor when compiler-rt is built.

> SCUDO is sse4.2, but tsan is sse3. Do you actually see any problems with 
> sse3? It's like 10 years old. I agree with you that strictly speaking we do 
> wrong thing for old processors.

Well, it seems that SSE3 is supported since Pentium 4 / newer versions of 
Athlon64. I don't see a big issue enabling it for x86-64 but for 32-bit systems 
you're ruling out quite a lot of hardware. My only pure x86-32 box (which I use 
to test stuff) does not support SSE3.

> But if we disable it, we disable it for everybody.  So if you don't hit 
> cashes with it, I would prefer to keep sse3 in tsan.

Well, I guess that depends on how you build compiler-rt. On Gentoo, we just 
pass user CFLAGS (I need to think more on that, tbh). I would rather see the 
compiler vendor deciding on which CPUs are to be supported by the compiler, 
rather than the build system silently bumping the minimum for one component.

That said, I think we need to work on improved portability of compiler runtimes 
shipped with clang. I will probably start an open discussion on that soonish. 
FWICS we pretty much 'officially' support building just one or two variants of 
compiler-rt for different ABIs of a single architecture. This doesn't scale 
well. While I'm not sure how significant the performance impact is but right 
now we either force compiler-rt to not use newer instructions (= make it 
slower) or randomly cause -march= not to be respected.


https://reviews.llvm.org/D28304



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


[PATCH] D26900: [cmake] Obtain LLVM_CMAKE_PATH from llvm-config

2017-01-06 Thread Michał Górny via Phabricator via cfe-commits
mgorny added reviewers: EricWF, mclow.lists, phosek, compnerd, Hahnfeld.
mgorny added a comment.

Little ping here. This is quite trivial, and since 
https://reviews.llvm.org/D26894 has been committed already I'd like to start 
adding changes like this one to all LLVM projects using llvm-config in 
stand-alone build.


https://reviews.llvm.org/D26900



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


[PATCH] D28304: [compiler-rt] [cmake] Disable appending -msse4.2 flag implicitly

2017-01-05 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

@cryptoad good to go then?


https://reviews.llvm.org/D28304



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


[PATCH] D28304: [compiler-rt] [cmake] Disable appending -msse4.2 flag implicitly

2017-01-05 Thread Michał Górny via Phabricator via cfe-commits
mgorny retitled this revision from "[compiler-rt] [cmake] Disable appending 
-msse* flags implicitly" to "[compiler-rt] [cmake] Disable appending -msse4.2 
flag implicitly".
mgorny updated the summary for this revision.
mgorny updated this revision to Diff 83298.

https://reviews.llvm.org/D28304

Files:
  cmake/config-ix.cmake
  lib/scudo/CMakeLists.txt


Index: lib/scudo/CMakeLists.txt
===
--- lib/scudo/CMakeLists.txt
+++ lib/scudo/CMakeLists.txt
@@ -4,7 +4,6 @@
 
 set(SCUDO_CFLAGS ${SANITIZER_COMMON_CFLAGS})
 append_rtti_flag(OFF SCUDO_CFLAGS)
-append_list_if(COMPILER_RT_HAS_MSSE4_2_FLAG -msse4.2 SCUDO_CFLAGS)
 
 set(SCUDO_SOURCES
   scudo_allocator.cpp
Index: cmake/config-ix.cmake
===
--- cmake/config-ix.cmake
+++ cmake/config-ix.cmake
@@ -29,7 +29,6 @@
 check_cxx_compiler_flag(-ftls-model=initial-exec 
COMPILER_RT_HAS_FTLS_MODEL_INITIAL_EXEC)
 check_cxx_compiler_flag(-fno-lto COMPILER_RT_HAS_FNO_LTO_FLAG)
 check_cxx_compiler_flag("-Werror -msse3" COMPILER_RT_HAS_MSSE3_FLAG)
-check_cxx_compiler_flag("-Werror -msse4.2"   COMPILER_RT_HAS_MSSE4_2_FLAG)
 check_cxx_compiler_flag(--sysroot=.  COMPILER_RT_HAS_SYSROOT_FLAG)
 
 if(NOT WIN32 AND NOT CYGWIN)


Index: lib/scudo/CMakeLists.txt
===
--- lib/scudo/CMakeLists.txt
+++ lib/scudo/CMakeLists.txt
@@ -4,7 +4,6 @@
 
 set(SCUDO_CFLAGS ${SANITIZER_COMMON_CFLAGS})
 append_rtti_flag(OFF SCUDO_CFLAGS)
-append_list_if(COMPILER_RT_HAS_MSSE4_2_FLAG -msse4.2 SCUDO_CFLAGS)
 
 set(SCUDO_SOURCES
   scudo_allocator.cpp
Index: cmake/config-ix.cmake
===
--- cmake/config-ix.cmake
+++ cmake/config-ix.cmake
@@ -29,7 +29,6 @@
 check_cxx_compiler_flag(-ftls-model=initial-exec COMPILER_RT_HAS_FTLS_MODEL_INITIAL_EXEC)
 check_cxx_compiler_flag(-fno-lto COMPILER_RT_HAS_FNO_LTO_FLAG)
 check_cxx_compiler_flag("-Werror -msse3" COMPILER_RT_HAS_MSSE3_FLAG)
-check_cxx_compiler_flag("-Werror -msse4.2"   COMPILER_RT_HAS_MSSE4_2_FLAG)
 check_cxx_compiler_flag(--sysroot=.  COMPILER_RT_HAS_SYSROOT_FLAG)
 
 if(NOT WIN32 AND NOT CYGWIN)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28304: [compiler-rt] [cmake] Disable appending -msse* flags implicitly

2017-01-05 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Oh, sorry that I didn't check that. Then I guess it's good enough for me, we're 
losing just few old Athlon 64 CPUs, I guess. I'll update the patch to remove 
4.2 only.


https://reviews.llvm.org/D28304



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


[PATCH] D27898: [compiler-rt] [builtins] Implement __floattitf() & __floatuntitf()

2017-01-06 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL291259: [builtins] Implement __floattitf() & __floatuntitf() 
(authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D27898?vs=82414=83385#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27898

Files:
  compiler-rt/trunk/lib/builtins/CMakeLists.txt
  compiler-rt/trunk/lib/builtins/floattitf.c
  compiler-rt/trunk/lib/builtins/floatuntitf.c
  compiler-rt/trunk/test/builtins/Unit/floattitf_test.c
  compiler-rt/trunk/test/builtins/Unit/floatuntitf_test.c

Index: compiler-rt/trunk/test/builtins/Unit/floatuntitf_test.c
===
--- compiler-rt/trunk/test/builtins/Unit/floatuntitf_test.c
+++ compiler-rt/trunk/test/builtins/Unit/floatuntitf_test.c
@@ -0,0 +1,220 @@
+//===-- floatuntitf.c - Test __floatuntitf ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file tests __floatuntitf for the compiler_rt library.
+//
+//===--===//
+
+#define QUAD_PRECISION
+#include "fp_lib.h"
+#include "int_lib.h"
+#include 
+#include 
+
+#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT)
+
+/* Returns: convert a tu_int to a fp_t, rounding toward even. */
+
+/* Assumption: fp_t is a IEEE 128 bit floating point type
+ * tu_int is a 128 bit integral type
+ */
+
+/* seee        |         |
+ *         |        
+ */
+
+COMPILER_RT_ABI fp_t __floatuntitf(tu_int a);
+
+int test__floatuntitf(tu_int a, fp_t expected) {
+fp_t x = __floatuntitf(a);
+if (x != expected) {
+utwords at;
+at.all = a;
+printf("error in __floatuntitf(0x%.16llX%.16llX) = %LA, expected %LA\n",
+   at.s.high, at.s.low, x, expected);
+}
+return x != expected;
+}
+
+char assumption_1[sizeof(tu_int) == 2*sizeof(du_int)] = {0};
+char assumption_2[sizeof(tu_int)*CHAR_BIT == 128] = {0};
+char assumption_3[sizeof(fp_t)*CHAR_BIT == 128] = {0};
+
+#endif
+
+int main() {
+#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT)
+if (test__floatuntitf(0, 0.0))
+return 1;
+
+if (test__floatuntitf(1, 1.0))
+return 1;
+if (test__floatuntitf(2, 2.0))
+return 1;
+if (test__floatuntitf(20, 20.0))
+return 1;
+
+if (test__floatuntitf(0x7F80ULL, 0x1.FEp+62))
+return 1;
+if (test__floatuntitf(0x7800ULL, 0x1.Ep+62))
+return 1;
+if (test__floatuntitf(0x7F00ULL, 0x1.FCp+62))
+return 1;
+if (test__floatuntitf(0x7000ULL, 0x1.Cp+62))
+return 1;
+if (test__floatuntitf(0x7FFFULL, 0xF.FFEp+59L))
+return 1;
+if (test__floatuntitf(0xFFFEULL, 0xF.FFEp+60L))
+return 1;
+if (test__floatuntitf(0xULL, 0xF.FFFp+60L))
+return 1;
+
+if (test__floatuntitf(0x8080ULL, 0x8.08p+60))
+return 1;
+if (test__floatuntitf(0x8800ULL, 0x8.8p+60))
+return 1;
+if (test__floatuntitf(0x8100ULL, 0x8.1p+60))
+return 1;
+if (test__floatuntitf(0x80001000ULL, 0x8.0001p+60))
+return 1;
+
+if (test__floatuntitf(0x8000ULL, 0x8p+60))
+return 1;
+if (test__floatuntitf(0x8001ULL, 0x8.001p+60L))
+return 1;
+
+if (test__floatuntitf(0x0007FB72E800LL, 0x1.FEDCBAp+50))
+return 1;
+
+if (test__floatuntitf(0x0007FB72EA00LL, 0x1.FEDCBA8p+50))
+return 1;
+if (test__floatuntitf(0x0007FB72EB00LL, 0x1.FEDCBACp+50))
+return 1;
+if (test__floatuntitf(0x0007FB72EBFFLL, 0x1.FEDCBAFFCp+50))
+return 1;
+if (test__floatuntitf(0x0007FB72EC00LL, 0x1.FEDCBBp+50))
+return 1;
+if (test__floatuntitf(0x0007FB72E801LL, 0x1.FEDCBA004p+50))
+return 1;
+
+if (test__floatuntitf(0x0007FB72E600LL, 0x1.FEDCB98p+50))
+return 1;
+if (test__floatuntitf(0x0007FB72E700LL, 0x1.FEDCB9Cp+50))
+return 1;
+if (test__floatuntitf(0x0007FB72E7FFLL, 0x1.FEDCB9FFCp+50))
+return 1;
+if (test__floatuntitf(0x0007FB72E401LL, 0x1.FEDCB9004p+50))
+return 1;
+if (test__floatuntitf(0x0007FB72E400LL, 0x1.FEDCB9p+50))
+return 1;
+
+if (test__floatuntitf(0x023479FD0E092DC0LL, 0x1.1A3CFE870496Ep+57))
+return 1;
+if 

[PATCH] D26796: [Driver] Use arch type to find compiler-rt libraries (on Linux)

2017-01-06 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

@compnerd, ping. Do you really think this is a real issue? As I said on the 
other patch, the only case when compiler-rt would generate i686-suffixed 
library is if the builder specifically used `-march=i686` for the compiler-rt 
build, and in that case the i386 variant (which is identical to the i686 
variant since both are built with the same flags) is built anyway.


https://reviews.llvm.org/D26796



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


[PATCH] D26900: [cmake] Obtain LLVM_CMAKE_PATH from llvm-config

2017-01-06 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

In https://reviews.llvm.org/D26900#638328, @EricWF wrote:

> Is there a way to write this patch so that old `llvm-config`'s continue to 
> work, at least for a little while until everybody upgrades?


Technically it's possible but I think it would add a lot of complexity. So if 
you believe that to be a major issue, I'd rather just wait a few days before 
applying the change. However, I don't think we really have a big market for 
people doing stand-alone builds ;-).


https://reviews.llvm.org/D26900



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


[PATCH] D28213: [Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin

2017-01-01 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: rsmith, t.p.northover, hfinkel, EricWF.
mgorny added a subscriber: cfe-commits.

Correct the logic used to set `ATOMIC_*_LOCK_FREE` preprocessor macros not
to rely on the ABI alignment of types. Instead, just assume all those
types are aligned correctly by default since clang uses safe alignment
for `_Atomic` types even if the underlying types are aligned to a lower
boundary by default.

For example, the `long long` and `double` types on x86 are aligned to
32-bit boundary by default. However, `_Atomic long long` and `_Atomic
double` are aligned to 64-bit boundary, therefore satisfying
the requirements of lock-free atomic operations.

This fixes PR #19355 by correcting the value of
`__GCC_ATOMIC_LLONG_LOCK_FREE` on x86, and therefore also fixing
the assumption made in libc++ tests. This also fixes PR #30581 by
applying a consistent logic between the functions used to implement
both interfaces.


https://reviews.llvm.org/D28213

Files:
  lib/Frontend/InitPreprocessor.cpp
  test/Sema/atomic-ops.c


Index: test/Sema/atomic-ops.c
===
--- test/Sema/atomic-ops.c
+++ test/Sema/atomic-ops.c
@@ -14,11 +14,7 @@
 _Static_assert(__GCC_ATOMIC_SHORT_LOCK_FREE == 2, "");
 _Static_assert(__GCC_ATOMIC_INT_LOCK_FREE == 2, "");
 _Static_assert(__GCC_ATOMIC_LONG_LOCK_FREE == 2, "");
-#ifdef __i386__
-_Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 1, "");
-#else
 _Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 2, "");
-#endif
 _Static_assert(__GCC_ATOMIC_POINTER_LOCK_FREE == 2, "");
 
 _Static_assert(__c11_atomic_is_lock_free(1), "");
Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -286,12 +286,12 @@
 
 /// Get the value the ATOMIC_*_LOCK_FREE macro should have for a type with
 /// the specified properties.
-static const char *getLockFreeValue(unsigned TypeWidth, unsigned TypeAlign,
-unsigned InlineWidth) {
+static const char *getLockFreeValue(unsigned TypeWidth, unsigned InlineWidth) {
   // Fully-aligned, power-of-2 sizes no larger than the inline
   // width will be inlined as lock-free operations.
-  if (TypeWidth == TypeAlign && (TypeWidth & (TypeWidth - 1)) == 0 &&
-  TypeWidth <= InlineWidth)
+  // Note: we do not need to check alignment since _Atomic(T) is always
+  // appropriately-aligned in clang.
+  if ((TypeWidth & (TypeWidth - 1)) == 0 && TypeWidth <= InlineWidth)
 return "2"; // "always lock free"
   // We cannot be certain what operations the lib calls might be
   // able to implement as lock-free on future processors.
@@ -881,7 +881,6 @@
 #define DEFINE_LOCK_FREE_MACRO(TYPE, Type) \
 Builder.defineMacro("__GCC_ATOMIC_" #TYPE "_LOCK_FREE", \
 getLockFreeValue(TI.get##Type##Width(), \
- TI.get##Type##Align(), \
  InlineWidthBits));
 DEFINE_LOCK_FREE_MACRO(BOOL, Bool);
 DEFINE_LOCK_FREE_MACRO(CHAR, Char);
@@ -894,7 +893,6 @@
 DEFINE_LOCK_FREE_MACRO(LLONG, LongLong);
 Builder.defineMacro("__GCC_ATOMIC_POINTER_LOCK_FREE",
 getLockFreeValue(TI.getPointerWidth(0),
- TI.getPointerAlign(0),
  InlineWidthBits));
 #undef DEFINE_LOCK_FREE_MACRO
   }


Index: test/Sema/atomic-ops.c
===
--- test/Sema/atomic-ops.c
+++ test/Sema/atomic-ops.c
@@ -14,11 +14,7 @@
 _Static_assert(__GCC_ATOMIC_SHORT_LOCK_FREE == 2, "");
 _Static_assert(__GCC_ATOMIC_INT_LOCK_FREE == 2, "");
 _Static_assert(__GCC_ATOMIC_LONG_LOCK_FREE == 2, "");
-#ifdef __i386__
-_Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 1, "");
-#else
 _Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 2, "");
-#endif
 _Static_assert(__GCC_ATOMIC_POINTER_LOCK_FREE == 2, "");
 
 _Static_assert(__c11_atomic_is_lock_free(1), "");
Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -286,12 +286,12 @@
 
 /// Get the value the ATOMIC_*_LOCK_FREE macro should have for a type with
 /// the specified properties.
-static const char *getLockFreeValue(unsigned TypeWidth, unsigned TypeAlign,
-unsigned InlineWidth) {
+static const char *getLockFreeValue(unsigned TypeWidth, unsigned InlineWidth) {
   // Fully-aligned, power-of-2 sizes no larger than the inline
   // width will be inlined as lock-free operations.
-  if (TypeWidth == TypeAlign && (TypeWidth & (TypeWidth - 1)) == 0 &&
-  TypeWidth <= InlineWidth)
+  // Note: we do not need to check alignment since _Atomic(T) is always
+  // appropriately-aligned in clang.
+  if ((TypeWidth & 

[PATCH] D28146: [compiler-rt] [test] [builtins] Remove obsolete/UB tests in __fixuns?fdi based

2016-12-28 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: ddunbar, sdmitrouk, dschuff.
mgorny added a subscriber: cfe-commits.
Herald added subscribers: mehdi_amini, dberris.

Remove the failing tests for __fixunssfdi() and __fixunsdfdi() that
relied on undefined (and most likely obsolete in terms of compiler-rt
implementation behavior).

Both tests presumed that 0x1.p+64 would be converted to
0xLL, that is the largest value in uint64 range.
However, the C/C++ standards do not specify the behavior for converting
a floating-point value to an integer of smaller range, and in this case
both libgcc and compiler-rt implementations return 0 instead.

Since the current behavior is correct with regards to standards
and there is no good way of expressing 0xLL in single-
or double-precision float, I've removed the failing test altogether.


https://reviews.llvm.org/D28146

Files:
  test/builtins/Unit/fixunsdfdi_test.c
  test/builtins/Unit/fixunssfdi_test.c


Index: test/builtins/Unit/fixunssfdi_test.c
===
--- test/builtins/Unit/fixunssfdi_test.c
+++ test/builtins/Unit/fixunssfdi_test.c
@@ -79,8 +79,6 @@
 return 1;
 if (test__fixunssfdi(0x1.00p+63F, 0x8000LL))
 return 1;
-if (test__fixunssfdi(0x1.00p+64F, 0xLL))
-return 1;
 if (test__fixunssfdi(0x1.FEp+62F, 0x7F80LL))
 return 1;
 if (test__fixunssfdi(0x1.FCp+62F, 0x7F00LL))
Index: test/builtins/Unit/fixunsdfdi_test.c
===
--- test/builtins/Unit/fixunsdfdi_test.c
+++ test/builtins/Unit/fixunsdfdi_test.c
@@ -95,9 +95,6 @@
 if (test__fixunsdfdi(0x1.Ep+62, 0x7800LL))
 return 1;
 
-if (test__fixunsdfdi(0x1.p+64, 0xLL))
-return 1;
-
 #if !TARGET_LIBGCC
 if (test__fixunsdfdi(-0x1.Fp+62, 0))
 return 1;


Index: test/builtins/Unit/fixunssfdi_test.c
===
--- test/builtins/Unit/fixunssfdi_test.c
+++ test/builtins/Unit/fixunssfdi_test.c
@@ -79,8 +79,6 @@
 return 1;
 if (test__fixunssfdi(0x1.00p+63F, 0x8000LL))
 return 1;
-if (test__fixunssfdi(0x1.00p+64F, 0xLL))
-return 1;
 if (test__fixunssfdi(0x1.FEp+62F, 0x7F80LL))
 return 1;
 if (test__fixunssfdi(0x1.FCp+62F, 0x7F00LL))
Index: test/builtins/Unit/fixunsdfdi_test.c
===
--- test/builtins/Unit/fixunsdfdi_test.c
+++ test/builtins/Unit/fixunsdfdi_test.c
@@ -95,9 +95,6 @@
 if (test__fixunsdfdi(0x1.Ep+62, 0x7800LL))
 return 1;
 
-if (test__fixunsdfdi(0x1.p+64, 0xLL))
-return 1;
-
 #if !TARGET_LIBGCC
 if (test__fixunsdfdi(-0x1.Fp+62, 0))
 return 1;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26796: [Driver] Use arch type to find compiler-rt libraries (on Linux)

2016-12-30 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

In https://reviews.llvm.org/D26796#632602, @compnerd wrote:

> This would need an upgrade path, since the output name can actually be 
> different from the `AchTypeName` (e.g. i386 vs i686).


I was considering committing this alongside with the i686 removal, and assuming 
that people are going to upgrade clang and compiler-rt in lockstep. Is there 
any other case that needs explicit consideration? Do you have another 
suggestion on handling this?


https://reviews.llvm.org/D26796



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


[PATCH] D28295: [libunwind] [cmake] Support overriding LLVM_CMAKE_PATH

2017-01-04 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: mclow.lists, beanz, phosek, EricWF.
mgorny added a subscriber: cfe-commits.

Make LLVM_CMAKE_PATH a cache variable in order to support user
overrides. This is useful when building multiple multilib variants of
libunwind using CMake files from a single-ABI install of LLVM, e.g. when
LLVM_LIBDIR_SUFFIX == "32" but CMake files are to be found in
/usr/lib64/cmake/llvm. Since libunwind is not using any of the LLVM
build configuration variables (just generic macros), it is fine to use
CMake files from a different ABI.


https://reviews.llvm.org/D28295

Files:
  CMakeLists.txt


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -43,7 +43,8 @@
 set(LLVM_INCLUDE_DIR ${INCLUDE_DIR} CACHE PATH "Path to llvm/include")
 set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree")
 set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source 
tree")
-set(LLVM_CMAKE_PATH 
"${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
+set(LLVM_CMAKE_PATH 
"${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm"
+CACHE PATH "Path to LLVM CMake modules")
 set(LLVM_LIT_PATH "${LLVM_PATH}/utils/lit/lit.py")
   else()
 message(FATAL_ERROR "llvm-config not found and LLVM_MAIN_SRC_DIR not 
defined. "


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -43,7 +43,8 @@
 set(LLVM_INCLUDE_DIR ${INCLUDE_DIR} CACHE PATH "Path to llvm/include")
 set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree")
 set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
-set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
+set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm"
+CACHE PATH "Path to LLVM CMake modules")
 set(LLVM_LIT_PATH "${LLVM_PATH}/utils/lit/lit.py")
   else()
 message(FATAL_ERROR "llvm-config not found and LLVM_MAIN_SRC_DIR not defined. "
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26900: [cmake] Obtain LLVM_CMAKE_PATH from llvm-config if available

2017-01-07 Thread Michał Górny via Phabricator via cfe-commits
mgorny retitled this revision from "[cmake] Obtain LLVM_CMAKE_PATH from 
llvm-config" to "[cmake] Obtain LLVM_CMAKE_PATH from llvm-config if available".
mgorny updated the summary for this revision.
mgorny updated this revision to Diff 83527.
mgorny added a comment.

Updated to support fallback to hardcoded path.


https://reviews.llvm.org/D26900

Files:
  CMakeLists.txt


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -58,7 +58,18 @@
   find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR}
 NO_DEFAULT_PATH)
 
-  set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
+  # --cmakedir is supported since llvm r291218 (4.0 release)
+  execute_process(
+COMMAND ${LLVM_CONFIG} --cmakedir
+RESULT_VARIABLE HAD_ERROR
+OUTPUT_VARIABLE CONFIG_OUTPUT)
+  if(NOT HAD_ERROR)
+string(STRIP "${CONFIG_OUTPUT}" LLVM_CMAKE_PATH)
+  else()
+set(LLVM_CMAKE_PATH
+"${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
+  endif()
+
   set(LLVMCONFIG_FILE "${LLVM_CMAKE_PATH}/LLVMConfig.cmake")
   if(EXISTS ${LLVMCONFIG_FILE})
 list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}")


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -58,7 +58,18 @@
   find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR}
 NO_DEFAULT_PATH)
 
-  set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
+  # --cmakedir is supported since llvm r291218 (4.0 release)
+  execute_process(
+COMMAND ${LLVM_CONFIG} --cmakedir
+RESULT_VARIABLE HAD_ERROR
+OUTPUT_VARIABLE CONFIG_OUTPUT)
+  if(NOT HAD_ERROR)
+string(STRIP "${CONFIG_OUTPUT}" LLVM_CMAKE_PATH)
+  else()
+set(LLVM_CMAKE_PATH
+"${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
+  endif()
+
   set(LLVMCONFIG_FILE "${LLVM_CMAKE_PATH}/LLVMConfig.cmake")
   if(EXISTS ${LLVMCONFIG_FILE})
 list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26764: [compiler-rt] [cmake] Remove i686 target that is duplicate to i386

2016-12-29 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Ping. @eugenis, do you consider it good to go then? Or do you want me to change 
something specifically?


https://reviews.llvm.org/D26764



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


[PATCH] D26796: [Driver] Use arch type to find compiler-rt libraries (on Linux)

2016-12-29 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Second ping.


https://reviews.llvm.org/D26796



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


[PATCH] D28304: [compiler-rt] [cmake] Disable appending -msse* flags implicitly

2017-01-04 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: cryptoad, kcc, samsonov.
mgorny added a subscriber: cfe-commits.
Herald added subscribers: dberris, kubabrecka.

Disable the code appending -msse3 and -msse4.2 flags implicitly when
the compiler supports them. The compiler support for those flags do not
indicate that the underlying CPU will support them, and passing those
flags to the compiler may result in SSE3/SSE4.2 code being emitted
*implicitly*.

If the target platform supports SSE3/SSE4.2 appropriately, the relevant
bits should be already enabled via -march= or equivalent. In this case
passing -msse* is redundant.

If a runtime detection is desired (which seems to be a case with SCUDO),
then (as gcc manpage points out) the specific SSE4.2 needs to be
isolated into a separate file, the -msse4.2 flag can be forced only
for that file and the function defined in that file can only be called
when the CPU is determined to support SSE4.2.

This fixes SIGILL on SCUDO when it is compiled using gcc-5.4.


https://reviews.llvm.org/D28304

Files:
  cmake/config-ix.cmake
  lib/scudo/CMakeLists.txt
  lib/tsan/CMakeLists.txt


Index: lib/tsan/CMakeLists.txt
===
--- lib/tsan/CMakeLists.txt
+++ lib/tsan/CMakeLists.txt
@@ -16,7 +16,6 @@
 endif()
 
 set(TSAN_RTL_CFLAGS ${TSAN_CFLAGS})
-append_list_if(COMPILER_RT_HAS_MSSE3_FLAG -msse3 TSAN_RTL_CFLAGS)
 append_list_if(SANITIZER_LIMIT_FRAME_SIZE -Wframe-larger-than=530
TSAN_RTL_CFLAGS)
 append_list_if(COMPILER_RT_HAS_WGLOBAL_CONSTRUCTORS_FLAG -Wglobal-constructors
Index: lib/scudo/CMakeLists.txt
===
--- lib/scudo/CMakeLists.txt
+++ lib/scudo/CMakeLists.txt
@@ -4,7 +4,6 @@
 
 set(SCUDO_CFLAGS ${SANITIZER_COMMON_CFLAGS})
 append_rtti_flag(OFF SCUDO_CFLAGS)
-append_list_if(COMPILER_RT_HAS_MSSE4_2_FLAG -msse4.2 SCUDO_CFLAGS)
 
 set(SCUDO_SOURCES
   scudo_allocator.cpp
Index: cmake/config-ix.cmake
===
--- cmake/config-ix.cmake
+++ cmake/config-ix.cmake
@@ -28,8 +28,6 @@
 check_cxx_compiler_flag(-std=c++11   COMPILER_RT_HAS_STD_CXX11_FLAG)
 check_cxx_compiler_flag(-ftls-model=initial-exec 
COMPILER_RT_HAS_FTLS_MODEL_INITIAL_EXEC)
 check_cxx_compiler_flag(-fno-lto COMPILER_RT_HAS_FNO_LTO_FLAG)
-check_cxx_compiler_flag("-Werror -msse3" COMPILER_RT_HAS_MSSE3_FLAG)
-check_cxx_compiler_flag("-Werror -msse4.2"   COMPILER_RT_HAS_MSSE4_2_FLAG)
 check_cxx_compiler_flag(--sysroot=.  COMPILER_RT_HAS_SYSROOT_FLAG)
 
 if(NOT WIN32 AND NOT CYGWIN)


Index: lib/tsan/CMakeLists.txt
===
--- lib/tsan/CMakeLists.txt
+++ lib/tsan/CMakeLists.txt
@@ -16,7 +16,6 @@
 endif()
 
 set(TSAN_RTL_CFLAGS ${TSAN_CFLAGS})
-append_list_if(COMPILER_RT_HAS_MSSE3_FLAG -msse3 TSAN_RTL_CFLAGS)
 append_list_if(SANITIZER_LIMIT_FRAME_SIZE -Wframe-larger-than=530
TSAN_RTL_CFLAGS)
 append_list_if(COMPILER_RT_HAS_WGLOBAL_CONSTRUCTORS_FLAG -Wglobal-constructors
Index: lib/scudo/CMakeLists.txt
===
--- lib/scudo/CMakeLists.txt
+++ lib/scudo/CMakeLists.txt
@@ -4,7 +4,6 @@
 
 set(SCUDO_CFLAGS ${SANITIZER_COMMON_CFLAGS})
 append_rtti_flag(OFF SCUDO_CFLAGS)
-append_list_if(COMPILER_RT_HAS_MSSE4_2_FLAG -msse4.2 SCUDO_CFLAGS)
 
 set(SCUDO_SOURCES
   scudo_allocator.cpp
Index: cmake/config-ix.cmake
===
--- cmake/config-ix.cmake
+++ cmake/config-ix.cmake
@@ -28,8 +28,6 @@
 check_cxx_compiler_flag(-std=c++11   COMPILER_RT_HAS_STD_CXX11_FLAG)
 check_cxx_compiler_flag(-ftls-model=initial-exec COMPILER_RT_HAS_FTLS_MODEL_INITIAL_EXEC)
 check_cxx_compiler_flag(-fno-lto COMPILER_RT_HAS_FNO_LTO_FLAG)
-check_cxx_compiler_flag("-Werror -msse3" COMPILER_RT_HAS_MSSE3_FLAG)
-check_cxx_compiler_flag("-Werror -msse4.2"   COMPILER_RT_HAS_MSSE4_2_FLAG)
 check_cxx_compiler_flag(--sysroot=.  COMPILER_RT_HAS_SYSROOT_FLAG)
 
 if(NOT WIN32 AND NOT CYGWIN)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28304: [compiler-rt] [cmake] Disable appending -msse* flags implicitly

2017-01-04 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

In https://reviews.llvm.org/D28304#635620, @cryptoad wrote:

> Hey Michal,
>  If I understand correctly, my next move is to move the CRC32 code into it's 
> own file an only enable SSE 4.2 for this file?


Yes, like that. Have a SSE4.2 CRC32 function in a separate file, and call it 
only when SSE4.2 is determined to be supported. Note that for this you'd need 
to refactor things a bit since it seems that the hw CRC32 code is used commonly 
be SSE4.2 and ARM.

Furthermore, you might want to do the runtime check only when SSE4.2 was not 
enabled at build time, i.e. skip it if user specified -msse4.2 or -march= 
option enabling it explicitly. I guess you could use the `#ifdef` for that (on 
a file where -msse4.2 is not forced).

> Shouldn't COMPILER_RT_HAS_MSSE4_2_FLAG be kept for that purpose or is there 
> an alternative way to do it?

I don't really see a point in keeping it if you can equally easily re-add it in 
a later patch.


https://reviews.llvm.org/D28304



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


[PATCH] D28295: [libunwind] [cmake] Support overriding LLVM_CMAKE_PATH

2017-01-07 Thread Michał Górny via Phabricator via cfe-commits
mgorny requested a review of this revision.
mgorny added a comment.

@EricWF suggests that it'd be better to wait a while before depending on newer 
llvm-config, so it'd probably be preferable to do this one instead first.


https://reviews.llvm.org/D28295



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


[PATCH] D28295: [libunwind] [cmake] Support overriding LLVM_CMAKE_PATH

2017-01-06 Thread Michał Górny via Phabricator via cfe-commits
mgorny planned changes to this revision.
mgorny added a comment.

Since https://reviews.llvm.org/D26894 was accepted, I will be preparing a patch 
using that instead.


https://reviews.llvm.org/D28295



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


[PATCH] D28304: [compiler-rt] [cmake] Disable appending -msse4.2 flag implicitly

2017-01-06 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL291217: [cmake] Disable appending -msse4.2 flag implicitly 
(authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D28304?vs=83298=83347#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28304

Files:
  compiler-rt/trunk/cmake/config-ix.cmake
  compiler-rt/trunk/lib/scudo/CMakeLists.txt


Index: compiler-rt/trunk/lib/scudo/CMakeLists.txt
===
--- compiler-rt/trunk/lib/scudo/CMakeLists.txt
+++ compiler-rt/trunk/lib/scudo/CMakeLists.txt
@@ -4,7 +4,6 @@
 
 set(SCUDO_CFLAGS ${SANITIZER_COMMON_CFLAGS})
 append_rtti_flag(OFF SCUDO_CFLAGS)
-append_list_if(COMPILER_RT_HAS_MSSE4_2_FLAG -msse4.2 SCUDO_CFLAGS)
 
 set(SCUDO_SOURCES
   scudo_allocator.cpp
Index: compiler-rt/trunk/cmake/config-ix.cmake
===
--- compiler-rt/trunk/cmake/config-ix.cmake
+++ compiler-rt/trunk/cmake/config-ix.cmake
@@ -29,7 +29,6 @@
 check_cxx_compiler_flag(-ftls-model=initial-exec 
COMPILER_RT_HAS_FTLS_MODEL_INITIAL_EXEC)
 check_cxx_compiler_flag(-fno-lto COMPILER_RT_HAS_FNO_LTO_FLAG)
 check_cxx_compiler_flag("-Werror -msse3" COMPILER_RT_HAS_MSSE3_FLAG)
-check_cxx_compiler_flag("-Werror -msse4.2"   COMPILER_RT_HAS_MSSE4_2_FLAG)
 check_cxx_compiler_flag(--sysroot=.  COMPILER_RT_HAS_SYSROOT_FLAG)
 
 if(NOT WIN32 AND NOT CYGWIN)


Index: compiler-rt/trunk/lib/scudo/CMakeLists.txt
===
--- compiler-rt/trunk/lib/scudo/CMakeLists.txt
+++ compiler-rt/trunk/lib/scudo/CMakeLists.txt
@@ -4,7 +4,6 @@
 
 set(SCUDO_CFLAGS ${SANITIZER_COMMON_CFLAGS})
 append_rtti_flag(OFF SCUDO_CFLAGS)
-append_list_if(COMPILER_RT_HAS_MSSE4_2_FLAG -msse4.2 SCUDO_CFLAGS)
 
 set(SCUDO_SOURCES
   scudo_allocator.cpp
Index: compiler-rt/trunk/cmake/config-ix.cmake
===
--- compiler-rt/trunk/cmake/config-ix.cmake
+++ compiler-rt/trunk/cmake/config-ix.cmake
@@ -29,7 +29,6 @@
 check_cxx_compiler_flag(-ftls-model=initial-exec COMPILER_RT_HAS_FTLS_MODEL_INITIAL_EXEC)
 check_cxx_compiler_flag(-fno-lto COMPILER_RT_HAS_FNO_LTO_FLAG)
 check_cxx_compiler_flag("-Werror -msse3" COMPILER_RT_HAS_MSSE3_FLAG)
-check_cxx_compiler_flag("-Werror -msse4.2"   COMPILER_RT_HAS_MSSE4_2_FLAG)
 check_cxx_compiler_flag(--sysroot=.  COMPILER_RT_HAS_SYSROOT_FLAG)
 
 if(NOT WIN32 AND NOT CYGWIN)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27898: [compiler-rt] [builtins] Implement __floattitf() & __floatuntitf()

2017-01-06 Thread Michał Górny via Phabricator via cfe-commits
mgorny added inline comments.



Comment at: lib/builtins/floattitf.c:65
+if (a & ((tu_int)1 << LDBL_MANT_DIG)) {
+a >>= 1;
+++e;

scanon wrote:
> mgorny wrote:
> > scanon wrote:
> > > Strictly speaking there's no need to adjust `a` here. If we rounded up 
> > > into a new binade, then `a` is necessarily `0b1000...0`, and the leading 
> > > 1 bit will get killed by the mask when we assemble `fb.u.high.all` 
> > > regardless of its position. Same comment applies to floatuntitf.
> > I'm sorry but I don't feel confident changing that. AFAIU if the 
> > LDBL_MANT_DIG+1 bit is set, this code shifts it lower, so it won't actually 
> > be killed by the mask.
> In binary128, as in all IEEE 754 binary interchange format encodings, the 
> leading bit of the significand is implicit. The only way to end up in this 
> code path is `0b111...1` rounding up to `0b100...00`, meaning that the 
> significand is 1.0, which is stored as all-zeros (i.e. the leading bit is 
> necessarily masked).
> 
> To be more explicit, LDBL_MANT_DIG is 113. If this shift happens, after the 
> shift bit 112 is set, and bits 111:0 are zero. The mask `((a >> 64) & 
> 0xLL)` discards bit 112 (= 64 + 48).
Well, I've tried removing this and it causes one of the tests to fail:

`error in __floatuntitf(0x) = 0X1P+127, 
expected 0X1P+128`


https://reviews.llvm.org/D27898



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


[PATCH] D27898: [compiler-rt] [builtins] Implement __floattitf() & __floatuntitf()

2017-01-06 Thread Michał Górny via Phabricator via cfe-commits
mgorny added inline comments.



Comment at: lib/builtins/floattitf.c:65
+if (a & ((tu_int)1 << LDBL_MANT_DIG)) {
+a >>= 1;
+++e;

scanon wrote:
> mgorny wrote:
> > scanon wrote:
> > > mgorny wrote:
> > > > scanon wrote:
> > > > > Strictly speaking there's no need to adjust `a` here. If we rounded 
> > > > > up into a new binade, then `a` is necessarily `0b1000...0`, and the 
> > > > > leading 1 bit will get killed by the mask when we assemble 
> > > > > `fb.u.high.all` regardless of its position. Same comment applies to 
> > > > > floatuntitf.
> > > > I'm sorry but I don't feel confident changing that. AFAIU if the 
> > > > LDBL_MANT_DIG+1 bit is set, this code shifts it lower, so it won't 
> > > > actually be killed by the mask.
> > > In binary128, as in all IEEE 754 binary interchange format encodings, the 
> > > leading bit of the significand is implicit. The only way to end up in 
> > > this code path is `0b111...1` rounding up to `0b100...00`, meaning that 
> > > the significand is 1.0, which is stored as all-zeros (i.e. the leading 
> > > bit is necessarily masked).
> > > 
> > > To be more explicit, LDBL_MANT_DIG is 113. If this shift happens, after 
> > > the shift bit 112 is set, and bits 111:0 are zero. The mask `((a >> 64) & 
> > > 0xLL)` discards bit 112 (= 64 + 48).
> > Well, I've tried removing this and it causes one of the tests to fail:
> > 
> > `error in __floatuntitf(0x) = 0X1P+127, 
> > expected 0X1P+128`
> This sounds like you removed the exponent adjustment (`++e`) as well as (or 
> instead of) the shift (`a >>= 1`). Without seeing the change, I can't be 
> certain, of course.
Yes, I did that. Now that you state that plainly, I finally understand what you 
meant ;-). However, if I were to do that, I would rather to do that separately, 
either in all relevant files or post unifying the code into one logical .inc. 
This would keep the history of changes cleaner.


https://reviews.llvm.org/D27898



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


[PATCH] D26244: [Driver] Prefer libraries installed next to Clang over those from GCC

2017-01-10 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

I think the easiest solution would be for you to use a path related to clang 
runtime directory, and install the runtimes there.

However, this would require rethinking the structure a bit to cover multilib, 
different ABIs, maybe cross. We have a cheap hack for this in clang-suite (I 
can give you link when I get home) but this really requires some smart thinking.


https://reviews.llvm.org/D26244



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


[PATCH] D27898: [compiler-rt] [builtins] Implement __floattitf() & __floatuntitf()

2016-12-21 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 82235.
mgorny marked an inline comment as done.
mgorny added a comment.

I think I've shifted all of `{`/`}` to be in line with keywords.

As for the splitting the code, you're probably right. However, I'd rather do 
that in a separate patch (I'll add it to my TODO, I promise).

I think that most of those files reuse a similar code -- I think it's for the 
case when the integer has greater range than the float. It would certainly also 
make sense to try to commonize the code used for signed and unsigned. However, 
I'm a little worried that it might make the result unreadable.


https://reviews.llvm.org/D27898

Files:
  lib/builtins/CMakeLists.txt
  lib/builtins/floattitf.c
  lib/builtins/floatuntitf.c
  test/builtins/Unit/floattitf_test.c
  test/builtins/Unit/floatuntitf_test.c

Index: test/builtins/Unit/floatuntitf_test.c
===
--- /dev/null
+++ test/builtins/Unit/floatuntitf_test.c
@@ -0,0 +1,220 @@
+//===-- floatuntitf.c - Test __floatuntitf ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file tests __floatuntitf for the compiler_rt library.
+//
+//===--===//
+
+#define QUAD_PRECISION
+#include "fp_lib.h"
+#include "int_lib.h"
+#include 
+#include 
+
+#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT)
+
+/* Returns: convert a tu_int to a fp_t, rounding toward even. */
+
+/* Assumption: fp_t is a IEEE 128 bit floating point type
+ * tu_int is a 128 bit integral type
+ */
+
+/* seee        |         |
+ *         |        
+ */
+
+COMPILER_RT_ABI fp_t __floatuntitf(tu_int a);
+
+int test__floatuntitf(tu_int a, fp_t expected) {
+fp_t x = __floatuntitf(a);
+if (x != expected) {
+utwords at;
+at.all = a;
+printf("error in __floatuntitf(0x%.16llX%.16llX) = %LA, expected %LA\n",
+   at.s.high, at.s.low, x, expected);
+}
+return x != expected;
+}
+
+char assumption_1[sizeof(tu_int) == 2*sizeof(du_int)] = {0};
+char assumption_2[sizeof(tu_int)*CHAR_BIT == 128] = {0};
+char assumption_3[sizeof(fp_t)*CHAR_BIT == 128] = {0};
+
+#endif
+
+int main() {
+#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT)
+if (test__floatuntitf(0, 0.0))
+return 1;
+
+if (test__floatuntitf(1, 1.0))
+return 1;
+if (test__floatuntitf(2, 2.0))
+return 1;
+if (test__floatuntitf(20, 20.0))
+return 1;
+
+if (test__floatuntitf(0x7F80ULL, 0x1.FEp+62))
+return 1;
+if (test__floatuntitf(0x7800ULL, 0x1.Ep+62))
+return 1;
+if (test__floatuntitf(0x7F00ULL, 0x1.FCp+62))
+return 1;
+if (test__floatuntitf(0x7000ULL, 0x1.Cp+62))
+return 1;
+if (test__floatuntitf(0x7FFFULL, 0xF.FFEp+59L))
+return 1;
+if (test__floatuntitf(0xFFFEULL, 0xF.FFEp+60L))
+return 1;
+if (test__floatuntitf(0xULL, 0xF.FFFp+60L))
+return 1;
+
+if (test__floatuntitf(0x8080ULL, 0x8.08p+60))
+return 1;
+if (test__floatuntitf(0x8800ULL, 0x8.8p+60))
+return 1;
+if (test__floatuntitf(0x8100ULL, 0x8.1p+60))
+return 1;
+if (test__floatuntitf(0x80001000ULL, 0x8.0001p+60))
+return 1;
+
+if (test__floatuntitf(0x8000ULL, 0x8p+60))
+return 1;
+if (test__floatuntitf(0x8001ULL, 0x8.001p+60L))
+return 1;
+
+if (test__floatuntitf(0x0007FB72E800LL, 0x1.FEDCBAp+50))
+return 1;
+
+if (test__floatuntitf(0x0007FB72EA00LL, 0x1.FEDCBA8p+50))
+return 1;
+if (test__floatuntitf(0x0007FB72EB00LL, 0x1.FEDCBACp+50))
+return 1;
+if (test__floatuntitf(0x0007FB72EBFFLL, 0x1.FEDCBAFFCp+50))
+return 1;
+if (test__floatuntitf(0x0007FB72EC00LL, 0x1.FEDCBBp+50))
+return 1;
+if (test__floatuntitf(0x0007FB72E801LL, 0x1.FEDCBA004p+50))
+return 1;
+
+if (test__floatuntitf(0x0007FB72E600LL, 0x1.FEDCB98p+50))
+return 1;
+if (test__floatuntitf(0x0007FB72E700LL, 0x1.FEDCB9Cp+50))
+return 1;
+if (test__floatuntitf(0x0007FB72E7FFLL, 0x1.FEDCB9FFCp+50))
+return 1;
+if (test__floatuntitf(0x0007FB72E401LL, 0x1.FEDCB9004p+50))
+return 1;
+if 

[PATCH] D27898: [compiler-rt] [builtins] Implement __floattitf() & __floatuntitf()

2016-12-18 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: sdmitrouk, rengolin, zatrazz.
mgorny added a subscriber: cfe-commits.
Herald added subscribers: dberris, aemerson.

Implement the missing __floattitf() and __floatuntitf() functions, to
convert 128-bit (unsigned) integers to quad-precision floating-point
types. This is needed e.g. on AArch64 where 'long double' is
a quad-precision type.

The code is based on the existing code for __floattixf()
and __floatuntixf(), updated to account for different bit field lengths
of quad-precision float. The tests are also copied, with the rounding
tests adjusted for longer mantissa.

(tested on AArch64)


https://reviews.llvm.org/D27898

Files:
  lib/builtins/CMakeLists.txt
  lib/builtins/floattitf.c
  lib/builtins/floatuntitf.c
  test/builtins/Unit/floattitf_test.c
  test/builtins/Unit/floatuntitf_test.c

Index: test/builtins/Unit/floatuntitf_test.c
===
--- /dev/null
+++ test/builtins/Unit/floatuntitf_test.c
@@ -0,0 +1,223 @@
+//===-- floatuntitf.c - Test __floatuntitf ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file tests __floatuntitf for the compiler_rt library.
+//
+//===--===//
+
+#define QUAD_PRECISION
+#include "fp_lib.h"
+#include "int_lib.h"
+#include 
+#include 
+
+#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT)
+
+/* Returns: convert a tu_int to a fp_t, rounding toward even. */
+
+/* Assumption: fp_t is a IEEE 128 bit floating point type
+ * tu_int is a 128 bit integral type
+ */
+
+/* seee        |         |
+ *         |        
+ */
+
+COMPILER_RT_ABI fp_t __floatuntitf(tu_int a);
+
+int test__floatuntitf(tu_int a, fp_t expected)
+{
+fp_t x = __floatuntitf(a);
+if (x != expected)
+{
+utwords at;
+at.all = a;
+printf("error in __floatuntitf(0x%.16llX%.16llX) = %LA, expected %LA\n",
+   at.s.high, at.s.low, x, expected);
+}
+return x != expected;
+}
+
+char assumption_1[sizeof(tu_int) == 2*sizeof(du_int)] = {0};
+char assumption_2[sizeof(tu_int)*CHAR_BIT == 128] = {0};
+char assumption_3[sizeof(fp_t)*CHAR_BIT == 128] = {0};
+
+#endif
+
+int main()
+{
+#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT)
+if (test__floatuntitf(0, 0.0))
+return 1;
+
+if (test__floatuntitf(1, 1.0))
+return 1;
+if (test__floatuntitf(2, 2.0))
+return 1;
+if (test__floatuntitf(20, 20.0))
+return 1;
+
+if (test__floatuntitf(0x7F80ULL, 0x1.FEp+62))
+return 1;
+if (test__floatuntitf(0x7800ULL, 0x1.Ep+62))
+return 1;
+if (test__floatuntitf(0x7F00ULL, 0x1.FCp+62))
+return 1;
+if (test__floatuntitf(0x7000ULL, 0x1.Cp+62))
+return 1;
+if (test__floatuntitf(0x7FFFULL, 0xF.FFEp+59L))
+return 1;
+if (test__floatuntitf(0xFFFEULL, 0xF.FFEp+60L))
+return 1;
+if (test__floatuntitf(0xULL, 0xF.FFFp+60L))
+return 1;
+
+if (test__floatuntitf(0x8080ULL, 0x8.08p+60))
+return 1;
+if (test__floatuntitf(0x8800ULL, 0x8.8p+60))
+return 1;
+if (test__floatuntitf(0x8100ULL, 0x8.1p+60))
+return 1;
+if (test__floatuntitf(0x80001000ULL, 0x8.0001p+60))
+return 1;
+
+if (test__floatuntitf(0x8000ULL, 0x8p+60))
+return 1;
+if (test__floatuntitf(0x8001ULL, 0x8.001p+60L))
+return 1;
+
+if (test__floatuntitf(0x0007FB72E800LL, 0x1.FEDCBAp+50))
+return 1;
+
+if (test__floatuntitf(0x0007FB72EA00LL, 0x1.FEDCBA8p+50))
+return 1;
+if (test__floatuntitf(0x0007FB72EB00LL, 0x1.FEDCBACp+50))
+return 1;
+if (test__floatuntitf(0x0007FB72EBFFLL, 0x1.FEDCBAFFCp+50))
+return 1;
+if (test__floatuntitf(0x0007FB72EC00LL, 0x1.FEDCBBp+50))
+return 1;
+if (test__floatuntitf(0x0007FB72E801LL, 0x1.FEDCBA004p+50))
+return 1;
+
+if (test__floatuntitf(0x0007FB72E600LL, 0x1.FEDCB98p+50))
+return 1;
+if (test__floatuntitf(0x0007FB72E700LL, 0x1.FEDCB9Cp+50))
+return 1;
+if (test__floatuntitf(0x0007FB72E7FFLL, 0x1.FEDCB9FFCp+50))
+return 1;
+if (test__floatuntitf(0x0007FB72E401LL, 0x1.FEDCB9004p+50))
+   

[PATCH] D27898: [compiler-rt] [builtins] Implement __floattitf() & __floatuntitf()

2016-12-23 Thread Michał Górny via Phabricator via cfe-commits
mgorny added inline comments.



Comment at: lib/builtins/floattitf.c:65
+if (a & ((tu_int)1 << LDBL_MANT_DIG)) {
+a >>= 1;
+++e;

scanon wrote:
> Strictly speaking there's no need to adjust `a` here. If we rounded up into a 
> new binade, then `a` is necessarily `0b1000...0`, and the leading 1 bit will 
> get killed by the mask when we assemble `fb.u.high.all` regardless of its 
> position. Same comment applies to floatuntitf.
I'm sorry but I don't feel confident changing that. AFAIU if the 
LDBL_MANT_DIG+1 bit is set, this code shifts it lower, so it won't actually be 
killed by the mask.


https://reviews.llvm.org/D27898



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


[PATCH] D28078: [compiler-rt] [tests] Add missing "int_lib.h" includes and extend guards

2016-12-23 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL290422: [tests] Add missing "int_lib.h" includes and extend 
guards (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D28078?vs=82402=82407#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28078

Files:
  compiler-rt/trunk/test/builtins/Unit/negdf2vfp_test.c
  compiler-rt/trunk/test/builtins/Unit/subdf3vfp_test.c


Index: compiler-rt/trunk/test/builtins/Unit/subdf3vfp_test.c
===
--- compiler-rt/trunk/test/builtins/Unit/subdf3vfp_test.c
+++ compiler-rt/trunk/test/builtins/Unit/subdf3vfp_test.c
@@ -11,6 +11,7 @@
 //
 
//===--===//
 
+#include "int_lib.h"
 #include 
 #include 
 #include 
Index: compiler-rt/trunk/test/builtins/Unit/negdf2vfp_test.c
===
--- compiler-rt/trunk/test/builtins/Unit/negdf2vfp_test.c
+++ compiler-rt/trunk/test/builtins/Unit/negdf2vfp_test.c
@@ -11,14 +11,15 @@
 //
 
//===--===//
 
+#include "int_lib.h"
 #include 
 #include 
 #include 
 
 
+#if __arm__
 extern COMPILER_RT_ABI double __negdf2vfp(double a);
 
-#if __arm__
 int test__negdf2vfp(double a)
 {
 double actual = __negdf2vfp(a);


Index: compiler-rt/trunk/test/builtins/Unit/subdf3vfp_test.c
===
--- compiler-rt/trunk/test/builtins/Unit/subdf3vfp_test.c
+++ compiler-rt/trunk/test/builtins/Unit/subdf3vfp_test.c
@@ -11,6 +11,7 @@
 //
 //===--===//
 
+#include "int_lib.h"
 #include 
 #include 
 #include 
Index: compiler-rt/trunk/test/builtins/Unit/negdf2vfp_test.c
===
--- compiler-rt/trunk/test/builtins/Unit/negdf2vfp_test.c
+++ compiler-rt/trunk/test/builtins/Unit/negdf2vfp_test.c
@@ -11,14 +11,15 @@
 //
 //===--===//
 
+#include "int_lib.h"
 #include 
 #include 
 #include 
 
 
+#if __arm__
 extern COMPILER_RT_ABI double __negdf2vfp(double a);
 
-#if __arm__
 int test__negdf2vfp(double a)
 {
 double actual = __negdf2vfp(a);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28078: [tests] Add missing "int_lib.h" includes and extend guards

2016-12-23 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: dschuff, kledzik, rengolin.
mgorny added a subscriber: cfe-commits.
Herald added a subscriber: aemerson.

Fix missing "int_lib.h" includes in ARM negdf2vfp and subdf3vfp tests.
Additionally, extend the __arm__ guard to cover the builtin definition
in the former. This is mostly intended to prevent build failures
and allow those tests to be properly skipped on other targets.


https://reviews.llvm.org/D28078

Files:
  test/builtins/Unit/negdf2vfp_test.c
  test/builtins/Unit/subdf3vfp_test.c


Index: test/builtins/Unit/subdf3vfp_test.c
===
--- test/builtins/Unit/subdf3vfp_test.c
+++ test/builtins/Unit/subdf3vfp_test.c
@@ -11,6 +11,7 @@
 //
 
//===--===//
 
+#include "int_lib.h"
 #include 
 #include 
 #include 
Index: test/builtins/Unit/negdf2vfp_test.c
===
--- test/builtins/Unit/negdf2vfp_test.c
+++ test/builtins/Unit/negdf2vfp_test.c
@@ -11,14 +11,15 @@
 //
 
//===--===//
 
+#include "int_lib.h"
 #include 
 #include 
 #include 
 
 
+#if __arm__
 extern COMPILER_RT_ABI double __negdf2vfp(double a);
 
-#if __arm__
 int test__negdf2vfp(double a)
 {
 double actual = __negdf2vfp(a);


Index: test/builtins/Unit/subdf3vfp_test.c
===
--- test/builtins/Unit/subdf3vfp_test.c
+++ test/builtins/Unit/subdf3vfp_test.c
@@ -11,6 +11,7 @@
 //
 //===--===//
 
+#include "int_lib.h"
 #include 
 #include 
 #include 
Index: test/builtins/Unit/negdf2vfp_test.c
===
--- test/builtins/Unit/negdf2vfp_test.c
+++ test/builtins/Unit/negdf2vfp_test.c
@@ -11,14 +11,15 @@
 //
 //===--===//
 
+#include "int_lib.h"
 #include 
 #include 
 #include 
 
 
+#if __arm__
 extern COMPILER_RT_ABI double __negdf2vfp(double a);
 
-#if __arm__
 int test__negdf2vfp(double a)
 {
 double actual = __negdf2vfp(a);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27898: [compiler-rt] [builtins] Implement __floattitf() & __floatuntitf()

2016-12-23 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated the summary for this revision.
mgorny updated this revision to Diff 82414.
mgorny added a comment.

Changed mantissa -> significand.


https://reviews.llvm.org/D27898

Files:
  lib/builtins/CMakeLists.txt
  lib/builtins/floattitf.c
  lib/builtins/floatuntitf.c
  test/builtins/Unit/floattitf_test.c
  test/builtins/Unit/floatuntitf_test.c

Index: test/builtins/Unit/floatuntitf_test.c
===
--- /dev/null
+++ test/builtins/Unit/floatuntitf_test.c
@@ -0,0 +1,220 @@
+//===-- floatuntitf.c - Test __floatuntitf ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file tests __floatuntitf for the compiler_rt library.
+//
+//===--===//
+
+#define QUAD_PRECISION
+#include "fp_lib.h"
+#include "int_lib.h"
+#include 
+#include 
+
+#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT)
+
+/* Returns: convert a tu_int to a fp_t, rounding toward even. */
+
+/* Assumption: fp_t is a IEEE 128 bit floating point type
+ * tu_int is a 128 bit integral type
+ */
+
+/* seee        |         |
+ *         |        
+ */
+
+COMPILER_RT_ABI fp_t __floatuntitf(tu_int a);
+
+int test__floatuntitf(tu_int a, fp_t expected) {
+fp_t x = __floatuntitf(a);
+if (x != expected) {
+utwords at;
+at.all = a;
+printf("error in __floatuntitf(0x%.16llX%.16llX) = %LA, expected %LA\n",
+   at.s.high, at.s.low, x, expected);
+}
+return x != expected;
+}
+
+char assumption_1[sizeof(tu_int) == 2*sizeof(du_int)] = {0};
+char assumption_2[sizeof(tu_int)*CHAR_BIT == 128] = {0};
+char assumption_3[sizeof(fp_t)*CHAR_BIT == 128] = {0};
+
+#endif
+
+int main() {
+#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT)
+if (test__floatuntitf(0, 0.0))
+return 1;
+
+if (test__floatuntitf(1, 1.0))
+return 1;
+if (test__floatuntitf(2, 2.0))
+return 1;
+if (test__floatuntitf(20, 20.0))
+return 1;
+
+if (test__floatuntitf(0x7F80ULL, 0x1.FEp+62))
+return 1;
+if (test__floatuntitf(0x7800ULL, 0x1.Ep+62))
+return 1;
+if (test__floatuntitf(0x7F00ULL, 0x1.FCp+62))
+return 1;
+if (test__floatuntitf(0x7000ULL, 0x1.Cp+62))
+return 1;
+if (test__floatuntitf(0x7FFFULL, 0xF.FFEp+59L))
+return 1;
+if (test__floatuntitf(0xFFFEULL, 0xF.FFEp+60L))
+return 1;
+if (test__floatuntitf(0xULL, 0xF.FFFp+60L))
+return 1;
+
+if (test__floatuntitf(0x8080ULL, 0x8.08p+60))
+return 1;
+if (test__floatuntitf(0x8800ULL, 0x8.8p+60))
+return 1;
+if (test__floatuntitf(0x8100ULL, 0x8.1p+60))
+return 1;
+if (test__floatuntitf(0x80001000ULL, 0x8.0001p+60))
+return 1;
+
+if (test__floatuntitf(0x8000ULL, 0x8p+60))
+return 1;
+if (test__floatuntitf(0x8001ULL, 0x8.001p+60L))
+return 1;
+
+if (test__floatuntitf(0x0007FB72E800LL, 0x1.FEDCBAp+50))
+return 1;
+
+if (test__floatuntitf(0x0007FB72EA00LL, 0x1.FEDCBA8p+50))
+return 1;
+if (test__floatuntitf(0x0007FB72EB00LL, 0x1.FEDCBACp+50))
+return 1;
+if (test__floatuntitf(0x0007FB72EBFFLL, 0x1.FEDCBAFFCp+50))
+return 1;
+if (test__floatuntitf(0x0007FB72EC00LL, 0x1.FEDCBBp+50))
+return 1;
+if (test__floatuntitf(0x0007FB72E801LL, 0x1.FEDCBA004p+50))
+return 1;
+
+if (test__floatuntitf(0x0007FB72E600LL, 0x1.FEDCB98p+50))
+return 1;
+if (test__floatuntitf(0x0007FB72E700LL, 0x1.FEDCB9Cp+50))
+return 1;
+if (test__floatuntitf(0x0007FB72E7FFLL, 0x1.FEDCB9FFCp+50))
+return 1;
+if (test__floatuntitf(0x0007FB72E401LL, 0x1.FEDCB9004p+50))
+return 1;
+if (test__floatuntitf(0x0007FB72E400LL, 0x1.FEDCB9p+50))
+return 1;
+
+if (test__floatuntitf(0x023479FD0E092DC0LL, 0x1.1A3CFE870496Ep+57))
+return 1;
+if (test__floatuntitf(0x023479FD0E092DA1LL, 0x1.1A3CFE870496D08p+57L))
+return 1;
+if (test__floatuntitf(0x023479FD0E092DB0LL, 0x1.1A3CFE870496D8p+57L))
+return 1;
+if (test__floatuntitf(0x023479FD0E092DB8LL, 0x1.1A3CFE870496DCp+57L))
+return 1;
+if 

[PATCH] D27898: [compiler-rt] [builtins] Implement __floattitf() & __floatuntitf()

2016-12-22 Thread Michał Górny via Phabricator via cfe-commits
mgorny added inline comments.



Comment at: lib/builtins/floatuntitf.c:73
+long_double_bits fb;
+fb.u.high.all = (du_int)(e + 16383) << 48/* exponent */
+  | ((a >> 64) & 0xLL);  /* mantissa */

rengolin wrote:
> rengolin wrote:
> > mgorny wrote:
> > > rengolin wrote:
> > > > nit: an hexadecimal pattern here would be clearer. same above.
> > > Do you mean something like: `(foo << 48) & 0x`?
> > No, just the `16383` to `0x3FFF`
> Though, now I think your proposal may be better. :)
> 
> Whatever works, I'm not too concerned about that.
Well, I used the decimal form because that's how the IEEE 754 standard 
specifies it, so I guessed the correlation would be clearer that way.


https://reviews.llvm.org/D27898



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


[PATCH] D27898: [compiler-rt] [builtins] Implement __floattitf() & __floatuntitf()

2016-12-22 Thread Michał Górny via Phabricator via cfe-commits
mgorny added inline comments.



Comment at: lib/builtins/floatuntitf.c:73
+long_double_bits fb;
+fb.u.high.all = (du_int)(e + 16383) << 48/* exponent */
+  | ((a >> 64) & 0xLL);  /* mantissa */

rengolin wrote:
> nit: an hexadecimal pattern here would be clearer. same above.
Do you mean something like: `(foo << 48) & 0x`?


https://reviews.llvm.org/D27898



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


[PATCH] D28213: [Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin

2017-03-23 Thread Michał Górny via Phabricator via cfe-commits
mgorny reopened this revision.
mgorny added a comment.
This revision is now accepted and ready to land.

Reopening since it has been reverted.


Repository:
  rL LLVM

https://reviews.llvm.org/D28213



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


[PATCH] D25157: [compiler-rt] [cmake] Respect COMPILER_RT_BUILD_* for libs, headers and tests

2017-03-29 Thread Michał Górny via Phabricator via cfe-commits
mgorny added inline comments.



Comment at: cmake/config-ix.cmake:438-441
 if (SANITIZER_COMMON_SUPPORTED_ARCH AND NOT LLVM_USE_SANITIZER AND
+(COMPILER_RT_BUILD_SANITIZERS OR COMPILER_RT_BUILD_XRAY) AND
 (OS_NAME MATCHES "Android|Darwin|Linux|FreeBSD" OR
 (OS_NAME MATCHES "Windows" AND (NOT MINGW AND NOT CYGWIN

compnerd wrote:
> What does this really leave in terms of targets which the sanitizer supports 
> but doesn't have the common library?
I'm not sure if I understand your question correctly. If it's about  the 
platform logic, I don't know what it is about and I think it's a bit out of 
scope of this change. My goal is to merely disable sanitizer-related stuff when 
sanitizers are not built.



Comment at: cmake/config-ix.cmake:562
   set(COMPILER_RT_HAS_XRAY FALSE)
 endif()

compnerd wrote:
> Seems like it might be a good time to hoist the OS checks and add a 
> `COMPILER_RT_*_SUPPORTED` macro (e.g. `COMPILER_RT_XRAY_SUPPORTED`).
Sounds like material for a separate patch to me.



Comment at: lib/CMakeLists.txt:60
+# the following set is conditional to COMPILER_RT_BUILD_XRAY
+# (via COMPILER_RT_HAS_* in config-ix.cmake)
+compiler_rt_build_runtime(xray)

compnerd wrote:
> Im not sure I understand the comment.  This looks like it may prevent 
> disabling X-ray?
The comment was supposed to indicate that we don't need 
`if(COMPILER_RT_BUILD_XRAY)` here because it is already included in 
COMPILER_RT_HAS_... value.


https://reviews.llvm.org/D25157



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


[PATCH] D25157: [compiler-rt] [cmake] Respect COMPILER_RT_BUILD_* for libs, headers and tests

2017-03-29 Thread Michał Górny via Phabricator via cfe-commits
mgorny added inline comments.



Comment at: test/sanitizer_common/CMakeLists.txt:7
 set(SUPPORTED_TOOLS)
-if(CMAKE_SYSTEM_NAME MATCHES "Darwin|Linux|FreeBSD" AND NOT ANDROID)
+if(CMAKE_SYSTEM_NAME MATCHES "Darwin|Linux|FreeBSD" AND NOT ANDROID AND
+   COMPILER_RT_HAS_ASAN)

jroelofs wrote:
> Are the `CMAKE_SYSTEM_NAME_MATCHES` guards here necessary any more, now that 
> the checks are happening in config-ix.cmake?
ASAN doesn't have any system guard in config-ix.cmake, and the other guards are 
different (narrower) than those in config-ix. I think those restrictions might 
be like that on purpose, so if I were to drop them, I'd rather do it in 
separate patch. @samsonov?


https://reviews.llvm.org/D25157



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


[PATCH] D25157: [compiler-rt] [cmake] Respect COMPILER_RT_BUILD_* for libs, headers and tests

2017-03-29 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 93347.
mgorny added a comment.

Needed to rebase again.


https://reviews.llvm.org/D25157

Files:
  cmake/config-ix.cmake
  include/CMakeLists.txt
  lib/CMakeLists.txt
  test/sanitizer_common/CMakeLists.txt

Index: test/sanitizer_common/CMakeLists.txt
===
--- test/sanitizer_common/CMakeLists.txt
+++ test/sanitizer_common/CMakeLists.txt
@@ -4,13 +4,20 @@
 set(SANITIZER_COMMON_TESTSUITES)
 
 set(SUPPORTED_TOOLS)
-if(CMAKE_SYSTEM_NAME MATCHES "Darwin|Linux|FreeBSD" AND NOT ANDROID)
+if(CMAKE_SYSTEM_NAME MATCHES "Darwin|Linux|FreeBSD" AND NOT ANDROID AND
+   COMPILER_RT_HAS_ASAN)
   list(APPEND SUPPORTED_TOOLS asan)
 endif()
 if(CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT ANDROID)
-  list(APPEND SUPPORTED_TOOLS tsan)
-  list(APPEND SUPPORTED_TOOLS msan)
-  list(APPEND SUPPORTED_TOOLS lsan)
+  if(COMPILER_RT_HAS_TSAN)
+list(APPEND SUPPORTED_TOOLS tsan)
+  endif()
+  if(COMPILER_RT_HAS_MSAN)
+list(APPEND SUPPORTED_TOOLS msan)
+  endif()
+  if(COMPILER_RT_HAS_LSAN)
+list(APPEND SUPPORTED_TOOLS lsan)
+  endif()
 endif()
 
 # Create a separate config for each tool we support.
Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -8,8 +8,7 @@
 # sanitizers or xray (or both).
 #
 #TODO: Refactor sanitizer_common into smaller pieces (e.g. flag parsing, utils).
-if (COMPILER_RT_HAS_SANITIZER_COMMON AND
-(COMPILER_RT_BUILD_SANITIZERS OR COMPILER_RT_BUILD_XRAY))
+if (COMPILER_RT_HAS_SANITIZER_COMMON)
   add_subdirectory(sanitizer_common)
 endif()
 
@@ -36,27 +35,27 @@
   endif()
 endfunction()
 
-if(COMPILER_RT_BUILD_SANITIZERS)
-  compiler_rt_build_runtime(interception)
+# the following set is conditional to COMPILER_RT_BUILD_SANITIZERS
+# (via COMPILER_RT_HAS_* in config-ix.cmake)
+compiler_rt_build_runtime(interception)
 
-  if(COMPILER_RT_HAS_SANITIZER_COMMON)
-add_subdirectory(stats)
-add_subdirectory(lsan)
-add_subdirectory(ubsan)
-  endif()
+if(COMPILER_RT_BUILD_SANITIZERS AND COMPILER_RT_HAS_SANITIZER_COMMON)
+  add_subdirectory(stats)
+  add_subdirectory(lsan)
+  add_subdirectory(ubsan)
+endif()
 
-  compiler_rt_build_sanitizer(asan)
-  compiler_rt_build_sanitizer(dfsan)
-  compiler_rt_build_sanitizer(msan)
-  compiler_rt_build_sanitizer(tsan tsan/dd)
-  compiler_rt_build_sanitizer(safestack)
-  compiler_rt_build_sanitizer(cfi)
-  compiler_rt_build_sanitizer(esan)
-  compiler_rt_build_sanitizer(scudo)
+compiler_rt_build_sanitizer(asan)
+compiler_rt_build_sanitizer(dfsan)
+compiler_rt_build_sanitizer(msan)
+compiler_rt_build_sanitizer(tsan tsan/dd)
+compiler_rt_build_sanitizer(safestack)
+compiler_rt_build_sanitizer(cfi)
+compiler_rt_build_sanitizer(esan)
+compiler_rt_build_sanitizer(scudo)
 
-  compiler_rt_build_runtime(profile)
-endif()
+compiler_rt_build_runtime(profile)
 
-if(COMPILER_RT_BUILD_XRAY)
-  compiler_rt_build_runtime(xray)
-endif()
+# the following set is conditional to COMPILER_RT_BUILD_XRAY
+# (via COMPILER_RT_HAS_* in config-ix.cmake)
+compiler_rt_build_runtime(xray)
Index: include/CMakeLists.txt
===
--- include/CMakeLists.txt
+++ include/CMakeLists.txt
@@ -1,19 +1,43 @@
-set(SANITIZER_HEADERS
-  sanitizer/allocator_interface.h
-  sanitizer/asan_interface.h
-  sanitizer/common_interface_defs.h
-  sanitizer/coverage_interface.h
-  sanitizer/dfsan_interface.h
-  sanitizer/esan_interface.h
-  sanitizer/linux_syscall_hooks.h
-  sanitizer/lsan_interface.h
-  sanitizer/msan_interface.h
-  sanitizer/tsan_interface.h
-  sanitizer/tsan_interface_atomic.h)
+set(SANITIZER_HEADERS)
+if(COMPILER_RT_HAS_SANITIZER_COMMON)
+  list(APPEND SANITIZER_HEADERS
+   sanitizer/allocator_interface.h
+   sanitizer/common_interface_defs.h
+   sanitizer/coverage_interface.h
+   sanitizer/linux_syscall_hooks.h)
+endif()
+if(COMPILER_RT_HAS_ASAN)
+  list(APPEND SANITIZER_HEADERS
+   sanitizer/asan_interface.h)
+endif()
+if(COMPILER_RT_HAS_DFSAN)
+  list(APPEND SANITIZER_HEADERS
+   sanitizer/dfsan_interface.h)
+endif()
+if(COMPILER_RT_HAS_ESAN)
+  list(APPEND SANITIZER_HEADERS
+   sanitizer/esan_interface.h)
+endif()
+if(COMPILER_RT_HAS_LSAN)
+  list(APPEND SANITIZER_HEADERS
+   sanitizer/lsan_interface.h)
+endif()
+if(COMPILER_RT_HAS_MSAN)
+  list(APPEND SANITIZER_HEADERS
+   sanitizer/msan_interface.h)
+endif()
+if(COMPILER_RT_HAS_TSAN)
+  list(APPEND SANITIZER_HEADERS
+   sanitizer/tsan_interface.h
+   sanitizer/tsan_interface_atomic.h)
+endif()
 
-set(XRAY_HEADERS
-  xray/xray_interface.h
-  xray/xray_log_interface.h)
+set(XRAY_HEADERS)
+if(COMPILER_RT_BUILD_XRAY)
+  list(APPEND XRAY_HEADERS
+   xray/xray_interface.h
+   xray/xray_log_interface.h)
+endif()
 
 set(COMPILER_RT_HEADERS
   ${SANITIZER_HEADERS}
Index: cmake/config-ix.cmake

[PATCH] D25157: [compiler-rt] [cmake] Respect COMPILER_RT_BUILD_* for libs, headers and tests

2017-03-28 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 93296.
mgorny added a comment.

Rebased. Ping. Now that we have lit tests for builtins, it would be really 
useful for us to be able to build them without having to enable sanitizers.


https://reviews.llvm.org/D25157

Files:
  cmake/config-ix.cmake
  include/CMakeLists.txt
  lib/CMakeLists.txt
  test/sanitizer_common/CMakeLists.txt

Index: test/sanitizer_common/CMakeLists.txt
===
--- test/sanitizer_common/CMakeLists.txt
+++ test/sanitizer_common/CMakeLists.txt
@@ -4,13 +4,20 @@
 set(SANITIZER_COMMON_TESTSUITES)
 
 set(SUPPORTED_TOOLS)
-if(CMAKE_SYSTEM_NAME MATCHES "Darwin|Linux|FreeBSD" AND NOT ANDROID)
+if(CMAKE_SYSTEM_NAME MATCHES "Darwin|Linux|FreeBSD" AND NOT ANDROID AND
+   COMPILER_RT_HAS_ASAN)
   list(APPEND SUPPORTED_TOOLS asan)
 endif()
 if(CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT ANDROID)
-  list(APPEND SUPPORTED_TOOLS tsan)
-  list(APPEND SUPPORTED_TOOLS msan)
-  list(APPEND SUPPORTED_TOOLS lsan)
+  if(COMPILER_RT_HAS_TSAN)
+list(APPEND SUPPORTED_TOOLS tsan)
+  endif()
+  if(COMPILER_RT_HAS_MSAN)
+list(APPEND SUPPORTED_TOOLS msan)
+  endif()
+  if(COMPILER_RT_HAS_LSAN)
+list(APPEND SUPPORTED_TOOLS lsan)
+  endif()
 endif()
 
 # Create a separate config for each tool we support.
Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -8,8 +8,7 @@
 # sanitizers or xray (or both).
 #
 #TODO: Refactor sanitizer_common into smaller pieces (e.g. flag parsing, utils).
-if (COMPILER_RT_HAS_SANITIZER_COMMON AND
-(COMPILER_RT_BUILD_SANITIZERS OR COMPILER_RT_BUILD_XRAY))
+if (COMPILER_RT_HAS_SANITIZER_COMMON)
   add_subdirectory(sanitizer_common)
 endif()
 
@@ -36,27 +35,27 @@
   endif()
 endfunction()
 
-if(COMPILER_RT_BUILD_SANITIZERS)
-  compiler_rt_build_runtime(interception)
+# the following set is conditional to COMPILER_RT_BUILD_SANITIZERS
+# (via COMPILER_RT_HAS_* in config-ix.cmake)
+compiler_rt_build_runtime(interception)
 
-  if(COMPILER_RT_HAS_SANITIZER_COMMON)
-add_subdirectory(stats)
-add_subdirectory(lsan)
-add_subdirectory(ubsan)
-  endif()
+if(COMPILER_RT_BUILD_SANITIZERS AND COMPILER_RT_HAS_SANITIZER_COMMON)
+  add_subdirectory(stats)
+  add_subdirectory(lsan)
+  add_subdirectory(ubsan)
+endif()
 
-  compiler_rt_build_sanitizer(asan)
-  compiler_rt_build_sanitizer(dfsan)
-  compiler_rt_build_sanitizer(msan)
-  compiler_rt_build_sanitizer(tsan tsan/dd)
-  compiler_rt_build_sanitizer(safestack)
-  compiler_rt_build_sanitizer(cfi)
-  compiler_rt_build_sanitizer(esan)
-  compiler_rt_build_sanitizer(scudo)
+compiler_rt_build_sanitizer(asan)
+compiler_rt_build_sanitizer(dfsan)
+compiler_rt_build_sanitizer(msan)
+compiler_rt_build_sanitizer(tsan tsan/dd)
+compiler_rt_build_sanitizer(safestack)
+compiler_rt_build_sanitizer(cfi)
+compiler_rt_build_sanitizer(esan)
+compiler_rt_build_sanitizer(scudo)
 
-  compiler_rt_build_runtime(profile)
-endif()
+compiler_rt_build_runtime(profile)
 
-if(COMPILER_RT_BUILD_XRAY)
-  compiler_rt_build_runtime(xray)
-endif()
+# the following set is conditional to COMPILER_RT_BUILD_XRAY
+# (via COMPILER_RT_HAS_* in config-ix.cmake)
+compiler_rt_build_runtime(xray)
Index: include/CMakeLists.txt
===
--- include/CMakeLists.txt
+++ include/CMakeLists.txt
@@ -1,18 +1,42 @@
-set(SANITIZER_HEADERS
-  sanitizer/allocator_interface.h
-  sanitizer/asan_interface.h
-  sanitizer/common_interface_defs.h
-  sanitizer/coverage_interface.h
-  sanitizer/dfsan_interface.h
-  sanitizer/esan_interface.h
-  sanitizer/linux_syscall_hooks.h
-  sanitizer/lsan_interface.h
-  sanitizer/msan_interface.h
-  sanitizer/tsan_interface.h
-  sanitizer/tsan_interface_atomic.h)
+set(SANITIZER_HEADERS)
+if(COMPILER_RT_HAS_SANITIZER_COMMON)
+  list(APPEND SANITIZER_HEADERS
+   sanitizer/allocator_interface.h
+   sanitizer/common_interface_defs.h
+   sanitizer/coverage_interface.h
+   sanitizer/linux_syscall_hooks.h)
+endif()
+if(COMPILER_RT_HAS_ASAN)
+  list(APPEND SANITIZER_HEADERS
+   sanitizer/asan_interface.h)
+endif()
+if(COMPILER_RT_HAS_DFSAN)
+  list(APPEND SANITIZER_HEADERS
+   sanitizer/dfsan_interface.h)
+endif()
+if(COMPILER_RT_HAS_ESAN)
+  list(APPEND SANITIZER_HEADERS
+   sanitizer/esan_interface.h)
+endif()
+if(COMPILER_RT_HAS_LSAN)
+  list(APPEND SANITIZER_HEADERS
+   sanitizer/lsan_interface.h)
+endif()
+if(COMPILER_RT_HAS_MSAN)
+  list(APPEND SANITIZER_HEADERS
+   sanitizer/msan_interface.h)
+endif()
+if(COMPILER_RT_HAS_TSAN)
+  list(APPEND SANITIZER_HEADERS
+   sanitizer/tsan_interface.h
+   sanitizer/tsan_interface_atomic.h)
+endif()
 
-set(XRAY_HEADERS
-  xray/xray_interface.h)
+set(XRAY_HEADERS)
+if(COMPILER_RT_BUILD_XRAY)
+  list(APPEND XRAY_HEADERS
+   xray/xray_interface.h)
+endif()
 
 set(COMPILER_RT_HEADERS
   ${SANITIZER_HEADERS}
Index: 

  1   2   3   4   5   6   7   8   9   >