1; RUN: llc < %s -march=sparc | FileCheck %s
2; RUN: llc < %s -march=sparc -mcpu=leon2 | FileCheck %s
3; RUN: llc < %s -march=sparc -mcpu=leon3 | FileCheck %s
4; RUN: llc < %s -march=sparc -mcpu=leon4 | FileCheck %s
5
6%struct.__jmp_buf_tag = type { [64 x i64], i32, %struct.__sigset_t, [8 x i8] }
7%struct.__sigset_t = type { [16 x i64] }
8
9@env_sigill = internal global [1 x %struct.__jmp_buf_tag] zeroinitializer, align 16
10
11define void @foo() #0 {
12entry:
13  call void @llvm.eh.sjlj.longjmp(i8* bitcast ([1 x %struct.__jmp_buf_tag]* @env_sigill to i8*))
14  unreachable
15
16; CHECK: @foo
17; CHECK: ta   3
18; CHECK: ld [%i0], %fp
19; CHECK: ld [%i0+4], %i1
20; CHECK: ld [%i0+8], %sp
21; CHECK: jmp %i1
22; CHECK: ld [%i0+12], %i7
23
24return:                                           ; No predecessors!
25  ret void
26}
27
28declare void @llvm.eh.sjlj.longjmp(i8*) #1
29
30define signext i32 @main() #0 {
31entry:
32  %retval = alloca i32, align 4
33  store i32 0, i32* %retval
34  %0 = call i8* @llvm.frameaddress(i32 0)
35  store i8* %0, i8** bitcast ([1 x %struct.__jmp_buf_tag]* @env_sigill to i8**)
36  %1 = call i8* @llvm.stacksave()
37  store i8* %1, i8** getelementptr (i8*, i8** bitcast ([1 x %struct.__jmp_buf_tag]* @env_sigill to i8**), i32 2)
38  %2 = call i32 @llvm.eh.sjlj.setjmp(i8* bitcast ([1 x %struct.__jmp_buf_tag]* @env_sigill to i8*))
39  %tobool = icmp ne i32 %2, 0
40  br i1 %tobool, label %if.then, label %if.else
41
42if.then:                                          ; preds = %entry
43  store i32 1, i32* %retval
44  br label %return
45
46if.else:                                          ; preds = %entry
47  call void @foo()
48  br label %if.end
49
50if.end:                                           ; preds = %if.else
51  store i32 0, i32* %retval
52  br label %return
53
54return:                                           ; preds = %if.end, %if.then
55  %3 = load i32, i32* %retval
56  ret i32 %3
57
58; CHECK: @main
59; CHECK:  st %fp, [%i0]
60; CHECK:  sethi %hi(.LBB1_2), %i1
61; CHECK:  or %i1, %lo(.LBB1_2), %i1
62; CHECK:  st %i1, [%i0+4]
63; CHECK:  st %sp, [%i0+8]
64; CHECK:  bn   .LBB1_2
65; CHECK:  st %i7, [%i0+12]
66; CHECK:  ba   .LBB1_1
67; CHECK:  nop
68; CHECK:.LBB1_1:                                ! %entry
69; CHECK:  ba   .LBB1_3
70; CHECK:  mov  %g0, %i0
71; CHECK:.LBB1_2:                                ! Block address taken
72; CHECK:  mov  1, %i0
73; CHECK:.LBB1_3:                                ! %entry
74; CHECK:  cmp %i0, 0
75; CHECK:  be   .LBB1_5
76; CHECK:  nop
77}
78declare i8* @llvm.frameaddress(i32) #2
79
80declare i8* @llvm.stacksave() #3
81
82declare i32 @llvm.eh.sjlj.setjmp(i8*) #3
83
84attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
85attributes #1 = { noreturn nounwind }
86attributes #2 = { nounwind readnone }
87attributes #3 = { nounwind }
88
89