xref: /aosp_15_r20/external/llvm/test/CodeGen/PowerPC/tls-pic.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=ppc64 -mcpu=pwr7 -O0 -relocation-model=pic < %s | FileCheck -check-prefix=OPT0 %s
2*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=ppc64 -mcpu=pwr7 -O1 -relocation-model=pic < %s | FileCheck -check-prefix=OPT1 %s
3*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=ppc32 -O0 -relocation-model=pic < %s | FileCheck -check-prefix=OPT0-32 %s
4*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=ppc32 -O1 -relocation-model=pic < %s | FileCheck -check-prefix=OPT1-32 %s
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Workertarget triple = "powerpc64-unknown-linux-gnu"
7*9880d681SAndroid Build Coastguard Worker; Test correct assembly code generation for thread-local storage using
8*9880d681SAndroid Build Coastguard Worker; the local dynamic model.
9*9880d681SAndroid Build Coastguard Worker
10*9880d681SAndroid Build Coastguard Worker@a = hidden thread_local global i32 0, align 4
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard Workerdefine signext i32 @main() nounwind {
13*9880d681SAndroid Build Coastguard Workerentry:
14*9880d681SAndroid Build Coastguard Worker  %retval = alloca i32, align 4
15*9880d681SAndroid Build Coastguard Worker  store i32 0, i32* %retval
16*9880d681SAndroid Build Coastguard Worker  %0 = load i32, i32* @a, align 4
17*9880d681SAndroid Build Coastguard Worker  ret i32 %0
18*9880d681SAndroid Build Coastguard Worker}
19*9880d681SAndroid Build Coastguard Worker
20*9880d681SAndroid Build Coastguard Worker; OPT0-LABEL: main:
21*9880d681SAndroid Build Coastguard Worker; OPT0:      addis [[REG:[0-9]+]], 2, a@got@tlsld@ha
22*9880d681SAndroid Build Coastguard Worker; OPT0:      addi 3, [[REG]], a@got@tlsld@l
23*9880d681SAndroid Build Coastguard Worker; OPT0:      bl __tls_get_addr(a@tlsld)
24*9880d681SAndroid Build Coastguard Worker; OPT0-NEXT: nop
25*9880d681SAndroid Build Coastguard Worker; OPT0:      addis [[REG2:[0-9]+]], 3, a@dtprel@ha
26*9880d681SAndroid Build Coastguard Worker; OPT0:      addi {{[0-9]+}}, [[REG2]], a@dtprel@l
27*9880d681SAndroid Build Coastguard Worker; OPT0-32-LABEL: main
28*9880d681SAndroid Build Coastguard Worker; OPT0-32:        addi {{[0-9]+}}, {{[0-9]+}}, a@got@tlsld
29*9880d681SAndroid Build Coastguard Worker; OPT0-32:        bl __tls_get_addr(a@tlsld)@PLT
30*9880d681SAndroid Build Coastguard Worker; OPT0-32:        addis [[REG:[0-9]+]], 3, a@dtprel@ha
31*9880d681SAndroid Build Coastguard Worker; OPT0-32:        addi  {{[0-9]+}}, [[REG]], a@dtprel@l
32*9880d681SAndroid Build Coastguard Worker; OPT1-32-LABEL: main
33*9880d681SAndroid Build Coastguard Worker; OPT1-32:        addi 3, {{[0-9]+}}, a@got@tlsld
34*9880d681SAndroid Build Coastguard Worker; OPT1-32:        bl __tls_get_addr(a@tlsld)@PLT
35*9880d681SAndroid Build Coastguard Worker; OPT1-32:        addis [[REG:[0-9]+]], 3, a@dtprel@ha
36*9880d681SAndroid Build Coastguard Worker; OPT1-32:        addi  {{[0-9]+}}, [[REG]], a@dtprel@l
37*9880d681SAndroid Build Coastguard Worker
38*9880d681SAndroid Build Coastguard Worker; Test peephole optimization for thread-local storage using the
39*9880d681SAndroid Build Coastguard Worker; local dynamic model.
40*9880d681SAndroid Build Coastguard Worker
41*9880d681SAndroid Build Coastguard Worker; OPT1-LABEL: main:
42*9880d681SAndroid Build Coastguard Worker; OPT1:      addis [[REG:[0-9]+]], 2, a@got@tlsld@ha
43*9880d681SAndroid Build Coastguard Worker; OPT1:      addi 3, [[REG]], a@got@tlsld@l
44*9880d681SAndroid Build Coastguard Worker; OPT1:      bl __tls_get_addr(a@tlsld)
45*9880d681SAndroid Build Coastguard Worker; OPT1-NEXT: nop
46*9880d681SAndroid Build Coastguard Worker; OPT1:      addis [[REG2:[0-9]+]], 3, a@dtprel@ha
47*9880d681SAndroid Build Coastguard Worker; OPT1:      lwa {{[0-9]+}}, a@dtprel@l([[REG2]])
48*9880d681SAndroid Build Coastguard Worker
49*9880d681SAndroid Build Coastguard Worker; Test correct assembly code generation for thread-local storage using
50*9880d681SAndroid Build Coastguard Worker; the general dynamic model.
51*9880d681SAndroid Build Coastguard Worker
52*9880d681SAndroid Build Coastguard Worker@a2 = thread_local global i32 0, align 4
53*9880d681SAndroid Build Coastguard Worker
54*9880d681SAndroid Build Coastguard Workerdefine signext i32 @main2() nounwind {
55*9880d681SAndroid Build Coastguard Workerentry:
56*9880d681SAndroid Build Coastguard Worker  %retval = alloca i32, align 4
57*9880d681SAndroid Build Coastguard Worker  store i32 0, i32* %retval
58*9880d681SAndroid Build Coastguard Worker  %0 = load i32, i32* @a2, align 4
59*9880d681SAndroid Build Coastguard Worker  ret i32 %0
60*9880d681SAndroid Build Coastguard Worker}
61*9880d681SAndroid Build Coastguard Worker
62*9880d681SAndroid Build Coastguard Worker; OPT1-LABEL: main2
63*9880d681SAndroid Build Coastguard Worker; OPT1:      addis [[REG:[0-9]+]], 2, a2@got@tlsgd@ha
64*9880d681SAndroid Build Coastguard Worker; OPT1:      addi 3, [[REG]], a2@got@tlsgd@l
65*9880d681SAndroid Build Coastguard Worker; OPT1:      bl __tls_get_addr(a2@tlsgd)
66*9880d681SAndroid Build Coastguard Worker; OPT1-NEXT: nop
67*9880d681SAndroid Build Coastguard Worker; OPT1-32-LABEL: main2
68*9880d681SAndroid Build Coastguard Worker; OPT1-32:        addi 3, {{[0-9]+}}, a2@got@tlsgd
69*9880d681SAndroid Build Coastguard Worker; OPT1-32:        bl __tls_get_addr(a2@tlsgd)@PLT
70