1 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -stop-after=finalize-isel %s -o - | FileCheck %s
3 @i = thread_local global i32 0, align 4
5 define noundef i32 @foo() {
6 ; CHECK: %0:gr64 = MOV64rm $rip, 1, $noreg, target-flags(x86-gottpoff) @i, $noreg :: (load (s64) from got)
7 ; CHECK: %1:gr32 = MOV32rm %0, 1, $noreg, 0, $fs :: (load (s32) from %ir.0)
8 ; CHECK: %2:gr32 = nsw INC32r %1, implicit-def dead $eflags
9 ; CHECK: MOV32mr %0, 1, $noreg, 0, $fs, %2 :: (store (s32) into %ir.0)
10 ; CHECK: $eax = COPY %2
13 %0 = call ptr @llvm.threadlocal.address(ptr @i)
14 %1 = load i32, ptr %0, align 4
15 %inc = add nsw i32 %1, 1
16 store i32 %inc, ptr %0, align 4
17 %2 = call ptr @llvm.threadlocal.address(ptr @i)
18 %3 = load i32, ptr %2, align 4
22 @j = thread_local addrspace(1) global i32 addrspace(0)* @i, align 4
23 define noundef i32 @bar() {
24 ; CHECK: %0:gr64 = MOV64rm $rip, 1, $noreg, target-flags(x86-gottpoff) @j, $noreg :: (load (s64) from got)
25 ; CHECK: %1:gr32 = MOV32rm %0, 1, $noreg, 0, $fs :: (load (s32) from %ir.0, addrspace 1)
26 ; CHECK: %2:gr32 = nsw INC32r %1, implicit-def dead $eflags
27 ; CHECK: MOV32mr %0, 1, $noreg, 0, $fs, %2 :: (store (s32) into %ir.0, addrspace 1)
28 ; CHECK: $eax = COPY %2
31 %0 = call ptr addrspace(1) @llvm.threadlocal.address.p1(ptr addrspace(1) @j)
32 %1 = load i32, ptr addrspace(1) %0, align 4
33 %inc = add nsw i32 %1, 1
34 store i32 %inc, ptr addrspace(1) %0, align 4
35 %2 = call ptr addrspace(1) @llvm.threadlocal.address.p1(ptr addrspace(1) @j)
36 %3 = load i32, ptr addrspace(1) %2, align 4
40 declare nonnull ptr @llvm.threadlocal.address(ptr nonnull) nounwind readnone willreturn
41 declare nonnull ptr addrspace(1) @llvm.threadlocal.address.p1(ptr addrspace(1) nonnull) nounwind readnone willreturn