[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
This commit is contained in:
Teresa Johnson
2016-08-12 13:53:02 +00:00
parent 565bdd9fed
commit f93b246f8b
9 changed files with 45 additions and 11 deletions

View File

@@ -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();
}