1 change: 1 addition & 0 deletions llvm/lib/Transforms/IPO/IPO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ void llvm::initializeIPO(PassRegistry &Registry) {
initializeGlobalDCELegacyPassPass(Registry);
initializeGlobalOptLegacyPassPass(Registry);
initializeGlobalSplitPass(Registry);
initializeHotColdSplittingLegacyPassPass(Registry);
initializeIPCPPass(Registry);
initializeAlwaysInlinerLegacyPassPass(Registry);
initializeSimpleInlinerPass(Registry);
Expand Down
7 changes: 7 additions & 0 deletions llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ static cl::opt<bool>
EnablePrepareForThinLTO("prepare-for-thinlto", cl::init(false), cl::Hidden,
cl::desc("Enable preparation for ThinLTO."));

cl::opt<bool> EnableHotColdSplit("hot-cold-split", cl::init(false), cl::Hidden,
cl::desc("Enable hot-cold splitting pass"));


static cl::opt<bool> RunPGOInstrGen(
"profile-generate", cl::init(false), cl::Hidden,
cl::desc("Enable PGO instrumentation."));
Expand Down Expand Up @@ -497,6 +501,9 @@ void PassManagerBuilder::populateModulePassManager(
// Infer attributes about declarations if possible.
MPM.add(createInferFunctionAttrsLegacyPass());

if (EnableHotColdSplit)
MPM.add(createHotColdSplittingPass());

addExtensionsToPM(EP_ModuleOptimizerEarly, MPM);

if (OptLevel > 2)
Expand Down
34 changes: 34 additions & 0 deletions llvm/test/Transforms/HotColdSplit/split-cold-1.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
; RUN: opt -hotcoldsplit -S < %s | FileCheck %s
source_filename = "bugpoint-output-054409e.bc"
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.13.0"

declare i32 @__gxx_personality_v0(...)

; Outlined function is called from a basic block named codeRepl
; CHECK: codeRepl:
; CHECK-NEXT: call coldcc void @foo
; Check that no recursive outlining is done.
; CHECK-NOT: codeRepl:
; Function Attrs: ssp uwtable
define hidden void @foo() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
entry:
br i1 undef, label %if.then, label %if.end

if.then: ; preds = %entry
unreachable

if.end: ; preds = %entry
br label %if.then12

if.then12: ; preds = %if.end
br label %cleanup40

cleanup40: ; preds = %if.then12
br label %return

return: ; preds = %cleanup40
ret void
}