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:
@@ -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()),
|
||||
|
||||
Reference in New Issue
Block a user