Index: include/llvm/Analysis/ProfileSummaryInfo.h =================================================================== --- include/llvm/Analysis/ProfileSummaryInfo.h +++ include/llvm/Analysis/ProfileSummaryInfo.h @@ -71,7 +71,12 @@ static char ID; ProfileSummaryInfoWrapperPass(); - ProfileSummaryInfo *getPSI(Module &M); + ProfileSummaryInfo *getPSI() { + return &*PSI; + } + + bool doInitialization(Module &M) override; + bool doFinalization(Module &M) override; void getAnalysisUsage(AnalysisUsage &AU) const override { AU.setPreservesAll(); } Index: lib/Analysis/ModuleSummaryAnalysis.cpp =================================================================== --- lib/Analysis/ModuleSummaryAnalysis.cpp +++ lib/Analysis/ModuleSummaryAnalysis.cpp @@ -228,7 +228,7 @@ } bool ModuleSummaryIndexWrapperPass::runOnModule(Module &M) { - auto &PSI = *getAnalysis().getPSI(M); + auto &PSI = *getAnalysis().getPSI(); Index = buildModuleSummaryIndex( M, [this](const Function &F) { Index: lib/Analysis/ProfileSummaryInfo.cpp =================================================================== --- lib/Analysis/ProfileSummaryInfo.cpp +++ lib/Analysis/ProfileSummaryInfo.cpp @@ -132,14 +132,6 @@ return ColdCountThreshold && C <= ColdCountThreshold.getValue(); } -ProfileSummaryInfo *ProfileSummaryInfoWrapperPass::getPSI(Module &M) { - if (!PSI) - PSI.reset(new ProfileSummaryInfo(&M)); - else - PSI->resetModule(&M); - return PSI.get(); -} - INITIALIZE_PASS(ProfileSummaryInfoWrapperPass, "profile-summary-info", "Profile summary info", false, true) @@ -148,6 +140,16 @@ initializeProfileSummaryInfoWrapperPassPass(*PassRegistry::getPassRegistry()); } +bool ProfileSummaryInfoWrapperPass::doInitialization(Module &M) { + PSI.reset(new ProfileSummaryInfo(&M)); + return false; +} + +bool ProfileSummaryInfoWrapperPass::doFinalization(Module &M) { + PSI.reset(); + return false; +} + char ProfileSummaryAnalysis::PassID; ProfileSummaryInfo ProfileSummaryAnalysis::run(Module &M, ModuleAnalysisManager &) { Index: lib/Transforms/IPO/Inliner.cpp =================================================================== --- lib/Transforms/IPO/Inliner.cpp +++ lib/Transforms/IPO/Inliner.cpp @@ -634,7 +634,7 @@ bool Inliner::inlineCalls(CallGraphSCC &SCC) { CallGraph &CG = getAnalysis().getCallGraph(); ACT = &getAnalysis(); - PSI = getAnalysis().getPSI(CG.getModule()); + PSI = getAnalysis().getPSI(); auto &TLI = getAnalysis().getTLI(); // We compute dedicated AA results for each function in the SCC as needed. We // use a lambda referencing external objects so that they live long enough to