|
@ -96,11 +96,9 @@ 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.dfg.insts[inst] |
|
|
self.func |
|
|
.branch_destination(&self.func.dfg.jump_tables) |
|
|
.block_successors(block) |
|
|
.iter() |
|
|
|
|
|
// Heuristic: chase the children in reverse. This puts
|
|
|
// Heuristic: chase the children in reverse. This puts
|
|
|
// the first successor block first in the postorder, all
|
|
|
// the first successor block first in the postorder, all
|
|
|
// other things being equal, which tends to prioritize
|
|
|
// other things being equal, which tends to prioritize
|
|
@ -111,7 +109,6 @@ impl Iterator for DfsIter<'_> { |
|
|
// purely for other consumers of the postorder we cache
|
|
|
// purely for other consumers of the postorder we cache
|
|
|
// here.
|
|
|
// here.
|
|
|
.rev() |
|
|
.rev() |
|
|
.map(|block| block.block(&self.func.dfg.value_lists)) |
|
|
|
|
|
// This is purely an optimization to avoid additional
|
|
|
// This is purely an optimization to avoid additional
|
|
|
// iterations of the loop, and is not required; it's
|
|
|
// iterations of the loop, and is not required; it's
|
|
|
// merely inlining the check from the outer conditional
|
|
|
// merely inlining the check from the outer conditional
|
|
@ -121,7 +118,6 @@ impl Iterator for DfsIter<'_> { |
|
|
.map(|block| (Event::Enter, block)), |
|
|
.map(|block| (Event::Enter, block)), |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Some((event, block)) |
|
|
Some((event, block)) |
|
|
} |
|
|
} |
|
|