216bfef7d5c5d10a5134cfe9086d7f402b2dfc2c
[oota-llvm.git] / test / CodeGen / AArch64 / got-abuse.ll
1 ; RUN: llc -mtriple=aarch64-none-linux-gnu -relocation-model=pic < %s | FileCheck %s
2 ; RUN: llc -mtriple=aarch64-none-linux-gnu -relocation-model=pic -filetype=obj < %s
3 ; RUN: llc -mtriple=arm64-none-linux-gnu -relocation-model=pic -o - %s | FileCheck %s
4 ; RUN: llc -mtriple=arm64-none-linux-gnu -relocation-model=pic -filetype=obj -o - %s
5
6 ; LLVM gives well-defined semantics to this horrible construct (though C says
7 ; it's undefined). Regardless, we shouldn't crash. The important feature here is
8 ; that in general the only way to access a GOT symbol is via a 64-bit
9 ; load. Neither of these alternatives has the ELF relocations required to
10 ; support it:
11 ;    + ldr wD, [xN, #:got_lo12:func]
12 ;    + add xD, xN, #:got_lo12:func
13
14 declare void @consume(i32)
15 declare void @func()
16
17 define void @foo() nounwind {
18 ; CHECK-LABEL: foo:
19 entry:
20   call void @consume(i32 ptrtoint (void ()* @func to i32))
21 ; CHECK: adrp x[[ADDRHI:[0-9]+]], :got:func
22 ; CHECK: ldr {{x[0-9]+}}, [x[[ADDRHI]], {{#?}}:got_lo12:func]
23   ret void
24 }
25