Skip to content

Commit

Permalink
[vm, compiler] Account for pair locations in MoveArgumentInstr on ris…
Browse files Browse the repository at this point in the history
…cv32.

TEST=dart-fuzz
Bug: #55181
Change-Id: I075f0b341858b8fcf408378dea1473bab07a87ec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357214
Reviewed-by: Alexander Aprelev <[email protected]>
Commit-Queue: Ryan Macnak <[email protected]>
  • Loading branch information
rmacnak-google authored and Commit Queue committed Mar 13, 2024
1 parent fb21055 commit 52f7908
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions runtime/vm/compiler/backend/il_riscv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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();
}
Expand Down

0 comments on commit 52f7908

Please sign in to comment.