From 9b339a82f6dac10a021d2a3baad1c1d68549901c Mon Sep 17 00:00:00 2001 From: klensy Date: Fri, 8 Nov 2024 20:32:09 +0300 Subject: [PATCH 1/2] try OptSize --- compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp | 4 ++-- src/bootstrap/src/core/build_steps/compile.rs | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index 5d2df6ddfc912..493f0e7f521eb 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -712,7 +712,7 @@ extern "C" LLVMRustResult LLVMRustOptimize( PGOOpt = PGOOptions(PGOGenPath, "", "", "", FS, PGOOptions::IRInstr, PGOOptions::NoCSAction, #if LLVM_VERSION_GE(19, 0) - PGOOptions::ColdFuncOpt::Default, + PGOOptions::ColdFuncOpt::OptSize, #endif DebugInfoForProfiling); } else if (PGOUsePath) { @@ -720,7 +720,7 @@ extern "C" LLVMRustResult LLVMRustOptimize( PGOOpt = PGOOptions(PGOUsePath, "", "", "", FS, PGOOptions::IRUse, PGOOptions::NoCSAction, #if LLVM_VERSION_GE(19, 0) - PGOOptions::ColdFuncOpt::Default, + PGOOptions::ColdFuncOpt::OptSize, #endif DebugInfoForProfiling); } else if (PGOSampleUsePath) { diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index 9ddcde7eb2cfc..6df5a186c6c16 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -1113,6 +1113,7 @@ pub fn rustc_cargo( // Apparently necessary to avoid overflowing the counters during // a Cargo build profile cargo.rustflag("-Cllvm-args=-vp-counters-per-site=4"); + cargo.rustflag("-Cllvm-args=-enable-pgo-force-function-attrs"); true } else { false @@ -1120,6 +1121,7 @@ pub fn rustc_cargo( } else if let Some(path) = &builder.config.rust_profile_use { if compiler.stage == 1 { cargo.rustflag(&format!("-Cprofile-use={path}")); + cargo.rustflag("-Cllvm-args=-enable-pgo-force-function-attrs"); if builder.is_verbose() { cargo.rustflag("-Cllvm-args=-pgo-warn-missing-function"); } From b9859258326f0d488c168c0fc510d538b5cee61a Mon Sep 17 00:00:00 2001 From: klensy Date: Fri, 8 Nov 2024 23:59:44 +0300 Subject: [PATCH 2/2] minsize --- compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index 493f0e7f521eb..077c5184c0c97 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -712,7 +712,7 @@ extern "C" LLVMRustResult LLVMRustOptimize( PGOOpt = PGOOptions(PGOGenPath, "", "", "", FS, PGOOptions::IRInstr, PGOOptions::NoCSAction, #if LLVM_VERSION_GE(19, 0) - PGOOptions::ColdFuncOpt::OptSize, + PGOOptions::ColdFuncOpt::MinSize, #endif DebugInfoForProfiling); } else if (PGOUsePath) { @@ -720,7 +720,7 @@ extern "C" LLVMRustResult LLVMRustOptimize( PGOOpt = PGOOptions(PGOUsePath, "", "", "", FS, PGOOptions::IRUse, PGOOptions::NoCSAction, #if LLVM_VERSION_GE(19, 0) - PGOOptions::ColdFuncOpt::OptSize, + PGOOptions::ColdFuncOpt::MinSize, #endif DebugInfoForProfiling); } else if (PGOSampleUsePath) {