File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
compiler/rustc_middle/src/mir Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ struct Cache {
27
27
switch_sources : OnceCell < SwitchSources > ,
28
28
is_cyclic : OnceCell < bool > ,
29
29
postorder : OnceCell < Vec < BasicBlock > > ,
30
+ reverse_postorder : OnceCell < Vec < BasicBlock > > ,
30
31
dominators : OnceCell < Dominators < BasicBlock > > ,
31
32
}
32
33
@@ -70,6 +71,17 @@ impl<'tcx> BasicBlocks<'tcx> {
70
71
} )
71
72
}
72
73
74
+ /// Returns basic blocks in a reverse postorder.
75
+ #[ inline]
76
+ pub fn reverse_postorder ( & self ) -> & [ BasicBlock ] {
77
+ self . cache . reverse_postorder . get_or_init ( || {
78
+ let mut rpo: Vec < _ > =
79
+ Postorder :: new ( & self . basic_blocks , START_BLOCK ) . map ( |( bb, _) | bb) . collect ( ) ;
80
+ rpo. reverse ( ) ;
81
+ rpo
82
+ } )
83
+ }
84
+
73
85
/// `switch_sources()[&(target, switch)]` returns a list of switch
74
86
/// values that lead to a `target` block from a `switch` block.
75
87
#[ inline]
You can’t perform that action at this time.
0 commit comments