1*9880d681SAndroid Build Coastguard Worker; Testcase generated from the following code: 2*9880d681SAndroid Build Coastguard Worker; extern __thread int i; 3*9880d681SAndroid Build Coastguard Worker; void f(); 4*9880d681SAndroid Build Coastguard Worker; int g(void) { 5*9880d681SAndroid Build Coastguard Worker; if (i) { 6*9880d681SAndroid Build Coastguard Worker; i = 0; 7*9880d681SAndroid Build Coastguard Worker; f(); 8*9880d681SAndroid Build Coastguard Worker; } 9*9880d681SAndroid Build Coastguard Worker; return i; 10*9880d681SAndroid Build Coastguard Worker; } 11*9880d681SAndroid Build Coastguard Worker; We want to make sure that TLS variables are not accessed before 12*9880d681SAndroid Build Coastguard Worker; the stack frame is set up. 13*9880d681SAndroid Build Coastguard Worker 14*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -relocation-model=pic | FileCheck %s 15*9880d681SAndroid Build Coastguard Worker 16*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 17*9880d681SAndroid Build Coastguard Workertarget triple = "x86_64-unknown-freebsd11.0" 18*9880d681SAndroid Build Coastguard Worker 19*9880d681SAndroid Build Coastguard Worker@i = external thread_local global i32, align 4 20*9880d681SAndroid Build Coastguard Worker 21*9880d681SAndroid Build Coastguard Workerdefine i32 @g() #0 { 22*9880d681SAndroid Build Coastguard Workerentry: 23*9880d681SAndroid Build Coastguard Worker %tmp = load i32, i32* @i, align 4 24*9880d681SAndroid Build Coastguard Worker %tobool = icmp eq i32 %tmp, 0 25*9880d681SAndroid Build Coastguard Worker br i1 %tobool, label %if.end, label %if.then 26*9880d681SAndroid Build Coastguard Worker 27*9880d681SAndroid Build Coastguard Workerif.then: ; preds = %entry 28*9880d681SAndroid Build Coastguard Worker store i32 0, i32* @i, align 4 29*9880d681SAndroid Build Coastguard Worker tail call void (...) @f() #2 30*9880d681SAndroid Build Coastguard Worker %.pre = load i32, i32* @i, align 4 31*9880d681SAndroid Build Coastguard Worker br label %if.end 32*9880d681SAndroid Build Coastguard Worker 33*9880d681SAndroid Build Coastguard Workerif.end: ; preds = %if.then, %entry 34*9880d681SAndroid Build Coastguard Worker %tmp1 = phi i32 [ 0, %entry ], [ %.pre, %if.then ] 35*9880d681SAndroid Build Coastguard Worker ret i32 %tmp1 36*9880d681SAndroid Build Coastguard Worker} 37*9880d681SAndroid Build Coastguard Worker 38*9880d681SAndroid Build Coastguard Worker; CHECK: g: # @g 39*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .cfi_startproc 40*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: # BB#0: # %entry 41*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: pushq %rbp 42*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .Ltmp0: 43*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .cfi_def_cfa_offset 16 44*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .Ltmp1: 45*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .cfi_offset %rbp, -16 46*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: movq %rsp, %rbp 47*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .Ltmp2: 48*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .cfi_def_cfa_register %rbp 49*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: pushq %rbx 50*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: pushq %rax 51*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .Ltmp3: 52*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .cfi_offset %rbx, -24 53*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: data16 54*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: leaq i@TLSGD(%rip), %rdi 55*9880d681SAndroid Build Coastguard Worker 56*9880d681SAndroid Build Coastguard Workerdeclare void @f(...) #1 57*9880d681SAndroid Build Coastguard Worker 58*9880d681SAndroid Build Coastguard Workerattributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" } 59*9880d681SAndroid Build Coastguard Workerattributes #1 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" } 60*9880d681SAndroid Build Coastguard Workerattributes #2 = { nounwind } 61