diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2011-03-04 19:43:38 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2011-03-04 19:43:38 +0000 |
commit | b8e6fdc23c3df1bddbe0e8b62f628a18223fc2b9 (patch) | |
tree | 58e1b57d8d1a46e24241e8e2716ca36133f1a0b9 /llvm/lib/CodeGen/SlotIndexes.cpp | |
parent | 906df92d5c469edb6943425cf8cfa6df19985e6a (diff) | |
download | bcm5719-llvm-b8e6fdc23c3df1bddbe0e8b62f628a18223fc2b9.tar.gz bcm5719-llvm-b8e6fdc23c3df1bddbe0e8b62f628a18223fc2b9.zip |
Renumber slot indexes locally when possible.
Initially, slot indexes are quad-spaced. There is room for inserting up to 3
new instructions between the original instructions.
When we run out of indexes between two instructions, renumber locally using
double-spaced indexes. The original quad-spacing means that we catch up quickly,
and we only have to renumber a handful of instructions to get a monotonic
sequence. This is much faster than renumbering the whole function as we did
before.
llvm-svn: 127023
Diffstat (limited to 'llvm/lib/CodeGen/SlotIndexes.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SlotIndexes.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SlotIndexes.cpp b/llvm/lib/CodeGen/SlotIndexes.cpp index 28e3fb5c159..c0ae34301dc 100644 --- a/llvm/lib/CodeGen/SlotIndexes.cpp +++ b/llvm/lib/CodeGen/SlotIndexes.cpp @@ -22,7 +22,8 @@ char SlotIndexes::ID = 0; INITIALIZE_PASS(SlotIndexes, "slotindexes", "Slot index numbering", false, false) -STATISTIC(NumRenumPasses, "Number of slot index renumber passes"); +STATISTIC(NumLocalRenum, "Number of local renumberings"); +STATISTIC(NumGlobalRenum, "Number of global renumberings"); void SlotIndexes::getAnalysisUsage(AnalysisUsage &au) const { au.setPreservesAll(); @@ -112,7 +113,7 @@ bool SlotIndexes::runOnMachineFunction(MachineFunction &fn) { void SlotIndexes::renumberIndexes() { // Renumber updates the index of every element of the index list. DEBUG(dbgs() << "\n*** Renumbering SlotIndexes ***\n"); - ++NumRenumPasses; + ++NumGlobalRenum; unsigned index = 0; @@ -123,6 +124,28 @@ void SlotIndexes::renumberIndexes() { } } +// Renumber indexes locally after curEntry was inserted, but failed to get a new +// index. +void SlotIndexes::renumberIndexes(IndexListEntry *curEntry) { + // Number indexes with half the default spacing so we can catch up quickly. + const unsigned Space = SlotIndex::InstrDist/2; + assert((Space & 3) == 0 && "InstrDist must be a multiple of 2*NUM"); + + IndexListEntry *start = curEntry->getPrev(); + unsigned index = start->getIndex(); + IndexListEntry *tail = getTail(); + do { + curEntry->setIndex(index += Space); + curEntry = curEntry->getNext(); + // If the next index is bigger, we have caught up. + } while (curEntry != tail && curEntry->getIndex() <= index); + + DEBUG(dbgs() << "\n*** Renumbered SlotIndexes " << start->getIndex() << '-' + << index << " ***\n"); + ++NumLocalRenum; +} + + void SlotIndexes::dump() const { for (const IndexListEntry *itr = front(); itr != getTail(); itr = itr->getNext()) { |