diff options
author | Teresa Johnson <tejohnson@google.com> | 2018-10-24 18:53:47 +0000 |
---|---|---|
committer | Teresa Johnson <tejohnson@google.com> | 2018-10-24 18:53:47 +0000 |
commit | c8dba682bba9c80654d7a10331f718da9b7b0475 (patch) | |
tree | 319803db7b4c42403065259031055708cb8362cf /llvm/lib/Transforms/Utils/CodeExtractor.cpp | |
parent | b40e0520e1b0c401c38aee194c0f7ef6f7849e98 (diff) | |
download | bcm5719-llvm-c8dba682bba9c80654d7a10331f718da9b7b0475.tar.gz bcm5719-llvm-c8dba682bba9c80654d7a10331f718da9b7b0475.zip |
[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
Diffstat (limited to 'llvm/lib/Transforms/Utils/CodeExtractor.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/CodeExtractor.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Utils/CodeExtractor.cpp b/llvm/lib/Transforms/Utils/CodeExtractor.cpp index 27b982578c4..328fe1fac65 100644 --- a/llvm/lib/Transforms/Utils/CodeExtractor.cpp +++ b/llvm/lib/Transforms/Utils/CodeExtractor.cpp @@ -228,19 +228,21 @@ buildExtractionBlockSet(ArrayRef<BasicBlock *> BBs, DominatorTree *DT, CodeExtractor::CodeExtractor(ArrayRef<BasicBlock *> BBs, DominatorTree *DT, bool AggregateArgs, BlockFrequencyInfo *BFI, BranchProbabilityInfo *BPI, bool AllowVarArgs, - bool AllowAlloca) + bool AllowAlloca, std::string Suffix) : DT(DT), AggregateArgs(AggregateArgs || AggregateArgsOpt), BFI(BFI), BPI(BPI), AllowVarArgs(AllowVarArgs), - Blocks(buildExtractionBlockSet(BBs, DT, AllowVarArgs, AllowAlloca)) {} + Blocks(buildExtractionBlockSet(BBs, DT, AllowVarArgs, AllowAlloca)), + Suffix(Suffix) {} CodeExtractor::CodeExtractor(DominatorTree &DT, Loop &L, bool AggregateArgs, BlockFrequencyInfo *BFI, - BranchProbabilityInfo *BPI) + BranchProbabilityInfo *BPI, std::string Suffix) : DT(&DT), AggregateArgs(AggregateArgs || AggregateArgsOpt), BFI(BFI), BPI(BPI), AllowVarArgs(false), Blocks(buildExtractionBlockSet(L.getBlocks(), &DT, /* AllowVarArgs */ false, - /* AllowAlloca */ false)) {} + /* AllowAlloca */ false)), + Suffix(Suffix) {} /// definedInRegion - Return true if the specified value is defined in the /// extracted region. @@ -669,10 +671,14 @@ Function *CodeExtractor::constructFunction(const ValueSet &inputs, FunctionType::get(RetTy, paramTy, AllowVarArgs && oldFunction->isVarArg()); + std::string SuffixToUse = + Suffix.empty() + ? (header->getName().empty() ? "extracted" : header->getName().str()) + : Suffix; // Create the new function Function *newFunction = Function::Create( funcType, GlobalValue::InternalLinkage, oldFunction->getAddressSpace(), - oldFunction->getName() + "_" + header->getName(), M); + oldFunction->getName() + "." + SuffixToUse, M); // If the old function is no-throw, so is the new one. if (oldFunction->doesNotThrow()) newFunction->setDoesNotThrow(); |