|
@ -96,31 +96,27 @@ impl Iterator for DfsIter<'_> { |
|
|
|
|
|
|
|
|
if event == Event::Enter && self.dfs.seen.insert(block) { |
|
|
if event == Event::Enter && self.dfs.seen.insert(block) { |
|
|
self.dfs.stack.push((Event::Exit, block)); |
|
|
self.dfs.stack.push((Event::Exit, block)); |
|
|
if let Some(inst) = self.func.layout.last_inst(block) { |
|
|
self.dfs.stack.extend( |
|
|
self.dfs.stack.extend( |
|
|
self.func |
|
|
self.func.dfg.insts[inst] |
|
|
.block_successors(block) |
|
|
.branch_destination(&self.func.dfg.jump_tables) |
|
|
// Heuristic: chase the children in reverse. This puts
|
|
|
.iter() |
|
|
// the first successor block first in the postorder, all
|
|
|
// Heuristic: chase the children in reverse. This puts
|
|
|
// other things being equal, which tends to prioritize
|
|
|
// the first successor block first in the postorder, all
|
|
|
// loop backedges over out-edges, putting the edge-block
|
|
|
// other things being equal, which tends to prioritize
|
|
|
// closer to the loop body and minimizing live-ranges in
|
|
|
// loop backedges over out-edges, putting the edge-block
|
|
|
// linear instruction space. This heuristic doesn't have
|
|
|
// closer to the loop body and minimizing live-ranges in
|
|
|
// any effect on the computation of dominators, and is
|
|
|
// linear instruction space. This heuristic doesn't have
|
|
|
// purely for other consumers of the postorder we cache
|
|
|
// any effect on the computation of dominators, and is
|
|
|
// here.
|
|
|
// purely for other consumers of the postorder we cache
|
|
|
.rev() |
|
|
// here.
|
|
|
// This is purely an optimization to avoid additional
|
|
|
.rev() |
|
|
// iterations of the loop, and is not required; it's
|
|
|
.map(|block| block.block(&self.func.dfg.value_lists)) |
|
|
// merely inlining the check from the outer conditional
|
|
|
// This is purely an optimization to avoid additional
|
|
|
// of this case to avoid the extra loop iteration. This
|
|
|
// iterations of the loop, and is not required; it's
|
|
|
// also avoids potential excess stack growth.
|
|
|
// merely inlining the check from the outer conditional
|
|
|
.filter(|block| !self.dfs.seen.contains(*block)) |
|
|
// of this case to avoid the extra loop iteration. This
|
|
|
.map(|block| (Event::Enter, block)), |
|
|
// also avoids potential excess stack growth.
|
|
|
); |
|
|
.filter(|block| !self.dfs.seen.contains(*block)) |
|
|
|
|
|
.map(|block| (Event::Enter, block)), |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Some((event, block)) |
|
|
Some((event, block)) |
|
|