[PATCH] D78417: [SlotIndexes] Add insertion point for insertMBBIntoMaps

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


This revision was automatically updated to reflect the committed changes.
Closed by commit rGf83833868b45: [SlotIndexes] Add insertion point for insertMBBIntoMaps (authored by critson).

Changed prior to commit:
  https://reviews.llvm.org/D78417?vs=258482&id=260050#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78417/new/

https://reviews.llvm.org/D78417

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


Index: llvm/include/llvm/CodeGen/SlotIndexes.h
===================================================================
--- llvm/include/llvm/CodeGen/SlotIndexes.h
+++ llvm/include/llvm/CodeGen/SlotIndexes.h
@@ -604,14 +604,22 @@
     }
 
     /// 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);
Index: llvm/include/llvm/CodeGen/LiveIntervals.h
===================================================================
--- llvm/include/llvm/CodeGen/LiveIntervals.h
+++ llvm/include/llvm/CodeGen/LiveIntervals.h
@@ -256,8 +256,9 @@
       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));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78417.260050.patch
Type: text/x-patch
Size: 2113 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200425/b03a7af0/attachment.bin>


More information about the llvm-commits mailing list