@@ -4,6 +4,7 @@ use anyhow::Context;
4
4
use clap:: builder:: { PossibleValue , TypedValueParser } ;
5
5
use clap:: { Arg , Parser , ValueEnum } ;
6
6
use collector:: api:: next_artifact:: NextArtifact ;
7
+ use collector:: codegen:: { codegen_diff, CodegenType } ;
7
8
use collector:: compile:: benchmark:: category:: Category ;
8
9
use collector:: compile:: benchmark:: profile:: Profile ;
9
10
use collector:: compile:: benchmark:: scenario:: Scenario ;
@@ -31,9 +32,9 @@ use tokio::runtime::Runtime;
31
32
use collector:: compile:: execute:: bencher:: BenchProcessor ;
32
33
use collector:: compile:: execute:: profiler:: { ProfileProcessor , Profiler } ;
33
34
use collector:: runtime:: {
34
- bench_runtime, prepare_runtime_benchmark_suite , runtime_benchmark_dir , BenchmarkFilter ,
35
- BenchmarkSuite , BenchmarkSuiteCompilation , CargoIsolationMode , RuntimeProfiler ,
36
- DEFAULT_RUNTIME_ITERATIONS ,
35
+ bench_runtime, get_runtime_benchmark_groups , prepare_runtime_benchmark_suite ,
36
+ runtime_benchmark_dir , BenchmarkFilter , BenchmarkSuite , BenchmarkSuiteCompilation ,
37
+ CargoIsolationMode , RuntimeProfiler , DEFAULT_RUNTIME_ITERATIONS ,
37
38
} ;
38
39
use collector:: runtime:: { profile_runtime, RuntimeCompilationOpts } ;
39
40
use collector:: toolchain:: {
@@ -452,6 +453,21 @@ enum Commands {
452
453
benchmark : String ,
453
454
} ,
454
455
456
+ /// Displays the diff between assembly, LLVM or MIR for a runtime benchmark group.
457
+ CodegenDiff {
458
+ /// Profiler to use
459
+ codegen_type : CodegenType ,
460
+
461
+ /// Runtime benchmark group to diff (name of a directory in `collector/runtime-benchmarks`)
462
+ group : String ,
463
+
464
+ /// The path to the local rustc used to compile the runtime benchmark
465
+ rustc1 : String ,
466
+
467
+ /// The path to a second rustc used to compile with the baseline
468
+ rustc2 : String ,
469
+ } ,
470
+
455
471
/// Benchmarks a local rustc
456
472
BenchLocal {
457
473
#[ command( flatten) ]
@@ -659,7 +675,7 @@ fn main_result() -> anyhow::Result<i32> {
659
675
// generated profiles.
660
676
RuntimeCompilationOpts :: default ( ) . debug_info ( "1" ) ,
661
677
) ?
662
- . suite ;
678
+ . extract_suite ( ) ;
663
679
Ok :: < _ , anyhow:: Error > ( ( toolchain, suite) )
664
680
} ;
665
681
@@ -692,6 +708,37 @@ fn main_result() -> anyhow::Result<i32> {
692
708
693
709
Ok ( 0 )
694
710
}
711
+ Commands :: CodegenDiff {
712
+ codegen_type,
713
+ group,
714
+ rustc1 : rustc,
715
+ rustc2,
716
+ } => {
717
+ let get_toolchain = |rustc : & str , id : & str | {
718
+ let toolchain = get_local_toolchain (
719
+ & [ Profile :: Opt ] ,
720
+ rustc,
721
+ None ,
722
+ None ,
723
+ None ,
724
+ id,
725
+ target_triple. clone ( ) ,
726
+ ) ?;
727
+ Ok :: < _ , anyhow:: Error > ( toolchain)
728
+ } ;
729
+
730
+ let toolchain1 = get_toolchain ( & rustc, "1" ) ?;
731
+ let toolchain2 = get_toolchain ( & rustc2, "2" ) ?;
732
+
733
+ let mut benchmark_groups =
734
+ get_runtime_benchmark_groups ( & runtime_benchmark_dir, Some ( group) ) ?;
735
+ let group = benchmark_groups. pop ( ) . unwrap ( ) ;
736
+ assert ! ( benchmark_groups. is_empty( ) ) ;
737
+
738
+ codegen_diff ( codegen_type, toolchain1, toolchain2, group) ?;
739
+ Ok ( 0 )
740
+ }
741
+
695
742
Commands :: BenchLocal {
696
743
local,
697
744
opts,
0 commit comments