#define LLVM_ANALYSIS_DOMINATOR_INTERNALS_H
#include "llvm/Analysis/Dominators.h"
-#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallPtrSet.h"
+
//===----------------------------------------------------------------------===//
//
// DominatorTree construction - This pass constructs immediate dominator
template<class GraphT>
void Compress(DominatorTreeBase<typename GraphT::NodeType>& DT,
typename GraphT::NodeType *VIn) {
- std::vector<typename GraphT::NodeType*> Work;
+ SmallVector<typename GraphT::NodeType*, 32> Work;
SmallPtrSet<typename GraphT::NodeType*, 32> Visited;
typename DominatorTreeBase<typename GraphT::NodeType>::InfoRec &VInVAInfo =
DT.Info[DT.Vertex[DT.Info[VIn].Ancestor]];
}
template<class GraphT>
-typename GraphT::NodeType* Eval(DominatorTreeBase<typename GraphT::NodeType>& DT,
- typename GraphT::NodeType *V) {
+typename GraphT::NodeType*
+Eval(DominatorTreeBase<typename GraphT::NodeType>& DT,
+ typename GraphT::NodeType *V) {
typename DominatorTreeBase<typename GraphT::NodeType>::InfoRec &VInfo =
DT.Info[V];
#if !BALANCE_IDOM_TREE
// Step #1: Number blocks in depth-first order and initialize variables used
// in later stages of the algorithm.
- for (unsigned i = 0, e = DT.Roots.size(); i != e; ++i)
+ for (unsigned i = 0, e = static_cast<unsigned>(DT.Roots.size());
+ i != e; ++i)
N = DFSPass<GraphT>(DT, DT.Roots[i], N);
// it might be that some blocks did not get a DFS number (e.g., blocks of
DT.Info[W];
// Step #2: Calculate the semidominators of all vertices
- bool HasChildOutsideDFS = false;
// initialize the semi dominator to point to the parent node
WInfo.Semi = WInfo.Parent;
- for (typename GraphTraits<Inverse<NodeT> >::ChildIteratorType CI =
- GraphTraits<Inverse<NodeT> >::child_begin(W),
- E = GraphTraits<Inverse<NodeT> >::child_end(W); CI != E; ++CI) {
- if (DT.Info.count(*CI)) { // Only if this predecessor is reachable!
- unsigned SemiU = DT.Info[Eval<GraphT>(DT, *CI)].Semi;
+ typedef GraphTraits<Inverse<NodeT> > InvTraits;
+ for (typename InvTraits::ChildIteratorType CI =
+ InvTraits::child_begin(W),
+ E = InvTraits::child_end(W); CI != E; ++CI) {
+ typename InvTraits::NodeType *N = *CI;
+ if (DT.Info.count(N)) { // Only if this predecessor is reachable!
+ unsigned SemiU = DT.Info[Eval<GraphT>(DT, N)].Semi;
if (SemiU < WInfo.Semi)
WInfo.Semi = SemiU;
}
- else {
- // if the child has no DFS number it is not post-dominated by any exit,
- // and so is the current block.
- HasChildOutsideDFS = true;
- }
}
- // if some child has no DFS number it is not post-dominated by any exit,
- // and so is the current block.
- if (DT.isPostDominator() && HasChildOutsideDFS)
- WInfo.Semi = 0;
-
DT.Info[DT.Vertex[WInfo.Semi]].Bucket.push_back(W);
typename GraphT::NodeType* WParent = DT.Vertex[WInfo.Parent];
DT.IDoms.clear();
DT.Info.clear();
std::vector<typename GraphT::NodeType*>().swap(DT.Vertex);
-
- // FIXME: This does not work on PostDomTrees. It seems likely that this is
- // due to an error in the algorithm for post-dominators. This really should
- // be investigated and fixed at some point.
- // DT.updateDFSNumbers();
-
- // Start out with the DFS numbers being invalid. Let them be computed if
- // demanded.
- DT.DFSInfoValid = false;
+
+ DT.updateDFSNumbers();
}
}