[compiler-rt] r314718 - [builtins] ARM: Reland fix for assembling builtins in thumb state.

Manoj Gupta via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 2 13:56:49 PDT 2017


Author: manojgupta
Date: Mon Oct  2 13:56:49 2017
New Revision: 314718

URL: http://llvm.org/viewvc/llvm-project?rev=314718&view=rev
Log:
[builtins] ARM: Reland fix for assembling builtins in thumb state.

Summary:
clang does not assemble files in thumb mode unless .thumb declaration
is present. Add .thumb/.arm decl to _FUNCTION macros to ensure 	that
files are assembled correctly.

Also add a fix to ensure that armv7k-watchos can assemble the
aeabi_c{f|d}cmp.S files.

Fixes PR 34715.

Reviewers: compnerd, peter.smith, srhines, weimingz, rengolin, efriedma, t.p.northover, fjricci

Reviewed By: compnerd

Subscribers: aemerson, javed.absar, llvm-commits, kristof.beyls

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

Modified:
    compiler-rt/trunk/lib/builtins/arm/aeabi_cdcmp.S
    compiler-rt/trunk/lib/builtins/arm/aeabi_cfcmp.S
    compiler-rt/trunk/lib/builtins/assembly.h

Modified: compiler-rt/trunk/lib/builtins/arm/aeabi_cdcmp.S
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/arm/aeabi_cdcmp.S?rev=314718&r1=314717&r2=314718&view=diff
==============================================================================
--- compiler-rt/trunk/lib/builtins/arm/aeabi_cdcmp.S (original)
+++ compiler-rt/trunk/lib/builtins/arm/aeabi_cdcmp.S Mon Oct  2 13:56:49 2017
@@ -46,9 +46,12 @@ DEFINE_COMPILERRT_FUNCTION(__aeabi_cdcmp
         pop {r0-r3, lr}
 
         // NaN has been ruled out, so __aeabi_cdcmple can't trap
+        // Use "it ne" + unconditional branch to guarantee a supported relocation if
+        // __aeabi_cdcmple is in a different section for some builds.
+        IT(ne)
         bne __aeabi_cdcmple
 
-#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
+#if defined(USE_THUMB_2)
         mov ip, #APSR_C
         msr APSR_nzcvq, ip
 #else

Modified: compiler-rt/trunk/lib/builtins/arm/aeabi_cfcmp.S
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/arm/aeabi_cfcmp.S?rev=314718&r1=314717&r2=314718&view=diff
==============================================================================
--- compiler-rt/trunk/lib/builtins/arm/aeabi_cfcmp.S (original)
+++ compiler-rt/trunk/lib/builtins/arm/aeabi_cfcmp.S Mon Oct  2 13:56:49 2017
@@ -46,9 +46,12 @@ DEFINE_COMPILERRT_FUNCTION(__aeabi_cfcmp
         pop {r0-r3, lr}
 
         // NaN has been ruled out, so __aeabi_cfcmple can't trap
+        // Use "it ne" + unconditional branch to guarantee a supported relocation if
+        // __aeabi_cfcmple is in a different section for some builds.
+        IT(ne)
         bne __aeabi_cfcmple
 
-#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
+#if defined(USE_THUMB_2)
         mov ip, #APSR_C
         msr APSR_nzcvq, ip
 #else

Modified: compiler-rt/trunk/lib/builtins/assembly.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/assembly.h?rev=314718&r1=314717&r2=314718&view=diff
==============================================================================
--- compiler-rt/trunk/lib/builtins/assembly.h (original)
+++ compiler-rt/trunk/lib/builtins/assembly.h Mon Oct  2 13:56:49 2017
@@ -75,7 +75,7 @@
  * - for '-mthumb -march=armv7' compiler defines '__thumb__' and '__thumb2__'
  */
 #if defined(__thumb2__) || defined(__thumb__)
-#define DEFINE_CODE_STATE .thumb
+#define DEFINE_CODE_STATE .thumb SEPARATOR
 #define DECLARE_FUNC_ENCODING    .thumb_func SEPARATOR
 #if defined(__thumb2__)
 #define USE_THUMB_2
@@ -89,7 +89,7 @@
 #define ITE(cond)
 #endif // defined(__thumb__2)
 #else // !defined(__thumb2__) && !defined(__thumb__)
-#define DEFINE_CODE_STATE .arm
+#define DEFINE_CODE_STATE .arm SEPARATOR
 #define DECLARE_FUNC_ENCODING
 #define IT(cond)
 #define ITT(cond)
@@ -132,6 +132,7 @@
 #endif
 #else // !defined(__arm)
 #define DECLARE_FUNC_ENCODING
+#define DEFINE_CODE_STATE
 #endif
 
 #define GLUE2(a, b) a##b
@@ -146,6 +147,7 @@
 #endif
 
 #define DEFINE_COMPILERRT_FUNCTION(name)                                       \
+  DEFINE_CODE_STATE                                                            \
   FILE_LEVEL_DIRECTIVE SEPARATOR                                               \
   .globl SYMBOL_NAME(name) SEPARATOR                                           \
   SYMBOL_IS_FUNC(SYMBOL_NAME(name)) SEPARATOR                                  \
@@ -154,6 +156,7 @@
   SYMBOL_NAME(name):
 
 #define DEFINE_COMPILERRT_THUMB_FUNCTION(name)                                 \
+  DEFINE_CODE_STATE                                                            \
   FILE_LEVEL_DIRECTIVE SEPARATOR                                               \
   .globl SYMBOL_NAME(name) SEPARATOR                                           \
   SYMBOL_IS_FUNC(SYMBOL_NAME(name)) SEPARATOR                                  \
@@ -162,6 +165,7 @@
   SYMBOL_NAME(name):
 
 #define DEFINE_COMPILERRT_PRIVATE_FUNCTION(name)                               \
+  DEFINE_CODE_STATE                                                            \
   FILE_LEVEL_DIRECTIVE SEPARATOR                                               \
   .globl SYMBOL_NAME(name) SEPARATOR                                           \
   SYMBOL_IS_FUNC(SYMBOL_NAME(name)) SEPARATOR                                  \
@@ -170,6 +174,7 @@
   SYMBOL_NAME(name):
 
 #define DEFINE_COMPILERRT_PRIVATE_FUNCTION_UNMANGLED(name)                     \
+  DEFINE_CODE_STATE                                                            \
   .globl name SEPARATOR                                                        \
   SYMBOL_IS_FUNC(name) SEPARATOR                                               \
   HIDDEN(name) SEPARATOR                                                       \




More information about the llvm-commits mailing list