http://llvm.org/bugs/show_bug.cgi?id=11087
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: [email protected]
ReportedBy: [email protected]
CC: [email protected]
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
this.
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
output):
00001000 <__main-0x8>:
1000: 4800 ldr r0, [pc, #0] (1004
<BuildAttributes$$gibberish+0x1004>)
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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs