summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MachineBasicBlock.cpp
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-08-16 21:46:03 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-08-16 21:46:03 +0000
commit41cf73ce16c016a02d875364a56e127b4cdf46e8 (patch)
treeb5266305dfabc0bd54211694d69a81b3e06f26a5 /llvm/lib/CodeGen/MachineBasicBlock.cpp
parent904cd39b0562cec4a53adc02307af64189306e08 (diff)
downloadbcm5719-llvm-41cf73ce16c016a02d875364a56e127b4cdf46e8.tar.gz
bcm5719-llvm-41cf73ce16c016a02d875364a56e127b4cdf46e8.zip
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
Diffstat (limited to 'llvm/lib/CodeGen/MachineBasicBlock.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineBasicBlock.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp
index 58f758890d7..29f3594ddae 100644
--- a/llvm/lib/CodeGen/MachineBasicBlock.cpp
+++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp
@@ -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");
OpenPOWER on IntegriCloud