Skip to content

Commit

Permalink
Emit fixed use constraints for indirect call destinations
Browse files Browse the repository at this point in the history
Work around bytecodealliance/regalloc2#145 in
the same way that we do for tail calls -- using a fixed use constraint.
  • Loading branch information
elliottt committed Mar 11, 2024
1 parent 99ea051 commit 1ed4a14
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
20 changes: 14 additions & 6 deletions cranelift/codegen/src/isa/aarch64/inst/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -867,12 +867,20 @@ fn aarch64_get_operands<F: Fn(VReg) -> VReg>(inst: &Inst, collector: &mut Operan
collector.reg_clobbers(info.clobbers);
}
&Inst::CallInd { ref info, .. } => {
if info.callee_callconv == CallConv::Tail {
// TODO(https://github.com/bytecodealliance/regalloc2/issues/145):
// This shouldn't be a fixed register constraint.
collector.reg_fixed_use(info.rn, xreg(1));
} else {
collector.reg_use(info.rn);
match info.callee_callconv {
CallConv::Tail => {
// TODO(https://github.com/bytecodealliance/regalloc2/issues/145):
// This shouldn't be a fixed register constraint.
collector.reg_fixed_use(info.rn, xreg(1));
}
CallConv::Winch => {
// TODO(https://github.com/bytecodealliance/regalloc2/issues/145):
// This shouldn't be a fixed register constraint.
collector.reg_fixed_use(info.rn, xreg(1));
}
_ => {
collector.reg_use(info.rn);
}
}
for u in &info.uses {
collector.reg_fixed_use(u.vreg, u.preg);
Expand Down
5 changes: 5 additions & 0 deletions cranelift/codegen/src/isa/x64/inst/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2370,6 +2370,11 @@ fn x64_get_operands<F: Fn(VReg) -> VReg>(inst: &Inst, collector: &mut OperandCol
// This shouldn't be a fixed register constraint.
collector.reg_fixed_use(*reg, regs::r15())
}
RegMem::Reg { reg } if info.callee_conv == CallConv::Winch => {
// TODO(https://github.com/bytecodealliance/regalloc2/issues/145):
// This shouldn't be a fixed register constraint.
collector.reg_fixed_use(*reg, regs::r15())
}
_ => dest.get_operands(collector),
}
for u in &info.uses {
Expand Down

0 comments on commit 1ed4a14

Please sign in to comment.