1; RUN: llc < %s -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr7 | FileCheck %s 2; RUN: llc < %s -mtriple=powerpc64-unknown-linux-gnu -mcpu=a2 | 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 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: addis [[REG:[0-9]+]], 2, env_sigill@toc@ha 18; CHECK: addi [[REG]], [[REG]], env_sigill@toc@l 19; CHECK: ld 31, 0([[REG]]) 20; CHECK: ld [[REG2:[0-9]+]], 8([[REG]]) 21; CHECK: ld 1, 16([[REG]]) 22; CHECK: mtctr [[REG2]] 23; CHECK: ld 30, 32([[REG]]) 24; CHECK: ld 2, 24([[REG]]) 25; CHECK: bctr 26 27return: ; No predecessors! 28 ret void 29} 30 31declare void @llvm.eh.sjlj.longjmp(i8*) #1 32 33define signext i32 @main() #0 { 34entry: 35 %retval = alloca i32, align 4 36 store i32 0, i32* %retval 37 %0 = call i8* @llvm.frameaddress(i32 0) 38 store i8* %0, i8** bitcast ([1 x %struct.__jmp_buf_tag]* @env_sigill to i8**) 39 %1 = call i8* @llvm.stacksave() 40 store i8* %1, i8** getelementptr (i8** bitcast ([1 x %struct.__jmp_buf_tag]* @env_sigill to i8**), i32 2) 41 %2 = call i32 @llvm.eh.sjlj.setjmp(i8* bitcast ([1 x %struct.__jmp_buf_tag]* @env_sigill to i8*)) 42 %tobool = icmp ne i32 %2, 0 43 br i1 %tobool, label %if.then, label %if.else 44 45if.then: ; preds = %entry 46 store i32 1, i32* %retval 47 br label %return 48 49if.else: ; preds = %entry 50 call void @foo() 51 br label %if.end 52 53if.end: ; preds = %if.else 54 store i32 0, i32* %retval 55 br label %return 56 57return: ; preds = %if.end, %if.then 58 %3 = load i32* %retval 59 ret i32 %3 60 61; FIXME: We should be saving VRSAVE on Darwin, but we're not! 62 63; CHECK: @main 64; CHECK: std 65; Make sure that we're not saving VRSAVE on non-Darwin: 66; CHECK-NOT: mfspr 67 68; CHECK-DAG: stfd 69; CHECK-DAG: stvx 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_1 78; CHECK: li 3, 1 79; CHECK: #EH_SjLj_Setup .LBB1_1 80; CHECK: b .LBB1_2 81 82; CHECK: .LBB1_1: 83; CHECK: mflr [[REGL:[0-9]+]] 84; CHECK: ld [[REG2:[0-9]+]], [[OFF]](31) # 8-byte Folded Reload 85; CHECK: std [[REGL]], 8([[REG2]]) 86; CHECK: li 3, 0 87 88; CHECK: .LBB1_2: 89 90; CHECK: lfd 91; CHECK: lvx 92; CHECK: ld 93; CHECK: blr 94 95; CHECK-NOAV: @main 96; CHECK-NOAV-NOT: stvx 97; CHECK-NOAV: bcl 98; CHECK-NOAV: mflr 99; CHECK-NOAV: bl foo 100; CHECK-NOAV-NOT: lvx 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** 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* %retval 132 ret i32 %3 133 134; CHECK: @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 148declare void @bar(i8*) #3 149 150declare i8* @llvm.frameaddress(i32) #2 151 152declare i8* @llvm.stacksave() #3 153 154declare i32 @llvm.eh.sjlj.setjmp(i8*) #3 155 156attributes #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" } 157attributes #1 = { noreturn nounwind } 158attributes #2 = { nounwind readnone } 159attributes #3 = { nounwind } 160 161