diff options
author | Hongbin Zheng <etherzhhb@gmail.com> | 2016-02-25 16:33:15 +0000 |
---|---|---|
committer | Hongbin Zheng <etherzhhb@gmail.com> | 2016-02-25 16:33:15 +0000 |
commit | 3f3ece8680951aaee2712dd69ca6ce2ede89c8b9 (patch) | |
tree | dccbcc9ae4ba146f7d60897e94accc7ffc91ca0f /lib/Analysis/DominanceFrontier.cpp | |
parent | e2c0114367761c2b72639ab25efe0ce31086fc5b (diff) |
Introduce DominanceFrontierAnalysis to the new PassManager to compute DominanceFrontier. NFC
Differential Revision: http://reviews.llvm.org/D17570
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@261883 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/DominanceFrontier.cpp')
-rw-r--r-- | lib/Analysis/DominanceFrontier.cpp | 50 |
1 files changed, 35 insertions, 15 deletions
diff --git a/lib/Analysis/DominanceFrontier.cpp b/lib/Analysis/DominanceFrontier.cpp index 90e7fd00dba..ef7062da775 100644 --- a/lib/Analysis/DominanceFrontier.cpp +++ b/lib/Analysis/DominanceFrontier.cpp @@ -9,6 +9,7 @@ #include "llvm/Analysis/DominanceFrontier.h" #include "llvm/Analysis/DominanceFrontierImpl.h" +#include "llvm/IR/PassManager.h" using namespace llvm; @@ -17,41 +18,60 @@ template class DominanceFrontierBase<BasicBlock>; template class ForwardDominanceFrontierBase<BasicBlock>; } -char DominanceFrontier::ID = 0; +char DominanceFrontierWrapperPass::ID = 0; -INITIALIZE_PASS_BEGIN(DominanceFrontier, "domfrontier", +INITIALIZE_PASS_BEGIN(DominanceFrontierWrapperPass, "domfrontier", "Dominance Frontier Construction", true, true) INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass) -INITIALIZE_PASS_END(DominanceFrontier, "domfrontier", +INITIALIZE_PASS_END(DominanceFrontierWrapperPass, "domfrontier", "Dominance Frontier Construction", true, true) -DominanceFrontier::DominanceFrontier() - : FunctionPass(ID), - Base() { - initializeDominanceFrontierPass(*PassRegistry::getPassRegistry()); + DominanceFrontierWrapperPass::DominanceFrontierWrapperPass() + : FunctionPass(ID), DF() { + initializeDominanceFrontierWrapperPassPass(*PassRegistry::getPassRegistry()); } -void DominanceFrontier::releaseMemory() { - Base.releaseMemory(); +void DominanceFrontierWrapperPass::releaseMemory() { + DF.releaseMemory(); } -bool DominanceFrontier::runOnFunction(Function &) { +bool DominanceFrontierWrapperPass::runOnFunction(Function &) { releaseMemory(); - Base.analyze(getAnalysis<DominatorTreeWrapperPass>().getDomTree()); + DF.analyze(getAnalysis<DominatorTreeWrapperPass>().getDomTree()); return false; } -void DominanceFrontier::getAnalysisUsage(AnalysisUsage &AU) const { +void DominanceFrontierWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); AU.addRequired<DominatorTreeWrapperPass>(); } -void DominanceFrontier::print(raw_ostream &OS, const Module *) const { - Base.print(OS); +void DominanceFrontierWrapperPass::print(raw_ostream &OS, const Module *) const { + DF.print(OS); } #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) -LLVM_DUMP_METHOD void DominanceFrontier::dump() const { +LLVM_DUMP_METHOD void DominanceFrontierWrapperPass::dump() const { print(dbgs()); } #endif + +char DominanceFrontierAnalysis::PassID; + +DominanceFrontier DominanceFrontierAnalysis::run(Function &F, + FunctionAnalysisManager *AM) { + DominanceFrontier DF; + DF.analyze(AM->getResult<DominatorTreeAnalysis>(F)); + return DF; +} + +DominanceFrontierPrinterPass::DominanceFrontierPrinterPass(raw_ostream &OS) + : OS(OS) {} + +PreservedAnalyses +DominanceFrontierPrinterPass::run(Function &F, FunctionAnalysisManager *AM) { + OS << "DominanceFrontier for function: " << F.getName() << "\n"; + AM->getResult<DominanceFrontierAnalysis>(F).print(OS); + + return PreservedAnalyses::all(); +} |