summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2019-01-22 22:49:22 +0000
committerVedant Kumar <vsk@apple.com>2019-01-22 22:49:22 +0000
commitcde65c0face16507ceb7e0d6f5d36f6f1b9cc04d (patch)
tree4d8c77bd931b9fa530d475e486b446641c244ae5 /llvm/lib/Transforms
parent58e342785644463e35dd85b36489129a97935705 (diff)
downloadbcm5719-llvm-cde65c0face16507ceb7e0d6f5d36f6f1b9cc04d.tar.gz
bcm5719-llvm-cde65c0face16507ceb7e0d6f5d36f6f1b9cc04d.zip
[HotColdSplit] Calculate BFI lazily to reduce compile-time, NFC
The splitting pass does not need BFI unless the Module actually has a profile summary. Do not calcualte BFI unless the summary is present. For the sqlite3 amalgamation, this reduces time spent in the splitting pass from 0.4% of the total to under 0.1%. llvm-svn: 351894
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/IPO/HotColdSplitting.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/IPO/HotColdSplitting.cpp b/llvm/lib/Transforms/IPO/HotColdSplitting.cpp
index eda96710b95..c5eb23c6a16 100644
--- a/llvm/lib/Transforms/IPO/HotColdSplitting.cpp
+++ b/llvm/lib/Transforms/IPO/HotColdSplitting.cpp
@@ -176,7 +176,7 @@ public:
private:
bool isFunctionCold(const Function &F) const;
bool shouldOutlineFrom(const Function &F) const;
- bool outlineColdRegions(Function &F);
+ bool outlineColdRegions(Function &F, bool HasProfileSummary);
Function *extractColdRegion(const BlockSequence &Region, DominatorTree &DT,
BlockFrequencyInfo *BFI, TargetTransformInfo &TTI,
OptimizationRemarkEmitter &ORE, unsigned Count);
@@ -448,7 +448,7 @@ public:
};
} // namespace
-bool HotColdSplitting::outlineColdRegions(Function &F) {
+bool HotColdSplitting::outlineColdRegions(Function &F, bool HasProfileSummary) {
bool Changed = false;
// The set of cold blocks.
@@ -466,7 +466,13 @@ bool HotColdSplitting::outlineColdRegions(Function &F) {
std::unique_ptr<DominatorTree> DT;
std::unique_ptr<PostDominatorTree> PDT;
- BlockFrequencyInfo *BFI = GetBFI(F);
+ // Calculate BFI lazily (it's only used to query ProfileSummaryInfo). This
+ // reduces compile-time significantly. TODO: When we *do* use BFI, we should
+ // be able to salvage its domtrees instead of recomputing them.
+ BlockFrequencyInfo *BFI = nullptr;
+ if (HasProfileSummary)
+ BFI = GetBFI(F);
+
TargetTransformInfo &TTI = GetTTI(F);
OptimizationRemarkEmitter &ORE = (*GetORE)(F);
@@ -476,7 +482,7 @@ bool HotColdSplitting::outlineColdRegions(Function &F) {
if (ColdBlocks.count(BB))
continue;
- bool Cold = PSI->isColdBlock(BB, BFI) ||
+ bool Cold = (BFI && PSI->isColdBlock(BB, BFI)) ||
(EnableStaticAnalyis && unlikelyExecuted(*BB));
if (!Cold)
continue;
@@ -550,6 +556,7 @@ bool HotColdSplitting::outlineColdRegions(Function &F) {
bool HotColdSplitting::run(Module &M) {
bool Changed = false;
+ bool HasProfileSummary = M.getProfileSummary();
for (auto It = M.begin(), End = M.end(); It != End; ++It) {
Function &F = *It;
@@ -573,7 +580,7 @@ bool HotColdSplitting::run(Module &M) {
}
LLVM_DEBUG(llvm::dbgs() << "Outlining in " << F.getName() << "\n");
- Changed |= outlineColdRegions(F);
+ Changed |= outlineColdRegions(F, HasProfileSummary);
}
return Changed;
}
OpenPOWER on IntegriCloud