Should we use R_ARM_MOVT_PREL for ARM PIC?
Rafael EspĂndola via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 20 11:54:50 PDT 2016
While refactoring some code I noticed that
@a = hidden global i32 42
define i32* @f() {
ret i32* @a
}
produces
movw r0, :lower16:(_a-(LPC0_0+8))
movt r0, :upper16:(_a-(LPC0_0+8))
LPC0_0:
add r0, pc, r0
When targeting MachO but
ldr r0, .LCPI0_0
.LPC0_0:
add r0, pc, r0
...
.LCPI0_0:
.long a-(.LPC0_0+8)
When targeting ELF.
We could use R_ARM_MOVT_PREL on ELF to use a movw/movt pair and an add
instead of a load and an add. Would that be an improvement? We use
movw/movt for non PIC code, so I assume so. Should I open a bug?
On a similar note, why there is no movw/movt pc relative relocation
that points to a got entry? That would be handy for when the variable
can be preempted.
Cheers,
Rafael
More information about the llvm-commits
mailing list