llvm.org GIT mirror llvm / 6a23921
Fix IPSCCP's code for deleting dead blocks to tolerate outstanding blockaddress users. This fixes PR5569. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89483 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 9 years ago
2 changed file(s) with 48 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
18681868 for (unsigned i = 0, e = BlocksToErase.size(); i != e; ++i) {
18691869 // If there are any PHI nodes in this successor, drop entries for BB now.
18701870 BasicBlock *DeadBB = BlocksToErase[i];
1871 while (!DeadBB->use_empty()) {
1872 Instruction *I = cast(DeadBB->use_back());
1871 for (Value::use_iterator UI = DeadBB->use_begin(), UE = DeadBB->use_end();
1872 UI != UE; ) {
1873 // Ignore blockaddress users; BasicBlock's dtor will handle them.
1874 Instruction *I = dyn_cast(*UI++);
1875 if (!I) continue;
1876
18731877 bool Folded = ConstantFoldTerminator(I->getParent());
18741878 if (!Folded) {
18751879 // The constant folder may not have been able to fold the terminator
0 ; RUN: opt < %s -internalize -ipsccp -S | FileCheck %s
1 ; PR5569
2
3 ; IPSCCP should prove that the blocks are dead and delete them, and
4 ; properly handle the dangling blockaddress constants.
5
6 ; CHECK: @bar.l = internal constant [2 x i8*] [i8* inttoptr (i32 1 to i8*), i8* inttoptr (i32 1 to i8*)]
7
8 @code = global [5 x i32] [i32 0, i32 0, i32 0, i32 0, i32 1], align 4 ; <[5 x i32]*> [#uses=0]
9 @bar.l = internal constant [2 x i8*] [i8* blockaddress(@bar, %lab0), i8* blockaddress(@bar, %end)] ; <[2 x i8*]*> [#uses=1]
10
11 define void @foo(i32 %x) nounwind readnone {
12 entry:
13 %b = alloca i32, align 4 ; [#uses=1]
14 volatile store i32 -1, i32* %b
15 ret void
16 }
17
18 define void @bar(i32* nocapture %pc) nounwind readonly {
19 entry:
20 br label %indirectgoto
21
22 lab0: ; preds = %indirectgoto
23 %indvar.next = add i32 %indvar, 1 ; [#uses=1]
24 br label %indirectgoto
25
26 end: ; preds = %indirectgoto
27 ret void
28
29 indirectgoto: ; preds = %lab0, %entry
30 %indvar = phi i32 [ %indvar.next, %lab0 ], [ 0, %entry ] ; [#uses=2]
31 %pc.addr.0 = getelementptr i32* %pc, i32 %indvar ; [#uses=1]
32 %tmp1.pn = load i32* %pc.addr.0 ; [#uses=1]
33 %indirect.goto.dest.in = getelementptr inbounds [2 x i8*]* @bar.l, i32 0, i32 %tmp1.pn ; [#uses=1]
34 %indirect.goto.dest = load i8** %indirect.goto.dest.in ; [#uses=1]
35 indirectbr i8* %indirect.goto.dest, [label %lab0, label %end]
36 }
37
38 define i32 @main() nounwind readnone {
39 entry:
40 ret i32 0
41 }