[CSSPGO] Turn on ext-tsp by default for CSSPGO.
authorHongtao Yu <hoy@fb.com>
Sat, 5 Feb 2022 01:17:35 +0000 (17:17 -0800)
committerHongtao Yu <hoy@fb.com>
Sat, 5 Feb 2022 03:46:44 +0000 (19:46 -0800)
I'm seeing ext-tsp helps CSSPGO for our intern large benchmarks so I'm turning on it for CSSPGO. For non-CS AutoFDO, ext-tsp doesn't seem to help, probably because of lower profile counts quality.

Reviewed By: wenlei

Differential Revision: https://reviews.llvm.org/D119048

llvm/lib/CodeGen/MachineBlockPlacement.cpp
llvm/lib/Transforms/IPO/SampleProfile.cpp
llvm/lib/Transforms/Utils/CodeLayout.cpp

index c93ffaabf74c82059bcfe15498bb737712ea5bdb..5ad3d4d21ce2ed9369a53f1208b04a0a908965f6 100644 (file)
@@ -200,10 +200,7 @@ static cl::opt<unsigned> TriangleChainCount(
     cl::init(2),
     cl::Hidden);
 
-static cl::opt<bool> 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<bool> EnableExtTspBlockPlacement;
 
 namespace llvm {
 extern cl::opt<unsigned> StaticLikelyProb;
index 0298f3c025db597eee94291738a63b1b53ea0021..38bbd506381b413f9ca70e0f12bb387ebdff9961 100644 (file)
@@ -295,6 +295,8 @@ static cl::opt<bool> OverwriteExistingWeights(
     "overwrite-existing-weights", cl::Hidden, cl::init(false),
     cl::desc("Ignore existing branch weights on IR and always overwrite."));
 
+extern cl::opt<bool> EnableExtTspBlockPlacement;
+
 namespace {
 
 using BlockWeightMap = DenseMap<const BasicBlock *, uint64_t>;
@@ -2000,6 +2002,10 @@ bool SampleProfileLoader::doInitialization(Module &M,
     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<SampleContextTracker>(
index dfb9f608eab2ffa73a6bf0d4b6028f602a56af4b..e46a939dcace487e963bd6f786a5d3d45518cce4 100644 (file)
 using namespace llvm;
 #define DEBUG_TYPE "code-layout"
 
+cl::opt<bool> 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<double>