@@ -11,7 +11,7 @@ use crate::tests::run_tests;
11
11
use crate :: timer:: Timer ;
12
12
use crate :: training:: {
13
13
gather_bolt_profiles, gather_llvm_profiles, gather_rustc_profiles, llvm_benchmarks,
14
- rustc_benchmarks,
14
+ rust_analyzer_benchmarks , rustc_benchmarks,
15
15
} ;
16
16
use crate :: utils:: artifact_size:: print_binary_sizes;
17
17
use crate :: utils:: io:: { copy_directory, reset_directory} ;
@@ -209,7 +209,8 @@ fn execute_pipeline(
209
209
let rustc_profile_dir_root = env. artifact_dir ( ) . join ( "rustc-pgo" ) ;
210
210
211
211
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) ;
213
214
214
215
if env. supports_shared_llvm ( ) {
215
216
// This first LLVM that we build will be thrown away after this stage, and it
@@ -227,7 +228,7 @@ fn execute_pipeline(
227
228
print_free_disk_space ( ) ?;
228
229
229
230
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) ;
231
232
if env. use_bolt ( ) {
232
233
cmd = cmd. with_rustc_bolt_ldflags ( ) ;
233
234
}
@@ -248,7 +249,7 @@ fn execute_pipeline(
248
249
let llvm_profile_dir_root = env. artifact_dir ( ) . join ( "llvm-pgo" ) ;
249
250
250
251
stage. section ( "Build PGO instrumented LLVM" , |section| {
251
- Bootstrap :: build ( env)
252
+ Bootstrap :: build_compiler ( env)
252
253
. llvm_pgo_instrument ( & llvm_profile_dir_root)
253
254
. avoid_rustc_rebuild ( )
254
255
. run ( section)
@@ -274,7 +275,7 @@ fn execute_pipeline(
274
275
// therefore the LLVM artifacts on disk are not "tainted" with BOLT instrumentation and they can be reused.
275
276
timer. section ( "Stage 3 (BOLT)" , |stage| {
276
277
stage. section ( "Build PGO optimized LLVM" , |stage| {
277
- Bootstrap :: build ( env)
278
+ Bootstrap :: build_compiler ( env)
278
279
. with_llvm_bolt_ldflags ( )
279
280
. llvm_pgo_optimize ( & llvm_pgo_profile)
280
281
. avoid_rustc_rebuild ( )
@@ -290,7 +291,7 @@ fn execute_pipeline(
290
291
// FIXME(kobzol): try gather profiles together, at once for LLVM and rustc
291
292
// Instrument the libraries and gather profiles
292
293
let llvm_profile = with_bolt_instrumented ( & llvm_lib, |llvm_profile_dir| {
293
- stage. section ( "Gather profiles" , |_| {
294
+ stage. section ( "Gather LLVM profiles" , |_| {
294
295
gather_bolt_profiles ( env, "LLVM" , llvm_benchmarks ( env) , llvm_profile_dir)
295
296
} )
296
297
} ) ?;
@@ -310,7 +311,7 @@ fn execute_pipeline(
310
311
311
312
// Instrument it and gather profiles
312
313
let rustc_profile = with_bolt_instrumented ( & rustc_lib, |rustc_profile_dir| {
313
- stage. section ( "Gather profiles" , |_| {
314
+ stage. section ( "Gather rustc profiles" , |_| {
314
315
gather_bolt_profiles ( env, "rustc" , rustc_benchmarks ( env) , rustc_profile_dir)
315
316
} )
316
317
} ) ?;
@@ -320,8 +321,28 @@ fn execute_pipeline(
320
321
bolt_optimize ( & rustc_lib, & rustc_profile, env)
321
322
. context ( "Could not optimize rustc with BOLT" ) ?;
322
323
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
+
323
344
// 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 ] )
325
346
} ) ?
326
347
} else {
327
348
vec ! [ ]
0 commit comments