Scalar: Avoid dereferencing end() in IndVarSimplify
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Wed, 17 Aug 2016 01:54:41 +0000 (01:54 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Wed, 17 Aug 2016 01:54:41 +0000 (01:54 +0000)
commit362d120488722bf91824f8e74748459525d10614
tree4cce742540e5e290c9c28203de44b17661219825
parent67c5885d091b6630040ee0f47af0e4a119389007
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
llvm/include/llvm/IR/Instruction.h
llvm/lib/IR/Instruction.cpp
llvm/lib/Transforms/Scalar/IndVarSimplify.cpp