1 ; RUN: opt -S -sccp < %s | FileCheck %s 2 3 declare void @BB0_f() 4 declare void @BB1_f() 5 6 ; Make sure we can eliminate what is in BB0 as we know that the indirectbr is going to BB1. 7 ; 8 ; CHECK-LABEL: define void @indbrtest1( 9 ; CHECK-NOT: call void @BB0_f() 10 ; CHECK: ret void 11 define void @indbrtest1() { 12 entry: 13 indirectbr i8* blockaddress(@indbrtest1, %BB1), [label %BB0, label %BB1] 14 BB0: 15 call void @BB0_f() 16 br label %BB1 17 BB1: 18 call void @BB1_f() 19 ret void 20 } 21 22 ; Make sure we can eliminate what is in BB0 as we know that the indirectbr is going to BB1 23 ; by looking through the casts. The casts should be folded away when they are visited 24 ; before the indirectbr instruction. 25 ; 26 ; CHECK-LABEL: define void @indbrtest2( 27 ; CHECK-NOT: call void @BB0_f() 28 ; CHECK: ret void 29 define void @indbrtest2() { 30 entry: 31 %a = ptrtoint i8* blockaddress(@indbrtest2, %BB1) to i64 32 %b = inttoptr i64 %a to i8* 33 %c = bitcast i8* %b to i8* 34 indirectbr i8* %b, [label %BB0, label %BB1] 35 BB0: 36 call void @BB0_f() 37 br label %BB1 38 BB1: 39 call void @BB1_f() 40 ret void 41 } 42 43 ; Make sure we can not eliminate BB0 as we do not know the target of the indirectbr. 44 ; 45 ; CHECK-LABEL: define void @indbrtest3( 46 ; CHECK: call void @BB0_f() 47 ; CHECK: ret void 48 define void @indbrtest3(i8** %Q) { 49 entry: 50 %t = load i8*, i8** %Q 51 indirectbr i8* %t, [label %BB0, label %BB1] 52 BB0: 53 call void @BB0_f() 54 br label %BB1 55 BB1: 56 call void @BB1_f() 57 ret void 58 } 59 60 ; Make sure we eliminate BB1 as we pick the first successor on undef. 61 ; 62 ; CHECK-LABEL: define void @indbrtest4( 63 ; CHECK: call void @BB0_f() 64 ; CHECK: ret void 65 define void @indbrtest4(i8** %Q) { 66 entry: 67 indirectbr i8* undef, [label %BB0, label %BB1] 68 BB0: 69 call void @BB0_f() 70 br label %BB1 71 BB1: 72 call void @BB1_f() 73 ret void 74 } 75 76 77