summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2011-11-14 21:11:15 +0000
committerEvan Cheng <evan.cheng@apple.com>2011-11-14 21:11:15 +0000
commitf2fc508d4d8a537b6ef04b860709aaa2551ad727 (patch)
treec66830e2ca48f381d6d3f321e7ddc3292ded7c80 /llvm/lib/CodeGen
parent28ffb7e4441059d8e88e110c7fa7d3c7d4920b23 (diff)
downloadbcm5719-llvm-f2fc508d4d8a537b6ef04b860709aaa2551ad727.tar.gz
bcm5719-llvm-f2fc508d4d8a537b6ef04b860709aaa2551ad727.zip
Avoid dereferencing off the beginning of lists.
llvm-svn: 144569
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/TwoAddressInstructionPass.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
index a702c6c8407..67963126491 100644
--- a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
+++ b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
@@ -999,10 +999,8 @@ TwoAddressInstructionPass::RescheduleMIBelowKill(MachineBasicBlock *MBB,
}
// Move debug info as well.
- if (From != MBB->begin()) {
- while (llvm::prior(From)->isDebugValue())
- --From;
- }
+ while (From != MBB->begin() && llvm::prior(From)->isDebugValue())
+ --From;
// Copies following MI may have been moved as well.
nmi = To;
@@ -1146,9 +1144,8 @@ TwoAddressInstructionPass::RescheduleKillAboveMI(MachineBasicBlock *MBB,
// Move the old kill above MI, don't forget to move debug info as well.
MachineBasicBlock::iterator InsertPos = mi;
- if (InsertPos != MBB->begin())
- while (llvm::prior(InsertPos)->isDebugValue())
- --InsertPos;
+ while (InsertPos != MBB->begin() && llvm::prior(InsertPos)->isDebugValue())
+ --InsertPos;
MachineBasicBlock::iterator From = KillMI;
MachineBasicBlock::iterator To = llvm::next(From);
while (llvm::prior(From)->isDebugValue())
OpenPOWER on IntegriCloud