From 33e0d056453ee1cb66bf210f21b786f0f7ed70ab Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Mon, 6 Jul 2020 15:42:31 +0200 Subject: [PATCH] machinst x64: have cmov modify its destination operand; This is tricky: the control flow implicitly implied by the operand makes it so that the output register may be undefined, if we mark it only as a "def". Make it a "mod" instead, which matches our usage in the codebase, and will make it crash if the output operand isn't unconditionally defined before the instruction. --- cranelift/codegen/src/isa/x64/inst/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cranelift/codegen/src/isa/x64/inst/mod.rs b/cranelift/codegen/src/isa/x64/inst/mod.rs index bb50f85f11..fc01c3e832 100644 --- a/cranelift/codegen/src/isa/x64/inst/mod.rs +++ b/cranelift/codegen/src/isa/x64/inst/mod.rs @@ -905,7 +905,7 @@ fn x64_get_regs(inst: &Inst, collector: &mut RegUsageCollector) { } Inst::Cmove { src, dst, .. } => { src.get_regs_as_uses(collector); - collector.add_def(*dst); + collector.add_mod(*dst); } Inst::Push64 { src } => { src.get_regs_as_uses(collector); @@ -1126,7 +1126,7 @@ fn x64_map_regs(inst: &mut Inst, mapper: &RUM) { .. } => { src.map_uses(mapper); - map_def(mapper, dst) + map_mod(mapper, dst) } Inst::Push64 { ref mut src } => src.map_uses(mapper), Inst::Pop64 { ref mut dst } => {