diff --git a/llvm/include/llvm/Analysis/ProfileSummaryInfo.h b/llvm/include/llvm/Analysis/ProfileSummaryInfo.h --- a/llvm/include/llvm/Analysis/ProfileSummaryInfo.h +++ b/llvm/include/llvm/Analysis/ProfileSummaryInfo.h @@ -189,8 +189,8 @@ static char ID; ProfileSummaryInfoWrapperPass(); - ProfileSummaryInfo &getPSI() { return *PSI; } - const ProfileSummaryInfo &getPSI() const { return *PSI; } + ProfileSummaryInfo *getPSI() { return PSI.get(); } + const ProfileSummaryInfo *getPSI() const { return PSI.get(); } bool doInitialization(Module &M) override; bool doFinalization(Module &M) override; diff --git a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp --- a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp +++ b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp @@ -866,7 +866,7 @@ } bool ModuleSummaryIndexWrapperPass::runOnModule(Module &M) { - auto *PSI = &getAnalysis().getPSI(); + auto *PSI = getAnalysis().getPSI(); Index.emplace(buildModuleSummaryIndex( M, [this](const Function &F) { diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -457,7 +457,7 @@ LI = &getAnalysis().getLoopInfo(); BPI.reset(new BranchProbabilityInfo(F, *LI)); BFI.reset(new BlockFrequencyInfo(F, *BPI, *LI)); - PSI = &getAnalysis().getPSI(); + PSI = getAnalysis().getPSI(); OptSize = F.hasOptSize(); if (ProfileGuidedSectionPrefix) { if (PSI->isFunctionHotInCallGraph(&F, *BFI)) diff --git a/llvm/lib/Transforms/IPO/HotColdSplitting.cpp b/llvm/lib/Transforms/IPO/HotColdSplitting.cpp --- a/llvm/lib/Transforms/IPO/HotColdSplitting.cpp +++ b/llvm/lib/Transforms/IPO/HotColdSplitting.cpp @@ -680,7 +680,7 @@ if (skipModule(M)) return false; ProfileSummaryInfo *PSI = - &getAnalysis().getPSI(); + getAnalysis().getPSI(); auto GTTI = [this](Function &F) -> TargetTransformInfo & { return this->getAnalysis().getTTI(F); }; diff --git a/llvm/lib/Transforms/IPO/Inliner.cpp b/llvm/lib/Transforms/IPO/Inliner.cpp --- a/llvm/lib/Transforms/IPO/Inliner.cpp +++ b/llvm/lib/Transforms/IPO/Inliner.cpp @@ -554,7 +554,7 @@ bool LegacyInlinerBase::inlineCalls(CallGraphSCC &SCC) { CallGraph &CG = getAnalysis().getCallGraph(); ACT = &getAnalysis(); - PSI = &getAnalysis().getPSI(); + PSI = getAnalysis().getPSI(); GetTLI = [&](Function &F) -> const TargetLibraryInfo & { return getAnalysis().getTLI(F); }; diff --git a/llvm/lib/Transforms/IPO/PartialInlining.cpp b/llvm/lib/Transforms/IPO/PartialInlining.cpp --- a/llvm/lib/Transforms/IPO/PartialInlining.cpp +++ b/llvm/lib/Transforms/IPO/PartialInlining.cpp @@ -362,7 +362,7 @@ AssumptionCacheTracker *ACT = &getAnalysis(); TargetTransformInfoWrapperPass *TTIWP = &getAnalysis(); - ProfileSummaryInfo &PSI = + ProfileSummaryInfo *PSI = getAnalysis().getPSI(); auto GetAssumptionCache = [&ACT](Function &F) -> AssumptionCache & { @@ -382,7 +382,7 @@ }; return PartialInlinerImpl(GetAssumptionCache, LookupAssumptionCache, GetTTI, - GetTLI, PSI) + GetTLI, *PSI) .run(M); } }; diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp --- a/llvm/lib/Transforms/IPO/SampleProfile.cpp +++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp @@ -1898,7 +1898,7 @@ TTIWP = &getAnalysis(); TLIWP = &getAnalysis(); ProfileSummaryInfo *PSI = - &getAnalysis().getPSI(); + getAnalysis().getPSI(); return SampleLoader.runOnModule(M, nullptr, PSI, nullptr); } diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp --- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -3780,7 +3780,7 @@ auto *LIWP = getAnalysisIfAvailable(); auto *LI = LIWP ? &LIWP->getLoopInfo() : nullptr; ProfileSummaryInfo *PSI = - &getAnalysis().getPSI(); + getAnalysis().getPSI(); BlockFrequencyInfo *BFI = (PSI && PSI->hasProfileSummary()) ? &getAnalysis().getBFI() : diff --git a/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp b/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp --- a/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp +++ b/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp @@ -2074,7 +2074,7 @@ getAnalysis().getBFI(); DominatorTree &DT = getAnalysis().getDomTree(); ProfileSummaryInfo &PSI = - getAnalysis().getPSI(); + *getAnalysis().getPSI(); RegionInfo &RI = getAnalysis().getRegionInfo(); std::unique_ptr OwnedORE = std::make_unique(&F); diff --git a/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp b/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp --- a/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp +++ b/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp @@ -423,7 +423,7 @@ bool PGOIndirectCallPromotionLegacyPass::runOnModule(Module &M) { ProfileSummaryInfo *PSI = - &getAnalysis().getPSI(); + getAnalysis().getPSI(); // Command-line option has the priority for InLTO. return promoteIndirectCalls(M, PSI, InLTO | ICPLTOMode, diff --git a/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp b/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp --- a/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp +++ b/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp @@ -154,7 +154,7 @@ ? &getAnalysis().getBFI() : nullptr, Fn.getEntryBlock(), - &getAnalysis().getPSI()); + getAnalysis().getPSI()); if (MadeChange) { LLVM_DEBUG(dbgs() << "********** Function after Constant Hoisting: " diff --git a/llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp b/llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp --- a/llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp +++ b/llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp @@ -642,7 +642,7 @@ auto &LI = getAnalysis().getLoopInfo(); auto &LAA = getAnalysis(); auto &DT = getAnalysis().getDomTree(); - auto *PSI = &getAnalysis().getPSI(); + auto *PSI = getAnalysis().getPSI(); auto *BFI = (PSI && PSI->hasProfileSummary()) ? &getAnalysis().getBFI() : nullptr; diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -1631,7 +1631,7 @@ auto *LAA = &getAnalysis(); auto *DB = &getAnalysis().getDemandedBits(); auto *ORE = &getAnalysis().getORE(); - auto *PSI = &getAnalysis().getPSI(); + auto *PSI = getAnalysis().getPSI(); std::function GetLAA = [&](Loop &L) -> const LoopAccessInfo & { return LAA->getInfo(&L); };