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> {
52
52
BasicBlocks { basic_blocks, cache : Cache :: default ( ) }
53
53
}
54
54
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]
55
64
pub fn dominators ( & self ) -> & Dominators < BasicBlock > {
56
65
self . cache . dominators . get_or_init ( || dominators ( self ) )
57
66
}
Original file line number Diff line number Diff line change @@ -446,6 +446,10 @@ fn mir_promoted(
446
446
pm:: Optimizations :: Allowed ,
447
447
) ;
448
448
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
+
449
453
lint_tail_expr_drop_order:: run_lint ( tcx, def, & body) ;
450
454
451
455
let promoted = promote_pass. promoted_fragments . into_inner ( ) ;
You can’t perform that action at this time.
0 commit comments