2014-05-24 20:50:23 +08:00
|
|
|
; RUN: llc -mtriple=aarch64-linux-gnu -verify-machineinstrs -relocation-model=pic %s -o - | FileCheck %s
|
2013-01-31 20:12:40 +08:00
|
|
|
|
|
|
|
@var = global i32 0
|
|
|
|
|
|
|
|
define i32 @get_globalvar() {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: get_globalvar:
|
2013-01-31 20:12:40 +08:00
|
|
|
|
2015-02-28 05:17:42 +08:00
|
|
|
%val = load i32, i32* @var
|
2013-01-31 20:12:40 +08:00
|
|
|
; CHECK: adrp x[[GOTHI:[0-9]+]], :got:var
|
2014-04-14 20:50:58 +08:00
|
|
|
; CHECK: ldr x[[GOTLOC:[0-9]+]], [x[[GOTHI]], {{#?}}:got_lo12:var]
|
2013-01-31 20:12:40 +08:00
|
|
|
; CHECK: ldr w0, [x[[GOTLOC]]]
|
|
|
|
|
|
|
|
ret i32 %val
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32* @get_globalvaraddr() {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: get_globalvaraddr:
|
2013-01-31 20:12:40 +08:00
|
|
|
|
2015-02-28 05:17:42 +08:00
|
|
|
%val = load i32, i32* @var
|
2013-01-31 20:12:40 +08:00
|
|
|
; CHECK: adrp x[[GOTHI:[0-9]+]], :got:var
|
2014-04-14 20:50:58 +08:00
|
|
|
; CHECK: ldr x0, [x[[GOTHI]], {{#?}}:got_lo12:var]
|
2013-01-31 20:12:40 +08:00
|
|
|
|
|
|
|
ret i32* @var
|
|
|
|
}
|
|
|
|
|
|
|
|
@hiddenvar = hidden global i32 0
|
|
|
|
|
|
|
|
define i32 @get_hiddenvar() {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: get_hiddenvar:
|
2013-01-31 20:12:40 +08:00
|
|
|
|
2015-02-28 05:17:42 +08:00
|
|
|
%val = load i32, i32* @hiddenvar
|
2013-01-31 20:12:40 +08:00
|
|
|
; CHECK: adrp x[[HI:[0-9]+]], hiddenvar
|
2014-04-14 20:50:58 +08:00
|
|
|
; CHECK: ldr w0, [x[[HI]], {{#?}}:lo12:hiddenvar]
|
2013-01-31 20:12:40 +08:00
|
|
|
|
|
|
|
ret i32 %val
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32* @get_hiddenvaraddr() {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: get_hiddenvaraddr:
|
2013-01-31 20:12:40 +08:00
|
|
|
|
2015-02-28 05:17:42 +08:00
|
|
|
%val = load i32, i32* @hiddenvar
|
2013-01-31 20:12:40 +08:00
|
|
|
; CHECK: adrp [[HI:x[0-9]+]], hiddenvar
|
2014-04-14 20:50:58 +08:00
|
|
|
; CHECK: add x0, [[HI]], {{#?}}:lo12:hiddenvar
|
2013-01-31 20:12:40 +08:00
|
|
|
|
|
|
|
ret i32* @hiddenvar
|
|
|
|
}
|
|
|
|
|
|
|
|
define void()* @get_func() {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: get_func:
|
2013-01-31 20:12:40 +08:00
|
|
|
|
|
|
|
ret void()* bitcast(void()*()* @get_func to void()*)
|
|
|
|
; CHECK: adrp x[[GOTHI:[0-9]+]], :got:get_func
|
2014-04-14 20:50:58 +08:00
|
|
|
; CHECK: ldr x0, [x[[GOTHI]], {{#?}}:got_lo12:get_func]
|
2013-07-14 04:38:47 +08:00
|
|
|
}
|