[PATCH] D77967: [Dominators] Facilitate updates to MachineDominator trees

Carl Ritson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 11 23:57:38 PDT 2020


critson created this revision.
critson added reviewers: kuhar, arsenm, hliao, nhaehnle.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

Add simple pass through methods for addNewBlock and applyUpdates
to MachineDominatorTree and MachinePostDominatorTree.
This enables preservation of the trees when performing simple
CFG edits, e.g. block insertion.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77967

Files:
  llvm/include/llvm/CodeGen/MachineDominators.h
  llvm/include/llvm/CodeGen/MachinePostDominators.h


Index: llvm/include/llvm/CodeGen/MachinePostDominators.h
===================================================================
--- llvm/include/llvm/CodeGen/MachinePostDominators.h
+++ llvm/include/llvm/CodeGen/MachinePostDominators.h
@@ -31,6 +31,11 @@
 public:
   static char ID;
 
+  using UpdateType = PostDomTreeT::UpdateType;
+  using UpdateKind = PostDomTreeT::UpdateKind;
+  static constexpr UpdateKind Insert = UpdateKind::Insert;
+  static constexpr UpdateKind Delete = UpdateKind::Delete;
+
   MachinePostDominatorTree();
 
   FunctionPass *createMachinePostDominatorTreePass();
@@ -77,6 +82,18 @@
     return PDT->findNearestCommonDominator(A, B);
   }
 
+  /// addNewBlock - Add a new node to the dominator tree information.  This
+  /// creates a new node as a child of DomBB dominator node,linking it into
+  /// the children list of the immediate dominator.
+  MachineDomTreeNode *addNewBlock(MachineBasicBlock *BB,
+                                  MachineBasicBlock *DomBB) {
+    return PDT->addNewBlock(BB, DomBB);
+  }
+
+  void applyUpdates(ArrayRef<UpdateType> Updates) {
+    PDT->applyUpdates(Updates);
+  }
+
   /// Returns the nearest common dominator of the given blocks.
   /// If that tree node is a virtual root, a nullptr will be returned.
   MachineBasicBlock *
Index: llvm/include/llvm/CodeGen/MachineDominators.h
===================================================================
--- llvm/include/llvm/CodeGen/MachineDominators.h
+++ llvm/include/llvm/CodeGen/MachineDominators.h
@@ -80,6 +80,11 @@
 public:
   static char ID; // Pass ID, replacement for typeid
 
+  using UpdateType = DomTreeT::UpdateType;
+  using UpdateKind = DomTreeT::UpdateKind;
+  static constexpr UpdateKind Insert = UpdateKind::Insert;
+  static constexpr UpdateKind Delete = UpdateKind::Delete;
+
   MachineDominatorTree();
   explicit MachineDominatorTree(MachineFunction &MF) : MachineFunctionPass(ID) {
     calculate(MF);
@@ -221,6 +226,11 @@
     return DT->isReachableFromEntry(A);
   }
 
+  void applyUpdates(ArrayRef<UpdateType> Updates) {
+    applySplitCriticalEdges();
+    DT->applyUpdates(Updates);
+  }
+
   void releaseMemory() override;
 
   void verifyAnalysis() const override;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77967.256837.patch
Type: text/x-patch
Size: 2208 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200412/9abd9715/attachment.bin>


More information about the llvm-commits mailing list