xref: /aosp_15_r20/external/llvm/test/CodeGen/SPARC/setjmp.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker;RUN: llc -march=sparc   < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker;RUN: llc -march=sparcv9 < %s | FileCheck %s --check-prefix=V9
3*9880d681SAndroid Build Coastguard Worker
4*9880d681SAndroid Build Coastguard Worker
5*9880d681SAndroid Build Coastguard Worker%0 = type { [32 x i32] }
6*9880d681SAndroid Build Coastguard Worker%struct.jmpbuf_env = type { i32, i32, [1 x %struct.__jmp_buf_tag], i32 }
7*9880d681SAndroid Build Coastguard Worker%struct.__jmp_buf_tag = type { [3 x i32], i32, %0 }
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard Worker@jenv = common unnamed_addr global %struct.jmpbuf_env* null
10*9880d681SAndroid Build Coastguard Worker@.cst = private unnamed_addr constant [30 x i8] c"in bar with jmp_buf's id: %d\0A\00", align 64
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: foo
13*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:   st {{.+}}, [%i0]
14*9880d681SAndroid Build Coastguard Worker; CHECK-DAG:   st {{.+}}, [%i0+4]
15*9880d681SAndroid Build Coastguard Worker; CHECK:       call _setjmp
16*9880d681SAndroid Build Coastguard Worker; CHECK:       ld [%fp+{{.+}}], %[[R:[gilo][0-7]]]
17*9880d681SAndroid Build Coastguard Worker; CHECK:       st %o0, [%[[R]]+{{.+}}]
18*9880d681SAndroid Build Coastguard Worker
19*9880d681SAndroid Build Coastguard Worker; V9-LABEL:   foo
20*9880d681SAndroid Build Coastguard Worker; V9-DAG:     st {{.+}}, [%i0]
21*9880d681SAndroid Build Coastguard Worker; V9-DAG:     st {{.+}}, [%i0+4]
22*9880d681SAndroid Build Coastguard Worker; V9:         call _setjmp
23*9880d681SAndroid Build Coastguard Worker; V9:         ldx [%fp+{{.+}}], %[[R:[gilo][0-7]]]
24*9880d681SAndroid Build Coastguard Worker; V9:         st %o0, [%[[R]]+{{.+}}]
25*9880d681SAndroid Build Coastguard Worker
26*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind
27*9880d681SAndroid Build Coastguard Workerdefine i32 @foo(%struct.jmpbuf_env* byval %inbuf) #0 {
28*9880d681SAndroid Build Coastguard Workerentry:
29*9880d681SAndroid Build Coastguard Worker  %0 = getelementptr inbounds %struct.jmpbuf_env, %struct.jmpbuf_env* %inbuf, i32 0, i32 0
30*9880d681SAndroid Build Coastguard Worker  store i32 0, i32* %0, align 4, !tbaa !4
31*9880d681SAndroid Build Coastguard Worker  %1 = getelementptr inbounds %struct.jmpbuf_env, %struct.jmpbuf_env* %inbuf, i32 0, i32 1
32*9880d681SAndroid Build Coastguard Worker  store i32 1, i32* %1, align 4, !tbaa !4
33*9880d681SAndroid Build Coastguard Worker  %2 = getelementptr inbounds %struct.jmpbuf_env, %struct.jmpbuf_env* %inbuf, i32 0, i32 2, i32 0
34*9880d681SAndroid Build Coastguard Worker  %3 = call i32 @_setjmp(%struct.__jmp_buf_tag* %2) #2
35*9880d681SAndroid Build Coastguard Worker  %4 = getelementptr inbounds %struct.jmpbuf_env, %struct.jmpbuf_env* %inbuf, i32 0, i32 3
36*9880d681SAndroid Build Coastguard Worker  store i32 %3, i32* %4, align 4, !tbaa !4
37*9880d681SAndroid Build Coastguard Worker  store %struct.jmpbuf_env* %inbuf, %struct.jmpbuf_env** @jenv, align 4, !tbaa !3
38*9880d681SAndroid Build Coastguard Worker  %5 = load i32, i32* %1, align 4, !tbaa !4
39*9880d681SAndroid Build Coastguard Worker  %6 = icmp eq i32 %5, 1
40*9880d681SAndroid Build Coastguard Worker  %7 = icmp eq i32 %3, 0
41*9880d681SAndroid Build Coastguard Worker  %or.cond = and i1 %6, %7
42*9880d681SAndroid Build Coastguard Worker  br i1 %or.cond, label %"4.i", label %bar.exit
43*9880d681SAndroid Build Coastguard Worker
44*9880d681SAndroid Build Coastguard Worker"4.i":                                            ; preds = %entry
45*9880d681SAndroid Build Coastguard Worker  call void @longjmp(%struct.__jmp_buf_tag* %2, i32 0) #1
46*9880d681SAndroid Build Coastguard Worker  unreachable
47*9880d681SAndroid Build Coastguard Worker
48*9880d681SAndroid Build Coastguard Workerbar.exit:                                         ; preds = %entry
49*9880d681SAndroid Build Coastguard Worker  %8 = load i32, i32* %0, align 4, !tbaa !4
50*9880d681SAndroid Build Coastguard Worker  %9 = call i32 (i8*, ...) @printf(i8* noalias getelementptr inbounds ([30 x i8], [30 x i8]* @.cst, i32 0, i32 0), i32 %8) #0
51*9880d681SAndroid Build Coastguard Worker  ret i32 0
52*9880d681SAndroid Build Coastguard Worker}
53*9880d681SAndroid Build Coastguard Worker
54*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind returns_twice
55*9880d681SAndroid Build Coastguard Workerdeclare i32 @_setjmp(%struct.__jmp_buf_tag*) #2
56*9880d681SAndroid Build Coastguard Worker
57*9880d681SAndroid Build Coastguard Worker; Function Attrs: noreturn nounwind
58*9880d681SAndroid Build Coastguard Workerdeclare void @longjmp(%struct.__jmp_buf_tag*, i32) #1
59*9880d681SAndroid Build Coastguard Worker
60*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind
61*9880d681SAndroid Build Coastguard Workerdeclare i32 @printf(i8* nocapture, ...) #0
62*9880d681SAndroid Build Coastguard Worker
63*9880d681SAndroid Build Coastguard Worker
64*9880d681SAndroid Build Coastguard Workerattributes #0 = { nounwind }
65*9880d681SAndroid Build Coastguard Workerattributes #1 = { noreturn nounwind }
66*9880d681SAndroid Build Coastguard Workerattributes #2 = { nounwind returns_twice }
67*9880d681SAndroid Build Coastguard Worker
68*9880d681SAndroid Build Coastguard Worker!0 = !{!"alias set 6: struct.jmpbuf_env*", !1}
69*9880d681SAndroid Build Coastguard Worker!1 = !{!1}
70*9880d681SAndroid Build Coastguard Worker!2 = !{!"alias set 3: int", !1}
71*9880d681SAndroid Build Coastguard Worker!3 = !{!0, !0, i64 0}
72*9880d681SAndroid Build Coastguard Worker!4 = !{!2, !2, i64 0}
73