[LLVMbugs] [Bug 11087] New: Save code space on ARM Thumb with PC-relative LDR

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Oct 7 17:10:25 PDT 2011


           Summary: Save code space on ARM Thumb with PC-relative LDR
           Product: libraries
           Version: 2.9
          Platform: PC
        OS/Version: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: ARM
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: xocotl at gmail.com
                CC: llvmbugs at cs.uiuc.edu

It would be nice if LLVM was able to save space on ARM Thumb/Thumb2 by using
PC-relative LDR, at least when set to optimize for size. The Keil compiler does

For example, instead of 8-byte MOVW/MOVT, what the Keil compiler will do is
intersperse the 8-byte relocation with the code, and use a PC-relative LDR.
This takes 6 bytes instead of 8. Trivial example from a boot loader (objdump

00001000 <__main-0x8>:
    1000:    4800          ldr    r0, [pc, #0]    (1004
    1002:    4700          bx    r0
    1004:    0000100d     .word    0x0000100d

The other nice effect of this is that it seems to search through your
already-existing constants before introducing new 4-byte addresses. So often
the 8-byte MOVW/MOVT becomes 2 bytes. Once, for example, I had a table of
function pointers, and it just pulled the address from there as it was only a
few hundred bytes away.

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list