1 ; RUN: opt -S -mtriple=x86_64-unknown-unknown -tlshoist --relocation-model=pic --tls-load-hoist=true -o - %s | FileCheck %s --check-prefix=HOIST0
2 ; RUN: opt -S -mtriple=x86_64-unknown-unknown -tlshoist --relocation-model=pic -o - %s | FileCheck %s --check-prefix=HOIST2
4 $_ZTW5thl_x = comdat any
6 @thl_x = thread_local global i32 0, align 4
8 ; Function Attrs: mustprogress uwtable
9 define i32 @_Z2f1i(i32 %c) local_unnamed_addr #0 {
11 %0 = load i32, i32* @thl_x, align 4
12 %call = tail call i32 @_Z5gfunci(i32 %0)
13 %1 = load i32, i32* @thl_x, align 4
14 %call1 = tail call i32 @_Z5gfunci(i32 %1)
20 ;HOIST0-NEXT: %tls_bitcast = bitcast i32* @thl_x to i32*
21 ;HOIST0-NEXT: %0 = load i32, i32* %tls_bitcast, align 4
22 ;HOIST0-NEXT: %call = tail call i32 @_Z5gfunci(i32 %0)
23 ;HOIST0-NEXT: %1 = load i32, i32* %tls_bitcast, align 4
24 ;HOIST0-NEXT: %call1 = tail call i32 @_Z5gfunci(i32 %1)
25 ;HOIST0-NEXT: ret i32 1
29 ;HOIST2-NEXT: %0 = load i32, i32* @thl_x, align 4
30 ;HOIST2-NEXT: %call = tail call i32 @_Z5gfunci(i32 %0)
31 ;HOIST2-NEXT: %1 = load i32, i32* @thl_x, align 4
32 ;HOIST2-NEXT: %call1 = tail call i32 @_Z5gfunci(i32 %1)
33 ;HOIST2-NEXT: ret i32 1
35 declare i32 @_Z5gfunci(i32) local_unnamed_addr #1
37 ; Function Attrs: uwtable
38 define weak_odr hidden i32* @_ZTW5thl_x() local_unnamed_addr #2 comdat {
42 attributes #0 = { mustprogress uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
43 attributes #1 = { "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
44 attributes #2 = { uwtable "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
46 !llvm.module.flags = !{!0, !1, !2}
48 !0 = !{i32 1, !"wchar_size", i32 4}
49 !1 = !{i32 7, !"PIC Level", i32 2}
50 !2 = !{i32 7, !"uwtable", i32 1}