This is an archive of the discontinued LLVM Phabricator instance.

[SlotIndexes] Add insertion point for insertMBBIntoMaps
ClosedPublic

Authored by critson on Apr 17 2020, 10:56 PM.

Details

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.

Diff Detail

Event Timeline

critson created this revision.Apr 17 2020, 10:56 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 17 2020, 10:56 PM

I don't get completely what is the difference between this and just calling insertMBBInMaps() with the new block created by split as the argument. Shouldn't the insertion point being automatically devised correctly if the block is inserted in the right position?

llvm/include/llvm/CodeGen/SlotIndexes.h
609

It seems it is actually put "before the next block in MachineFunction insertion order" (I don't think it has anything to do with it being a predecessor or a successor).

I don't get completely what is the difference between this and just calling insertMBBInMaps() with the new block created by split as the argument. Shouldn't the insertion point being automatically devised correctly if the block is inserted in the right position?

I think the best way to describe the difference is that, at present, insertMBBInMaps inserts the block between blocks, but for splitting we need to the ability to insert the block between instructions. When splitting a sequence of instructions which already have slot indexes, the block needs to come before a given instruction, rather than the next block (which is after the instructions in the new block).

An alternative implementation to the one in this patch would be to change insertMBBInMaps so that it checks if first instruction of the block being added has a slot index. If so, then the block should go before that index, otherwise the current behaviour is maintained, i.e. for new empty blocks, or new blocks of new instructions.

This revision is now accepted and ready to land.Apr 24 2020, 12:13 AM
This revision was automatically updated to reflect the committed changes.