[llvm-commits] [llvm] r107504 - /llvm/trunk/include/llvm/CodeGen/SlotIndexes.h
Jakob Stoklund Olesen
stoklund at 2pi.dk
Fri Jul 2 12:54:45 PDT 2010
Author: stoklund
Date: Fri Jul 2 14:54:45 2010
New Revision: 107504
URL: http://llvm.org/viewvc/llvm-project?rev=107504&view=rev
Log:
Handle unindexed instructions in SlotIndices.
SlotIndexes::insertMachineInstrInMaps would crash when trying to insert an
instruction imediately after an unmapped debug value.
Modified:
llvm/trunk/include/llvm/CodeGen/SlotIndexes.h
Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SlotIndexes.h?rev=107504&r1=107503&r2=107504&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/SlotIndexes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Fri Jul 2 14:54:45 2010
@@ -663,15 +663,20 @@
MachineBasicBlock::iterator miItr(mi);
bool needRenumber = false;
IndexListEntry *newEntry;
-
+ // Get previous index, considering that not all instructions are indexed.
IndexListEntry *prevEntry;
- if (miItr == mbb->begin()) {
+ for (;;) {
// If mi is at the mbb beginning, get the prev index from the mbb.
- prevEntry = &mbbRangeItr->second.first.entry();
- } else {
- // Otherwise get it from the previous instr.
- MachineBasicBlock::iterator pItr(prior(miItr));
- prevEntry = &getInstructionIndex(pItr).entry();
+ if (miItr == mbb->begin()) {
+ prevEntry = &mbbRangeItr->second.first.entry();
+ break;
+ }
+ // Otherwise rewind until we find a mapped instruction.
+ Mi2IndexMap::const_iterator itr = mi2iMap.find(--miItr);
+ if (itr != mi2iMap.end()) {
+ prevEntry = &itr->second.entry();
+ break;
+ }
}
// Get next entry from previous entry.
More information about the llvm-commits
mailing list