diff options
author | Hongbin Zheng <etherzhhb@gmail.com> | 2016-02-25 17:54:07 +0000 |
---|---|---|
committer | Hongbin Zheng <etherzhhb@gmail.com> | 2016-02-25 17:54:07 +0000 |
commit | 3f97840721817d36d5bb5348a628b1d20c8fc4c3 (patch) | |
tree | 44773d0ab6cf720c7d715596e342231c26ad8031 /llvm/lib/Analysis/PostDominators.cpp | |
parent | 5a8453d576319f5bca9dc3788e1ae29694e55911 (diff) | |
download | bcm5719-llvm-3f97840721817d36d5bb5348a628b1d20c8fc4c3.tar.gz bcm5719-llvm-3f97840721817d36d5bb5348a628b1d20c8fc4c3.zip |
Introduce analysis pass to compute PostDominators in the new pass manager. NFC
Differential Revision: http://reviews.llvm.org/D17537
llvm-svn: 261902
Diffstat (limited to 'llvm/lib/Analysis/PostDominators.cpp')
-rw-r--r-- | llvm/lib/Analysis/PostDominators.cpp | 34 |
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(); +} |