diff options
| author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2013-03-08 18:08:54 +0000 |
|---|---|---|
| committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2013-03-08 18:08:54 +0000 |
| commit | faae9d3ae36cb7a982ce2d707548933b7eab4c1f (patch) | |
| tree | dc67cb81d6de23ed0a30e414129a5fd1f49b1b69 /llvm | |
| parent | 22210a450db74a55dc4992f0e978d335a1814ba2 (diff) | |
| download | bcm5719-llvm-faae9d3ae36cb7a982ce2d707548933b7eab4c1f.tar.gz bcm5719-llvm-faae9d3ae36cb7a982ce2d707548933b7eab4c1f.zip | |
Avoid creating a SlotIndex from the end() iterator.
No test case, spotted by inspection.
llvm-svn: 176705
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/include/llvm/CodeGen/SlotIndexes.h | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/llvm/include/llvm/CodeGen/SlotIndexes.h b/llvm/include/llvm/CodeGen/SlotIndexes.h index 78fb233e5ff..0f85c994a22 100644 --- a/llvm/include/llvm/CodeGen/SlotIndexes.h +++ b/llvm/include/llvm/CodeGen/SlotIndexes.h @@ -396,12 +396,16 @@ namespace llvm { return index.isValid() ? index.listEntry()->getInstr() : 0; } - /// Returns the next non-null index. - SlotIndex getNextNonNullIndex(SlotIndex index) { - IndexList::iterator itr(index.listEntry()); - ++itr; - while (itr != indexList.end() && itr->getInstr() == 0) { ++itr; } - return SlotIndex(itr, index.getSlot()); + /// Returns the next non-null index, if one exists. + /// Otherwise returns getLastIndex(). + SlotIndex getNextNonNullIndex(SlotIndex Index) { + IndexList::iterator I = Index.listEntry(); + IndexList::iterator E = indexList.end(); + while (I != E) + if ((++I)->getInstr()) + return SlotIndex(I, Index.getSlot()); + // We reached the end of the function. + return getLastIndex(); } /// getIndexBefore - Returns the index of the last indexed instruction |

