[llvm] r174851 - Fix the unused but nearly correct method SlotIndexes::insertMBBInMaps() and add
Cameron Zwarich
zwarich at apple.com
Sun Feb 10 15:29:54 PST 2013
Author: zwarich
Date: Sun Feb 10 17:29:54 2013
New Revision: 174851
URL: http://llvm.org/viewvc/llvm-project?rev=174851&view=rev
Log:
Fix the unused but nearly correct method SlotIndexes::insertMBBInMaps() and add
support for updating SlotIndexes to MachineBasicBlock::SplitCriticalEdge(). This
calls renumberIndexes() every time; it should be improved to only renumber
locally.
Modified:
llvm/trunk/include/llvm/CodeGen/SlotIndexes.h
llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp
Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SlotIndexes.h?rev=174851&r1=174850&r2=174851&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/SlotIndexes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Sun Feb 10 17:29:54 2013
@@ -602,21 +602,21 @@ namespace llvm {
void insertMBBInMaps(MachineBasicBlock *mbb) {
MachineFunction::iterator nextMBB =
llvm::next(MachineFunction::iterator(mbb));
- IndexListEntry *startEntry = createEntry(0, 0);
- IndexListEntry *stopEntry = createEntry(0, 0);
- IndexListEntry *nextEntry = 0;
- if (nextMBB == mbb->getParent()->end()) {
- nextEntry = indexList.end();
- } else {
+ IndexListEntry *nextEntry = 0;
+ if (nextMBB == mbb->getParent()->end())
+ nextEntry = &indexList.back();
+ else
nextEntry = getMBBStartIdx(nextMBB).listEntry();
- }
- indexList.insert(nextEntry, startEntry);
- indexList.insert(nextEntry, stopEntry);
+ IndexListEntry *startEntry = createEntry(0, 0);
+ IndexListEntry *stopEntry = createEntry(0, 0);
+
+ indexList.insertAfter(nextEntry, startEntry);
+ indexList.insertAfter(startEntry, stopEntry);
SlotIndex startIdx(startEntry, SlotIndex::Slot_Block);
- SlotIndex endIdx(nextEntry, SlotIndex::Slot_Block);
+ SlotIndex endIdx(stopEntry, SlotIndex::Slot_Block);
assert(unsigned(mbb->getNumber()) == MBBRanges.size() &&
"Blocks must be added in order");
@@ -624,6 +624,8 @@ namespace llvm {
idx2MBBMap.push_back(IdxMBBPair(startIdx, mbb));
+ // FIXME: Renumber locally instead of renumbering the whole function every
+ // time a new block is inserted.
renumberIndexes();
std::sort(idx2MBBMap.begin(), idx2MBBMap.end(), Idx2MBBCompare());
}
Modified: llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp?rev=174851&r1=174850&r2=174851&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp Sun Feb 10 17:29:54 2013
@@ -662,6 +662,9 @@ MachineBasicBlock::SplitCriticalEdge(Mac
" BB#" << getNumber()
<< " -- BB#" << NMBB->getNumber()
<< " -- BB#" << Succ->getNumber() << '\n');
+ SlotIndexes *Indexes = P->getAnalysisIfAvailable<SlotIndexes>();
+ if (Indexes)
+ Indexes->insertMBBInMaps(NMBB);
// On some targets like Mips, branches may kill virtual registers. Make sure
// that LiveVariables is properly updated after updateTerminator replaces the
@@ -697,6 +700,17 @@ MachineBasicBlock::SplitCriticalEdge(Mac
if (!NMBB->isLayoutSuccessor(Succ)) {
Cond.clear();
MF->getTarget().getInstrInfo()->InsertBranch(*NMBB, Succ, NULL, Cond, dl);
+
+ if (Indexes) {
+ for (instr_iterator I = NMBB->instr_begin(), E = NMBB->instr_end();
+ I != E; ++I) {
+ // Some instructions may have been moved to NMBB by updateTerminator(),
+ // so we first remove any instruction that already has an index.
+ if (Indexes->hasIndex(I))
+ Indexes->removeMachineInstrFromMaps(I);
+ Indexes->insertMachineInstrInMaps(I);
+ }
+ }
}
// Fix PHI nodes in Succ so they refer to NMBB instead of this
More information about the llvm-commits
mailing list