xref: /aosp_15_r20/external/llvm/test/CodeGen/PowerPC/tls-store2.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=ppc64 -mcpu=pwr7 -O2 -relocation-model=pic < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-m:e-i64:64-n32:64"
4*9880d681SAndroid Build Coastguard Workertarget triple = "powerpc64le-unknown-linux-gnu"
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Worker; Test back-to-back stores of TLS variables to ensure call sequences no
7*9880d681SAndroid Build Coastguard Worker; longer overlap.
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard Worker@__once_callable = external thread_local global i8**
10*9880d681SAndroid Build Coastguard Worker@__once_call = external thread_local global void ()*
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard Workerdefine i64 @call_once(i64 %flag, i8* %ptr) {
13*9880d681SAndroid Build Coastguard Workerentry:
14*9880d681SAndroid Build Coastguard Worker  %var = alloca i8*, align 8
15*9880d681SAndroid Build Coastguard Worker  store i8* %ptr, i8** %var, align 8
16*9880d681SAndroid Build Coastguard Worker  store i8** %var, i8*** @__once_callable, align 8
17*9880d681SAndroid Build Coastguard Worker  store void ()* @__once_call_impl, void ()** @__once_call, align 8
18*9880d681SAndroid Build Coastguard Worker  ret i64 %flag
19*9880d681SAndroid Build Coastguard Worker}
20*9880d681SAndroid Build Coastguard Worker
21*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: call_once:
22*9880d681SAndroid Build Coastguard Worker; CHECK: addi 3, {{[0-9]+}}, __once_callable@got@tlsgd@l
23*9880d681SAndroid Build Coastguard Worker; CHECK: bl __tls_get_addr(__once_callable@tlsgd)
24*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: nop
25*9880d681SAndroid Build Coastguard Worker; FIXME: We could check here for 'std {{[0-9]+}}, 0(3)', but that no longer
26*9880d681SAndroid Build Coastguard Worker; works because, with new scheduling freedom, we create a copy of R3 based on the
27*9880d681SAndroid Build Coastguard Worker; initial scheduling, but don't coalesce it again after we move the instructions
28*9880d681SAndroid Build Coastguard Worker; so that the copy is no longer necessary.
29*9880d681SAndroid Build Coastguard Worker; CHECK: addi 3, {{[0-9]+}}, __once_call@got@tlsgd@l
30*9880d681SAndroid Build Coastguard Worker; CHECK: bl __tls_get_addr(__once_call@tlsgd)
31*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: nop
32*9880d681SAndroid Build Coastguard Worker; FIXME: We don't really need the copy here either, we could move the store up.
33*9880d681SAndroid Build Coastguard Worker; CHECK: mr [[REG1:[0-9]+]], 3
34*9880d681SAndroid Build Coastguard Worker; CHECK: std {{[0-9]+}}, 0([[REG1]])
35*9880d681SAndroid Build Coastguard Worker
36*9880d681SAndroid Build Coastguard Workerdeclare void @__once_call_impl()
37