llvm.org GIT mirror llvm / 9da02b8
Remove the ability for ADCE to remove unreachable blocks in loop nests, because, as Eli pointed out, SimplifyCFG already does this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53104 91177308-0d34-0410-b5e6-96231b3b80d8 Owen Anderson 11 years ago
2 changed file(s) with 0 addition(s) and 75 deletion(s). Raw diff Collapse all Expand all
5252 SmallPtrSet alive;
5353 SmallVector worklist;
5454
55 SmallPtrSet reachable;
56 SmallVector unreachable;
57
58 // First, collect the set of reachable blocks ...
59 for (df_ext_iterator >
60 DI = df_ext_begin(&F.getEntryBlock(), reachable),
61 DE = df_ext_end(&F.getEntryBlock(), reachable); DI != DE; ++DI)
62 ; // Deliberately empty, df_ext_iterator will fill in the set.
63
64 // ... and then invert it into the list of unreachable ones. These
65 // blocks will be removed from the function.
66 for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE; ++FI)
67 if (!reachable.count(FI))
68 unreachable.push_back(FI);
69
70 // Prepare to remove blocks by removing the PHI node entries for those blocks
71 // in their successors, and remove them from reference counting.
72 for (SmallVector::iterator UI = unreachable.begin(),
73 UE = unreachable.end(); UI != UE; ++UI) {
74 BasicBlock* BB = *UI;
75 for (succ_iterator SI = succ_begin(BB), SE = succ_end(BB);
76 SI != SE; ++SI) {
77 BasicBlock* succ = *SI;
78 BasicBlock::iterator succ_inst = succ->begin();
79 while (PHINode* P = dyn_cast(succ_inst)) {
80 P->removeIncomingValue(BB);
81 ++succ_inst;
82 }
83 }
84
85 BB->dropAllReferences();
86 }
87
88 // Finally, erase the unreachable blocks.
89 for (SmallVector::iterator UI = unreachable.begin(),
90 UE = unreachable.end(); UI != UE; ++UI)
91 (*UI)->eraseFromParent();
92
9355 // Collect the set of "root" instructions that are known live.
9456 for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I)
9557 if (isa(I.getInstructionIterator()) ||
+0
-37
test/Transforms/ADCE/2008-07-02-Unreachable.ll less more
None ; RUN: llvm-as < %s | opt -adce -simplifycfg | llvm-dis | not grep forcond
1 ; PR2509
2
3 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
4 target triple = "i686-apple-darwin9.3.0"
5 @g_3 = external global i8 ; [#uses=2]
6
7 define i32 @func_1() nounwind {
8 entry:
9 br i1 false, label %ifelse, label %ifthen
10
11 ifthen: ; preds = %entry
12 br label %ifend
13
14 ifelse: ; preds = %entry
15 %tmp3 = load i8* @g_3 ; [#uses=0]
16 br label %forcond.thread
17
18 forcond.thread: ; preds = %ifelse
19 br label %afterfor
20
21 forcond: ; preds = %forinc
22 br i1 false, label %afterfor, label %forbody
23
24 forbody: ; preds = %forcond
25 br label %forinc
26
27 forinc: ; preds = %forbody
28 br label %forcond
29
30 afterfor: ; preds = %forcond, %forcond.thread
31 %tmp10 = load i8* @g_3 ; [#uses=0]
32 br label %ifend
33
34 ifend: ; preds = %afterfor, %ifthen
35 ret i32 0
36 }