[llvm] r187646 - Fix dereferencing end iterator in SimplifyCFG. Patch by Ye Mei.
Alexey Samsonov
samsonov at google.com
Fri Aug 2 01:06:49 PDT 2013
Author: samsonov
Date: Fri Aug 2 03:06:43 2013
New Revision: 187646
URL: http://llvm.org/viewvc/llvm-project?rev=187646&view=rev
Log:
Fix dereferencing end iterator in SimplifyCFG. Patch by Ye Mei.
Modified:
llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=187646&r1=187645&r2=187646&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Fri Aug 2 03:06:43 2013
@@ -4290,7 +4290,8 @@ bool SimplifyCFGOpt::SimplifyParallelAnd
// 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::SimplifyParallelAnd
// 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(Basic
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) {
More information about the llvm-commits
mailing list