Index: llvm/trunk/include/llvm/Analysis/ProfileSummaryInfo.h =================================================================== --- llvm/trunk/include/llvm/Analysis/ProfileSummaryInfo.h +++ llvm/trunk/include/llvm/Analysis/ProfileSummaryInfo.h @@ -98,14 +98,14 @@ bool isFunctionEntryCold(const Function *F); /// Returns true if \p F contains only cold code. bool isFunctionColdInCallGraph(const Function *F, BlockFrequencyInfo &BFI); - /// Returns true if \p F is a hot function. + /// Returns true if count \p C is considered hot. bool isHotCount(uint64_t C); /// Returns true if count \p C is considered cold. bool isColdCount(uint64_t C); - /// Returns true if BasicBlock \p B is considered hot. - bool isHotBB(const BasicBlock *B, BlockFrequencyInfo *BFI); - /// Returns true if BasicBlock \p B is considered cold. - bool isColdBB(const BasicBlock *B, BlockFrequencyInfo *BFI); + /// Returns true if BasicBlock \p BB is considered hot. + bool isHotBlock(const BasicBlock *BB, BlockFrequencyInfo *BFI); + /// Returns true if BasicBlock \p BB is considered cold. + bool isColdBlock(const BasicBlock *BB, BlockFrequencyInfo *BFI); /// Returns true if CallSite \p CS is considered hot. bool isHotCallSite(const CallSite &CS, BlockFrequencyInfo *BFI); /// Returns true if Callsite \p CS is considered cold. @@ -134,9 +134,8 @@ static char ID; ProfileSummaryInfoWrapperPass(); - ProfileSummaryInfo *getPSI() { - return &*PSI; - } + ProfileSummaryInfo &getPSI() { return *PSI; } + const ProfileSummaryInfo &getPSI() const { return *PSI; } bool doInitialization(Module &M) override; bool doFinalization(Module &M) override; Index: llvm/trunk/lib/Analysis/ModuleSummaryAnalysis.cpp =================================================================== --- llvm/trunk/lib/Analysis/ModuleSummaryAnalysis.cpp +++ llvm/trunk/lib/Analysis/ModuleSummaryAnalysis.cpp @@ -665,7 +665,7 @@ } bool ModuleSummaryIndexWrapperPass::runOnModule(Module &M) { - auto &PSI = *getAnalysis().getPSI(); + auto *PSI = &getAnalysis().getPSI(); Index.emplace(buildModuleSummaryIndex( M, [this](const Function &F) { @@ -673,7 +673,7 @@ *const_cast(&F)) .getBFI()); }, - &PSI)); + PSI)); return false; } Index: llvm/trunk/lib/Analysis/ProfileSummaryInfo.cpp =================================================================== --- llvm/trunk/lib/Analysis/ProfileSummaryInfo.cpp +++ llvm/trunk/lib/Analysis/ProfileSummaryInfo.cpp @@ -151,7 +151,7 @@ return true; } for (const auto &BB : *F) - if (isHotBB(&BB, &BFI)) + if (isHotBlock(&BB, &BFI)) return true; return false; } @@ -180,7 +180,7 @@ return false; } for (const auto &BB : *F) - if (!isColdBB(&BB, &BFI)) + if (!isColdBlock(&BB, &BFI)) return false; return true; } @@ -253,14 +253,14 @@ return ColdCountThreshold ? ColdCountThreshold.getValue() : 0; } -bool ProfileSummaryInfo::isHotBB(const BasicBlock *B, BlockFrequencyInfo *BFI) { - auto Count = BFI->getBlockProfileCount(B); +bool ProfileSummaryInfo::isHotBlock(const BasicBlock *BB, BlockFrequencyInfo *BFI) { + auto Count = BFI->getBlockProfileCount(BB); return Count && isHotCount(*Count); } -bool ProfileSummaryInfo::isColdBB(const BasicBlock *B, +bool ProfileSummaryInfo::isColdBlock(const BasicBlock *BB, BlockFrequencyInfo *BFI) { - auto Count = BFI->getBlockProfileCount(B); + auto Count = BFI->getBlockProfileCount(BB); return Count && isColdCount(*Count); } Index: llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp =================================================================== --- llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp +++ llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp @@ -416,7 +416,7 @@ OptSize = F.optForSize(); ProfileSummaryInfo *PSI = - getAnalysis().getPSI(); + &getAnalysis().getPSI(); if (ProfileGuidedSectionPrefix) { if (PSI->isFunctionHotInCallGraph(&F, *BFI)) F.setSectionPrefix(".hot"); Index: llvm/trunk/lib/Transforms/IPO/HotColdSplitting.cpp =================================================================== --- llvm/trunk/lib/Transforms/IPO/HotColdSplitting.cpp +++ llvm/trunk/lib/Transforms/IPO/HotColdSplitting.cpp @@ -266,7 +266,7 @@ if (!mayExtractBlock(BB)) continue; bool Cold = - PSI.isColdBB(&BB, BFI) || (EnableStaticAnalyis && unlikelyExecuted(BB)); + PSI.isColdBlock(&BB, BFI) || (EnableStaticAnalyis && unlikelyExecuted(BB)); if (!Cold) continue; @@ -465,7 +465,7 @@ if (skipModule(M)) return false; ProfileSummaryInfo *PSI = - getAnalysis().getPSI(); + &getAnalysis().getPSI(); auto GTTI = [this](Function &F) -> TargetTransformInfo & { return this->getAnalysis().getTTI(F); }; Index: llvm/trunk/lib/Transforms/IPO/Inliner.cpp =================================================================== --- llvm/trunk/lib/Transforms/IPO/Inliner.cpp +++ llvm/trunk/lib/Transforms/IPO/Inliner.cpp @@ -746,7 +746,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); Index: llvm/trunk/lib/Transforms/IPO/PartialInlining.cpp =================================================================== --- llvm/trunk/lib/Transforms/IPO/PartialInlining.cpp +++ llvm/trunk/lib/Transforms/IPO/PartialInlining.cpp @@ -359,7 +359,7 @@ TargetTransformInfoWrapperPass *TTIWP = &getAnalysis(); ProfileSummaryInfo *PSI = - getAnalysis().getPSI(); + &getAnalysis().getPSI(); std::function GetAssumptionCache = [&ACT](Function &F) -> AssumptionCache & { @@ -468,7 +468,7 @@ // Only consider regions with predecessor blocks that are considered // not-cold (default: part of the top 99.99% of all block counters) // AND greater than our minimum block execution count (default: 100). - if (PSI->isColdBB(thisBB, BFI) || + if (PSI->isColdBlock(thisBB, BFI) || BBProfileCount(thisBB) < MinBlockCounterExecution) continue; for (auto SI = succ_begin(thisBB); SI != succ_end(thisBB); ++SI) { Index: llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp =================================================================== --- llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp +++ llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp @@ -1599,7 +1599,7 @@ ACT = &getAnalysis(); TTIWP = &getAnalysis(); ProfileSummaryInfo *PSI = - getAnalysis().getPSI(); + &getAnalysis().getPSI(); return SampleLoader.runOnModule(M, nullptr, PSI); } Index: llvm/trunk/lib/Transforms/Instrumentation/ControlHeightReduction.cpp =================================================================== --- llvm/trunk/lib/Transforms/Instrumentation/ControlHeightReduction.cpp +++ llvm/trunk/lib/Transforms/Instrumentation/ControlHeightReduction.cpp @@ -2040,7 +2040,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); Index: llvm/trunk/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp =================================================================== --- llvm/trunk/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp +++ llvm/trunk/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp @@ -427,7 +427,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, Index: llvm/trunk/unittests/Analysis/ProfileSummaryInfoTest.cpp =================================================================== --- llvm/trunk/unittests/Analysis/ProfileSummaryInfoTest.cpp +++ llvm/trunk/unittests/Analysis/ProfileSummaryInfoTest.cpp @@ -118,8 +118,8 @@ BasicBlock *BB1 = BB0.getTerminator()->getSuccessor(0); BlockFrequencyInfo BFI = buildBFI(*F); - EXPECT_FALSE(PSI.isHotBB(&BB0, &BFI)); - EXPECT_FALSE(PSI.isColdBB(&BB0, &BFI)); + EXPECT_FALSE(PSI.isHotBlock(&BB0, &BFI)); + EXPECT_FALSE(PSI.isColdBlock(&BB0, &BFI)); CallSite CS1(BB1->getFirstNonPHI()); EXPECT_FALSE(PSI.isHotCallSite(CS1, &BFI)); @@ -156,10 +156,10 @@ BasicBlock *BB3 = BB1->getSingleSuccessor(); BlockFrequencyInfo BFI = buildBFI(*F); - EXPECT_TRUE(PSI.isHotBB(&BB0, &BFI)); - EXPECT_TRUE(PSI.isHotBB(BB1, &BFI)); - EXPECT_FALSE(PSI.isHotBB(BB2, &BFI)); - EXPECT_TRUE(PSI.isHotBB(BB3, &BFI)); + EXPECT_TRUE(PSI.isHotBlock(&BB0, &BFI)); + EXPECT_TRUE(PSI.isHotBlock(BB1, &BFI)); + EXPECT_FALSE(PSI.isHotBlock(BB2, &BFI)); + EXPECT_TRUE(PSI.isHotBlock(BB3, &BFI)); CallSite CS1(BB1->getFirstNonPHI()); auto *CI2 = BB2->getFirstNonPHI(); @@ -188,10 +188,10 @@ BasicBlock *BB3 = BB1->getSingleSuccessor(); BlockFrequencyInfo BFI = buildBFI(*F); - EXPECT_TRUE(PSI.isHotBB(&BB0, &BFI)); - EXPECT_TRUE(PSI.isHotBB(BB1, &BFI)); - EXPECT_FALSE(PSI.isHotBB(BB2, &BFI)); - EXPECT_TRUE(PSI.isHotBB(BB3, &BFI)); + EXPECT_TRUE(PSI.isHotBlock(&BB0, &BFI)); + EXPECT_TRUE(PSI.isHotBlock(BB1, &BFI)); + EXPECT_FALSE(PSI.isHotBlock(BB2, &BFI)); + EXPECT_TRUE(PSI.isHotBlock(BB3, &BFI)); CallSite CS1(BB1->getFirstNonPHI()); auto *CI2 = BB2->getFirstNonPHI();