1 ; RUN: llc < %s -mtriple=x86_64-apple-darwin | FileCheck %s
2 ; TLS function were wrongly model and after fixing that, shrink-wrapping
3 ; cannot help here. To achieve the expected lowering, we need to playing
4 ; tricks similar to AArch64 fast TLS calling convention (r255821).
5 ; Re-enable the following run line when
6 ; _RUN_: llc < %s -mtriple=x86_64-apple-darwin -enable-shrink-wrap=true | FileCheck --check-prefix=SHRINK %s
7 %struct.S = type { i8 }
9 @sg = internal thread_local global %struct.S zeroinitializer, align 1
10 @__dso_handle = external global i8
11 @__tls_guard = internal thread_local unnamed_addr global i1 false
13 declare void @_ZN1SC1Ev(%struct.S*)
14 declare void @_ZN1SD1Ev(%struct.S*)
15 declare i32 @_tlv_atexit(void (i8*)*, i8*, i8*)
17 ; Every GPR should be saved - except rdi, rax, and rsp
18 ; CHECK-LABEL: _ZTW2sg
40 ; SHRINK-LABEL: _ZTW2sg
63 define cxx_fast_tlscc nonnull %struct.S* @_ZTW2sg() {
64 %.b.i = load i1, i1* @__tls_guard, align 1
65 br i1 %.b.i, label %__tls_init.exit, label %init.i
68 store i1 true, i1* @__tls_guard, align 1
69 tail call void @_ZN1SC1Ev(%struct.S* nonnull @sg) #2
70 %1 = tail call i32 @_tlv_atexit(void (i8*)* nonnull bitcast (void (%struct.S*)* @_ZN1SD1Ev to void (i8*)*), i8* nonnull getelementptr inbounds (%struct.S, %struct.S* @sg, i64 0, i32 0), i8* nonnull @__dso_handle) #2
71 br label %__tls_init.exit