Move default blocks into jump tables (#5756)

Move the default block off of the br_table instrution, and into the JumpTable that it references.
This commit is contained in:
Trevor Elliott
2023-02-10 08:53:30 -08:00
committed by GitHub
parent 49613be393
commit d99783fc91
21 changed files with 118 additions and 175 deletions

View File

@@ -129,9 +129,7 @@ impl<'short, 'long> InstBuilderBase<'short> for FuncInstBuilder<'short, 'long> {
}
}
ir::InstructionData::BranchTable {
table, destination, ..
} => {
ir::InstructionData::BranchTable { table, .. } => {
// Unlike all other jumps/branches, jump tables are
// capable of having the same successor appear
// multiple times, so we must deduplicate.
@@ -144,9 +142,12 @@ impl<'short, 'long> InstBuilderBase<'short> for FuncInstBuilder<'short, 'long> {
.jump_tables
.get(*table)
.expect("you are referencing an undeclared jump table")
.iter()
.filter(|&dest_block| unique.insert(*dest_block))
.all_branches()
{
if !unique.insert(*dest_block) {
continue;
}
// Call `declare_block_predecessor` instead of `declare_successor` for
// avoiding the borrow checker.
self.builder
@@ -154,7 +155,6 @@ impl<'short, 'long> InstBuilderBase<'short> for FuncInstBuilder<'short, 'long> {
.ssa
.declare_block_predecessor(*dest_block, inst);
}
self.builder.declare_successor(*destination, inst);
}
inst => debug_assert!(!inst.opcode().is_branch()),