blob: 806fae934f9ae170c6413ddbba47d03f4ebd3912 [file] [log] [blame]
Davide Italiano228978c2016-02-20 00:44:47 +00001; Testcase generated from the following code:
2; extern __thread int i;
3; void f();
4; int g(void) {
5; if (i) {
6; i = 0;
7; f();
8; }
9; return i;
10; }
11; We want to make sure that TLS variables are not accessed before
12; the stack frame is set up.
13
14; RUN: llc < %s -relocation-model=pic | FileCheck %s
15
16target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
17target triple = "x86_64-unknown-freebsd11.0"
18
19@i = external thread_local global i32, align 4
20
21define i32 @g() #0 {
22entry:
23 %tmp = load i32, i32* @i, align 4
24 %tobool = icmp eq i32 %tmp, 0
25 br i1 %tobool, label %if.end, label %if.then
26
27if.then: ; preds = %entry
28 store i32 0, i32* @i, align 4
29 tail call void (...) @f() #2
30 %.pre = load i32, i32* @i, align 4
31 br label %if.end
32
33if.end: ; preds = %if.then, %entry
34 %tmp1 = phi i32 [ 0, %entry ], [ %.pre, %if.then ]
35 ret i32 %tmp1
36}
37
38; CHECK: g: # @g
39; CHECK-NEXT: .cfi_startproc
40; CHECK-NEXT: # BB#0: # %entry
41; CHECK-NEXT: pushq %rbp
Matthias Braun39c3c892016-11-30 23:48:26 +000042; CHECK-NEXT: .Lcfi0:
Davide Italiano228978c2016-02-20 00:44:47 +000043; CHECK-NEXT: .cfi_def_cfa_offset 16
Matthias Braun39c3c892016-11-30 23:48:26 +000044; CHECK-NEXT: .Lcfi1:
Davide Italiano228978c2016-02-20 00:44:47 +000045; CHECK-NEXT: .cfi_offset %rbp, -16
46; CHECK-NEXT: movq %rsp, %rbp
Matthias Braun39c3c892016-11-30 23:48:26 +000047; CHECK-NEXT: .Lcfi2:
Davide Italiano228978c2016-02-20 00:44:47 +000048; CHECK-NEXT: .cfi_def_cfa_register %rbp
49; CHECK-NEXT: pushq %rbx
50; CHECK-NEXT: pushq %rax
Matthias Braun39c3c892016-11-30 23:48:26 +000051; CHECK-NEXT: .Lcfi3:
Davide Italiano228978c2016-02-20 00:44:47 +000052; CHECK-NEXT: .cfi_offset %rbx, -24
53; CHECK-NEXT: data16
54; CHECK-NEXT: leaq i@TLSGD(%rip), %rdi
55
56declare void @f(...) #1
57
58attributes #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" }
59attributes #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" }
60attributes #2 = { nounwind }