1 ; RUN: llc --relocation-model=pic < %s | FileCheck %s
2 ; RUN: llc --relocation-model=pic --relax-elf-relocations --filetype=obj -o - < %s | llvm-objdump -d -r - | FileCheck %s --check-prefix=OBJ
4 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-unknown-linux-gnu"
7 @global = external global i32
10 define ptr @global_addr() #0 {
11 ; CHECK-LABEL: global_addr:
12 ; CHECK: movq global@GOTPCREL_NORELAX(%rip), %rax
15 ; OBJ-LABEL: <global_addr>:
17 ; OBJ-NEXT: R_X86_64_GOTPCREL global
22 define i32 @global_load() #0 {
23 ; CHECK-LABEL: global_load:
24 ; CHECK: movq global@GOTPCREL_NORELAX(%rip), [[REG:%r[0-9a-z]+]]
25 ; CHECK: movl ([[REG]]), %eax
28 ; OBJ-LABEL: <global_load>:
30 ; OBJ-NEXT: R_X86_64_GOTPCREL global
32 %load = load i32, ptr @global
36 define void @global_store() #0 {
37 ; CHECK-LABEL: global_store:
38 ; CHECK: movq global@GOTPCREL_NORELAX(%rip), [[REG:%r[0-9a-z]+]]
39 ; CHECK: movl $0, ([[REG]])
42 ; OBJ-LABEL: <global_store>:
44 ; OBJ-NEXT: R_X86_64_GOTPCREL global
46 store i32 0, ptr @global
50 define ptr @func_addr() #0 {
51 ; CHECK-LABEL: func_addr:
52 ; CHECK: movq func@GOTPCREL(%rip), %rax
55 ; OBJ-LABEL: <func_addr>:
57 ; OBJ-NEXT: R_X86_64_REX_GOTPCRELX func
62 ; Jump tables shouldn't go through the GOT.
63 define i32 @jump_table(i32 %x) #0 {
64 ; CHECK-LABEL: jump_table:
67 switch i32 %x, label %default [
85 attributes #0 = { "target-features"="+tagged-globals" }