xref: /aosp_15_r20/external/llvm/test/CodeGen/SystemZ/tls-06.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; Test general-dynamic TLS access optimizations.
2*9880d681SAndroid Build Coastguard Worker;
3*9880d681SAndroid Build Coastguard Worker; If we access two different TLS variables, we need two calls to
4*9880d681SAndroid Build Coastguard Worker; __tls_get_offset, but should load _GLOBAL_OFFSET_TABLE only once.
5*9880d681SAndroid Build Coastguard Worker;
6*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mcpu=z10 -mtriple=s390x-linux-gnu -relocation-model=pic | grep "__tls_get_offset" | count 2
7*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mcpu=z10 -mtriple=s390x-linux-gnu -relocation-model=pic | grep "_GLOBAL_OFFSET_TABLE_" | count 1
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard Worker@x = thread_local global i32 0
10*9880d681SAndroid Build Coastguard Worker@y = thread_local global i32 0
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard Workerdefine i32 @foo() {
13*9880d681SAndroid Build Coastguard Worker  %valx = load i32, i32* @x
14*9880d681SAndroid Build Coastguard Worker  %valy = load i32, i32* @y
15*9880d681SAndroid Build Coastguard Worker  %add = add nsw i32 %valx, %valy
16*9880d681SAndroid Build Coastguard Worker  ret i32 %add
17*9880d681SAndroid Build Coastguard Worker}
18