summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/IPO/HotColdSplitting.cpp16
-rw-r--r--llvm/lib/Transforms/Utils/CodeExtractor.cpp16
2 files changed, 20 insertions, 12 deletions
diff --git a/llvm/lib/Transforms/IPO/HotColdSplitting.cpp b/llvm/lib/Transforms/IPO/HotColdSplitting.cpp
index d3e086e972a..a63cd842241 100644
--- a/llvm/lib/Transforms/IPO/HotColdSplitting.cpp
+++ b/llvm/lib/Transforms/IPO/HotColdSplitting.cpp
@@ -265,7 +265,7 @@ private:
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 @@ bool HotColdSplitting::shouldOutlineFrom(const Function &F) const {
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 @@ const Function *HotColdSplitting::outlineColdBlocks(Function &F,
++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);
}
}
}
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();
OpenPOWER on IntegriCloud