@@ -11,7 +11,7 @@ use crate::tests::run_tests;
1111use crate :: timer:: Timer ;
1212use crate :: training:: {
1313 gather_bolt_profiles, gather_llvm_profiles, gather_rustc_profiles, llvm_benchmarks,
14- rustc_benchmarks,
14+ rust_analyzer_benchmarks , rustc_benchmarks,
1515} ;
1616use crate :: utils:: artifact_size:: print_binary_sizes;
1717use crate :: utils:: io:: { copy_directory, reset_directory} ;
@@ -209,7 +209,8 @@ fn execute_pipeline(
209209 let rustc_profile_dir_root = env. artifact_dir ( ) . join ( "rustc-pgo" ) ;
210210
211211 stage. section ( "Build PGO instrumented rustc and LLVM" , |section| {
212- let mut builder = Bootstrap :: build ( env) . rustc_pgo_instrument ( & rustc_profile_dir_root) ;
212+ let mut builder =
213+ Bootstrap :: build_compiler ( env) . rustc_pgo_instrument ( & rustc_profile_dir_root) ;
213214
214215 if env. supports_shared_llvm ( ) {
215216 // This first LLVM that we build will be thrown away after this stage, and it
@@ -227,7 +228,7 @@ fn execute_pipeline(
227228 print_free_disk_space ( ) ?;
228229
229230 stage. section ( "Build PGO optimized rustc" , |section| {
230- let mut cmd = Bootstrap :: build ( env) . rustc_pgo_optimize ( & profile) ;
231+ let mut cmd = Bootstrap :: build_compiler ( env) . rustc_pgo_optimize ( & profile) ;
231232 if env. use_bolt ( ) {
232233 cmd = cmd. with_rustc_bolt_ldflags ( ) ;
233234 }
@@ -248,7 +249,7 @@ fn execute_pipeline(
248249 let llvm_profile_dir_root = env. artifact_dir ( ) . join ( "llvm-pgo" ) ;
249250
250251 stage. section ( "Build PGO instrumented LLVM" , |section| {
251- Bootstrap :: build ( env)
252+ Bootstrap :: build_compiler ( env)
252253 . llvm_pgo_instrument ( & llvm_profile_dir_root)
253254 . avoid_rustc_rebuild ( )
254255 . run ( section)
@@ -274,7 +275,7 @@ fn execute_pipeline(
274275 // therefore the LLVM artifacts on disk are not "tainted" with BOLT instrumentation and they can be reused.
275276 timer. section ( "Stage 3 (BOLT)" , |stage| {
276277 stage. section ( "Build PGO optimized LLVM" , |stage| {
277- Bootstrap :: build ( env)
278+ Bootstrap :: build_compiler ( env)
278279 . with_llvm_bolt_ldflags ( )
279280 . llvm_pgo_optimize ( & llvm_pgo_profile)
280281 . avoid_rustc_rebuild ( )
@@ -290,7 +291,7 @@ fn execute_pipeline(
290291 // FIXME(kobzol): try gather profiles together, at once for LLVM and rustc
291292 // Instrument the libraries and gather profiles
292293 let llvm_profile = with_bolt_instrumented ( & llvm_lib, |llvm_profile_dir| {
293- stage. section ( "Gather profiles" , |_| {
294+ stage. section ( "Gather LLVM profiles" , |_| {
294295 gather_bolt_profiles ( env, "LLVM" , llvm_benchmarks ( env) , llvm_profile_dir)
295296 } )
296297 } ) ?;
@@ -310,7 +311,7 @@ fn execute_pipeline(
310311
311312 // Instrument it and gather profiles
312313 let rustc_profile = with_bolt_instrumented ( & rustc_lib, |rustc_profile_dir| {
313- stage. section ( "Gather profiles" , |_| {
314+ stage. section ( "Gather rustc profiles" , |_| {
314315 gather_bolt_profiles ( env, "rustc" , rustc_benchmarks ( env) , rustc_profile_dir)
315316 } )
316317 } ) ?;
@@ -320,8 +321,28 @@ fn execute_pipeline(
320321 bolt_optimize ( & rustc_lib, & rustc_profile, env)
321322 . context ( "Could not optimize rustc with BOLT" ) ?;
322323
324+ Bootstrap :: build_rust_analyzer ( env)
325+ . avoid_rustc_rebuild ( )
326+ . with_rustc_bolt_ldflags ( )
327+ . run ( stage) ?;
328+ let ra_binary = env. build_artifacts ( ) . join ( "stage1-tools-bin" ) . join ( "rust-analyzer" ) ;
329+ let ra_profile = with_bolt_instrumented ( & ra_binary, |ra_profile_dir| {
330+ stage. section ( "Gather rust analyzer profiles" , |_| {
331+ gather_bolt_profiles (
332+ env,
333+ "rust-analyzer" ,
334+ rust_analyzer_benchmarks ( env, & ra_binary) ,
335+ ra_profile_dir,
336+ )
337+ } )
338+ } ) ?;
339+
340+ // Now optimize rust-analyzer with BOLT.
341+ bolt_optimize ( & ra_binary, & ra_profile, env)
342+ . context ( "Could not optimize rust-analyzer with BOLT" ) ?;
343+
323344 // LLVM is not being cleared here, we want to use the BOLT-optimized LLVM
324- Ok ( vec ! [ llvm_profile, rustc_profile] )
345+ Ok ( vec ! [ llvm_profile, rustc_profile, ra_profile ] )
325346 } ) ?
326347 } else {
327348 vec ! [ ]
0 commit comments