summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/Analysis/ProfileSummaryInfo.h15
-rw-r--r--llvm/lib/Analysis/ModuleSummaryAnalysis.cpp4
-rw-r--r--llvm/lib/Analysis/ProfileSummaryInfo.cpp12
-rw-r--r--llvm/lib/CodeGen/CodeGenPrepare.cpp2
-rw-r--r--llvm/lib/Transforms/IPO/HotColdSplitting.cpp4
-rw-r--r--llvm/lib/Transforms/IPO/Inliner.cpp2
-rw-r--r--llvm/lib/Transforms/IPO/PartialInlining.cpp4
-rw-r--r--llvm/lib/Transforms/IPO/SampleProfile.cpp2
-rw-r--r--llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp2
-rw-r--r--llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp2
-rw-r--r--llvm/unittests/Analysis/ProfileSummaryInfoTest.cpp20
11 files changed, 34 insertions, 35 deletions
diff --git a/llvm/include/llvm/Analysis/ProfileSummaryInfo.h b/llvm/include/llvm/Analysis/ProfileSummaryInfo.h
index 58b67e74ba5..3aef4be72d7 100644
--- a/llvm/include/llvm/Analysis/ProfileSummaryInfo.h
+++ b/llvm/include/llvm/Analysis/ProfileSummaryInfo.h
@@ -98,14 +98,14 @@ public:
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 @@ public:
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;
diff --git a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
index 237faede16b..5a13149c022 100644
--- a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -665,7 +665,7 @@ ModuleSummaryIndexWrapperPass::ModuleSummaryIndexWrapperPass()
}
bool ModuleSummaryIndexWrapperPass::runOnModule(Module &M) {
- auto &PSI = *getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
+ auto *PSI = &getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
Index.emplace(buildModuleSummaryIndex(
M,
[this](const Function &F) {
@@ -673,7 +673,7 @@ bool ModuleSummaryIndexWrapperPass::runOnModule(Module &M) {
*const_cast<Function *>(&F))
.getBFI());
},
- &PSI));
+ PSI));
return false;
}
diff --git a/llvm/lib/Analysis/ProfileSummaryInfo.cpp b/llvm/lib/Analysis/ProfileSummaryInfo.cpp
index 7472b6201c2..bd8459ddb82 100644
--- a/llvm/lib/Analysis/ProfileSummaryInfo.cpp
+++ b/llvm/lib/Analysis/ProfileSummaryInfo.cpp
@@ -151,7 +151,7 @@ bool ProfileSummaryInfo::isFunctionHotInCallGraph(const Function *F,
return true;
}
for (const auto &BB : *F)
- if (isHotBB(&BB, &BFI))
+ if (isHotBlock(&BB, &BFI))
return true;
return false;
}
@@ -180,7 +180,7 @@ bool ProfileSummaryInfo::isFunctionColdInCallGraph(const Function *F,
return false;
}
for (const auto &BB : *F)
- if (!isColdBB(&BB, &BFI))
+ if (!isColdBlock(&BB, &BFI))
return false;
return true;
}
@@ -253,14 +253,14 @@ uint64_t ProfileSummaryInfo::getOrCompColdCountThreshold() {
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);
}
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 1facf9d220a..01f0e762aaf 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -416,7 +416,7 @@ bool CodeGenPrepare::runOnFunction(Function &F) {
OptSize = F.optForSize();
ProfileSummaryInfo *PSI =
- getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
+ &getAnalysis<ProfileSummaryInfoWrapperPass>().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
index 621ac7dc8ab..7c6bf147241 100644
--- a/llvm/lib/Transforms/IPO/HotColdSplitting.cpp
+++ b/llvm/lib/Transforms/IPO/HotColdSplitting.cpp
@@ -266,7 +266,7 @@ static BlockSequence getLargestColdRegion(Function &F, ProfileSummaryInfo &PSI,
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 @@ bool HotColdSplittingLegacyPass::runOnModule(Module &M) {
if (skipModule(M))
return false;
ProfileSummaryInfo *PSI =
- getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
+ &getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
auto GTTI = [this](Function &F) -> TargetTransformInfo & {
return this->getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
};
diff --git a/llvm/lib/Transforms/IPO/Inliner.cpp b/llvm/lib/Transforms/IPO/Inliner.cpp
index 66aea45323f..44001b5779c 100644
--- a/llvm/lib/Transforms/IPO/Inliner.cpp
+++ b/llvm/lib/Transforms/IPO/Inliner.cpp
@@ -746,7 +746,7 @@ inlineCallsImpl(CallGraphSCC &SCC, CallGraph &CG,
bool LegacyInlinerBase::inlineCalls(CallGraphSCC &SCC) {
CallGraph &CG = getAnalysis<CallGraphWrapperPass>().getCallGraph();
ACT = &getAnalysis<AssumptionCacheTracker>();
- PSI = getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
+ PSI = &getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
auto &TLI = getAnalysis<TargetLibraryInfoWrapperPass>().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
index bcb19af85b2..a96342bfc80 100644
--- a/llvm/lib/Transforms/IPO/PartialInlining.cpp
+++ b/llvm/lib/Transforms/IPO/PartialInlining.cpp
@@ -359,7 +359,7 @@ struct PartialInlinerLegacyPass : public ModulePass {
TargetTransformInfoWrapperPass *TTIWP =
&getAnalysis<TargetTransformInfoWrapperPass>();
ProfileSummaryInfo *PSI =
- getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
+ &getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
std::function<AssumptionCache &(Function &)> GetAssumptionCache =
[&ACT](Function &F) -> AssumptionCache & {
@@ -468,7 +468,7 @@ PartialInlinerImpl::computeOutliningColdRegionsInfo(Function *F,
// 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) {
diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp
index a78e0d459c8..37f1ea4a807 100644
--- a/llvm/lib/Transforms/IPO/SampleProfile.cpp
+++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp
@@ -1599,7 +1599,7 @@ bool SampleProfileLoaderLegacyPass::runOnModule(Module &M) {
ACT = &getAnalysis<AssumptionCacheTracker>();
TTIWP = &getAnalysis<TargetTransformInfoWrapperPass>();
ProfileSummaryInfo *PSI =
- getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
+ &getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
return SampleLoader.runOnModule(M, nullptr, PSI);
}
diff --git a/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp b/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
index 10ad6d5eff6..1ada0b71309 100644
--- a/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
+++ b/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
@@ -2040,7 +2040,7 @@ bool ControlHeightReductionLegacyPass::runOnFunction(Function &F) {
getAnalysis<BlockFrequencyInfoWrapperPass>().getBFI();
DominatorTree &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
ProfileSummaryInfo &PSI =
- *getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
+ getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
RegionInfo &RI = getAnalysis<RegionInfoPass>().getRegionInfo();
std::unique_ptr<OptimizationRemarkEmitter> OwnedORE =
llvm::make_unique<OptimizationRemarkEmitter>(&F);
diff --git a/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp b/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
index d839dd21a23..7edc53d07c7 100644
--- a/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
+++ b/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
@@ -427,7 +427,7 @@ static bool promoteIndirectCalls(Module &M, ProfileSummaryInfo *PSI,
bool PGOIndirectCallPromotionLegacyPass::runOnModule(Module &M) {
ProfileSummaryInfo *PSI =
- getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
+ &getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
// Command-line option has the priority for InLTO.
return promoteIndirectCalls(M, PSI, InLTO | ICPLTOMode,
diff --git a/llvm/unittests/Analysis/ProfileSummaryInfoTest.cpp b/llvm/unittests/Analysis/ProfileSummaryInfoTest.cpp
index a37d1490fad..95d8426c3f2 100644
--- a/llvm/unittests/Analysis/ProfileSummaryInfoTest.cpp
+++ b/llvm/unittests/Analysis/ProfileSummaryInfoTest.cpp
@@ -118,8 +118,8 @@ TEST_F(ProfileSummaryInfoTest, TestNoProfile) {
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 @@ TEST_F(ProfileSummaryInfoTest, InstrProf) {
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 @@ TEST_F(ProfileSummaryInfoTest, SampleProf) {
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();
OpenPOWER on IntegriCloud