mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-21 06:30:16 +00:00
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174851 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
36f54480f8
commit
f5844a7515
@ -602,21 +602,21 @@ namespace llvm {
|
|||||||
void insertMBBInMaps(MachineBasicBlock *mbb) {
|
void insertMBBInMaps(MachineBasicBlock *mbb) {
|
||||||
MachineFunction::iterator nextMBB =
|
MachineFunction::iterator nextMBB =
|
||||||
llvm::next(MachineFunction::iterator(mbb));
|
llvm::next(MachineFunction::iterator(mbb));
|
||||||
|
|
||||||
|
IndexListEntry *nextEntry = 0;
|
||||||
|
if (nextMBB == mbb->getParent()->end())
|
||||||
|
nextEntry = &indexList.back();
|
||||||
|
else
|
||||||
|
nextEntry = getMBBStartIdx(nextMBB).listEntry();
|
||||||
|
|
||||||
IndexListEntry *startEntry = createEntry(0, 0);
|
IndexListEntry *startEntry = createEntry(0, 0);
|
||||||
IndexListEntry *stopEntry = createEntry(0, 0);
|
IndexListEntry *stopEntry = createEntry(0, 0);
|
||||||
IndexListEntry *nextEntry = 0;
|
|
||||||
|
|
||||||
if (nextMBB == mbb->getParent()->end()) {
|
indexList.insertAfter(nextEntry, startEntry);
|
||||||
nextEntry = indexList.end();
|
indexList.insertAfter(startEntry, stopEntry);
|
||||||
} else {
|
|
||||||
nextEntry = getMBBStartIdx(nextMBB).listEntry();
|
|
||||||
}
|
|
||||||
|
|
||||||
indexList.insert(nextEntry, startEntry);
|
|
||||||
indexList.insert(nextEntry, stopEntry);
|
|
||||||
|
|
||||||
SlotIndex startIdx(startEntry, SlotIndex::Slot_Block);
|
SlotIndex startIdx(startEntry, SlotIndex::Slot_Block);
|
||||||
SlotIndex endIdx(nextEntry, SlotIndex::Slot_Block);
|
SlotIndex endIdx(stopEntry, SlotIndex::Slot_Block);
|
||||||
|
|
||||||
assert(unsigned(mbb->getNumber()) == MBBRanges.size() &&
|
assert(unsigned(mbb->getNumber()) == MBBRanges.size() &&
|
||||||
"Blocks must be added in order");
|
"Blocks must be added in order");
|
||||||
@ -624,6 +624,8 @@ namespace llvm {
|
|||||||
|
|
||||||
idx2MBBMap.push_back(IdxMBBPair(startIdx, mbb));
|
idx2MBBMap.push_back(IdxMBBPair(startIdx, mbb));
|
||||||
|
|
||||||
|
// FIXME: Renumber locally instead of renumbering the whole function every
|
||||||
|
// time a new block is inserted.
|
||||||
renumberIndexes();
|
renumberIndexes();
|
||||||
std::sort(idx2MBBMap.begin(), idx2MBBMap.end(), Idx2MBBCompare());
|
std::sort(idx2MBBMap.begin(), idx2MBBMap.end(), Idx2MBBCompare());
|
||||||
}
|
}
|
||||||
|
@ -662,6 +662,9 @@ MachineBasicBlock::SplitCriticalEdge(MachineBasicBlock *Succ, Pass *P) {
|
|||||||
" BB#" << getNumber()
|
" BB#" << getNumber()
|
||||||
<< " -- BB#" << NMBB->getNumber()
|
<< " -- BB#" << NMBB->getNumber()
|
||||||
<< " -- BB#" << Succ->getNumber() << '\n');
|
<< " -- 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
|
// On some targets like Mips, branches may kill virtual registers. Make sure
|
||||||
// that LiveVariables is properly updated after updateTerminator replaces the
|
// that LiveVariables is properly updated after updateTerminator replaces the
|
||||||
@ -697,6 +700,17 @@ MachineBasicBlock::SplitCriticalEdge(MachineBasicBlock *Succ, Pass *P) {
|
|||||||
if (!NMBB->isLayoutSuccessor(Succ)) {
|
if (!NMBB->isLayoutSuccessor(Succ)) {
|
||||||
Cond.clear();
|
Cond.clear();
|
||||||
MF->getTarget().getInstrInfo()->InsertBranch(*NMBB, Succ, NULL, Cond, dl);
|
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
|
// Fix PHI nodes in Succ so they refer to NMBB instead of this
|
||||||
|
Loading…
x
Reference in New Issue
Block a user