Skip to content

Commit

Permalink
[RISC-V] Fix GitHub_* tests (#88640)
Browse files Browse the repository at this point in the history
* [RISC-V] Fix GitHub_17585 test failure

* [RISC-V] Fix GitHub_23147 test failure

* [RISC-V] Remove lvIsHfaRegArg assertion

* [RISC-V] Update
  • Loading branch information
clamp03 authored Jul 16, 2023
1 parent 6c29448 commit 44c46e1
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 22 deletions.
26 changes: 21 additions & 5 deletions src/coreclr/jit/codegenriscv64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6515,7 +6515,14 @@ void CodeGen::genJmpMethod(GenTree* jmp)
// Must be <= 16 bytes or else it wouldn't be passed in registers, except for HFA,
// which can be bigger (and is handled above).
noway_assert(EA_SIZE_IN_BYTES(varDsc->lvSize()) <= 16);
loadType = varDsc->GetLayout()->GetGCPtrType(0);
if (emitter::isFloatReg(argReg))
{
loadType = varDsc->lvIs4Field1 ? TYP_FLOAT : TYP_DOUBLE;
}
else
{
loadType = varDsc->GetLayout()->GetGCPtrType(0);
}
}
else
{
Expand All @@ -6532,14 +6539,23 @@ void CodeGen::genJmpMethod(GenTree* jmp)
regSet.AddMaskVars(genRegMask(argReg));
gcInfo.gcMarkRegPtrVal(argReg, loadType);

if (compiler->lvaIsMultiregStruct(varDsc, compiler->info.compIsVarArgs))
if (varDsc->GetOtherArgReg() < REG_STK)
{
// Restore the second register.
argRegNext = genRegArgNext(argReg);
argRegNext = varDsc->GetOtherArgReg();

if (emitter::isFloatReg(argRegNext))
{
loadType = varDsc->lvIs4Field2 ? TYP_FLOAT : TYP_DOUBLE;
}
else
{
loadType = varDsc->GetLayout()->GetGCPtrType(1);
}

loadType = varDsc->GetLayout()->GetGCPtrType(1);
loadSize = emitActualTypeSize(loadType);
GetEmitter()->emitIns_R_S(ins_Load(loadType), loadSize, argRegNext, varNum, TARGET_POINTER_SIZE);
int offs = loadSize == EA_4BYTE ? 4 : 8;
GetEmitter()->emitIns_R_S(ins_Load(loadType), loadSize, argRegNext, varNum, offs);

regSet.AddMaskVars(genRegMask(argRegNext));
gcInfo.gcMarkRegPtrVal(argRegNext, loadType);
Expand Down
31 changes: 14 additions & 17 deletions src/coreclr/vm/riscv64/virtualcallstubcpu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ struct DispatchStub
private:
friend struct DispatchHolder;

DWORD _entryPoint[9];
DWORD _pad;
DWORD _entryPoint[8];
size_t _expectedMT;
PCODE _implTarget;
PCODE _failTarget;
Expand All @@ -102,30 +101,28 @@ struct DispatchHolder
void Initialize(DispatchHolder* pDispatchHolderRX, PCODE implTarget, PCODE failTarget, size_t expectedMT)
{
// auipc t4,0
// addi t4, t4, 36
// ld t0,0(a0) ; methodTable from object in $a0
// ld t6,0(t4) // t6 _expectedMT
// bne t6, t0, failLabel
// ld t4, 8(t4) // t4 _implTarget
// ld t0, 0(a0) // methodTable from object in $a0
// ld t6, 32(t4) // t6 _expectedMT
// bne t6, t0, failLabel
// ld t4, 40(t4) // t4 _implTarget
// jalr x0, t4, 0
// failLabel:
// ld t4, 16(t4) // t4 _failTarget
// ld t4, 48(t4) // t4 _failTarget
// jalr x0, t4, 0
//
//
// _expectedMT
// _implTarget
// _failTarget

_stub._entryPoint[0] = DISPATCH_STUB_FIRST_DWORD; // auipc t4,0 // 0x00000e97
_stub._entryPoint[1] = 0x028e8e93; // addi t4, t4, 40
_stub._entryPoint[2] = 0x00053283; // ld t0, 0(a0) //; methodTable from object in $a0
_stub._entryPoint[3] = 0x000ebf83; // ld r6, 0(t4) // t6 _expectedMT
_stub._entryPoint[4] = 0x005f9663; // bne t6, t0, failLabel
_stub._entryPoint[5] = 0x008ebe83; // ld t4, 8(t4) // t4 _implTarget
_stub._entryPoint[6] = 0x000e8067; // jalr x0, t4, 0
_stub._entryPoint[7] = 0x010ebe83; // ld t4, 16(t4) // t4 _failTarget
_stub._entryPoint[8] = 0x000e8067; // jalr x0, t4, 0
_stub._entryPoint[0] = DISPATCH_STUB_FIRST_DWORD; // auipc t4,0 // 0x00000e97
_stub._entryPoint[1] = 0x00053283; // ld t0, 0(a0) // methodTable from object in $a0
_stub._entryPoint[2] = 0x020ebf83; // ld t6, 32(t4) // t6 _expectedMT
_stub._entryPoint[3] = 0x005f9663; // bne t6, t0, failLabel
_stub._entryPoint[4] = 0x028ebe83; // ld t4, 40(t4) // t4 _implTarget
_stub._entryPoint[5] = 0x000e8067; // jalr x0, t4, 0
_stub._entryPoint[6] = 0x030ebe83; // ld t4, 48(t4) // t4 _failTarget
_stub._entryPoint[7] = 0x000e8067; // jalr x0, t4, 0

_stub._expectedMT = expectedMT;
_stub._implTarget = implTarget;
Expand Down

0 comments on commit 44c46e1

Please sign in to comment.