llvm.org GIT mirror llvm / 36c4deb
Fix PR8247: JumpThreading can cause a block to become unreachable while still having predecessor, if it is part of a self-loop. Because of this, we cannot use the Simplify* APIs, as they can assert-fail on unreachable code. Since it's not easy to determine if a given threading will cause a block to become unreachable, simply defer simplifying simplification to later InstCombine and/or DCE passes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115082 91177308-0d34-0410-b5e6-96231b3b80d8 Owen Anderson 9 years ago
2 changed file(s) with 31 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
612612 TerminatorInst *BBTerm = BB->getTerminator();
613613 for (unsigned i = 0, e = BBTerm->getNumSuccessors(); i != e; ++i) {
614614 if (i == BestSucc) continue;
615 RemovePredecessorAndSimplify(BBTerm->getSuccessor(i), BB, TD);
615 BBTerm->getSuccessor(i)->removePredecessor(BB, true);
616616 }
617617
618618 DEBUG(dbgs() << " In block '" << BB->getName()
663663 if (PI == PE) {
664664 unsigned ToRemove = Baseline == LazyValueInfo::True ? 1 : 0;
665665 unsigned ToKeep = Baseline == LazyValueInfo::True ? 0 : 1;
666 RemovePredecessorAndSimplify(CondBr->getSuccessor(ToRemove), BB, TD);
666 CondBr->getSuccessor(ToRemove)->removePredecessor(BB, true);
667667 BranchInst::Create(CondBr->getSuccessor(ToKeep), CondBr);
668668 CondBr->eraseFromParent();
669669 return true;
14691469 TerminatorInst *PredTerm = PredBB->getTerminator();
14701470 for (unsigned i = 0, e = PredTerm->getNumSuccessors(); i != e; ++i)
14711471 if (PredTerm->getSuccessor(i) == BB) {
1472 RemovePredecessorAndSimplify(BB, PredBB, TD);
1472 BB->removePredecessor(PredBB, true);
14731473 PredTerm->setSuccessor(i, NewBB);
14741474 }
14751475
16191619
16201620 // PredBB no longer jumps to BB, remove entries in the PHI node for the edge
16211621 // that we nuked.
1622 RemovePredecessorAndSimplify(BB, PredBB, TD);
1622 BB->removePredecessor(PredBB, true);
16231623
16241624 // Remove the unconditional branch at the end of the PredBB block.
16251625 OldPredBranch->eraseFromParent();
483483 bb288.bb289.loopexit_crit_edge:
484484 unreachable
485485 }
486
487 ; PR 8247
488 %struct.S1 = type { i8, i8 }
489 @func_89.l_245 = internal constant %struct.S1 { i8 33, i8 6 }, align 1
490 define void @func_89(i16 zeroext %p_90, %struct.S1* nocapture %p_91, i32* nocapture %p_92) nounwind ssp {
491 entry:
492 store i32 0, i32* %p_92, align 4
493 br i1 false, label %lbl_260, label %if.else
494
495 if.else: ; preds = %entry
496 br label %for.cond
497
498 for.cond: ; preds = %lbl_260, %if.else
499 %l_245.0 = phi i16 [ %l_245.1, %lbl_260 ], [ 33, %if.else ]
500 %l_261.0 = phi i32 [ %and, %lbl_260 ], [ 255, %if.else ]
501 %tobool21 = icmp ult i16 %l_245.0, 256
502 br i1 %tobool21, label %if.end, label %lbl_260
503
504 lbl_260: ; preds = %for.cond, %entry
505 %l_245.1 = phi i16 [ 1569, %entry ], [ %l_245.0, %for.cond ]
506 %l_261.1 = phi i32 [ 255, %entry ], [ %l_261.0, %for.cond ]
507 %and = and i32 %l_261.1, 1
508 br label %for.cond
509
510 if.end: ; preds = %for.cond
511 ret void
512 }