From 52f7908b2762b28bac7f41d36d584fb41f8a9793 Mon Sep 17 00:00:00 2001 From: Ryan Macnak Date: Wed, 13 Mar 2024 22:32:11 +0000 Subject: [PATCH] [vm, compiler] Account for pair locations in MoveArgumentInstr on riscv32. TEST=dart-fuzz Bug: https://github.com/dart-lang/sdk/issues/55181 Change-Id: I075f0b341858b8fcf408378dea1473bab07a87ec Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357214 Reviewed-by: Alexander Aprelev Commit-Queue: Ryan Macnak --- runtime/vm/compiler/backend/il_riscv.cc | 33 ++++++++++++++++--------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/runtime/vm/compiler/backend/il_riscv.cc b/runtime/vm/compiler/backend/il_riscv.cc index 0c6c5a1381a1..238cd635c1cf 100644 --- a/runtime/vm/compiler/backend/il_riscv.cc +++ b/runtime/vm/compiler/backend/il_riscv.cc @@ -463,19 +463,22 @@ void MoveArgumentInstr::EmitNativeCode(FlowGraphCompiler* compiler) { ASSERT(compiler->is_optimizing()); const Location value = compiler->RebaseIfImprovesAddressing(locs()->in(0)); - const intptr_t offset = - location().stack_index() * compiler::target::kWordSize; if (value.IsRegister()) { - __ StoreToOffset(value.reg(), SP, offset); + __ StoreToOffset(value.reg(), SP, + location().stack_index() * compiler::target::kWordSize); #if XLEN == 32 } else if (value.IsPairLocation()) { __ StoreToOffset(value.AsPairLocation()->At(1).reg(), SP, - offset + compiler::target::kWordSize); - __ StoreToOffset(value.AsPairLocation()->At(0).reg(), SP, offset); + location().AsPairLocation()->At(1).stack_index() * + compiler::target::kWordSize); + __ StoreToOffset(value.AsPairLocation()->At(0).reg(), SP, + location().AsPairLocation()->At(0).stack_index() * + compiler::target::kWordSize); #endif } else if (value.IsConstant()) { if (representation() == kUnboxedDouble) { ASSERT(value.constant_instruction()->HasZeroRepresentation()); + intptr_t offset = location().stack_index() * compiler::target::kWordSize; #if XLEN == 32 __ StoreToOffset(ZR, SP, offset + compiler::target::kWordSize); __ StoreToOffset(ZR, SP, offset); @@ -485,10 +488,15 @@ void MoveArgumentInstr::EmitNativeCode(FlowGraphCompiler* compiler) { } else if (representation() == kUnboxedInt64) { ASSERT(value.constant_instruction()->HasZeroRepresentation()); #if XLEN == 32 - __ StoreToOffset(ZR, SP, offset + compiler::target::kWordSize); - __ StoreToOffset(ZR, SP, offset); + __ StoreToOffset(ZR, SP, + location().AsPairLocation()->At(1).stack_index() * + compiler::target::kWordSize); + __ StoreToOffset(ZR, SP, + location().AsPairLocation()->At(0).stack_index() * + compiler::target::kWordSize); #else - __ StoreToOffset(ZR, SP, offset); + __ StoreToOffset(ZR, SP, + location().stack_index() * compiler::target::kWordSize); #endif } else { ASSERT(representation() == kTagged); @@ -502,14 +510,17 @@ void MoveArgumentInstr::EmitNativeCode(FlowGraphCompiler* compiler) { reg = TMP; __ LoadObject(TMP, constant); } - __ StoreToOffset(reg, SP, offset); + __ StoreToOffset(reg, SP, + location().stack_index() * compiler::target::kWordSize); } } else if (value.IsFpuRegister()) { - __ StoreDToOffset(value.fpu_reg(), SP, offset); + __ StoreDToOffset(value.fpu_reg(), SP, + location().stack_index() * compiler::target::kWordSize); } else if (value.IsStackSlot()) { const intptr_t value_offset = value.ToStackSlotOffset(); __ LoadFromOffset(TMP, value.base_reg(), value_offset); - __ StoreToOffset(TMP, SP, offset); + __ StoreToOffset(TMP, SP, + location().stack_index() * compiler::target::kWordSize); } else { UNREACHABLE(); }