summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/PostDominators.cpp
diff options
context:
space:
mode:
authorHongbin Zheng <etherzhhb@gmail.com>2016-02-25 16:33:06 +0000
committerHongbin Zheng <etherzhhb@gmail.com>2016-02-25 16:33:06 +0000
commita0273a04f53e89c6ef771a73ddedc4c25bbf62d9 (patch)
treeacc9cc0cde44a120159c5678c46f6adcdb8f51cc /llvm/lib/Analysis/PostDominators.cpp
parent148445ef985eedf7d2d05467b5b8d634fc156bd6 (diff)
downloadbcm5719-llvm-a0273a04f53e89c6ef771a73ddedc4c25bbf62d9.tar.gz
bcm5719-llvm-a0273a04f53e89c6ef771a73ddedc4c25bbf62d9.zip
Introduce analysis pass to compute PostDominators in the new pass manager. NFC
Differential Revision: http://reviews.llvm.org/D17537 llvm-svn: 261882
Diffstat (limited to 'llvm/lib/Analysis/PostDominators.cpp')
-rw-r--r--llvm/lib/Analysis/PostDominators.cpp34
1 files changed, 24 insertions, 10 deletions
diff --git a/llvm/lib/Analysis/PostDominators.cpp b/llvm/lib/Analysis/PostDominators.cpp
index 6d929091e3d..b515108fafb 100644
--- a/llvm/lib/Analysis/PostDominators.cpp
+++ b/llvm/lib/Analysis/PostDominators.cpp
@@ -16,6 +16,7 @@
#include "llvm/ADT/SetOperations.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/Instructions.h"
+#include "llvm/IR/PassManager.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/GenericDomTreeConstruction.h"
using namespace llvm;
@@ -26,25 +27,38 @@ using namespace llvm;
// PostDominatorTree Implementation
//===----------------------------------------------------------------------===//
-char PostDominatorTree::ID = 0;
-INITIALIZE_PASS(PostDominatorTree, "postdomtree",
+char PostDominatorTreeWrapperPass::ID = 0;
+INITIALIZE_PASS(PostDominatorTreeWrapperPass, "postdomtree",
"Post-Dominator Tree Construction", true, true)
-bool PostDominatorTree::runOnFunction(Function &F) {
- DT->recalculate(F);
+bool PostDominatorTreeWrapperPass::runOnFunction(Function &F) {
+ DT.recalculate(F);
return false;
}
-PostDominatorTree::~PostDominatorTree() {
- delete DT;
+void PostDominatorTreeWrapperPass::print(raw_ostream &OS, const Module *) const {
+ DT.print(OS);
}
-void PostDominatorTree::print(raw_ostream &OS, const Module *) const {
- DT->print(OS);
+FunctionPass* llvm::createPostDomTree() {
+ return new PostDominatorTreeWrapperPass();
}
+char PostDominatorTreeAnalysis::PassID;
-FunctionPass* llvm::createPostDomTree() {
- return new PostDominatorTree();
+PostDominatorTree PostDominatorTreeAnalysis::run(Function &F) {
+ PostDominatorTree PDT;
+ PDT.recalculate(F);
+ return PDT;
}
+PostDominatorTreePrinterPass::PostDominatorTreePrinterPass(raw_ostream &OS)
+ : OS(OS) {}
+
+PreservedAnalyses
+PostDominatorTreePrinterPass::run(Function &F, FunctionAnalysisManager *AM) {
+ OS << "PostDominatorTree for function: " << F.getName() << "\n";
+ AM->getResult<PostDominatorTreeAnalysis>(F).print(OS);
+
+ return PreservedAnalyses::all();
+}
OpenPOWER on IntegriCloud