1 ; RUN: llc < %s -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr7 -verify-machineinstrs | FileCheck %s
2 ; RUN: llc < %s -mtriple=powerpc64-unknown-linux-gnu -mcpu=a2 -verify-machineinstrs | FileCheck -check-prefix=CHECK-NOAV %s
3 target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f128:128:128-v128:128:128-n32:64"
4 target triple = "powerpc64-unknown-linux-gnu"
6 %struct.__jmp_buf_tag = type { [64 x i64], i32, %struct.__sigset_t, [8 x i8] }
7 %struct.__sigset_t = type { [16 x i64] }
9 @env_sigill = internal global [1 x %struct.__jmp_buf_tag] zeroinitializer, align 16
10 @cond = external global i8, align 1
12 define void @foo() #0 {
14 call void @llvm.eh.sjlj.longjmp(i8* bitcast ([1 x %struct.__jmp_buf_tag]* @env_sigill to i8*))
18 ; CHECK: addis [[REG:[0-9]+]], 2, env_sigill@toc@ha
19 ; CHECK: addi [[REG]], [[REG]], env_sigill@toc@l
20 ; CHECK: ld 31, 0([[REG]])
21 ; CHECK: ld [[REG2:[0-9]+]], 8([[REG]])
22 ; CHECK-DAG: ld 1, 16([[REG]])
23 ; CHECK-DAG: mtctr [[REG2]]
24 ; CHECK-DAG: ld 30, 32([[REG]])
25 ; CHECK-DAG: ld 2, 24([[REG]])
28 return: ; No predecessors!
32 declare void @llvm.eh.sjlj.longjmp(i8*) #1
34 define signext i32 @main() #0 {
36 %retval = alloca i32, align 4
37 store i32 0, i32* %retval
38 %0 = call i8* @llvm.frameaddress(i32 0)
39 store i8* %0, i8** bitcast ([1 x %struct.__jmp_buf_tag]* @env_sigill to i8**)
40 %1 = call i8* @llvm.stacksave()
41 store i8* %1, i8** getelementptr (i8*, i8** bitcast ([1 x %struct.__jmp_buf_tag]* @env_sigill to i8**), i32 2)
42 %2 = call i32 @llvm.eh.sjlj.setjmp(i8* bitcast ([1 x %struct.__jmp_buf_tag]* @env_sigill to i8*))
43 %tobool = icmp ne i32 %2, 0
44 br i1 %tobool, label %if.then, label %if.else
46 if.then: ; preds = %entry
47 store i32 1, i32* %retval
50 if.else: ; preds = %entry
54 if.end: ; preds = %if.else
55 store i32 0, i32* %retval
58 return: ; preds = %if.end, %if.then
59 %3 = load i32, i32* %retval
62 ; FIXME: We should be saving VRSAVE on Darwin, but we're not!
66 ; Make sure that we're not saving VRSAVE on non-Darwin:
72 ; CHECK-DAG: addis [[REG:[0-9]+]], 2, env_sigill@toc@ha
73 ; CHECK-DAG: std 31, env_sigill@toc@l([[REG]])
74 ; CHECK-DAG: addi [[REGA:[0-9]+]], [[REG]], env_sigill@toc@l
75 ; CHECK-DAG: std [[REGA]], [[OFF:[0-9]+]](31) # 8-byte Folded Spill
76 ; CHECK-DAG: std 1, 16([[REGA]])
77 ; CHECK-DAG: std 2, 24([[REGA]])
78 ; CHECK: bcl 20, 31, .LBB1_3
80 ; CHECK: #EH_SjLj_Setup .LBB1_3
84 ; CHECK: mflr [[REGL:[0-9]+]]
85 ; CHECK: ld [[REG2:[0-9]+]], [[OFF]](31) # 8-byte Folded Reload
86 ; CHECK: std [[REGL]], 8([[REG2]])
96 ; CHECK-NOAV-LABEL: main:
97 ; CHECK-NOAV-NOT: stxvd2x
101 ; CHECK-NOAV-NOT: lxvd2x
105 define signext i32 @main2() #0 {
107 %a = alloca i8, align 64
108 call void @bar(i8* %a)
109 %retval = alloca i32, align 4
110 store i32 0, i32* %retval
111 %0 = call i8* @llvm.frameaddress(i32 0)
112 store i8* %0, i8** bitcast ([1 x %struct.__jmp_buf_tag]* @env_sigill to i8**)
113 %1 = call i8* @llvm.stacksave()
114 store i8* %1, i8** getelementptr (i8*, i8** bitcast ([1 x %struct.__jmp_buf_tag]* @env_sigill to i8**), i32 2)
115 %2 = call i32 @llvm.eh.sjlj.setjmp(i8* bitcast ([1 x %struct.__jmp_buf_tag]* @env_sigill to i8*))
116 %tobool = icmp ne i32 %2, 0
117 br i1 %tobool, label %if.then, label %if.else
119 if.then: ; preds = %entry
120 store i32 1, i32* %retval
123 if.else: ; preds = %entry
127 if.end: ; preds = %if.else
128 store i32 0, i32* %retval
131 return: ; preds = %if.end, %if.then
132 %3 = load i32, i32* %retval
135 ; CHECK-LABEL: main2:
137 ; CHECK: addis [[REG:[0-9]+]], 2, env_sigill@toc@ha
138 ; CHECK-DAG: std 31, env_sigill@toc@l([[REG]])
139 ; CHECK-DAG: addi [[REGB:[0-9]+]], [[REG]], env_sigill@toc@l
140 ; CHECK-DAG: std [[REGB]], [[OFF:[0-9]+]](31) # 8-byte Folded Spill
141 ; CHECK-DAG: std 1, 16([[REGB]])
142 ; CHECK-DAG: std 2, 24([[REGB]])
143 ; CHECK-DAG: std 30, 32([[REGB]])
149 define void @test_sjlj_setjmp() #0 {
151 %0 = load i8, i8* @cond, align 1
152 %tobool = trunc i8 %0 to i1
153 br i1 %tobool, label %return, label %end
156 %1 = call i32 @llvm.eh.sjlj.setjmp(i8* bitcast ([1 x %struct.__jmp_buf_tag]* @env_sigill to i8*))
162 ; CHECK-LABEL: test_sjlj_setjmp:
163 ; intrinsic llvm.eh.sjlj.setjmp does not call builtin function _setjmp.
164 ; CHECK-NOT: bl _setjmp
167 declare void @bar(i8*) #3
169 declare i8* @llvm.frameaddress(i32) #2
171 declare i8* @llvm.stacksave() #3
173 declare i32 @llvm.eh.sjlj.setjmp(i8*) #3
175 attributes #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" }
176 attributes #1 = { noreturn nounwind }
177 attributes #2 = { nounwind readnone }
178 attributes #3 = { nounwind }