From 49900481cb1ed5f30cd541e3885b6082b1572312 Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Wed, 24 May 2023 13:44:53 +0100 Subject: [PATCH] Handle dedicated scratch registers in the redundant move eliminator When a dedicated scratch register is provided by the environment, the redundant move eliminator needs to assume that this register can be clobbered by any instruction. This register can't be specified as a clobber because it is also used by jump instructions which cannot have operands. --- src/ion/moves.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ion/moves.rs b/src/ion/moves.rs index 5e0abd8d..5bd8031e 100644 --- a/src/ion/moves.rs +++ b/src/ion/moves.rs @@ -796,6 +796,13 @@ impl<'a, F: Function> Env<'a, F> { for reg in this.func.inst_clobbers(inst) { redundant_moves.clear_alloc(Allocation::reg(reg)); } + // The dedicated scratch registers may be clobbered by any + // instruction. + for reg in this.env.scratch_by_class { + if let Some(reg) = reg { + redundant_moves.clear_alloc(Allocation::reg(reg)); + } + } } }