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 @@ -140,8 +140,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 @@ -857,7 +857,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 @@ -432,7 +432,7 @@ OptSize = F.hasOptSize(); ProfileSummaryInfo *PSI = - &getAnalysis().getPSI(); + getAnalysis().getPSI(); if (ProfileGuidedSectionPrefix) { if (PSI->isFunctionHotInCallGraph(&F, *BFI)) F.setSectionPrefix(".hot"); 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 @@ -697,7 +697,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 @@ -756,7 +756,7 @@ bool LegacyInlinerBase::inlineCalls(CallGraphSCC &SCC) { CallGraph &CG = getAnalysis().getCallGraph(); ACT = &getAnalysis(); - PSI = &getAnalysis().getPSI(); + PSI = getAnalysis().getPSI(); auto &TLI = getAnalysis().getTLI(); auto GetAssumptionCache = [&](Function &F) -> AssumptionCache & { return ACT->getAssumptionCache(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 @@ -364,7 +364,7 @@ TargetTransformInfoWrapperPass *TTIWP = &getAnalysis(); ProfileSummaryInfo *PSI = - &getAnalysis().getPSI(); + getAnalysis().getPSI(); std::function GetAssumptionCache = [&ACT](Function &F) -> AssumptionCache & { 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 @@ -1646,7 +1646,7 @@ ACT = &getAnalysis(); TTIWP = &getAnalysis(); ProfileSummaryInfo *PSI = - &getAnalysis().getPSI(); + getAnalysis().getPSI(); return SampleLoader.runOnModule(M, nullptr, PSI); } 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 @@ -3588,7 +3588,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 @@ -2070,7 +2070,7 @@ getAnalysis().getBFI(); DominatorTree &DT = getAnalysis().getDomTree(); ProfileSummaryInfo &PSI = - getAnalysis().getPSI(); + *getAnalysis().getPSI(); RegionInfo &RI = getAnalysis().getRegionInfo(); std::unique_ptr OwnedORE = llvm::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 @@ -424,7 +424,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 @@ -153,7 +153,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 @@ -640,7 +640,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 @@ -1502,7 +1502,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); };