[IDFCalculator] Use DominatorTreeBase instead of DominatorTree
authorDaniel Berlin <dberlin@dberlin.org>
Wed, 14 Oct 2015 19:54:24 +0000 (19:54 +0000)
committerDaniel Berlin <dberlin@dberlin.org>
Wed, 14 Oct 2015 19:54:24 +0000 (19:54 +0000)
Summary:
IDFCalculator used a DominatorTree instance for its calculations. Since the PostDominatorTree struct is not a subclass of DominatorTree, it wasn't possible to use PDT in IDFCalculator to compute post-dominance frontiers.

This patch makes IDFCalculator work with a DominatorTreeBase<BasicBlock> instead, which enables PDTs to be utilized.

Patch by Victor Campos (vhscampos@gmail.com)

Reviewers: dberlin

Subscribers: dberlin, llvm-commits

Differential Revision: http://reviews.llvm.org/D13725

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250320 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/IteratedDominanceFrontier.h

index 5a339f10f50fdf347dc3a36aea4543ccfa7bc74e..a1ded2554d44b12297f127b0ce629231d953c143 100644 (file)
@@ -34,7 +34,7 @@ namespace llvm {
 class BasicBlock;
 template <class T> class DomTreeNodeBase;
 typedef DomTreeNodeBase<BasicBlock> DomTreeNode;
-class DominatorTree;
+template <class T> class DominatorTreeBase;
 
 /// \brief Determine the iterated dominance frontier, given a set of defining
 /// blocks, and optionally, a set of live-in blocks.
@@ -47,7 +47,7 @@ class DominatorTree;
 class IDFCalculator {
 
 public:
-  IDFCalculator(DominatorTree &DT) : DT(DT), useLiveIn(false) {}
+  IDFCalculator(DominatorTreeBase<BasicBlock> &DT) : DT(DT), useLiveIn(false) {}
 
   /// \brief Give the IDF calculator the set of blocks in which the value is
   /// defined.  This is equivalent to the set of starting blocks it should be
@@ -85,7 +85,7 @@ public:
   void calculate(SmallVectorImpl<BasicBlock *> &IDFBlocks);
 
 private:
-  DominatorTree &DT;
+  DominatorTreeBase<BasicBlock> &DT;
   bool useLiveIn;
   DenseMap<DomTreeNode *, unsigned> DomLevels;
   const SmallPtrSetImpl<BasicBlock *> *LiveInBlocks;