2015-12-05 01:40:13 +08:00
|
|
|
; RUN: llc < %s -mtriple=x86_64-apple-darwin | FileCheck %s
|
2016-01-07 03:09:26 +08:00
|
|
|
; TLS function were wrongly model and after fixing that, shrink-wrapping
|
|
|
|
; cannot help here. To achieve the expected lowering, we need to playing
|
|
|
|
; tricks similar to AArch64 fast TLS calling convention (r255821).
|
2016-01-12 09:08:46 +08:00
|
|
|
; Applying tricks on x86-64 similar to r255821.
|
|
|
|
; RUN: llc < %s -mtriple=x86_64-apple-darwin -enable-shrink-wrap=true | FileCheck %s
|
2016-01-17 00:39:46 +08:00
|
|
|
; RUN: llc < %s -mtriple=x86_64-apple-darwin -O0 | FileCheck %s --check-prefix=CHECK-O0
|
2015-12-05 01:40:13 +08:00
|
|
|
%struct.S = type { i8 }
|
|
|
|
|
|
|
|
@sg = internal thread_local global %struct.S zeroinitializer, align 1
|
|
|
|
@__dso_handle = external global i8
|
|
|
|
@__tls_guard = internal thread_local unnamed_addr global i1 false
|
2016-01-16 03:35:42 +08:00
|
|
|
@sum1 = internal thread_local global i32 0, align 4
|
2015-12-05 01:40:13 +08:00
|
|
|
|
|
|
|
declare void @_ZN1SC1Ev(%struct.S*)
|
|
|
|
declare void @_ZN1SD1Ev(%struct.S*)
|
|
|
|
declare i32 @_tlv_atexit(void (i8*)*, i8*, i8*)
|
|
|
|
|
|
|
|
; Every GPR should be saved - except rdi, rax, and rsp
|
|
|
|
; CHECK-LABEL: _ZTW2sg
|
2016-01-12 09:08:46 +08:00
|
|
|
; CHECK-NOT: pushq %r11
|
|
|
|
; CHECK-NOT: pushq %r10
|
|
|
|
; CHECK-NOT: pushq %r9
|
|
|
|
; CHECK-NOT: pushq %r8
|
|
|
|
; CHECK-NOT: pushq %rsi
|
|
|
|
; CHECK-NOT: pushq %rdx
|
|
|
|
; CHECK-NOT: pushq %rcx
|
|
|
|
; CHECK-NOT: pushq %rbx
|
2015-12-05 01:40:13 +08:00
|
|
|
; CHECK: callq
|
|
|
|
; CHECK: jne
|
|
|
|
; CHECK: callq
|
|
|
|
; CHECK: tlv_atexit
|
|
|
|
; CHECK: callq
|
2016-01-12 09:08:46 +08:00
|
|
|
; CHECK-NOT: popq %rbx
|
|
|
|
; CHECK-NOT: popq %rcx
|
|
|
|
; CHECK-NOT: popq %rdx
|
|
|
|
; CHECK-NOT: popq %rsi
|
|
|
|
; CHECK-NOT: popq %r8
|
|
|
|
; CHECK-NOT: popq %r9
|
|
|
|
; CHECK-NOT: popq %r10
|
|
|
|
; CHECK-NOT: popq %r11
|
2016-03-19 07:38:49 +08:00
|
|
|
|
|
|
|
; CHECK-O0-LABEL: _ZTW2sg
|
|
|
|
; CHECK-O0: pushq %r11
|
|
|
|
; CHECK-O0: pushq %r10
|
|
|
|
; CHECK-O0: pushq %r9
|
|
|
|
; CHECK-O0: pushq %r8
|
|
|
|
; CHECK-O0: pushq %rsi
|
|
|
|
; CHECK-O0: pushq %rdx
|
|
|
|
; CHECK-O0: pushq %rcx
|
|
|
|
; CHECK-O0: callq
|
|
|
|
; CHECK-O0: jne
|
|
|
|
; CHECK-O0: callq
|
|
|
|
; CHECK-O0: tlv_atexit
|
|
|
|
; CHECK-O0: callq
|
|
|
|
; CHECK-O0: popq %rcx
|
|
|
|
; CHECK-O0: popq %rdx
|
|
|
|
; CHECK-O0: popq %rsi
|
|
|
|
; CHECK-O0: popq %r8
|
|
|
|
; CHECK-O0: popq %r9
|
|
|
|
; CHECK-O0: popq %r10
|
|
|
|
; CHECK-O0: popq %r11
|
2016-01-12 09:08:46 +08:00
|
|
|
define cxx_fast_tlscc nonnull %struct.S* @_ZTW2sg() nounwind {
|
2015-12-05 01:40:13 +08:00
|
|
|
%.b.i = load i1, i1* @__tls_guard, align 1
|
|
|
|
br i1 %.b.i, label %__tls_init.exit, label %init.i
|
|
|
|
|
|
|
|
init.i:
|
|
|
|
store i1 true, i1* @__tls_guard, align 1
|
|
|
|
tail call void @_ZN1SC1Ev(%struct.S* nonnull @sg) #2
|
|
|
|
%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
|
|
|
|
br label %__tls_init.exit
|
|
|
|
|
|
|
|
__tls_init.exit:
|
|
|
|
ret %struct.S* @sg
|
|
|
|
}
|
2016-01-16 03:35:42 +08:00
|
|
|
|
|
|
|
; CHECK-LABEL: _ZTW4sum1
|
|
|
|
; CHECK-NOT: pushq %r11
|
|
|
|
; CHECK-NOT: pushq %r10
|
|
|
|
; CHECK-NOT: pushq %r9
|
|
|
|
; CHECK-NOT: pushq %r8
|
|
|
|
; CHECK-NOT: pushq %rsi
|
|
|
|
; CHECK-NOT: pushq %rdx
|
|
|
|
; CHECK-NOT: pushq %rcx
|
|
|
|
; CHECK-NOT: pushq %rbx
|
|
|
|
; CHECK: callq
|
2016-03-19 07:38:49 +08:00
|
|
|
; CHECK-O0-LABEL: _ZTW4sum1
|
|
|
|
; CHECK-O0-NOT: pushq %r11
|
|
|
|
; CHECK-O0-NOT: pushq %r10
|
|
|
|
; CHECK-O0-NOT: pushq %r9
|
|
|
|
; CHECK-O0-NOT: pushq %r8
|
|
|
|
; CHECK-O0-NOT: pushq %rsi
|
|
|
|
; CHECK-O0-NOT: pushq %rdx
|
|
|
|
; CHECK-O0-NOT: pushq %rcx
|
|
|
|
; CHECK-O0-NOT: pushq %rbx
|
|
|
|
; CHECK-O0-NOT: movq %r11
|
|
|
|
; CHECK-O0-NOT: movq %r10
|
|
|
|
; CHECK-O0-NOT: movq %r9
|
|
|
|
; CHECK-O0-NOT: movq %r8
|
|
|
|
; CHECK-O0-NOT: movq %rsi
|
|
|
|
; CHECK-O0-NOT: movq %rdx
|
|
|
|
; CHECK-O0-NOT: movq %rcx
|
|
|
|
; CHECK-O0-NOT: movq %rbx
|
|
|
|
; CHECK-O0: callq
|
2016-01-16 03:35:42 +08:00
|
|
|
define cxx_fast_tlscc nonnull i32* @_ZTW4sum1() nounwind {
|
|
|
|
ret i32* @sum1
|
|
|
|
}
|
2016-01-17 00:39:46 +08:00
|
|
|
|
|
|
|
; Make sure at O0 we don't overwrite RBP.
|
|
|
|
; CHECK-O0-LABEL: _ZTW4sum2
|
|
|
|
; CHECK-O0: pushq %rbp
|
|
|
|
; CHECK-O0: movq %rsp, %rbp
|
|
|
|
; CHECK-O0-NOT: movq %r{{.*}}, (%rbp)
|
|
|
|
define cxx_fast_tlscc i32* @_ZTW4sum2() #0 {
|
|
|
|
ret i32* @sum1
|
|
|
|
}
|
|
|
|
|
2016-03-19 07:38:49 +08:00
|
|
|
; Make sure at O0, we don't generate spilling/reloading of the CSRs.
|
|
|
|
; CHECK-O0-LABEL: tls_test2
|
|
|
|
; CHECK-O0-NOT: pushq %r11
|
|
|
|
; CHECK-O0-NOT: pushq %r10
|
|
|
|
; CHECK-O0-NOT: pushq %r9
|
|
|
|
; CHECK-O0-NOT: pushq %r8
|
|
|
|
; CHECK-O0-NOT: pushq %rsi
|
|
|
|
; CHECK-O0-NOT: pushq %rdx
|
|
|
|
; CHECK-O0: callq {{.*}}tls_helper
|
|
|
|
; CHECK-O0-NOT: popq %rdx
|
|
|
|
; CHECK-O0-NOT: popq %rsi
|
|
|
|
; CHECK-O0-NOT: popq %r8
|
|
|
|
; CHECK-O0-NOT: popq %r9
|
|
|
|
; CHECK-O0-NOT: popq %r10
|
|
|
|
; CHECK-O0-NOT: popq %r11
|
|
|
|
; CHECK-O0: ret
|
|
|
|
%class.C = type { i32 }
|
|
|
|
@tC = internal thread_local global %class.C zeroinitializer, align 4
|
|
|
|
declare cxx_fast_tlscc void @tls_helper()
|
|
|
|
define cxx_fast_tlscc %class.C* @tls_test2() #1 {
|
|
|
|
call cxx_fast_tlscc void @tls_helper()
|
|
|
|
ret %class.C* @tC
|
|
|
|
}
|
2016-01-17 00:39:46 +08:00
|
|
|
attributes #0 = { nounwind "no-frame-pointer-elim"="true" }
|
2016-03-19 07:38:49 +08:00
|
|
|
attributes #1 = { nounwind }
|