@@ -176,8 +176,11 @@ impl flags::AnalysisStats {
176176 shuffle ( & mut rng, & mut bodies) ;
177177 }
178178
179+ if !self . skip_lowering {
180+ self . run_body_lowering ( db, & vfs, & bodies, verbosity) ;
181+ }
182+
179183 if !self . skip_inference {
180- // FIXME: Consider running inference on all body kinds?
181184 self . run_inference ( db, & vfs, & bodies, verbosity) ;
182185 }
183186
@@ -255,9 +258,11 @@ impl flags::AnalysisStats {
255258 }
256259 fail += 1 ;
257260 }
258- eprintln ! ( "{:<20} {}" , "Data layouts:" , sw. elapsed( ) ) ;
261+ let data_layout_time = sw. elapsed ( ) ;
262+ eprintln ! ( "{:<20} {}" , "Data layouts:" , data_layout_time) ;
259263 eprintln ! ( "Failed data layouts: {fail} ({}%)" , percentage( fail, all) ) ;
260264 report_metric ( "failed data layouts" , fail, "#" ) ;
265+ report_metric ( "data layout time" , data_layout_time. time . as_millis ( ) as u64 , "ms" ) ;
261266 }
262267
263268 fn run_const_eval ( & self , db : & RootDatabase , consts : & [ hir:: Const ] , verbosity : Verbosity ) {
@@ -283,9 +288,11 @@ impl flags::AnalysisStats {
283288 }
284289 fail += 1 ;
285290 }
286- eprintln ! ( "{:<20} {}" , "Const evaluation:" , sw. elapsed( ) ) ;
291+ let const_eval_time = sw. elapsed ( ) ;
292+ eprintln ! ( "{:<20} {}" , "Const evaluation:" , const_eval_time) ;
287293 eprintln ! ( "Failed const evals: {fail} ({}%)" , percentage( fail, all) ) ;
288294 report_metric ( "failed const evals" , fail, "#" ) ;
295+ report_metric ( "const eval time" , const_eval_time. time . as_millis ( ) as u64 , "ms" ) ;
289296 }
290297
291298 fn run_mir_lowering ( & self , db : & RootDatabase , bodies : & [ DefWithBody ] , verbosity : Verbosity ) {
@@ -310,9 +317,11 @@ impl flags::AnalysisStats {
310317 }
311318 fail += 1 ;
312319 }
313- eprintln ! ( "{:<20} {}" , "MIR lowering:" , sw. elapsed( ) ) ;
320+ let mir_lowering_time = sw. elapsed ( ) ;
321+ eprintln ! ( "{:<20} {}" , "MIR lowering:" , mir_lowering_time) ;
314322 eprintln ! ( "Mir failed bodies: {fail} ({}%)" , percentage( fail, all) ) ;
315323 report_metric ( "mir failed bodies" , fail, "#" ) ;
324+ report_metric ( "mir lowering time" , mir_lowering_time. time . as_millis ( ) as u64 , "ms" ) ;
316325 }
317326
318327 fn run_inference (
@@ -596,6 +605,7 @@ impl flags::AnalysisStats {
596605 }
597606
598607 bar. finish_and_clear ( ) ;
608+ let inference_time = inference_sw. elapsed ( ) ;
599609 eprintln ! (
600610 " exprs: {}, ??ty: {} ({}%), ?ty: {} ({}%), !ty: {}" ,
601611 num_exprs,
@@ -614,12 +624,83 @@ impl flags::AnalysisStats {
614624 percentage( num_pats_partially_unknown, num_pats) ,
615625 num_pat_type_mismatches
616626 ) ;
627+ eprintln ! ( "{:<20} {}" , "Inference:" , inference_time) ;
617628 report_metric ( "unknown type" , num_exprs_unknown, "#" ) ;
618629 report_metric ( "type mismatches" , num_expr_type_mismatches, "#" ) ;
619630 report_metric ( "pattern unknown type" , num_pats_unknown, "#" ) ;
620631 report_metric ( "pattern type mismatches" , num_pat_type_mismatches, "#" ) ;
632+ report_metric ( "inference time" , inference_time. time . as_millis ( ) as u64 , "ms" ) ;
633+ }
634+
635+ fn run_body_lowering (
636+ & self ,
637+ db : & RootDatabase ,
638+ vfs : & Vfs ,
639+ bodies : & [ DefWithBody ] ,
640+ verbosity : Verbosity ,
641+ ) {
642+ let mut bar = match verbosity {
643+ Verbosity :: Quiet | Verbosity :: Spammy => ProgressReport :: hidden ( ) ,
644+ _ if self . parallel || self . output . is_some ( ) => ProgressReport :: hidden ( ) ,
645+ _ => ProgressReport :: new ( bodies. len ( ) as u64 ) ,
646+ } ;
647+
648+ let mut sw = self . stop_watch ( ) ;
649+ bar. tick ( ) ;
650+ for & body_id in bodies {
651+ let name = body_id. name ( db) . unwrap_or_else ( Name :: missing) ;
652+ let module = body_id. module ( db) ;
653+ let full_name = || {
654+ module
655+ . krate ( )
656+ . display_name ( db)
657+ . map ( |it| it. canonical_name ( ) . to_string ( ) )
658+ . into_iter ( )
659+ . chain (
660+ module
661+ . path_to_root ( db)
662+ . into_iter ( )
663+ . filter_map ( |it| it. name ( db) )
664+ . rev ( )
665+ . chain ( Some ( name. clone ( ) ) )
666+ . map ( |it| it. display ( db) . to_string ( ) ) ,
667+ )
668+ . join ( "::" )
669+ } ;
670+ if let Some ( only_name) = self . only . as_deref ( ) {
671+ if name. display ( db) . to_string ( ) != only_name && full_name ( ) != only_name {
672+ continue ;
673+ }
674+ }
675+ let mut msg = format ! ( "processing: {}" , full_name( ) ) ;
676+ if verbosity. is_verbose ( ) {
677+ let source = match body_id {
678+ DefWithBody :: Function ( it) => it. source ( db) . map ( |it| it. syntax ( ) . cloned ( ) ) ,
679+ DefWithBody :: Static ( it) => it. source ( db) . map ( |it| it. syntax ( ) . cloned ( ) ) ,
680+ DefWithBody :: Const ( it) => it. source ( db) . map ( |it| it. syntax ( ) . cloned ( ) ) ,
681+ DefWithBody :: Variant ( it) => it. source ( db) . map ( |it| it. syntax ( ) . cloned ( ) ) ,
682+ DefWithBody :: InTypeConst ( _) => unimplemented ! ( ) ,
683+ } ;
684+ if let Some ( src) = source {
685+ let original_file = src. file_id . original_file ( db) ;
686+ let path = vfs. file_path ( original_file) ;
687+ let syntax_range = src. value . text_range ( ) ;
688+ format_to ! ( msg, " ({} {:?})" , path, syntax_range) ;
689+ }
690+ }
691+ if verbosity. is_spammy ( ) {
692+ bar. println ( msg. to_string ( ) ) ;
693+ }
694+ bar. set_message ( & msg) ;
695+ let ( body, sm) = db. body_with_source_map ( body_id. into ( ) ) ;
696+ // endregion:patterns
697+ bar. inc ( 1 ) ;
698+ }
621699
622- eprintln ! ( "{:<20} {}" , "Inference:" , inference_sw. elapsed( ) ) ;
700+ bar. finish_and_clear ( ) ;
701+ let body_lowering_time = sw. elapsed ( ) ;
702+ eprintln ! ( "{:<20} {}" , "Body lowering:" , body_lowering_time) ;
703+ report_metric ( "body lowering time" , body_lowering_time. time . as_millis ( ) as u64 , "ms" ) ;
623704 }
624705
625706 fn stop_watch ( & self ) -> StopWatch {
0 commit comments