mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-27 05:32:22 +00:00
Fix dereferencing end iterator in SimplifyCFG. Patch by Ye Mei.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187646 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ee1d7db74b
commit
e393b73808
@ -4290,7 +4290,8 @@ bool SimplifyCFGOpt::SimplifyParallelAndOr(BasicBlock *BB, IRBuilder<> &Builder,
|
||||
// Do the transformation.
|
||||
BasicBlock *CB;
|
||||
bool Iteration = true;
|
||||
BasicBlock::iterator ItOld = Builder.GetInsertPoint();
|
||||
BasicBlock *SaveInsertBB = Builder.GetInsertBlock();
|
||||
BasicBlock::iterator SaveInsertPt = Builder.GetInsertPoint();
|
||||
BranchInst *PBI = dyn_cast<BranchInst>(FirstCondBlock->getTerminator());
|
||||
Value *PC = PBI->getCondition();
|
||||
do {
|
||||
@ -4319,8 +4320,8 @@ bool SimplifyCFGOpt::SimplifyParallelAndOr(BasicBlock *BB, IRBuilder<> &Builder,
|
||||
// make CB unreachable and let downstream to delete the block.
|
||||
new UnreachableInst(CB->getContext(), CB);
|
||||
} while (Iteration);
|
||||
|
||||
Builder.SetInsertPoint(ItOld);
|
||||
if (SaveInsertBB)
|
||||
Builder.SetInsertPoint(SaveInsertBB, SaveInsertPt);
|
||||
DEBUG(dbgs() << "Use parallel and/or in:\n" << *FirstCondBlock);
|
||||
return true;
|
||||
}
|
||||
@ -4454,11 +4455,13 @@ bool SimplifyCFGOpt::MergeIfRegion(BasicBlock *BB, IRBuilder<> &Builder,
|
||||
FirstEntryBlock->getInstList().splice(FirstEntryBlock->end(), SecondEntryBlock->getInstList());
|
||||
BranchInst *PBI = dyn_cast<BranchInst>(FirstEntryBlock->getTerminator());
|
||||
Value *CC = PBI->getCondition();
|
||||
BasicBlock::iterator ItOld = Builder.GetInsertPoint();
|
||||
BasicBlock *SaveInsertBB = Builder.GetInsertBlock();
|
||||
BasicBlock::iterator SaveInsertPt = Builder.GetInsertPoint();
|
||||
Builder.SetInsertPoint(PBI);
|
||||
Value *NC = Builder.CreateOr(CInst1, CC);
|
||||
PBI->replaceUsesOfWith(CC, NC);
|
||||
Builder.SetInsertPoint(ItOld);
|
||||
if (SaveInsertBB)
|
||||
Builder.SetInsertPoint(SaveInsertBB, SaveInsertPt);
|
||||
|
||||
// Remove IfTrue1
|
||||
if (IfTrue1 != FirstEntryBlock) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user