Skip to content

Commit ef8016a

Browse files
authored
Checker: process defs/clobbers on branches to allow checking of try-calls. (#224)
The regalloc checker previously handled branches specially: it skipped the normal operand-procesing logic because it handles block-call arguments explicitly with parallel moves. However, this is no longer fully correct in the presence of try-calls: these are branches but also have normal uses, defs, and clobbers, so we need to process those normally. The comment noted also that we needed to skip operand processing on branches because edge-moves may come before branches, but I'm not sure that exemption ever made sense: if moves interfere with operands to the branch (e.g. conditional branch inputs) we should catch that too. This simplifies the checker's instruction handling to no longer skip branches' operands, with no other changes (and no changes to the allocator itself). Addresses bytecodealliance/wasmtime#10585 (and will fix once we release with this and pull into Cranelift).
1 parent 3fc2514 commit ef8016a

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

src/checker.rs

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -758,25 +758,22 @@ impl<'a, F: Function> Checker<'a, F> {
758758

759759
/// For each original instruction, create an `Op`.
760760
fn handle_inst(&mut self, block: Block, inst: Inst, out: &Output) {
761-
// Skip normal checks if this is a branch: the blockparams do
762-
// not exist in post-regalloc code, and the edge-moves have to
763-
// be inserted before the branch rather than after.
764-
if !self.f.is_branch(inst) {
765-
let operands: Vec<_> = self.f.inst_operands(inst).iter().cloned().collect();
766-
let allocs: Vec<_> = out.inst_allocs(inst).iter().cloned().collect();
767-
let clobbers: Vec<_> = self.f.inst_clobbers(inst).into_iter().collect();
768-
let checkinst = CheckerInst::Op {
769-
inst,
770-
operands,
771-
allocs,
772-
clobbers,
773-
};
774-
trace!("checker: adding inst {:?}", checkinst);
775-
self.bb_insts.get_mut(&block).unwrap().push(checkinst);
776-
}
777-
// Instead, if this is a branch, emit a ParallelMove on each
778-
// outgoing edge as necessary to handle blockparams.
779-
else {
761+
// Process uses, defs, and clobbers.
762+
let operands: Vec<_> = self.f.inst_operands(inst).iter().cloned().collect();
763+
let allocs: Vec<_> = out.inst_allocs(inst).iter().cloned().collect();
764+
let clobbers: Vec<_> = self.f.inst_clobbers(inst).into_iter().collect();
765+
let checkinst = CheckerInst::Op {
766+
inst,
767+
operands,
768+
allocs,
769+
clobbers,
770+
};
771+
trace!("checker: adding inst {:?}", checkinst);
772+
self.bb_insts.get_mut(&block).unwrap().push(checkinst);
773+
774+
// If this is a branch, emit a ParallelMove on each outgoing
775+
// edge as necessary to handle blockparams.
776+
if self.f.is_branch(inst) {
780777
for (i, &succ) in self.f.block_succs(block).iter().enumerate() {
781778
let args = self.f.branch_blockparams(block, inst, i);
782779
let params = self.f.block_params(succ);

0 commit comments

Comments
 (0)