llvm.org GIT mirror llvm / 998cbb0
Revert rev. 63876. It is causing llvm-gcc bootstrap failure. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63888 91177308-0d34-0410-b5e6-96231b3b80d8 Devang Patel 10 years ago
5 changed file(s) with 16 addition(s) and 72 deletion(s). Raw diff Collapse all Expand all
3737 /// basic block must have their PHI nodes updated.
3838 ///
3939 bool ConstantFoldTerminator(BasicBlock *BB);
40
41 //===----------------------------------------------------------------------===//
42 // CFG Simplification
43 //
44
45 /// isTerminatorFirstRelevantInsn - Return true if Term is very first
46 /// instruction ignoring Phi nodes and dbg intrinsics.
47 bool isTerminatorFirstRelevantInsn(BasicBlock *BB, Instruction *Term);
4840
4941 //===----------------------------------------------------------------------===//
5042 // Local dead code elimination.
147147 if (!PN->hasOneUse()) return;
148148
149149 BasicBlock *BB = BI->getParent();
150 if (!isTerminatorFirstRelevantInsn (BB, BI))
150 if (&*BB->begin() != PN || &*next(BB->begin()) != BI)
151151 return;
152152
153153 // Ok, we have this really simple case, walk the PHI operands, looking for
181181 if (!PN->hasOneUse()) return;
182182
183183 BasicBlock *BB = SI->getParent();
184 if (!isTerminatorFirstRelevantInsn (BB, SI))
184 if (&*BB->begin() != PN || &*next(BB->begin()) != SI)
185185 return;
186186
187187 bool RemovedPreds = false;
147147 return false;
148148 }
149149
150 //===----------------------------------------------------------------------===//
151 // CFG Simplification
152 //
153
154 /// isTerminatorFirstRelevantInsn - Return true if Term is very first
155 /// instruction ignoring Phi nodes and dbg intrinsics.
156 bool llvm::isTerminatorFirstRelevantInsn(BasicBlock *BB, Instruction *Term) {
157 BasicBlock::iterator BBI = Term;
158 while (BBI != BB->begin()) {
159 --BBI;
160 if (!isa(BBI))
161 break;
162 }
163 if (isa(BBI) || &*BBI == Term)
164 return true;
165 return false;
166 }
167150
168151 //===----------------------------------------------------------------------===//
169152 // Local dead code elimination...
13291329 return true;
13301330 }
13311331
1332 /// isTerminatorFirstRelevantInsn - Return true if Term is very first
1333 /// instruction ignoring Phi nodes and dbg intrinsics.
1334 static bool isTerminatorFirstRelevantInsn(BasicBlock *BB, Instruction *Term) {
1335 BasicBlock::iterator BBI = Term;
1336 while (BBI != BB->begin()) {
1337 --BBI;
1338 if (!isa(BBI))
1339 break;
1340 }
1341 if (isa(BBI) || &*BBI == Term)
1342 return true;
1343 return false;
1344 }
1345
13321346 /// SimplifyCondBranchToTwoReturns - If we found a conditional branch that goes
13331347 /// to two returning blocks, try to merge them together into one return,
13341348 /// introducing a select if the return values disagree.
+0
-45
test/Transforms/CondProp/basictest-dbg.ll less more
None ; RUN: llvm-as < %s | opt -condprop | llvm-dis | \
1 ; RUN: not grep {br label}
2
3 %llvm.dbg.anchor.type = type { i32, i32 }
4 %llvm.dbg.compile_unit.type = type { i32, { }*, i32, i8*, i8*, i8*, i1, i1, i8* }
5
6 @llvm.dbg.compile_units = linkonce constant %llvm.dbg.anchor.type { i32 458752, i32 17 }, section "llvm.metadata" ;
7
8 @.str = internal constant [4 x i8] c"a.c\00", section "llvm.metadata" ; <[4 x i8]*> [#uses=1]
9 @.str1 = internal constant [6 x i8] c"/tmp/\00", section "llvm.metadata" ; <[6 x i8]*> [#uses=1]
10 @.str2 = internal constant [55 x i8] c"4.2.1 (Based on Apple Inc. build 5636) (LLVM build 00)\00", section "llvm.metadata" ; <[55 x i8]*> [#uses=1]
11 @llvm.dbg.compile_unit = internal constant %llvm.dbg.compile_unit.type { i32 458769, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.compile_units to { }*), i32 1, i8* getelementptr ([4 x i8]* @.str, i32 0, i32 0), i8* getelementptr ([6 x i8]* @.str1, i32 0, i32 0), i8* getelementptr ([55 x i8]* @.str2, i32 0, i32 0), i1 true, i1 false, i8* null }, section "llvm.metadata" ; <%llvm.dbg.compile_unit.type*> [#uses=1]
12
13 declare void @llvm.dbg.stoppoint(i32, i32, { }*) nounwind
14
15
16 define i32 @test(i1 %C) {
17 br i1 %C, label %T1, label %F1
18
19 T1: ; preds = %0
20 call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
21 br label %Cont
22
23 F1: ; preds = %0
24 call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
25 br label %Cont
26
27 Cont: ; preds = %F1, %T1
28 %C2 = phi i1 [ false, %F1 ], [ true, %T1 ] ; [#uses=1]
29 call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
30 br i1 %C2, label %T2, label %F2
31
32 T2: ; preds = %Cont
33 call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
34 call void @bar( )
35 call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
36 ret i32 17
37
38 F2: ; preds = %Cont
39 call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*))
40 ret i32 1
41 }
42
43 declare void @bar()
44