refactor BlockLoweringOrder::new (#6255)

Co-authored-by: Falk Zwimpfer <24669719+FalkZ@users.noreply.github.com>
Co-authored-by: Moritz Waser <mzrw.dev@pm.me>
This commit is contained in:
Remo Senekowitsch
2023-04-21 00:24:32 +02:00
committed by GitHub
parent 8376944b3f
commit 1192697c7e

View File

@@ -188,14 +188,10 @@ impl BlockLoweringOrder {
// Step 2: walk the postorder from the domtree in reverse to produce our desired node // Step 2: walk the postorder from the domtree in reverse to produce our desired node
// lowering order, identifying critical edges to split along the way. // lowering order, identifying critical edges to split along the way.
let mut lb_to_bindex = FxHashMap::default();
let mut lowered_order = Vec::new(); let mut lowered_order = Vec::new();
for &block in domtree.cfg_postorder().iter().rev() { for &block in domtree.cfg_postorder().iter().rev() {
let lb = LoweredBlock::Orig { block }; lowered_order.push(LoweredBlock::Orig { block });
let bindex = BlockIndex::new(lowered_order.len());
lb_to_bindex.insert(lb.clone(), bindex);
lowered_order.push(lb);
if block_out_count[block] > 1 { if block_out_count[block] > 1 {
let range = block_succ_range[block].clone(); let range = block_succ_range[block].clone();
@@ -209,14 +205,19 @@ impl BlockLoweringOrder {
succ, succ,
succ_idx: succ_ix as u32, succ_idx: succ_ix as u32,
}; };
let bindex = BlockIndex::new(lowered_order.len());
lb_to_bindex.insert(*lb, bindex);
lowered_order.push(*lb); lowered_order.push(*lb);
} }
} }
} }
} }
let lb_to_bindex = FxHashMap::from_iter(
lowered_order
.iter()
.enumerate()
.map(|(i, &lb)| (lb, BlockIndex::new(i))),
);
// Step 3: build the successor tables given the lowering order. We can't perform this step // Step 3: build the successor tables given the lowering order. We can't perform this step
// during the creation of `lowering_order`, as we need `lb_to_bindex` to be fully populated // during the creation of `lowering_order`, as we need `lb_to_bindex` to be fully populated
// first. // first.