diff options
| author | Teresa Johnson <tejohnson@google.com> | 2016-08-12 13:53:02 +0000 |
|---|---|---|
| committer | Teresa Johnson <tejohnson@google.com> | 2016-08-12 13:53:02 +0000 |
| commit | f93b246f8b22137abe69842ab4a99747d95a7f7a (patch) | |
| tree | 95b3703eb5458c5152ed11937dbd23d24a1f9cd4 /llvm/lib | |
| parent | 565bdd9fed999909827d75a4bea27ace05b4445d (diff) | |
| download | bcm5719-llvm-f93b246f8b22137abe69842ab4a99747d95a7f7a.tar.gz bcm5719-llvm-f93b246f8b22137abe69842ab4a99747d95a7f7a.zip | |
[PM] Port ModuleSummaryIndex analysis to new pass manager
Summary:
Port the ModuleSummaryAnalysisWrapperPass to the new pass manager.
Use it in the ported BitcodeWriterPass (similar to how we use the
legacy ModuleSummaryAnalysisWrapperPass in the legacy WriteBitcodePass).
Also, pass the -module-summary opt flag through to the new pass
manager pipeline and through to the bitcode writer pass, and add
a test that uses it.
Reviewers: mehdi_amini
Subscribers: llvm-commits, mehdi_amini
Differential Revision: https://reviews.llvm.org/D23439
llvm-svn: 278508
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Analysis/ModuleSummaryAnalysis.cpp | 13 | ||||
| -rw-r--r-- | llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp | 11 | ||||
| -rw-r--r-- | llvm/lib/Passes/PassBuilder.cpp | 1 | ||||
| -rw-r--r-- | llvm/lib/Passes/PassRegistry.def | 1 |
4 files changed, 20 insertions, 6 deletions
diff --git a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp index e457f1c00f4..d4081918d35 100644 --- a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp +++ b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp @@ -174,6 +174,19 @@ ModuleSummaryIndexBuilder::ModuleSummaryIndexBuilder( } } +char ModuleSummaryIndexAnalysis::PassID; + +const ModuleSummaryIndex & +ModuleSummaryIndexAnalysis::run(Module &M, ModuleAnalysisManager &AM) { + auto &FAM = AM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager(); + IndexBuilder = llvm::make_unique<ModuleSummaryIndexBuilder>( + &M, [&FAM](const Function &F) { + return &( + FAM.getResult<BlockFrequencyAnalysis>(*const_cast<Function *>(&F))); + }); + return IndexBuilder->getIndex(); +} + char ModuleSummaryIndexWrapperPass::ID = 0; INITIALIZE_PASS_BEGIN(ModuleSummaryIndexWrapperPass, "module-summary-analysis", "Module Summary Analysis", false, true) diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp index 3e89ade424a..e8e0b103d09 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp @@ -19,12 +19,11 @@ #include "llvm/Pass.h" using namespace llvm; -PreservedAnalyses BitcodeWriterPass::run(Module &M, ModuleAnalysisManager &) { - std::unique_ptr<ModuleSummaryIndex> Index; - if (EmitSummaryIndex) - Index = ModuleSummaryIndexBuilder(&M).takeIndex(); - WriteBitcodeToFile(&M, OS, ShouldPreserveUseListOrder, Index.get(), - EmitModuleHash); +PreservedAnalyses BitcodeWriterPass::run(Module &M, ModuleAnalysisManager &AM) { + const ModuleSummaryIndex *Index = + EmitSummaryIndex ? &(AM.getResult<ModuleSummaryIndexAnalysis>(M)) + : nullptr; + WriteBitcodeToFile(&M, OS, ShouldPreserveUseListOrder, Index, EmitModuleHash); return PreservedAnalyses::all(); } diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp index 19239ba98ce..32aa87bde3c 100644 --- a/llvm/lib/Passes/PassBuilder.cpp +++ b/llvm/lib/Passes/PassBuilder.cpp @@ -38,6 +38,7 @@ #include "llvm/Analysis/LoopAccessAnalysis.h" #include "llvm/Analysis/LoopInfo.h" #include "llvm/Analysis/MemoryDependenceAnalysis.h" +#include "llvm/Analysis/ModuleSummaryAnalysis.h" #include "llvm/Analysis/OptimizationDiagnosticInfo.h" #include "llvm/Analysis/PostDominators.h" #include "llvm/Analysis/ProfileSummaryInfo.h" diff --git a/llvm/lib/Passes/PassRegistry.def b/llvm/lib/Passes/PassRegistry.def index 76672227540..2e897b37088 100644 --- a/llvm/lib/Passes/PassRegistry.def +++ b/llvm/lib/Passes/PassRegistry.def @@ -21,6 +21,7 @@ #endif MODULE_ANALYSIS("callgraph", CallGraphAnalysis()) MODULE_ANALYSIS("lcg", LazyCallGraphAnalysis()) +MODULE_ANALYSIS("module-summary", ModuleSummaryIndexAnalysis()) MODULE_ANALYSIS("no-op-module", NoOpModuleAnalysis()) MODULE_ANALYSIS("profile-summary", ProfileSummaryAnalysis()) MODULE_ANALYSIS("targetlibinfo", TargetLibraryAnalysis()) |

