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(ptr @env_sigill)
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(ptr) #1
34 define signext i32 @main() #0 {
36 %retval = alloca i32, align 4
37 store i32 0, ptr %retval
38 %0 = call ptr @llvm.frameaddress(i32 0)
39 store ptr %0, ptr @env_sigill
40 %1 = call ptr @llvm.stacksave()
41 store ptr %1, ptr getelementptr (ptr, ptr @env_sigill, i32 2)
42 %2 = call i32 @llvm.eh.sjlj.setjmp(ptr @env_sigill)
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, ptr %retval
50 if.else: ; preds = %entry
54 if.end: ; preds = %if.else
55 store i32 0, ptr %retval
58 return: ; preds = %if.end, %if.then
59 %3 = load i32, ptr %retval
65 ; Make sure that we're not saving VRSAVE:
71 ; CHECK-DAG: addis [[REG:[0-9]+]], 2, env_sigill@toc@ha
72 ; CHECK-DAG: std 31, env_sigill@toc@l([[REG]])
73 ; CHECK-DAG: addi [[REGA:[0-9]+]], [[REG]], env_sigill@toc@l
74 ; CHECK-DAG: std [[REGA]], [[OFF:[0-9]+]](31) # 8-byte Folded Spill
75 ; CHECK-DAG: std 1, 16([[REGA]])
76 ; CHECK-DAG: std 2, 24([[REGA]])
77 ; CHECK: bcl 20, 31, .LBB1_3
79 ; CHECK: #EH_SjLj_Setup .LBB1_3
83 ; CHECK: ld [[REG2:[0-9]+]], [[OFF]](31) # 8-byte Folded Reload
84 ; CHECK: mflr [[REGL:[0-9]+]]
85 ; CHECK: std [[REGL]], 8([[REG2]])
95 ; CHECK-NOAV-LABEL: main:
96 ; CHECK-NOAV-NOT: stxvd2x
100 ; CHECK-NOAV-NOT: lxvd2x
104 define signext i32 @main2() #0 {
106 %a = alloca i8, align 64
107 call void @bar(ptr %a)
108 %retval = alloca i32, align 4
109 store i32 0, ptr %retval
110 %0 = call ptr @llvm.frameaddress(i32 0)
111 store ptr %0, ptr @env_sigill
112 %1 = call ptr @llvm.stacksave()
113 store ptr %1, ptr getelementptr (ptr, ptr @env_sigill, i32 2)
114 %2 = call i32 @llvm.eh.sjlj.setjmp(ptr @env_sigill)
115 %tobool = icmp ne i32 %2, 0
116 br i1 %tobool, label %if.then, label %if.else
118 if.then: ; preds = %entry
119 store i32 1, ptr %retval
122 if.else: ; preds = %entry
126 if.end: ; preds = %if.else
127 store i32 0, ptr %retval
130 return: ; preds = %if.end, %if.then
131 %3 = load i32, ptr %retval
134 ; CHECK-LABEL: main2:
136 ; CHECK: addis [[REG:[0-9]+]], 2, env_sigill@toc@ha
137 ; CHECK-DAG: std 31, env_sigill@toc@l([[REG]])
138 ; CHECK-DAG: addi [[REGB:[0-9]+]], [[REG]], env_sigill@toc@l
139 ; CHECK-DAG: std [[REGB]], [[OFF:[0-9]+]](31) # 8-byte Folded Spill
140 ; CHECK-DAG: std 1, 16([[REGB]])
141 ; CHECK-DAG: std 2, 24([[REGB]])
142 ; CHECK-DAG: std 30, 32([[REGB]])
148 define void @test_sjlj_setjmp() #0 {
150 %0 = load i8, ptr @cond, align 1
151 %tobool = trunc i8 %0 to i1
152 br i1 %tobool, label %return, label %end
155 %1 = call i32 @llvm.eh.sjlj.setjmp(ptr @env_sigill)
161 ; CHECK-LABEL: test_sjlj_setjmp:
162 ; intrinsic llvm.eh.sjlj.setjmp does not call builtin function _setjmp.
163 ; CHECK-NOT: bl _setjmp
166 declare void @bar(ptr) #3
168 declare ptr @llvm.frameaddress(i32) #2
170 declare ptr @llvm.stacksave() #3
172 declare i32 @llvm.eh.sjlj.setjmp(ptr) #3
174 attributes #0 = { nounwind "less-precise-fpmad"="false" "frame-pointer"="non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
175 attributes #1 = { noreturn nounwind }
176 attributes #2 = { nounwind readnone }
177 attributes #3 = { nounwind }