diff --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp b/llvm/lib/CodeGen/MachineBlockPlacement.cpp --- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp +++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp @@ -200,10 +200,7 @@ cl::init(2), cl::Hidden); -static cl::opt EnableExtTspBlockPlacement( - "enable-ext-tsp-block-placement", cl::Hidden, cl::init(false), - cl::desc("Enable machine block placement based on the ext-tsp model, " - "optimizing I-cache utilization.")); +extern cl::opt EnableExtTspBlockPlacement; namespace llvm { extern cl::opt StaticLikelyProb; diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp --- a/llvm/lib/Transforms/IPO/SampleProfile.cpp +++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp @@ -295,6 +295,8 @@ "overwrite-existing-weights", cl::Hidden, cl::init(false), cl::desc("Ignore existing branch weights on IR and always overwrite.")); +extern cl::opt EnableExtTspBlockPlacement; + namespace { using BlockWeightMap = DenseMap; @@ -2000,6 +2002,10 @@ if (!SampleProfileUseProfi.getNumOccurrences()) SampleProfileUseProfi = true; + // Enable EXT-TSP block layout for CSSPGO. + if (!EnableExtTspBlockPlacement.getNumOccurrences()) + EnableExtTspBlockPlacement = true; + if (FunctionSamples::ProfileIsCSFlat) { // Tracker for profiles under different context ContextTracker = std::make_unique( diff --git a/llvm/lib/Transforms/Utils/CodeLayout.cpp b/llvm/lib/Transforms/Utils/CodeLayout.cpp --- a/llvm/lib/Transforms/Utils/CodeLayout.cpp +++ b/llvm/lib/Transforms/Utils/CodeLayout.cpp @@ -45,6 +45,11 @@ using namespace llvm; #define DEBUG_TYPE "code-layout" +cl::opt EnableExtTspBlockPlacement( + "enable-ext-tsp-block-placement", cl::Hidden, cl::init(false), + cl::desc("Enable machine block placement based on the ext-tsp model, " + "optimizing I-cache utilization.")); + // Algorithm-specific constants. The values are tuned for the best performance // of large-scale front-end bound binaries. static cl::opt