aboutsummaryrefslogtreecommitdiffstats
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
commit8aee7d8f9eab71a29f8f3a5a541144bef4fb5ac4 (patch)
treed614105281911e21261f66fc8540bd97e05c8913
parent41e00172c51a1666cbcda5df2c6f45d685068fbb (diff)
downloadexternal_llvm-8aee7d8f9eab71a29f8f3a5a541144bef4fb5ac4.zip
external_llvm-8aee7d8f9eab71a29f8f3a5a541144bef4fb5ac4.tar.gz
external_llvm-8aee7d8f9eab71a29f8f3a5a541144bef4fb5ac4.tar.bz2
Avoid dereferencing off the beginning of lists.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144569 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/TwoAddressInstructionPass.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/CodeGen/TwoAddressInstructionPass.cpp b/lib/CodeGen/TwoAddressInstructionPass.cpp
index a702c6c..6796312 100644
--- a/lib/CodeGen/TwoAddressInstructionPass.cpp
+++ b/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())