Manman Ren | 19c7bbe | 2015-12-04 17:40:13 +0000 | [diff] [blame] | 1 | ; RUN: llc < %s -mtriple=x86_64-apple-darwin | FileCheck %s |
Quentin Colombet | eb61e8e | 2016-01-06 19:09:26 +0000 | [diff] [blame] | 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). |
Manman Ren | ed967f3 | 2016-01-12 01:08:46 +0000 | [diff] [blame] | 5 | ; Applying tricks on x86-64 similar to r255821. |
| 6 | ; RUN: llc < %s -mtriple=x86_64-apple-darwin -enable-shrink-wrap=true | FileCheck %s |
Manman Ren | 19c7bbe | 2015-12-04 17:40:13 +0000 | [diff] [blame] | 7 | %struct.S = type { i8 } |
| 8 | |
| 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 |
Manman Ren | 4fe01bd | 2016-01-15 19:35:42 +0000 | [diff] [blame^] | 12 | @sum1 = internal thread_local global i32 0, align 4 |
Manman Ren | 19c7bbe | 2015-12-04 17:40:13 +0000 | [diff] [blame] | 13 | |
| 14 | declare void @_ZN1SC1Ev(%struct.S*) |
| 15 | declare void @_ZN1SD1Ev(%struct.S*) |
| 16 | declare i32 @_tlv_atexit(void (i8*)*, i8*, i8*) |
| 17 | |
| 18 | ; Every GPR should be saved - except rdi, rax, and rsp |
| 19 | ; CHECK-LABEL: _ZTW2sg |
Manman Ren | ed967f3 | 2016-01-12 01:08:46 +0000 | [diff] [blame] | 20 | ; CHECK-NOT: pushq %r11 |
| 21 | ; CHECK-NOT: pushq %r10 |
| 22 | ; CHECK-NOT: pushq %r9 |
| 23 | ; CHECK-NOT: pushq %r8 |
| 24 | ; CHECK-NOT: pushq %rsi |
| 25 | ; CHECK-NOT: pushq %rdx |
| 26 | ; CHECK-NOT: pushq %rcx |
| 27 | ; CHECK-NOT: pushq %rbx |
Manman Ren | 19c7bbe | 2015-12-04 17:40:13 +0000 | [diff] [blame] | 28 | ; CHECK: callq |
| 29 | ; CHECK: jne |
| 30 | ; CHECK: callq |
| 31 | ; CHECK: tlv_atexit |
| 32 | ; CHECK: callq |
Manman Ren | ed967f3 | 2016-01-12 01:08:46 +0000 | [diff] [blame] | 33 | ; CHECK-NOT: popq %rbx |
| 34 | ; CHECK-NOT: popq %rcx |
| 35 | ; CHECK-NOT: popq %rdx |
| 36 | ; CHECK-NOT: popq %rsi |
| 37 | ; CHECK-NOT: popq %r8 |
| 38 | ; CHECK-NOT: popq %r9 |
| 39 | ; CHECK-NOT: popq %r10 |
| 40 | ; CHECK-NOT: popq %r11 |
| 41 | define cxx_fast_tlscc nonnull %struct.S* @_ZTW2sg() nounwind { |
Manman Ren | 19c7bbe | 2015-12-04 17:40:13 +0000 | [diff] [blame] | 42 | %.b.i = load i1, i1* @__tls_guard, align 1 |
| 43 | br i1 %.b.i, label %__tls_init.exit, label %init.i |
| 44 | |
| 45 | init.i: |
| 46 | store i1 true, i1* @__tls_guard, align 1 |
| 47 | tail call void @_ZN1SC1Ev(%struct.S* nonnull @sg) #2 |
| 48 | %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 |
| 49 | br label %__tls_init.exit |
| 50 | |
| 51 | __tls_init.exit: |
| 52 | ret %struct.S* @sg |
| 53 | } |
Manman Ren | 4fe01bd | 2016-01-15 19:35:42 +0000 | [diff] [blame^] | 54 | |
| 55 | ; CHECK-LABEL: _ZTW4sum1 |
| 56 | ; CHECK-NOT: pushq %r11 |
| 57 | ; CHECK-NOT: pushq %r10 |
| 58 | ; CHECK-NOT: pushq %r9 |
| 59 | ; CHECK-NOT: pushq %r8 |
| 60 | ; CHECK-NOT: pushq %rsi |
| 61 | ; CHECK-NOT: pushq %rdx |
| 62 | ; CHECK-NOT: pushq %rcx |
| 63 | ; CHECK-NOT: pushq %rbx |
| 64 | ; CHECK: callq |
| 65 | define cxx_fast_tlscc nonnull i32* @_ZTW4sum1() nounwind { |
| 66 | ret i32* @sum1 |
| 67 | } |