1 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
2 ; RUN: --relocation-model=pic -mcpu=pwr10 -ppc-asm-full-reg-names < %s | FileCheck %s --check-prefix=CHECK-S
3 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
4 ; RUN: --relocation-model=pic -mcpu=pwr10 -ppc-asm-full-reg-names --filetype=obj -o %t.o < %s
5 ; RUN: llvm-objdump --mcpu=pwr10 -dr %t.o |FileCheck %s --check-prefix=CHECK-O
6 ; RUN: llvm-readelf -s %t.o | FileCheck %s --check-prefix=CHECK-SYM
8 ; These test cases are to ensure that when using pc relative memory operations
9 ; ABI correct code and relocations are produced for General Dynamic TLS Model.
11 @x = external thread_local global i32, align 4
13 define nonnull ptr @GeneralDynamicAddressLoad() {
14 ; CHECK-S-LABEL: GeneralDynamicAddressLoad:
15 ; CHECK-S: paddi r3, 0, x@got@tlsgd@pcrel, 1
16 ; CHECK-S-NEXT: bl __tls_get_addr@notoc(x@tlsgd)
17 ; CHECK-S-NEXT: addi r1, r1, 32
18 ; CHECK-S-NEXT: ld r0, 16(r1)
19 ; CHECK-S-NEXT: mtlr r0
21 ; CHECK-O-LABEL: <GeneralDynamicAddressLoad>:
22 ; CHECK-O: c: 00 00 10 06 00 00 60 38 paddi 3, 0, 0, 1
23 ; CHECK-O-NEXT: 000000000000000c: R_PPC64_GOT_TLSGD_PCREL34 x
24 ; CHECK-O-NEXT: 14: 01 00 00 48 bl 0x14
25 ; CHECK-O-NEXT: 0000000000000014: R_PPC64_TLSGD x
26 ; CHECK-O-NEXT: 0000000000000014: R_PPC64_REL24_NOTOC __tls_get_addr
31 define i32 @GeneralDynamicValueLoad() {
32 ; CHECK-S-LABEL: GeneralDynamicValueLoad:
33 ; CHECK-S: paddi r3, 0, x@got@tlsgd@pcrel, 1
34 ; CHECK-S-NEXT: bl __tls_get_addr@notoc(x@tlsgd)
35 ; CHECK-S-NEXT: lwz r3, 0(r3)
36 ; CHECK-S-NEXT: addi r1, r1, 32
37 ; CHECK-S-NEXT: ld r0, 16(r1)
38 ; CHECK-S-NEXT: mtlr r0
40 ; CHECK-O-LABEL: <GeneralDynamicValueLoad>:
41 ; CHECK-O: 4c: 00 00 10 06 00 00 60 38 paddi 3, 0, 0, 1
42 ; CHECK-O-NEXT: 000000000000004c: R_PPC64_GOT_TLSGD_PCREL34 x
43 ; CHECK-O-NEXT: 54: 01 00 00 48 bl 0x54
44 ; CHECK-O-NEXT: 0000000000000054: R_PPC64_TLSGD x
45 ; CHECK-O-NEXT: 0000000000000054: R_PPC64_REL24_NOTOC __tls_get_addr
46 ; CHECK-O-NEXT: 58: 00 00 63 80 lwz 3, 0(3)
48 ; CHECK-SYM-LABEL: Symbol table '.symtab' contains 7 entries
49 ; CHECK-SYM: 0000000000000000 0 TLS GLOBAL DEFAULT UND x
51 %0 = load i32, ptr @x, align 4