File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,15 @@ impl<'tcx> BasicBlocks<'tcx> {
5252 BasicBlocks { basic_blocks, cache : Cache :: default ( ) }
5353 }
5454
55+ /// Force caching of traversals.
56+ pub fn cache_traversals ( & self ) {
57+ let _ = self . predecessors ( ) ;
58+ let _ = self . switch_sources ( ) ;
59+ let _ = self . reverse_postorder ( ) ;
60+ let _ = self . dominators ( ) ;
61+ }
62+
63+ #[ inline]
5564 pub fn dominators ( & self ) -> & Dominators < BasicBlock > {
5665 self . cache . dominators . get_or_init ( || dominators ( self ) )
5766 }
Original file line number Diff line number Diff line change @@ -446,6 +446,10 @@ fn mir_promoted(
446446 pm:: Optimizations :: Allowed ,
447447 ) ;
448448
449+ // The returned MIR will be used for analyses. Make sure that the traversals are computed
450+ // early, so we don't have to re-run them.
451+ body. basic_blocks . cache_traversals ( ) ;
452+
449453 lint_tail_expr_drop_order:: run_lint ( tcx, def, & body) ;
450454
451455 let promoted = promote_pass. promoted_fragments . into_inner ( ) ;
You can’t perform that action at this time.
0 commit comments