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 3target 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" 4target triple = "powerpc64-unknown-linux-gnu" 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@cond = external global i8, align 1 11 12define void @foo() #0 { 13entry: 14 call void @llvm.eh.sjlj.longjmp(i8* bitcast ([1 x %struct.__jmp_buf_tag]* @env_sigill to i8*)) 15 unreachable 16 17; CHECK: @foo 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]]) 26; CHECK: bctr 27 28return: ; No predecessors! 29 ret void 30} 31 32declare void @llvm.eh.sjlj.longjmp(i8*) #1 33 34define signext i32 @main() #0 { 35entry: 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 45 46if.then: ; preds = %entry 47 store i32 1, i32* %retval 48 br label %return 49 50if.else: ; preds = %entry 51 call void @foo() 52 br label %if.end 53 54if.end: ; preds = %if.else 55 store i32 0, i32* %retval 56 br label %return 57 58return: ; preds = %if.end, %if.then 59 %3 = load i32, i32* %retval 60 ret i32 %3 61 62 63; CHECK-LABEL: main: 64; CHECK: std 65; Make sure that we're not saving VRSAVE: 66; CHECK-NOT: mfspr 67 68; CHECK-DAG: stfd 69; CHECK-DAG: stxvd2x 70 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 78; CHECK: li 3, 1 79; CHECK: #EH_SjLj_Setup .LBB1_3 80; CHECK: # %bb.1: 81 82; CHECK: .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]]) 86; CHECK: li 3, 0 87 88; CHECK: .LBB1_5: 89 90; CHECK-DAG: lfd 91; CHECK-DAG: lxvd2x 92; CHECK: ld 93; CHECK: blr 94 95; CHECK-NOAV-LABEL: main: 96; CHECK-NOAV-NOT: stxvd2x 97; CHECK-NOAV: bcl 98; CHECK-NOAV: mflr 99; CHECK-NOAV: bl foo 100; CHECK-NOAV-NOT: lxvd2x 101; CHECK-NOAV: blr 102} 103 104define signext i32 @main2() #0 { 105entry: 106 %a = alloca i8, align 64 107 call void @bar(i8* %a) 108 %retval = alloca i32, align 4 109 store i32 0, i32* %retval 110 %0 = call i8* @llvm.frameaddress(i32 0) 111 store i8* %0, i8** bitcast ([1 x %struct.__jmp_buf_tag]* @env_sigill to i8**) 112 %1 = call i8* @llvm.stacksave() 113 store i8* %1, i8** getelementptr (i8*, i8** bitcast ([1 x %struct.__jmp_buf_tag]* @env_sigill to i8**), i32 2) 114 %2 = call i32 @llvm.eh.sjlj.setjmp(i8* bitcast ([1 x %struct.__jmp_buf_tag]* @env_sigill to i8*)) 115 %tobool = icmp ne i32 %2, 0 116 br i1 %tobool, label %if.then, label %if.else 117 118if.then: ; preds = %entry 119 store i32 1, i32* %retval 120 br label %return 121 122if.else: ; preds = %entry 123 call void @foo() 124 br label %if.end 125 126if.end: ; preds = %if.else 127 store i32 0, i32* %retval 128 br label %return 129 130return: ; preds = %if.end, %if.then 131 %3 = load i32, i32* %retval 132 ret i32 %3 133 134; CHECK-LABEL: main2: 135 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]]) 143; CHECK: bcl 20, 31, 144 145; CHECK: blr 146} 147 148define void @test_sjlj_setjmp() #0 { 149entry: 150 %0 = load i8, i8* @cond, align 1 151 %tobool = trunc i8 %0 to i1 152 br i1 %tobool, label %return, label %end 153 154end: 155 %1 = call i32 @llvm.eh.sjlj.setjmp(i8* bitcast ([1 x %struct.__jmp_buf_tag]* @env_sigill to i8*)) 156 br label %return 157 158return: 159 ret void 160 161; CHECK-LABEL: test_sjlj_setjmp: 162; intrinsic llvm.eh.sjlj.setjmp does not call builtin function _setjmp. 163; CHECK-NOT: bl _setjmp 164} 165 166declare void @bar(i8*) #3 167 168declare i8* @llvm.frameaddress(i32) #2 169 170declare i8* @llvm.stacksave() #3 171 172declare i32 @llvm.eh.sjlj.setjmp(i8*) #3 173 174attributes #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" } 175attributes #1 = { noreturn nounwind } 176attributes #2 = { nounwind readnone } 177attributes #3 = { nounwind } 178 179