forked from OSchip/llvm-project
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:
parent
904cd39b05
commit
41cf73ce16
|
@ -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");
|
||||
|
|
Loading…
Reference in New Issue