[llvm-bugs] [Bug 38394] New: Feature request: inline __aeabi_read_tp for ARMv7a ELF TLS

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jul 31 13:37:25 PDT 2018


            Bug ID: 38394
           Summary: Feature request: inline __aeabi_read_tp for ARMv7a ELF
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: ARM
          Assignee: unassignedbugs at nondot.org
          Reporter: rprichard at google.com
                CC: llvm-bugs at lists.llvm.org

Clang generates a call to an __aeabi_read_tp function to access an arm32 ELF
TLS variable using the Initial-Exec or Local-Exec access models. GCC also
generates a call to this ABI function for ARMv5, but for better performance on
ARMv7, it inlines the call.

Could Clang also inline the call?


    __thread int tlsvar;

    int bump() {
      return ++tlsvar;

Clang output (clang test.c -target arm-linuxeabi -march=armv7a -Os -S):

      push  {r11, lr}
      mov r11, sp
      ldr r2, .LCPI0_0
      bl  __aeabi_read_tp
      ldr r1, [r0, r2]
      add r1, r1, #1
      str r1, [r0, r2]
      mov r0, r1
      pop {r11, pc}

GCC output (arm-linux-gnueabi-gcc-7 test.c -march=armv5 -Os -S):

      str lr, [sp, #-4]!
      bl  __aeabi_read_tp @ load_tp_soft
      ldr r2, .L3
      ldr r3, [r0, r2]
      add r3, r3, #1
      str r3, [r0, r2]
      mov r0, r3
      ldr pc, [sp], #4

GCC output (arm-linux-gnueabi-gcc-7 test.c -march=armv7-a -Os -S):

      ldr r3, .L2
      mrc p15, 0, r2, c13, c0, 3  @ load_tp_hard
      ldr r0, [r2, r3]
      add r0, r0, #1
      str r0, [r2, r3]
      bx  lr

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180731/de63939e/attachment.html>

More information about the llvm-bugs mailing list