1 ; RUN: llc < %s -mtriple=x86_64-apple-darwin | FileCheck %s 2 ; RUN: llc < %s -mtriple=x86_64-apple-darwin -enable-shrink-wrap=true | FileCheck --check-prefix=SHRINK %s 3 %struct.S = type { i8 } 4 5 @sg = internal thread_local global %struct.S zeroinitializer, align 1 6 @__dso_handle = external global i8 7 @__tls_guard = internal thread_local unnamed_addr global i1 false 8 9 declare void @_ZN1SC1Ev(%struct.S*) 10 declare void @_ZN1SD1Ev(%struct.S*) 11 declare i32 @_tlv_atexit(void (i8*)*, i8*, i8*) 12 13 ; Every GPR should be saved - except rdi, rax, and rsp 14 ; CHECK-LABEL: _ZTW2sg 15 ; CHECK: pushq %r11 16 ; CHECK: pushq %r10 17 ; CHECK: pushq %r9 18 ; CHECK: pushq %r8 19 ; CHECK: pushq %rsi 20 ; CHECK: pushq %rdx 21 ; CHECK: pushq %rcx 22 ; CHECK: pushq %rbx 23 ; CHECK: callq 24 ; CHECK: jne 25 ; CHECK: callq 26 ; CHECK: tlv_atexit 27 ; CHECK: callq 28 ; CHECK: popq %rbx 29 ; CHECK: popq %rcx 30 ; CHECK: popq %rdx 31 ; CHECK: popq %rsi 32 ; CHECK: popq %r8 33 ; CHECK: popq %r9 34 ; CHECK: popq %r10 35 ; CHECK: popq %r11 36 ; SHRINK-LABEL: _ZTW2sg 37 ; SHRINK: callq 38 ; SHRINK: jne 39 ; SHRINK: pushq %r11 40 ; SHRINK: pushq %r10 41 ; SHRINK: pushq %r9 42 ; SHRINK: pushq %r8 43 ; SHRINK: pushq %rsi 44 ; SHRINK: pushq %rdx 45 ; SHRINK: pushq %rcx 46 ; SHRINK: pushq %rbx 47 ; SHRINK: callq 48 ; SHRINK: tlv_atexit 49 ; SHRINK: popq %rbx 50 ; SHRINK: popq %rcx 51 ; SHRINK: popq %rdx 52 ; SHRINK: popq %rsi 53 ; SHRINK: popq %r8 54 ; SHRINK: popq %r9 55 ; SHRINK: popq %r10 56 ; SHRINK: popq %r11 57 ; SHRINK: LBB{{.*}}: 58 ; SHRINK: callq 59 define cxx_fast_tlscc nonnull %struct.S* @_ZTW2sg() { 60 %.b.i = load i1, i1* @__tls_guard, align 1 61 br i1 %.b.i, label %__tls_init.exit, label %init.i 62 63 init.i: 64 store i1 true, i1* @__tls_guard, align 1 65 tail call void @_ZN1SC1Ev(%struct.S* nonnull @sg) #2 66 %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 67 br label %__tls_init.exit 68 69 __tls_init.exit: 70 ret %struct.S* @sg 71 } 72