llvm.org GIT mirror llvm / 164bd15
Convert a llc -filetype=obj test into a llvm-mc test. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193534 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 6 years ago
2 changed file(s) with 98 addition(s) and 16 deletion(s). Raw diff Collapse all Expand all
0 ; RUN: llc -mtriple=aarch64-none-linux-gnu -verify-machineinstrs -relocation-model=pic %s -o - | FileCheck %s
1 ; RUN: llc -mtriple=aarch64-none-linux-gnu -verify-machineinstrs -relocation-model=pic -filetype=obj %s -o -| llvm-objdump -r - | FileCheck --check-prefix=CHECK-ELF %s
21
32 @var = global i32 0
4
5 ; CHECK-ELF: RELOCATION RECORDS FOR [.rela.text]
63
74 define i32 @get_globalvar() {
85 ; CHECK-LABEL: get_globalvar:
129 ; CHECK: ldr x[[GOTLOC:[0-9]+]], [x[[GOTHI]], #:got_lo12:var]
1310 ; CHECK: ldr w0, [x[[GOTLOC]]]
1411
15 ; CHECK-ELF: R_AARCH64_ADR_GOT_PAGE var
16 ; CHECK-ELF: R_AARCH64_LD64_GOT_LO12_NC var
1712 ret i32 %val
1813 }
1914
2419 ; CHECK: adrp x[[GOTHI:[0-9]+]], :got:var
2520 ; CHECK: ldr x0, [x[[GOTHI]], #:got_lo12:var]
2621
27 ; CHECK-ELF: R_AARCH64_ADR_GOT_PAGE var
28 ; CHECK-ELF: R_AARCH64_LD64_GOT_LO12_NC var
2922 ret i32* @var
3023 }
3124
3831 ; CHECK: adrp x[[HI:[0-9]+]], hiddenvar
3932 ; CHECK: ldr w0, [x[[HI]], #:lo12:hiddenvar]
4033
41 ; CHECK-ELF: R_AARCH64_ADR_PREL_PG_HI21 hiddenvar
42 ; CHECK-ELF: R_AARCH64_LDST32_ABS_LO12_NC hiddenvar
4334 ret i32 %val
4435 }
4536
5041 ; CHECK: adrp [[HI:x[0-9]+]], hiddenvar
5142 ; CHECK: add x0, [[HI]], #:lo12:hiddenvar
5243
53 ; CHECK-ELF: R_AARCH64_ADR_PREL_PG_HI21 hiddenvar
54 ; CHECK-ELF: R_AARCH64_ADD_ABS_LO12_NC hiddenvar
5544 ret i32* @hiddenvar
5645 }
5746
6150 ret void()* bitcast(void()*()* @get_func to void()*)
6251 ; CHECK: adrp x[[GOTHI:[0-9]+]], :got:get_func
6352 ; CHECK: ldr x0, [x[[GOTHI]], #:got_lo12:get_func]
64
65 ; Particularly important that the ADRP gets a relocation, LLVM tends to think
66 ; it can relax it because it knows where get_func is. It can't!
67 ; CHECK-ELF: R_AARCH64_ADR_GOT_PAGE get_func
68 ; CHECK-ELF: R_AARCH64_LD64_GOT_LO12_NC get_func
6953 }
0 // RUN: llvm-mc -triple=aarch64-none-linux-gnu -filetype=obj %s -o -| llvm-objdump -r - | FileCheck %s
1
2 // CHECK: RELOCATION RECORDS FOR [.rela.text]
3
4 .file "/home/espindola/llvm/llvm/test/CodeGen/AArch64/basic-pic.ll"
5 .text
6 .globl get_globalvar
7 .type get_globalvar,@function
8 get_globalvar: // @get_globalvar
9 .cfi_startproc
10 // BB#0:
11 adrp x0, :got:var
12 ldr x0, [x0, #:got_lo12:var]
13 ldr w0, [x0]
14 ret
15 .Ltmp0:
16 .size get_globalvar, .Ltmp0-get_globalvar
17 .cfi_endproc
18
19 // CHECK: R_AARCH64_ADR_GOT_PAGE var
20 // CHECK: R_AARCH64_LD64_GOT_LO12_NC var
21
22 .globl get_globalvaraddr
23 .type get_globalvaraddr,@function
24 get_globalvaraddr: // @get_globalvaraddr
25 .cfi_startproc
26 // BB#0:
27 adrp x0, :got:var
28 ldr x0, [x0, #:got_lo12:var]
29 ret
30 .Ltmp1:
31 .size get_globalvaraddr, .Ltmp1-get_globalvaraddr
32 .cfi_endproc
33 // CHECK: R_AARCH64_ADR_GOT_PAGE var
34 // CHECK: R_AARCH64_LD64_GOT_LO12_NC var
35
36 .globl get_hiddenvar
37 .type get_hiddenvar,@function
38 get_hiddenvar: // @get_hiddenvar
39 .cfi_startproc
40 // BB#0:
41 adrp x0, hiddenvar
42 ldr w0, [x0, #:lo12:hiddenvar]
43 ret
44 .Ltmp2:
45 .size get_hiddenvar, .Ltmp2-get_hiddenvar
46 .cfi_endproc
47 // CHECK: R_AARCH64_ADR_PREL_PG_HI21 hiddenvar
48 // CHECK: R_AARCH64_LDST32_ABS_LO12_NC hiddenvar
49
50 .globl get_hiddenvaraddr
51 .type get_hiddenvaraddr,@function
52 get_hiddenvaraddr: // @get_hiddenvaraddr
53 .cfi_startproc
54 // BB#0:
55 adrp x0, hiddenvar
56 add x0, x0, #:lo12:hiddenvar
57 ret
58 .Ltmp3:
59 .size get_hiddenvaraddr, .Ltmp3-get_hiddenvaraddr
60 .cfi_endproc
61 // CHECK: R_AARCH64_ADR_PREL_PG_HI21 hiddenvar
62 // CHECK: R_AARCH64_ADD_ABS_LO12_NC hiddenvar
63
64 .globl get_func
65 .type get_func,@function
66 get_func: // @get_func
67 .cfi_startproc
68 // BB#0:
69 adrp x0, :got:get_func
70 ldr x0, [x0, #:got_lo12:get_func]
71 ret
72 .Ltmp4:
73 .size get_func, .Ltmp4-get_func
74 .cfi_endproc
75
76 // Particularly important that the ADRP gets a relocation, LLVM tends to think
77 // it can relax it because it knows where get_func is. It can't!
78 // CHECK: R_AARCH64_ADR_GOT_PAGE get_func
79 // CHECK: R_AARCH64_LD64_GOT_LO12_NC get_func
80
81 .type var,@object // @var
82 .bss
83 .globl var
84 .align 2
85 var:
86 .word 0 // 0x0
87 .size var, 4
88
89 .hidden hiddenvar // @hiddenvar
90 .type hiddenvar,@object
91 .globl hiddenvar
92 .align 2
93 hiddenvar:
94 .word 0 // 0x0
95 .size hiddenvar, 4
96
97