[llvm] f838338 - [SlotIndexes] Add insertion point for insertMBBIntoMaps

Carl Ritson via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 24 18:12:30 PDT 2020


Author: Carl Ritson
Date: 2020-04-25T09:36:19+09:00
New Revision: f83833868b459b176ff7554053bd40b70cd42af0

URL: https://github.com/llvm/llvm-project/commit/f83833868b459b176ff7554053bd40b70cd42af0
DIFF: https://github.com/llvm/llvm-project/commit/f83833868b459b176ff7554053bd40b70cd42af0.diff

LOG: [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

Added: 
    

Modified: 
    llvm/include/llvm/CodeGen/LiveIntervals.h
    llvm/include/llvm/CodeGen/SlotIndexes.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/CodeGen/LiveIntervals.h b/llvm/include/llvm/CodeGen/LiveIntervals.h
index 1d89e6f38c72..1b921eea782d 100644
--- a/llvm/include/llvm/CodeGen/LiveIntervals.h
+++ b/llvm/include/llvm/CodeGen/LiveIntervals.h
@@ -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));

diff  --git a/llvm/include/llvm/CodeGen/SlotIndexes.h b/llvm/include/llvm/CodeGen/SlotIndexes.h
index 85bd7a404f9b..19eab7ae5e35 100644
--- a/llvm/include/llvm/CodeGen/SlotIndexes.h
+++ b/llvm/include/llvm/CodeGen/SlotIndexes.h
@@ -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);


        


More information about the llvm-commits mailing list