• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -mtriple=aarch64-linux-gnu -verify-machineinstrs -relocation-model=pic %s -o - | FileCheck %s
2
3@var = global i32 0
4
5define i32 @get_globalvar() {
6; CHECK-LABEL: get_globalvar:
7
8  %val = load i32, i32* @var
9; CHECK: adrp x[[GOTHI:[0-9]+]], :got:var
10; CHECK: ldr x[[GOTLOC:[0-9]+]], [x[[GOTHI]], :got_lo12:var]
11; CHECK: ldr w0, [x[[GOTLOC]]]
12
13  ret i32 %val
14}
15
16define i32* @get_globalvaraddr() {
17; CHECK-LABEL: get_globalvaraddr:
18
19  %val = load i32, i32* @var
20; CHECK: adrp x[[GOTHI:[0-9]+]], :got:var
21; CHECK: ldr x0, [x[[GOTHI]], :got_lo12:var]
22
23  ret i32* @var
24}
25
26@hiddenvar = hidden global i32 0
27
28define i32 @get_hiddenvar() {
29; CHECK-LABEL: get_hiddenvar:
30
31  %val = load i32, i32* @hiddenvar
32; CHECK: adrp x[[HI:[0-9]+]], hiddenvar
33; CHECK: ldr w0, [x[[HI]], :lo12:hiddenvar]
34
35  ret i32 %val
36}
37
38define i32* @get_hiddenvaraddr() {
39; CHECK-LABEL: get_hiddenvaraddr:
40
41  %val = load i32, i32* @hiddenvar
42; CHECK: adrp [[HI:x[0-9]+]], hiddenvar
43; CHECK: add x0, [[HI]], :lo12:hiddenvar
44
45  ret i32* @hiddenvar
46}
47
48define void()* @get_func() {
49; CHECK-LABEL: get_func:
50
51  ret void()* bitcast(void()*()* @get_func to void()*)
52; CHECK: adrp x[[GOTHI:[0-9]+]], :got:get_func
53; CHECK: ldr x0, [x[[GOTHI]], :got_lo12:get_func]
54}
55