machinst: Steal the used/defs Sets when emitting a call in ABICall;

This commit is contained in:
Benjamin Bouvier
2020-05-06 19:10:24 +02:00
parent 19d8a7f1fb
commit 528d3c1355
3 changed files with 8 additions and 4 deletions

View File

@@ -72,6 +72,7 @@ use alloc::vec::Vec;
use regalloc::{RealReg, Reg, RegClass, Set, SpillSlot, Writable}; use regalloc::{RealReg, Reg, RegClass, Set, SpillSlot, Writable};
use core::mem;
use log::{debug, trace}; use log::{debug, trace};
/// A location for an argument or return value. /// A location for an argument or return value.
@@ -1267,8 +1268,11 @@ impl ABICall for AArch64ABICall {
} }
} }
fn emit_call<C: LowerCtx<I = Self::I>>(&self, ctx: &mut C) { fn emit_call<C: LowerCtx<I = Self::I>>(&mut self, ctx: &mut C) {
let (uses, defs) = (self.uses.clone(), self.defs.clone()); let (uses, defs) = (
mem::replace(&mut self.uses, Set::empty()),
mem::replace(&mut self.defs, Set::empty()),
);
match &self.dest { match &self.dest {
&CallDest::ExtName(ref name, RelocDistance::Near) => ctx.emit(Inst::Call { &CallDest::ExtName(ref name, RelocDistance::Near) => ctx.emit(Inst::Call {
dest: name.clone(), dest: name.clone(),

View File

@@ -1263,7 +1263,7 @@ pub(crate) fn lower_insn_to_regs<C: LowerCtx<I = Inst>>(ctx: &mut C, insn: IRIns
Opcode::Call | Opcode::CallIndirect => { Opcode::Call | Opcode::CallIndirect => {
let loc = ctx.srcloc(insn); let loc = ctx.srcloc(insn);
let (abi, inputs) = match op { let (mut abi, inputs) = match op {
Opcode::Call => { Opcode::Call => {
let (extname, dist) = ctx.call_target(insn).unwrap(); let (extname, dist) = ctx.call_target(insn).unwrap();
let extname = extname.clone(); let extname = extname.clone();

View File

@@ -167,5 +167,5 @@ pub trait ABICall {
/// registers are also logically defs, but should never be read; their /// registers are also logically defs, but should never be read; their
/// values are "defined" (to the regalloc) but "undefined" in every other /// values are "defined" (to the regalloc) but "undefined" in every other
/// sense.) /// sense.)
fn emit_call<C: LowerCtx<I = Self::I>>(&self, ctx: &mut C); fn emit_call<C: LowerCtx<I = Self::I>>(&mut self, ctx: &mut C);
} }