diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2010-07-02 19:54:45 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2010-07-02 19:54:45 +0000 |
commit | ec8c3e8cccdadfdf8957c3ff8e7cace38897113c (patch) | |
tree | 6b09f9c6fda457f2e05185999fbf7137f211b97d /include/llvm/CodeGen/SlotIndexes.h | |
parent | 3b9c7ebc444ccc311a5e4125b904f9767244577a (diff) | |
download | llvm-ec8c3e8cccdadfdf8957c3ff8e7cace38897113c.tar.gz llvm-ec8c3e8cccdadfdf8957c3ff8e7cace38897113c.tar.bz2 llvm-ec8c3e8cccdadfdf8957c3ff8e7cace38897113c.tar.xz |
Handle unindexed instructions in SlotIndices.
SlotIndexes::insertMachineInstrInMaps would crash when trying to insert an
instruction imediately after an unmapped debug value.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107504 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/CodeGen/SlotIndexes.h')
-rw-r--r-- | include/llvm/CodeGen/SlotIndexes.h | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/include/llvm/CodeGen/SlotIndexes.h b/include/llvm/CodeGen/SlotIndexes.h index 3c56d0d67d..b1bd4cd30b 100644 --- a/include/llvm/CodeGen/SlotIndexes.h +++ b/include/llvm/CodeGen/SlotIndexes.h @@ -663,15 +663,20 @@ namespace llvm { 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. |