[llvm] r278858 - CodeGen: Don't dereference end() in MachineBasicBlock::CorrectExtraCFGEdges
Duncan P. N. Exon Smith via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 16 14:46:03 PDT 2016
Author: dexonsmith
Date: Tue Aug 16 16:46:03 2016
New Revision: 278858
URL: http://llvm.org/viewvc/llvm-project?rev=278858&view=rev
Log:
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().
Modified:
llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp
Modified: llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp?rev=278858&r1=278857&r2=278858&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp Tue Aug 16 16:46:03 2016
@@ -1087,16 +1087,16 @@ bool MachineBasicBlock::CorrectExtraCFGE
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");
More information about the llvm-commits
mailing list