mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-03 17:31:50 +00:00
7da5357aca
In PIC mode we were previously computing global variable addresses (or GOT entry addresses) by adding the PC, the PC-relative GOT displacement and the GOT-relative symbol/GOT entry displacement. Because the latter two displacements are fixed, we ended up performing one more addition than necessary. This change causes us to compute addresses using a single PC-relative displacement, resulting in a shorter code sequence. This reduces code size by about 4% in a recent build of Chromium for Android. As a result of this change we no longer need to compute the GOT base address in the ARM backend, which allows us to remove the Global Base Reg pass and SDAG lowering for the GOT. We also now no longer use the GOT when addressing a symbol which is known to be defined in the same linkage unit. Specifically, the symbol must have either hidden visibility or a strong definition in the current module in order to not use the the GOT. This is a change from the previous behaviour where we would use the GOT to address externally visible symbols defined in the same module. I think the only cases where this could matter are cases involving symbol interposition, but we don't really support that well anyway. Differential Revision: http://reviews.llvm.org/D13650 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251322 91177308-0d34-0410-b5e6-96231b3b80d8
55 lines
1.7 KiB
LLVM
55 lines
1.7 KiB
LLVM
; RUN: llc < %s -mtriple=armv6-apple-darwin -relocation-model=static | FileCheck %s -check-prefix=STATIC
|
|
; RUN: llc < %s -mtriple=armv6-apple-darwin -relocation-model=dynamic-no-pic | FileCheck %s -check-prefix=DYNAMIC
|
|
; RUN: llc < %s -mtriple=armv6-apple-darwin -relocation-model=pic | FileCheck %s -check-prefix=PIC
|
|
; RUN: llc < %s -mtriple=thumbv6-apple-darwin -relocation-model=pic | FileCheck %s -check-prefix=PIC_T
|
|
; RUN: llc < %s -mtriple=armv7-apple-darwin -relocation-model=pic | FileCheck %s -check-prefix=PIC_V7
|
|
; RUN: llc < %s -mtriple=armv6-linux-gnueabi -relocation-model=pic | FileCheck %s -check-prefix=LINUX
|
|
; RUN: llc < %s -mtriple=thumbv6-linux-gnueabi -relocation-model=pic | FileCheck %s -check-prefix=LINUX_T
|
|
|
|
@G = external global i32
|
|
|
|
define i32 @test1() {
|
|
; STATIC: _test1:
|
|
; STATIC: ldr r0, LCPI0_0
|
|
; STATIC: ldr r0, [r0]
|
|
; STATIC: .long _G
|
|
|
|
; DYNAMIC: _test1:
|
|
; DYNAMIC: ldr r0, LCPI0_0
|
|
; DYNAMIC: ldr r0, [r0]
|
|
; DYNAMIC: ldr r0, [r0]
|
|
; DYNAMIC: .long L_G$non_lazy_ptr
|
|
|
|
; PIC: _test1
|
|
; PIC: ldr r0, LCPI0_0
|
|
; PIC: ldr r0, [pc, r0]
|
|
; PIC: ldr r0, [r0]
|
|
; PIC: .long L_G$non_lazy_ptr-(LPC0_0+8)
|
|
|
|
; PIC_T: _test1
|
|
; PIC_T: ldr r0, LCPI0_0
|
|
; PIC_T: add r0, pc
|
|
; PIC_T: ldr r0, [r0]
|
|
; PIC_T: ldr r0, [r0]
|
|
; PIC_T: .long L_G$non_lazy_ptr-(LPC0_0+4)
|
|
|
|
; PIC_V7: _test1
|
|
; PIC_V7: movw r0, :lower16:(L_G$non_lazy_ptr-(LPC0_0+8))
|
|
; PIC_V7: movt r0, :upper16:(L_G$non_lazy_ptr-(LPC0_0+8))
|
|
; PIC_V7: ldr r0, [pc, r0]
|
|
; PIC_V7: ldr r0, [r0]
|
|
|
|
; LINUX: test1
|
|
; LINUX: ldr r0, .LCPI0_0
|
|
; LINUX: ldr r0, [pc, r0]
|
|
; LINUX: ldr r0, [r0]
|
|
; LINUX: .long G(GOT_PREL)-((.LPC0_0+8)-.Ltmp0)
|
|
|
|
; LINUX_T: ldr r0, .LCPI0_0
|
|
; LINUX_T: add r0, pc
|
|
; LINUX_T: ldr r0, [r0]
|
|
; LINUX_T: ldr r0, [r0]
|
|
%tmp = load i32, i32* @G
|
|
ret i32 %tmp
|
|
}
|