1 ; RUN: opt -S -ipsccp < %s | FileCheck %s
6 ; Make sure we can eliminate what is in BB0 as we know that the indirectbr is going to BB1.
8 ; CHECK-LABEL: define void @indbrtest1(
9 ; CHECK-NOT: call void @BB0_f()
11 define void @indbrtest1() {
13 indirectbr i8* blockaddress(@indbrtest1, %BB1), [label %BB0, label %BB1]
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.
26 ; CHECK-LABEL: define void @indbrtest2(
27 ; CHECK-NOT: call void @BB0_f()
29 define void @indbrtest2() {
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]
43 ; Make sure we can not eliminate BB0 as we do not know the target of the indirectbr.
45 ; CHECK-LABEL: define void @indbrtest3(
46 ; CHECK: call void @BB0_f()
48 define void @indbrtest3(i8** %Q) {
50 %t = load i8*, i8** %Q
51 indirectbr i8* %t, [label %BB0, label %BB1]
60 ; Make sure we eliminate BB1 as we pick the first successor on undef.
62 ; CHECK-LABEL: define void @indbrtest4(
63 ; CHECK: call void @BB0_f()
65 define void @indbrtest4(i8** %Q) {
67 indirectbr i8* undef, [label %BB0, label %BB1]
77 ; CHECK-LABEL: define internal i32 @indbrtest5(
78 ; CHECK: ret i32 undef
79 define internal i32 @indbrtest5(i1 %c) {
81 br i1 %c, label %bb1, label %bb2
84 br label %branch.block
88 br label %branch.block
91 %addr = phi i8* [blockaddress(@indbrtest5, %target1), %bb1], [blockaddress(@indbrtest5, %target2), %bb2]
92 indirectbr i8* %addr, [label %target1, label %target2]
102 define i32 @indbrtest5_callee(i1 %c) {
103 ; CHECK-LABEL: define i32 @indbrtest5_callee(
104 ; CHECK-NEXT: %r = call i32 @indbrtest5(i1 %c)
105 ; CHECK-NEXT: ret i32 10
106 %r = call i32 @indbrtest5(i1 %c)