llvm.org GIT mirror llvm / d668839
third bug from PR6119: the xor dupe extension allows for arbitrary terminators in predecessors, don't assume it is a conditional or uncond branch. The testcase shows an example where they can happen with switches. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94323 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 9 years ago
2 changed file(s) with 30 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
14231423
14241424 // Unless PredBB ends with an unconditional branch, split the edge so that we
14251425 // can just clone the bits from BB into the end of the new PredBB.
1426 BranchInst *OldPredBranch = cast(PredBB->getTerminator());
1427
1428 if (!OldPredBranch->isUnconditional()) {
1426 BranchInst *OldPredBranch = dyn_cast(PredBB->getTerminator());
1427
1428 if (OldPredBranch == 0 || !OldPredBranch->isUnconditional()) {
14291429 PredBB = SplitEdge(PredBB, BB, this);
14301430 OldPredBranch = cast(PredBB->getTerminator());
14311431 }
285285 br label %for.cond
286286 }
287287
288 ; PR6119
289 define i32 @test10(i32 %action, i32 %type) nounwind {
290 entry:
291 %cmp2 = icmp eq i32 %type, 0 ; [#uses=1]
292 switch i32 %action, label %lor.rhs [
293 i32 1, label %if.then
294 i32 0, label %lor.end
295 ]
296
297 if.then: ; preds = %for.cond, %lor.end, %entry
298 ret i32 undef
299
300 lor.rhs: ; preds = %entry
301 %cmp101 = icmp eq i32 %action, 2 ; [#uses=1]
302 br label %lor.end
303
304 lor.end: ; preds = %lor.rhs, %entry
305 %0 = phi i1 [ %cmp101, %lor.rhs ], [ true, %entry ] ; [#uses=1]
306 %cmp103 = xor i1 %cmp2, %0 ; [#uses=1]
307 br i1 %cmp103, label %for.cond, label %if.then
308
309 for.cond: ; preds = %for.body, %lor.end
310 br i1 undef, label %if.then, label %for.body
311
312 for.body: ; preds = %for.cond
313 br label %for.cond
314 }