llvm-toolchain/debian/patches/atomic_library_1.diff
Sylvestre Ledru 9e36f19118 * New snapshot release
* Merge changes from the 3.3 branch (see 1:3.3-10)
* Install libclang.so in /usr/lib/*/libclang-3.3.so
* Install libclang.so.1 in /usr/lib/*/libclang-3.3.so.1
* Also ship the python clang binding (python-clang-3.3)
  (LLVM no longer mean Low Level Virtual Machine)
* Disable the build of lldb under HURD
* Ship the lldb headers into lldb-X.Y-dev (Closes: #723743)
  I might create a liblldb-X.Y library at some point but I think it is too
  early.
* Fix "cannot compile this atomic library call"
  Thanks to Francisco Facioni for the refresh (Closes: #705115)
* Install libclang.so in /usr/lib/*/libclang-3.3.so
* Install libclang.so.1 in /usr/lib/*/libclang-3.3.so.1
* Also ship the python clang binding (python-clang-3.3)
* Fix a FTBFS with a duplicate declaration of shouldUseInlineAtomic
* Update the build dependency from tcl8.5 to tcl (Closes: #725953)
2013-10-10 11:40:12 +00:00

46 lines
2.4 KiB
Diff

Index: llvm-toolchain-snapshot_3.4~svn192346/clang/lib/Basic/Targets.cpp
===================================================================
--- llvm-toolchain-snapshot_3.4~svn192346.orig/clang/lib/Basic/Targets.cpp 2013-10-10 13:39:24.086081296 +0200
+++ llvm-toolchain-snapshot_3.4~svn192346/clang/lib/Basic/Targets.cpp 2013-10-10 13:39:24.082081296 +0200
@@ -3612,6 +3612,20 @@
return Version >= 7;
}
+ static bool shouldUseInlineAtomic(const llvm::Triple &T) {
+ // On linux, binaries targeting old cpus call functions in libgcc to
+ // perform atomic operations. The implementation in libgcc then calls into
+ // the kernel which on armv6 and newer uses ldrex and strex. The net result
+ // is that if we assume the kernel is at least as recent as the hardware,
+ // it is safe to use atomic instructions on armv6 and newer.
+ if (T.getOS() != llvm::Triple::Linux)
+ return false;
+ StringRef ArchName = T.getArchName();
+ if (ArchName.startswith("armv6") || ArchName.startswith("armv7"))
+ return true;
+ return false;
+ }
+
public:
ARMTargetInfo(const llvm::Triple &Triple)
: TargetInfo(Triple), ABI("aapcs-linux"), CPU("arm1136j-s"),
Index: llvm-toolchain-snapshot_3.4~svn192346/clang/test/CodeGen/linux-arm-atomic.c
===================================================================
--- llvm-toolchain-snapshot_3.4~svn192346.orig/clang/test/CodeGen/linux-arm-atomic.c 2013-10-10 13:39:24.086081296 +0200
+++ llvm-toolchain-snapshot_3.4~svn192346/clang/test/CodeGen/linux-arm-atomic.c 2013-10-10 13:39:24.082081296 +0200
@@ -1,5 +1,15 @@
// RUN: %clang_cc1 %s -emit-llvm -o - -triple=armv7-unknown-linux | FileCheck %s
// RUN: %clang_cc1 %s -emit-llvm -o - -triple=armv6-unknown-linux | FileCheck %s
+
+typedef int _Atomic_word;
+_Atomic_word exchange_and_add(volatile _Atomic_word *__mem, int __val) {
+ return __atomic_fetch_add(__mem, __val, __ATOMIC_ACQ_REL);
+}
+
+// CHECK: define {{.*}} @exchange_and_add
+// CHECK: atomicrmw {{.*}} add
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=armv7-unknown-linux | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=armv6-unknown-linux | FileCheck %s
// RUN: %clang_cc1 %s -emit-llvm -o - -triple=thumbv7-unknown-linux | FileCheck %s
// RUN: %clang_cc1 %s -emit-llvm -o - -triple=armv6-unknown-freebsd | FileCheck %s
// RUN: %clang_cc1 %s -emit-llvm -o - -triple=armv6-unknown-bitrig | FileCheck %s