[PATCH] D39700: [Builtins] Do not use tailcall for Thumb1

Weiming Zhao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 6 14:27:45 PST 2017


weimingz created this revision.
Herald added a subscriber: javed.absar.

The `b` instruction in Thumb1 has limited range, which may cause link-time errors if the jump target is far away.
This patch guards the tailcalls for non-Thumb1


Repository:
  rL LLVM

https://reviews.llvm.org/D39700

Files:
  lib/builtins/arm/aeabi_memcmp.S
  lib/builtins/arm/aeabi_memmove.S
  lib/builtins/arm/aeabi_memset.S


Index: lib/builtins/arm/aeabi_memset.S
===================================================================
--- lib/builtins/arm/aeabi_memset.S
+++ lib/builtins/arm/aeabi_memset.S
@@ -18,7 +18,13 @@
         mov     r3, r1
         mov     r1, r2
         mov     r2, r3
+#ifdef USE_THUMB_1
+        push    {r7, lr}
+        bl      memset
+        pop     {r7, pc}
+#else
         b       memset
+#endif
 END_COMPILERRT_FUNCTION(__aeabi_memset)
 
 DEFINE_AEABI_FUNCTION_ALIAS(__aeabi_memset4, __aeabi_memset)
@@ -28,7 +34,13 @@
 DEFINE_COMPILERRT_FUNCTION(__aeabi_memclr)
         mov     r2, r1
         movs    r1, #0
+#ifdef USE_THUMB_1
+        push    {r7, lr}
+        bl      memset
+        pop     {r7, pc}
+#else
         b       memset
+#endif
 END_COMPILERRT_FUNCTION(__aeabi_memclr)
 
 DEFINE_AEABI_FUNCTION_ALIAS(__aeabi_memclr4, __aeabi_memclr)
Index: lib/builtins/arm/aeabi_memmove.S
===================================================================
--- lib/builtins/arm/aeabi_memmove.S
+++ lib/builtins/arm/aeabi_memmove.S
@@ -13,7 +13,13 @@
 
         .p2align 2
 DEFINE_COMPILERRT_FUNCTION(__aeabi_memmove)
+#ifdef USE_THUMB_1
+        push    {r7, lr}
+        bl      memmove
+        pop     {r7, pc}
+#else
         b       memmove
+#endif
 END_COMPILERRT_FUNCTION(__aeabi_memmove)
 
 DEFINE_AEABI_FUNCTION_ALIAS(__aeabi_memmove4, __aeabi_memmove)
Index: lib/builtins/arm/aeabi_memcmp.S
===================================================================
--- lib/builtins/arm/aeabi_memcmp.S
+++ lib/builtins/arm/aeabi_memcmp.S
@@ -14,7 +14,13 @@
         .syntax unified
         .p2align 2
 DEFINE_COMPILERRT_FUNCTION(__aeabi_memcmp)
+#ifdef USE_THUMB_1
+        push    {r7, lr}
+        bl      memcmp
+        pop     {r7, pc}
+#else
         b       memcmp
+#endif
 END_COMPILERRT_FUNCTION(__aeabi_memcmp)
 
 DEFINE_AEABI_FUNCTION_ALIAS(__aeabi_memcmp4, __aeabi_memcmp)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39700.121788.patch
Type: text/x-patch
Size: 1901 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171106/c254e4a5/attachment.bin>


More information about the llvm-commits mailing list