aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/IR/Dominators.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/IR/Dominators.h')
-rw-r--r--include/llvm/IR/Dominators.h66
1 files changed, 35 insertions, 31 deletions
diff --git a/include/llvm/IR/Dominators.h b/include/llvm/IR/Dominators.h
index 37447c353b19..f445a49b67b8 100644
--- a/include/llvm/IR/Dominators.h
+++ b/include/llvm/IR/Dominators.h
@@ -15,26 +15,19 @@
#ifndef LLVM_IR_DOMINATORS_H
#define LLVM_IR_DOMINATORS_H
-#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/DepthFirstIterator.h"
+#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/ADT/GraphTraits.h"
#include "llvm/ADT/SmallPtrSet.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/CFG.h"
-#include "llvm/IR/Function.h"
+#include "llvm/IR/PassManager.h"
#include "llvm/Pass.h"
-#include "llvm/Support/Compiler.h"
#include "llvm/Support/GenericDomTree.h"
-#include "llvm/Support/raw_ostream.h"
-#include <algorithm>
namespace llvm {
-// FIXME: Replace this brittle forward declaration with the include of the new
-// PassManager.h when doing so doesn't break the PassManagerBuilder.
-template <typename IRUnitT> class AnalysisManager;
-class PreservedAnalyses;
+class Function;
+class BasicBlock;
+class raw_ostream;
extern template class DomTreeNodeBase<BasicBlock>;
extern template class DominatorTreeBase<BasicBlock>;
@@ -62,6 +55,26 @@ public:
bool isSingleEdge() const;
};
+template <> struct DenseMapInfo<BasicBlockEdge> {
+ static unsigned getHashValue(const BasicBlockEdge *V);
+ typedef DenseMapInfo<const BasicBlock *> BBInfo;
+ static inline BasicBlockEdge getEmptyKey() {
+ return BasicBlockEdge(BBInfo::getEmptyKey(), BBInfo::getEmptyKey());
+ }
+ static inline BasicBlockEdge getTombstoneKey() {
+ return BasicBlockEdge(BBInfo::getTombstoneKey(), BBInfo::getTombstoneKey());
+ }
+
+ static unsigned getHashValue(const BasicBlockEdge &Edge) {
+ return hash_combine(BBInfo::getHashValue(Edge.getStart()),
+ BBInfo::getHashValue(Edge.getEnd()));
+ }
+ static bool isEqual(const BasicBlockEdge &LHS, const BasicBlockEdge &RHS) {
+ return BBInfo::isEqual(LHS.getStart(), RHS.getStart()) &&
+ BBInfo::isEqual(LHS.getEnd(), RHS.getEnd());
+ }
+};
+
/// \brief Concrete subclass of DominatorTreeBase that is used to compute a
/// normal dominator tree.
///
@@ -186,40 +199,31 @@ template <> struct GraphTraits<DominatorTree*>
};
/// \brief Analysis pass which computes a \c DominatorTree.
-class DominatorTreeAnalysis {
+class DominatorTreeAnalysis : public AnalysisInfoMixin<DominatorTreeAnalysis> {
+ friend AnalysisInfoMixin<DominatorTreeAnalysis>;
+ static char PassID;
+
public:
/// \brief Provide the result typedef for this analysis pass.
typedef DominatorTree Result;
- /// \brief Opaque, unique identifier for this analysis pass.
- static void *ID() { return (void *)&PassID; }
-
/// \brief Run the analysis pass over a function and produce a dominator tree.
- DominatorTree run(Function &F);
-
- /// \brief Provide access to a name for this pass for debugging purposes.
- static StringRef name() { return "DominatorTreeAnalysis"; }
-
-private:
- static char PassID;
+ DominatorTree run(Function &F, AnalysisManager<Function> &);
};
/// \brief Printer pass for the \c DominatorTree.
-class DominatorTreePrinterPass {
+class DominatorTreePrinterPass
+ : public PassInfoMixin<DominatorTreePrinterPass> {
raw_ostream &OS;
public:
explicit DominatorTreePrinterPass(raw_ostream &OS);
- PreservedAnalyses run(Function &F, AnalysisManager<Function> *AM);
-
- static StringRef name() { return "DominatorTreePrinterPass"; }
+ PreservedAnalyses run(Function &F, AnalysisManager<Function> &AM);
};
/// \brief Verifier pass for the \c DominatorTree.
-struct DominatorTreeVerifierPass {
- PreservedAnalyses run(Function &F, AnalysisManager<Function> *AM);
-
- static StringRef name() { return "DominatorTreeVerifierPass"; }
+struct DominatorTreeVerifierPass : PassInfoMixin<DominatorTreeVerifierPass> {
+ PreservedAnalyses run(Function &F, AnalysisManager<Function> &AM);
};
/// \brief Legacy analysis pass which computes a \c DominatorTree.