From 13ef6d4efc52eaed9e2c67ecaa334c9a51cde5fc Mon Sep 17 00:00:00 2001
From: Amir Ayupov <amir.aupov@gmail.com>
Date: Fri, 29 Dec 2023 11:39:30 -0800
Subject: [PATCH] [BOLT] Use CDSort and CDSplit

CDSort and CDSplit are the most recent versions of function ordering and function splitting algorithms with some improvements over the previous baseline (ext-tsp and two-way splitting).
---
 src/tools/opt-dist/src/bolt.rs | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/tools/opt-dist/src/bolt.rs b/src/tools/opt-dist/src/bolt.rs
index f694c08f9b937..eb10426f0604d 100644
--- a/src/tools/opt-dist/src/bolt.rs
+++ b/src/tools/opt-dist/src/bolt.rs
@@ -62,9 +62,11 @@ pub fn bolt_optimize(path: &Utf8Path, profile: &BoltProfile) -> anyhow::Result<(
         // Reorder basic blocks within functions
         .arg("-reorder-blocks=ext-tsp")
         // Reorder functions within the binary
-        .arg("-reorder-functions=hfsort+")
+        .arg("-reorder-functions=cdsort")
         // Split function code into hot and code regions
         .arg("-split-functions")
+        // Split using best available strategy (three-way splitting, Cache-Directed Sort)
+        .arg("-split-strategy=cdsplit")
         // Split as many basic blocks as possible
         .arg("-split-all-cold")
         // Move jump tables to a separate section