summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-08-17 01:54:41 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-08-17 01:54:41 +0000
commit362d120488722bf91824f8e74748459525d10614 (patch)
tree4cce742540e5e290c9c28203de44b17661219825 /llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
parent67c5885d091b6630040ee0f47af0e4a119389007 (diff)
downloadbcm5719-llvm-362d120488722bf91824f8e74748459525d10614.tar.gz
bcm5719-llvm-362d120488722bf91824f8e74748459525d10614.zip
Scalar: Avoid dereferencing end() in IndVarSimplify
IndVarSimplify::sinkUnusedInvariants calls BasicBlock::getFirstInsertionPt on the ExitBlock and moves instructions before it. This can return end(), so it's not safe to dereference. Add an iterator-based overload to Instruction::moveBefore to avoid the UB. llvm-svn: 278886
Diffstat (limited to 'llvm/lib/Transforms/Scalar/IndVarSimplify.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/IndVarSimplify.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
index b014747cbc1..a11bef5d784 100644
--- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -2058,7 +2058,7 @@ void IndVarSimplify::sinkUnusedInvariants(Loop *L) {
BasicBlock *Preheader = L->getLoopPreheader();
if (!Preheader) return;
- Instruction *InsertPt = &*ExitBlock->getFirstInsertionPt();
+ BasicBlock::iterator InsertPt = ExitBlock->getFirstInsertionPt();
BasicBlock::iterator I(Preheader->getTerminator());
while (I != Preheader->begin()) {
--I;
@@ -2127,9 +2127,9 @@ void IndVarSimplify::sinkUnusedInvariants(Loop *L) {
Done = true;
}
- ToMove->moveBefore(InsertPt);
+ ToMove->moveBefore(*ExitBlock, InsertPt);
if (Done) break;
- InsertPt = ToMove;
+ InsertPt = ToMove->getIterator();
}
}
OpenPOWER on IntegriCloud