[hot-cold-split] Name split functions with ".cold" suffix
Summary:
The current default of appending "_"+entry block label to the new
extracted cold function breaks demangling. Change the deliminator from
"_" to "." to enable demangling. Because the header block label will
be empty for release compile code, use "extracted" after the "." when
the label is empty.
Additionally, add a mechanism for the client to pass in an alternate
suffix applied after the ".", and have the hot cold split pass use
"cold."+Count, where the Count is currently 1 but can be used to
uniquely number multiple cold functions split out from the same function
with D53588.
Reviewers: sebpop, hiraditya
Subscribers: llvm-commits, erik.pilkington
Differential Revision: https://reviews.llvm.org/D53534
llvm-svn: 345178
diff --git a/llvm/lib/Transforms/IPO/HotColdSplitting.cpp b/llvm/lib/Transforms/IPO/HotColdSplitting.cpp
index d3e086e..a63cd84 100644
--- a/llvm/lib/Transforms/IPO/HotColdSplitting.cpp
+++ b/llvm/lib/Transforms/IPO/HotColdSplitting.cpp
@@ -265,7 +265,7 @@
DominatorTree *DT, PostDomTree *PDT);
Function *extractColdRegion(const SmallVectorImpl<BasicBlock *> &Region,
DominatorTree *DT, BlockFrequencyInfo *BFI,
- OptimizationRemarkEmitter &ORE);
+ OptimizationRemarkEmitter &ORE, unsigned Count);
bool isOutlineCandidate(const SmallVectorImpl<BasicBlock *> &Region,
const BasicBlock *Exit) const {
if (!Exit)
@@ -331,16 +331,18 @@
return true;
}
-Function *
-HotColdSplitting::extractColdRegion(const SmallVectorImpl<BasicBlock *> &Region,
- DominatorTree *DT, BlockFrequencyInfo *BFI,
- OptimizationRemarkEmitter &ORE) {
+Function *HotColdSplitting::extractColdRegion(
+ const SmallVectorImpl<BasicBlock *> &Region, DominatorTree *DT,
+ BlockFrequencyInfo *BFI, OptimizationRemarkEmitter &ORE, unsigned Count) {
assert(!Region.empty());
LLVM_DEBUG(for (auto *BB : Region)
llvm::dbgs() << "\nExtracting: " << *BB;);
// TODO: Pass BFI and BPI to update profile information.
- CodeExtractor CE(Region, DT);
+ CodeExtractor CE(Region, DT, /* AggregateArgs */ false, /* BFI */ nullptr,
+ /* BPI */ nullptr, /* AllowVarArgs */ false,
+ /* AllowAlloca */ false,
+ /* Suffix */ "cold." + std::to_string(Count));
SetVector<Value *> Inputs, Outputs, Sinks;
CE.findInputsOutputs(Inputs, Outputs, Sinks);
@@ -426,7 +428,7 @@
++NumColdSESEFound;
ValidColdRegion.push_back(ExitColdRegion);
// Candidate for outlining. FIXME: Continue outlining.
- return extractColdRegion(ValidColdRegion, DT, BFI, ORE);
+ return extractColdRegion(ValidColdRegion, DT, BFI, ORE, /* Count */ 1);
}
}
}