@@ -84,17 +84,20 @@ impl ControlFlowGraph {
8484 func_def_body : & FuncDefBody ,
8585 ) -> impl DoubleEndedIterator < Item = Region > {
8686 let mut post_order = SmallVec :: < [ _ ; 8 ] > :: new ( ) ;
87- self . traverse_whole_func ( func_def_body, & mut TraversalState {
88- incoming_edge_counts : EntityOrientedDenseMap :: new ( ) ,
87+ self . traverse_whole_func (
88+ func_def_body,
89+ & mut TraversalState {
90+ incoming_edge_counts : EntityOrientedDenseMap :: new ( ) ,
8991
90- pre_order_visit : |_| { } ,
91- post_order_visit : |region| post_order. push ( region) ,
92+ pre_order_visit : |_| { } ,
93+ post_order_visit : |region| post_order. push ( region) ,
9294
93- // NOTE(eddyb) this doesn't impact semantics, but combined with
94- // the final reversal, it should keep targets in the original
95- // order in the cases when they didn't get deduplicated.
96- reverse_targets : true ,
97- } ) ;
95+ // NOTE(eddyb) this doesn't impact semantics, but combined with
96+ // the final reversal, it should keep targets in the original
97+ // order in the cases when they didn't get deduplicated.
98+ reverse_targets : true ,
99+ } ,
100+ ) ;
98101 post_order. into_iter ( ) . rev ( )
99102 }
100103}
@@ -906,10 +909,13 @@ impl DeferredEdgeBundleSet {
906909 Err ( new_deferred) => {
907910 assert ! ( new_deferred. edge_bundle. target == target) ;
908911 assert ! ( matches!( new_deferred. condition, LazyCond :: True ) ) ;
909- ( None , DeferredEdgeBundleSet :: Always {
910- target,
911- edge_bundle : new_deferred. edge_bundle . with_target ( ( ) ) ,
912- } )
912+ (
913+ None ,
914+ DeferredEdgeBundleSet :: Always {
915+ target,
916+ edge_bundle : new_deferred. edge_bundle . with_target ( ( ) ) ,
917+ } ,
918+ )
913919 }
914920 }
915921 }
@@ -918,14 +924,17 @@ impl DeferredEdgeBundleSet {
918924 for ( i, ( & target, deferred) ) in target_to_deferred. iter_mut ( ) . enumerate ( ) {
919925 // HACK(eddyb) "take" `deferred` so it can be passed to
920926 // `matches` (and put back if that returned `Err`).
921- let taken_deferred = mem:: replace ( deferred, DeferredEdgeBundle {
922- condition : LazyCond :: False ,
923- edge_bundle : IncomingEdgeBundle {
924- target : Default :: default ( ) ,
925- accumulated_count : Default :: default ( ) ,
926- target_inputs : Default :: default ( ) ,
927+ let taken_deferred = mem:: replace (
928+ deferred,
929+ DeferredEdgeBundle {
930+ condition : LazyCond :: False ,
931+ edge_bundle : IncomingEdgeBundle {
932+ target : Default :: default ( ) ,
933+ accumulated_count : Default :: default ( ) ,
934+ target_inputs : Default :: default ( ) ,
935+ } ,
927936 } ,
928- } ) ;
937+ ) ;
929938
930939 match matches ( taken_deferred. with_target ( target) ) {
931940 Ok ( x) => {
@@ -1111,13 +1120,16 @@ impl<'a> Structurizer<'a> {
11111120 // in the general case (but special-cased because this is very
11121121 // close to being structurizable, just needs a bit of plumbing).
11131122 let mut control_inst_on_exit_from = EntityOrientedDenseMap :: new ( ) ;
1114- control_inst_on_exit_from. insert ( self . func_def_body . body , ControlInst {
1115- attrs : AttrSet :: default ( ) ,
1116- kind : ControlInstKind :: Unreachable ,
1117- inputs : [ ] . into_iter ( ) . collect ( ) ,
1118- targets : [ ] . into_iter ( ) . collect ( ) ,
1119- target_inputs : FxIndexMap :: default ( ) ,
1120- } ) ;
1123+ control_inst_on_exit_from. insert (
1124+ self . func_def_body . body ,
1125+ ControlInst {
1126+ attrs : AttrSet :: default ( ) ,
1127+ kind : ControlInstKind :: Unreachable ,
1128+ inputs : [ ] . into_iter ( ) . collect ( ) ,
1129+ targets : [ ] . into_iter ( ) . collect ( ) ,
1130+ target_inputs : FxIndexMap :: default ( ) ,
1131+ } ,
1132+ ) ;
11211133 self . func_def_body . unstructured_cfg = Some ( ControlFlowGraph {
11221134 control_inst_on_exit_from,
11231135 loop_merge_to_loop_header : Default :: default ( ) ,
@@ -1133,13 +1145,15 @@ impl<'a> Structurizer<'a> {
11331145
11341146 _ => {
11351147 // Repair all the regions that remain unclaimed, including the body.
1136- let structurize_region_state = mem:: take ( & mut self . structurize_region_state )
1137- . into_iter ( )
1138- . chain ( [ ( self . func_def_body . body , StructurizeRegionState :: Ready {
1139- accumulated_backedge_count : IncomingEdgeCount :: default ( ) ,
1148+ let structurize_region_state =
1149+ mem:: take ( & mut self . structurize_region_state ) . into_iter ( ) . chain ( [ (
1150+ self . func_def_body . body ,
1151+ StructurizeRegionState :: Ready {
1152+ accumulated_backedge_count : IncomingEdgeCount :: default ( ) ,
11401153
1141- region_deferred_edges : func_body_deferred_edges,
1142- } ) ] ) ;
1154+ region_deferred_edges : func_body_deferred_edges,
1155+ } ,
1156+ ) ] ) ;
11431157 for ( target, state) in structurize_region_state {
11441158 if let StructurizeRegionState :: Ready { region_deferred_edges, .. } = state {
11451159 self . rebuild_cfg_from_unclaimed_region_deferred_edges (
@@ -1537,11 +1551,13 @@ impl<'a> Structurizer<'a> {
15371551 . map ( |backedge| backedge. accumulated_count )
15381552 . unwrap_or_default ( ) ;
15391553
1540- let old_state =
1541- self . structurize_region_state . insert ( region, StructurizeRegionState :: Ready {
1554+ let old_state = self . structurize_region_state . insert (
1555+ region,
1556+ StructurizeRegionState :: Ready {
15421557 accumulated_backedge_count,
15431558 region_deferred_edges : deferred_edges,
1544- } ) ;
1559+ } ,
1560+ ) ;
15451561 if !matches ! ( old_state, Some ( StructurizeRegionState :: InProgress ) ) {
15461562 unreachable ! (
15471563 "cfg::Structurizer::structurize_region: \
0 commit comments