Index: include/llvm/Transforms/Utils/CodeExtractor.h =================================================================== --- include/llvm/Transforms/Utils/CodeExtractor.h +++ include/llvm/Transforms/Utils/CodeExtractor.h @@ -64,6 +64,11 @@ unsigned NumExitBlocks = std::numeric_limits::max(); Type *RetTy; + // Suffix to use when creating extracted function (appended to the original + // function name). If empty, the default is to append "_" + entry block + // label to the original function name. + StringRef Suffix; + public: /// Create a code extractor for a sequence of blocks. /// @@ -78,7 +83,8 @@ CodeExtractor(ArrayRef BBs, DominatorTree *DT = nullptr, bool AggregateArgs = false, BlockFrequencyInfo *BFI = nullptr, BranchProbabilityInfo *BPI = nullptr, - bool AllowVarArgs = false, bool AllowAlloca = false); + bool AllowVarArgs = false, bool AllowAlloca = false, + StringRef Suffix = ""); /// Create a code extractor for a loop body. /// @@ -86,7 +92,7 @@ /// block sequence of the loop. CodeExtractor(DominatorTree &DT, Loop &L, bool AggregateArgs = false, BlockFrequencyInfo *BFI = nullptr, - BranchProbabilityInfo *BPI = nullptr); + BranchProbabilityInfo *BPI = nullptr, StringRef Suffix = ""); /// Perform the extraction, returning the new function. /// Index: lib/Transforms/IPO/HotColdSplitting.cpp =================================================================== --- lib/Transforms/IPO/HotColdSplitting.cpp +++ lib/Transforms/IPO/HotColdSplitting.cpp @@ -340,7 +340,9 @@ 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"); SetVector Inputs, Outputs, Sinks; CE.findInputsOutputs(Inputs, Outputs, Sinks); Index: lib/Transforms/Utils/CodeExtractor.cpp =================================================================== --- lib/Transforms/Utils/CodeExtractor.cpp +++ lib/Transforms/Utils/CodeExtractor.cpp @@ -228,19 +228,21 @@ CodeExtractor::CodeExtractor(ArrayRef BBs, DominatorTree *DT, bool AggregateArgs, BlockFrequencyInfo *BFI, BranchProbabilityInfo *BPI, bool AllowVarArgs, - bool AllowAlloca) + bool AllowAlloca, StringRef 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, StringRef 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. @@ -672,7 +674,9 @@ // Create the new function Function *newFunction = Function::Create( funcType, GlobalValue::InternalLinkage, oldFunction->getAddressSpace(), - oldFunction->getName() + "_" + header->getName(), M); + Suffix.empty() ? oldFunction->getName() + "_" + header->getName() + : oldFunction->getName() + Suffix, + M); // If the old function is no-throw, so is the new one. if (oldFunction->doesNotThrow()) newFunction->setDoesNotThrow(); Index: test/Transforms/HotColdSplit/split-cold-2.ll =================================================================== --- test/Transforms/HotColdSplit/split-cold-2.ll +++ test/Transforms/HotColdSplit/split-cold-2.ll @@ -4,10 +4,10 @@ ; Make sure this compiles. This test used to fail with an invalid phi node: the ; two predecessors were outlined and the SSA representation was invalid. -; CHECK: remark: :0:0: fun split cold code into fun_if.else +; CHECK: remark: :0:0: fun split cold code into fun.cold ; CHECK-LABEL: @fun ; CHECK: codeRepl: -; CHECK-NEXT: call void @fun_if.else +; CHECK-NEXT: call void @fun.cold define void @fun() { entry: Index: test/Transforms/HotColdSplit/split-out-dbg-val-of-arg.ll =================================================================== --- test/Transforms/HotColdSplit/split-out-dbg-val-of-arg.ll +++ test/Transforms/HotColdSplit/split-out-dbg-val-of-arg.ll @@ -1,6 +1,6 @@ ; RUN: opt -hotcoldsplit -S < %s | FileCheck %s -; CHECK-LABEL: define {{.*}}@foo_if.end +; CHECK-LABEL: define {{.*}}@foo.cold ; CHECK-NOT: llvm.dbg.value define void @foo(i32 %arg1) !dbg !6 {