Rework br_table to use BlockCall (#5731)

Rework br_table to use BlockCall, allowing us to avoid adding new nodes during ssa construction to hold block arguments. Additionally, many places where we previously matched on InstructionData to extract branch destinations can be replaced with a use of branch_destination or branch_destination_mut.
This commit is contained in:
Trevor Elliott
2023-02-16 09:23:27 -08:00
committed by GitHub
parent c3c16eb207
commit 80c147d9c0
26 changed files with 475 additions and 269 deletions

View File

@@ -422,7 +422,7 @@ impl Mutator for ReplaceBlockParamWithConst {
// Remove parameters in branching instructions that point to this block
for pred in cfg.pred_iter(self.block) {
let dfg = &mut func.dfg;
for branch in dfg.insts[pred.inst].branch_destination_mut().into_iter() {
for branch in dfg.insts[pred.inst].branch_destination_mut(&mut dfg.jump_tables) {
if branch.block(&dfg.value_lists) == self.block {
branch.remove(param_index, &mut dfg.value_lists);
}
@@ -711,7 +711,7 @@ impl Mutator for MergeBlocks {
// If the branch instruction that lead us to this block wasn't an unconditional jump, then
// we have a conditional jump sequence that we should not break.
let branch_dests = func.dfg.insts[pred.inst].branch_destination();
let branch_dests = func.dfg.insts[pred.inst].branch_destination(&func.dfg.jump_tables);
if branch_dests.len() != 1 {
return Some((
func,