[SlotIndexes] Add insertion point for insertMBBIntoMaps

Summary:
Allow the specification of an insertion point (MachineInstr)
for insertMBBIntoMaps.
This makes it possible to update slot indexes and live intervals
when trivially splitting a block by specifying the point of the
split as the insertion point for the block in the maps.

Reviewers: qcolombet, arsenm, kariddi, MaskRay, tpr

Reviewed By: kariddi

Subscribers: MatzeB, wdng, arphaman, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D78417
This commit is contained in:
Carl Ritson 2020-04-25 09:34:46 +09:00
parent 5339029ff7
commit f83833868b
2 changed files with 13 additions and 4 deletions

View File

@ -256,8 +256,9 @@ class VirtRegMap;
return Indexes->getMBBFromIndex(index);
}
void insertMBBInMaps(MachineBasicBlock *MBB) {
Indexes->insertMBBInMaps(MBB);
void insertMBBInMaps(MachineBasicBlock *MBB,
MachineInstr *InsertionPoint = nullptr) {
Indexes->insertMBBInMaps(MBB, InsertionPoint);
assert(unsigned(MBB->getNumber()) == RegMaskBlocks.size() &&
"Blocks must be added in order.");
RegMaskBlocks.push_back(std::make_pair(RegMaskSlots.size(), 0));

View File

@ -604,14 +604,22 @@ class raw_ostream;
}
/// Add the given MachineBasicBlock into the maps.
void insertMBBInMaps(MachineBasicBlock *mbb) {
/// If \p InsertionPoint is specified then the block will be placed
/// before the given machine instr, otherwise it will be placed
/// before the next block in MachineFunction insertion order.
void insertMBBInMaps(MachineBasicBlock *mbb,
MachineInstr *InsertionPoint = nullptr) {
MachineFunction::iterator nextMBB =
std::next(MachineFunction::iterator(mbb));
IndexListEntry *startEntry = nullptr;
IndexListEntry *endEntry = nullptr;
IndexList::iterator newItr;
if (nextMBB == mbb->getParent()->end()) {
if (InsertionPoint) {
startEntry = createEntry(nullptr, 0);
endEntry = getInstructionIndex(*InsertionPoint).listEntry();
newItr = indexList.insert(endEntry->getIterator(), startEntry);
} else if (nextMBB == mbb->getParent()->end()) {
startEntry = &indexList.back();
endEntry = createEntry(nullptr, 0);
newItr = indexList.insertAfter(startEntry->getIterator(), endEntry);