CodeGen: Don't dereference end() in MachineBasicBlock::CorrectExtraCFGEdges

The current MachineBasicBlock might be the last block, so FallThru may
be past the end().  Use getNextNode(), which will convert to nullptr,
rather than &*++, which is invalid if we reach the end().

llvm-svn: 278858
This commit is contained in:
Duncan P. N. Exon Smith 2016-08-16 21:46:03 +00:00
parent 904cd39b05
commit 41cf73ce16
1 changed files with 4 additions and 4 deletions

View File

@ -1087,16 +1087,16 @@ bool MachineBasicBlock::CorrectExtraCFGEdges(MachineBasicBlock *DestA,
bool Changed = false;
MachineFunction::iterator FallThru = std::next(getIterator());
MachineBasicBlock *FallThru = getNextNode();
if (!DestA && !DestB) {
// Block falls through to successor.
DestA = &*FallThru;
DestB = &*FallThru;
DestA = FallThru;
DestB = FallThru;
} else if (DestA && !DestB) {
if (IsCond)
// Block ends in conditional jump that falls through to successor.
DestB = &*FallThru;
DestB = FallThru;
} else {
assert(DestA && DestB && IsCond &&
"CFG in a bad state. Cannot correct CFG edges");