1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr7 | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mtriple=powerpc64-unknown-linux-gnu -mcpu=a2 | FileCheck -check-prefix=CHECK-NOAV %s 3*9880d681SAndroid Build Coastguard Workertarget 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*9880d681SAndroid Build Coastguard Workertarget triple = "powerpc64-unknown-linux-gnu" 5*9880d681SAndroid Build Coastguard Worker 6*9880d681SAndroid Build Coastguard Worker%struct.__jmp_buf_tag = type { [64 x i64], i32, %struct.__sigset_t, [8 x i8] } 7*9880d681SAndroid Build Coastguard Worker%struct.__sigset_t = type { [16 x i64] } 8*9880d681SAndroid Build Coastguard Worker 9*9880d681SAndroid Build Coastguard Worker@env_sigill = internal global [1 x %struct.__jmp_buf_tag] zeroinitializer, align 16 10*9880d681SAndroid Build Coastguard Worker 11*9880d681SAndroid Build Coastguard Workerdefine void @foo() #0 { 12*9880d681SAndroid Build Coastguard Workerentry: 13*9880d681SAndroid Build Coastguard Worker call void @llvm.eh.sjlj.longjmp(i8* bitcast ([1 x %struct.__jmp_buf_tag]* @env_sigill to i8*)) 14*9880d681SAndroid Build Coastguard Worker unreachable 15*9880d681SAndroid Build Coastguard Worker 16*9880d681SAndroid Build Coastguard Worker; CHECK: @foo 17*9880d681SAndroid Build Coastguard Worker; CHECK: addis [[REG:[0-9]+]], 2, env_sigill@toc@ha 18*9880d681SAndroid Build Coastguard Worker; CHECK: addi [[REG]], [[REG]], env_sigill@toc@l 19*9880d681SAndroid Build Coastguard Worker; CHECK: ld 31, 0([[REG]]) 20*9880d681SAndroid Build Coastguard Worker; CHECK: ld [[REG2:[0-9]+]], 8([[REG]]) 21*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: ld 1, 16([[REG]]) 22*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: mtctr [[REG2]] 23*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: ld 30, 32([[REG]]) 24*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: ld 2, 24([[REG]]) 25*9880d681SAndroid Build Coastguard Worker; CHECK: bctr 26*9880d681SAndroid Build Coastguard Worker 27*9880d681SAndroid Build Coastguard Workerreturn: ; No predecessors! 28*9880d681SAndroid Build Coastguard Worker ret void 29*9880d681SAndroid Build Coastguard Worker} 30*9880d681SAndroid Build Coastguard Worker 31*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.eh.sjlj.longjmp(i8*) #1 32*9880d681SAndroid Build Coastguard Worker 33*9880d681SAndroid Build Coastguard Workerdefine signext i32 @main() #0 { 34*9880d681SAndroid Build Coastguard Workerentry: 35*9880d681SAndroid Build Coastguard Worker %retval = alloca i32, align 4 36*9880d681SAndroid Build Coastguard Worker store i32 0, i32* %retval 37*9880d681SAndroid Build Coastguard Worker %0 = call i8* @llvm.frameaddress(i32 0) 38*9880d681SAndroid Build Coastguard Worker store i8* %0, i8** bitcast ([1 x %struct.__jmp_buf_tag]* @env_sigill to i8**) 39*9880d681SAndroid Build Coastguard Worker %1 = call i8* @llvm.stacksave() 40*9880d681SAndroid Build Coastguard Worker store i8* %1, i8** getelementptr (i8*, i8** bitcast ([1 x %struct.__jmp_buf_tag]* @env_sigill to i8**), i32 2) 41*9880d681SAndroid Build Coastguard Worker %2 = call i32 @llvm.eh.sjlj.setjmp(i8* bitcast ([1 x %struct.__jmp_buf_tag]* @env_sigill to i8*)) 42*9880d681SAndroid Build Coastguard Worker %tobool = icmp ne i32 %2, 0 43*9880d681SAndroid Build Coastguard Worker br i1 %tobool, label %if.then, label %if.else 44*9880d681SAndroid Build Coastguard Worker 45*9880d681SAndroid Build Coastguard Workerif.then: ; preds = %entry 46*9880d681SAndroid Build Coastguard Worker store i32 1, i32* %retval 47*9880d681SAndroid Build Coastguard Worker br label %return 48*9880d681SAndroid Build Coastguard Worker 49*9880d681SAndroid Build Coastguard Workerif.else: ; preds = %entry 50*9880d681SAndroid Build Coastguard Worker call void @foo() 51*9880d681SAndroid Build Coastguard Worker br label %if.end 52*9880d681SAndroid Build Coastguard Worker 53*9880d681SAndroid Build Coastguard Workerif.end: ; preds = %if.else 54*9880d681SAndroid Build Coastguard Worker store i32 0, i32* %retval 55*9880d681SAndroid Build Coastguard Worker br label %return 56*9880d681SAndroid Build Coastguard Worker 57*9880d681SAndroid Build Coastguard Workerreturn: ; preds = %if.end, %if.then 58*9880d681SAndroid Build Coastguard Worker %3 = load i32, i32* %retval 59*9880d681SAndroid Build Coastguard Worker ret i32 %3 60*9880d681SAndroid Build Coastguard Worker 61*9880d681SAndroid Build Coastguard Worker; FIXME: We should be saving VRSAVE on Darwin, but we're not! 62*9880d681SAndroid Build Coastguard Worker 63*9880d681SAndroid Build Coastguard Worker; CHECK: @main 64*9880d681SAndroid Build Coastguard Worker; CHECK: std 65*9880d681SAndroid Build Coastguard Worker; Make sure that we're not saving VRSAVE on non-Darwin: 66*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: mfspr 67*9880d681SAndroid Build Coastguard Worker 68*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: stfd 69*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: stvx 70*9880d681SAndroid Build Coastguard Worker 71*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: addis [[REG:[0-9]+]], 2, env_sigill@toc@ha 72*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: std 31, env_sigill@toc@l([[REG]]) 73*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: addi [[REGA:[0-9]+]], [[REG]], env_sigill@toc@l 74*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: std [[REGA]], [[OFF:[0-9]+]](31) # 8-byte Folded Spill 75*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: std 1, 16([[REGA]]) 76*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: std 2, 24([[REGA]]) 77*9880d681SAndroid Build Coastguard Worker; CHECK: bcl 20, 31, .LBB1_5 78*9880d681SAndroid Build Coastguard Worker; CHECK: li 3, 1 79*9880d681SAndroid Build Coastguard Worker; CHECK: #EH_SjLj_Setup .LBB1_5 80*9880d681SAndroid Build Coastguard Worker; CHECK: b .LBB1_1 81*9880d681SAndroid Build Coastguard Worker 82*9880d681SAndroid Build Coastguard Worker; CHECK: .LBB1_4: 83*9880d681SAndroid Build Coastguard Worker 84*9880d681SAndroid Build Coastguard Worker; CHECK: lfd 85*9880d681SAndroid Build Coastguard Worker; CHECK: lvx 86*9880d681SAndroid Build Coastguard Worker; CHECK: ld 87*9880d681SAndroid Build Coastguard Worker; CHECK: blr 88*9880d681SAndroid Build Coastguard Worker 89*9880d681SAndroid Build Coastguard Worker; CHECK: .LBB1_5: 90*9880d681SAndroid Build Coastguard Worker; CHECK: mflr [[REGL:[0-9]+]] 91*9880d681SAndroid Build Coastguard Worker; CHECK: ld [[REG2:[0-9]+]], [[OFF]](31) # 8-byte Folded Reload 92*9880d681SAndroid Build Coastguard Worker; CHECK: std [[REGL]], 8([[REG2]]) 93*9880d681SAndroid Build Coastguard Worker; CHECK: li 3, 0 94*9880d681SAndroid Build Coastguard Worker 95*9880d681SAndroid Build Coastguard Worker; CHECK-NOAV: @main 96*9880d681SAndroid Build Coastguard Worker; CHECK-NOAV-NOT: stvx 97*9880d681SAndroid Build Coastguard Worker; CHECK-NOAV: bcl 98*9880d681SAndroid Build Coastguard Worker; CHECK-NOAV: mflr 99*9880d681SAndroid Build Coastguard Worker; CHECK-NOAV: bl foo 100*9880d681SAndroid Build Coastguard Worker; CHECK-NOAV-NOT: lvx 101*9880d681SAndroid Build Coastguard Worker; CHECK-NOAV: blr 102*9880d681SAndroid Build Coastguard Worker} 103*9880d681SAndroid Build Coastguard Worker 104*9880d681SAndroid Build Coastguard Workerdefine signext i32 @main2() #0 { 105*9880d681SAndroid Build Coastguard Workerentry: 106*9880d681SAndroid Build Coastguard Worker %a = alloca i8, align 64 107*9880d681SAndroid Build Coastguard Worker call void @bar(i8* %a) 108*9880d681SAndroid Build Coastguard Worker %retval = alloca i32, align 4 109*9880d681SAndroid Build Coastguard Worker store i32 0, i32* %retval 110*9880d681SAndroid Build Coastguard Worker %0 = call i8* @llvm.frameaddress(i32 0) 111*9880d681SAndroid Build Coastguard Worker store i8* %0, i8** bitcast ([1 x %struct.__jmp_buf_tag]* @env_sigill to i8**) 112*9880d681SAndroid Build Coastguard Worker %1 = call i8* @llvm.stacksave() 113*9880d681SAndroid Build Coastguard Worker store i8* %1, i8** getelementptr (i8*, i8** bitcast ([1 x %struct.__jmp_buf_tag]* @env_sigill to i8**), i32 2) 114*9880d681SAndroid Build Coastguard Worker %2 = call i32 @llvm.eh.sjlj.setjmp(i8* bitcast ([1 x %struct.__jmp_buf_tag]* @env_sigill to i8*)) 115*9880d681SAndroid Build Coastguard Worker %tobool = icmp ne i32 %2, 0 116*9880d681SAndroid Build Coastguard Worker br i1 %tobool, label %if.then, label %if.else 117*9880d681SAndroid Build Coastguard Worker 118*9880d681SAndroid Build Coastguard Workerif.then: ; preds = %entry 119*9880d681SAndroid Build Coastguard Worker store i32 1, i32* %retval 120*9880d681SAndroid Build Coastguard Worker br label %return 121*9880d681SAndroid Build Coastguard Worker 122*9880d681SAndroid Build Coastguard Workerif.else: ; preds = %entry 123*9880d681SAndroid Build Coastguard Worker call void @foo() 124*9880d681SAndroid Build Coastguard Worker br label %if.end 125*9880d681SAndroid Build Coastguard Worker 126*9880d681SAndroid Build Coastguard Workerif.end: ; preds = %if.else 127*9880d681SAndroid Build Coastguard Worker store i32 0, i32* %retval 128*9880d681SAndroid Build Coastguard Worker br label %return 129*9880d681SAndroid Build Coastguard Worker 130*9880d681SAndroid Build Coastguard Workerreturn: ; preds = %if.end, %if.then 131*9880d681SAndroid Build Coastguard Worker %3 = load i32, i32* %retval 132*9880d681SAndroid Build Coastguard Worker ret i32 %3 133*9880d681SAndroid Build Coastguard Worker 134*9880d681SAndroid Build Coastguard Worker; CHECK: @main2 135*9880d681SAndroid Build Coastguard Worker 136*9880d681SAndroid Build Coastguard Worker; CHECK: addis [[REG:[0-9]+]], 2, env_sigill@toc@ha 137*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: std 31, env_sigill@toc@l([[REG]]) 138*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: addi [[REGB:[0-9]+]], [[REG]], env_sigill@toc@l 139*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: std [[REGB]], [[OFF:[0-9]+]](31) # 8-byte Folded Spill 140*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: std 1, 16([[REGB]]) 141*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: std 2, 24([[REGB]]) 142*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: std 30, 32([[REGB]]) 143*9880d681SAndroid Build Coastguard Worker; CHECK: bcl 20, 31, 144*9880d681SAndroid Build Coastguard Worker 145*9880d681SAndroid Build Coastguard Worker; CHECK: blr 146*9880d681SAndroid Build Coastguard Worker} 147*9880d681SAndroid Build Coastguard Worker 148*9880d681SAndroid Build Coastguard Workerdeclare void @bar(i8*) #3 149*9880d681SAndroid Build Coastguard Worker 150*9880d681SAndroid Build Coastguard Workerdeclare i8* @llvm.frameaddress(i32) #2 151*9880d681SAndroid Build Coastguard Worker 152*9880d681SAndroid Build Coastguard Workerdeclare i8* @llvm.stacksave() #3 153*9880d681SAndroid Build Coastguard Worker 154*9880d681SAndroid Build Coastguard Workerdeclare i32 @llvm.eh.sjlj.setjmp(i8*) #3 155*9880d681SAndroid Build Coastguard Worker 156*9880d681SAndroid Build Coastguard Workerattributes #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" } 157*9880d681SAndroid Build Coastguard Workerattributes #1 = { noreturn nounwind } 158*9880d681SAndroid Build Coastguard Workerattributes #2 = { nounwind readnone } 159*9880d681SAndroid Build Coastguard Workerattributes #3 = { nounwind } 160*9880d681SAndroid Build Coastguard Worker 161