1 ; RUN: llc < %s -mtriple=x86_64-apple-darwin | FileCheck %s 2 3 ; Teach CGP to dup returns to enable tail call optimization. 4 ; rdar://9147433 5 6 define i32 @foo(i32 %x) nounwind ssp { 7 ; CHECK-LABEL: foo: 8 entry: 9 switch i32 %x, label %return [ 10 i32 1, label %sw.bb 11 i32 2, label %sw.bb1 12 i32 3, label %sw.bb3 13 i32 4, label %sw.bb5 14 i32 5, label %sw.bb7 15 i32 6, label %sw.bb9 16 ] 17 18 sw.bb: ; preds = %entry 19 ; CHECK: jmp _f1 20 %call = tail call i32 @f1() nounwind 21 br label %return 22 23 sw.bb1: ; preds = %entry 24 ; CHECK: jmp _f2 25 %call2 = tail call i32 @f2() nounwind 26 br label %return 27 28 sw.bb3: ; preds = %entry 29 ; CHECK: jmp _f3 30 %call4 = tail call i32 @f3() nounwind 31 br label %return 32 33 sw.bb5: ; preds = %entry 34 ; CHECK: jmp _f4 35 %call6 = tail call i32 @f4() nounwind 36 br label %return 37 38 sw.bb7: ; preds = %entry 39 ; CHECK: jmp _f5 40 %call8 = tail call i32 @f5() nounwind 41 br label %return 42 43 sw.bb9: ; preds = %entry 44 ; CHECK: jmp _f6 45 %call10 = tail call i32 @f6() nounwind 46 br label %return 47 48 return: ; preds = %entry, %sw.bb9, %sw.bb7, %sw.bb5, %sw.bb3, %sw.bb1, %sw.bb 49 %retval.0 = phi i32 [ %call10, %sw.bb9 ], [ %call8, %sw.bb7 ], [ %call6, %sw.bb5 ], [ %call4, %sw.bb3 ], [ %call2, %sw.bb1 ], [ %call, %sw.bb ], [ 0, %entry ] 50 ret i32 %retval.0 51 } 52 53 declare i32 @f1() 54 55 declare i32 @f2() 56 57 declare i32 @f3() 58 59 declare i32 @f4() 60 61 declare i32 @f5() 62 63 declare i32 @f6() 64 65 ; rdar://11958338 66 %0 = type opaque 67 68 declare i8* @bar(i8*) uwtable optsize noinline ssp 69 70 define hidden %0* @thingWithValue(i8* %self) uwtable ssp { 71 entry: 72 ; CHECK-LABEL: thingWithValue: 73 ; CHECK: jmp _bar 74 br i1 undef, label %if.then.i, label %if.else.i 75 76 if.then.i: ; preds = %entry 77 br label %someThingWithValue.exit 78 79 if.else.i: ; preds = %entry 80 %call4.i = tail call i8* @bar(i8* undef) optsize 81 br label %someThingWithValue.exit 82 83 someThingWithValue.exit: ; preds = %if.else.i, %if.then.i 84 %retval.0.in.i = phi i8* [ undef, %if.then.i ], [ %call4.i, %if.else.i ] 85 %retval.0.i = bitcast i8* %retval.0.in.i to %0* 86 ret %0* %retval.0.i 87 } 88