diff --git a/src/coreclr/jit/codegenloongarch64.cpp b/src/coreclr/jit/codegenloongarch64.cpp index 38e9899090b3b7..aef35cf49b660e 100644 --- a/src/coreclr/jit/codegenloongarch64.cpp +++ b/src/coreclr/jit/codegenloongarch64.cpp @@ -974,7 +974,8 @@ void CodeGen::instGen_Set_Reg_To_Imm(emitAttr size, if (EA_IS_RELOC(size)) { assert(genIsValidIntReg(reg)); - emit->emitIns_R_AI(INS_bl, size, reg, imm); // for example: EA_PTR_DSP_RELOC + // for example: EA_PTR_DSP_RELOC + emit->emitIns_R_AI(INS_bl, size, reg, imm DEBUGARG(targetHandle) DEBUGARG(gtFlags)); } else { @@ -3698,7 +3699,9 @@ void CodeGen::genEmitHelperCall(unsigned helper, int argSize, emitAttr retSize, if (m_compiler->opts.compReloc) { // TODO-LOONGARCH64: here the bl is special flag rather than a real instruction. - GetEmitter()->emitIns_R_AI(INS_bl, EA_PTR_DSP_RELOC, callTargetReg, (ssize_t)pAddr); + GetEmitter()->emitIns_R_AI(INS_bl, EA_PTR_DSP_RELOC, callTargetReg, + (ssize_t)pAddr DEBUGARG((size_t)m_compiler->eeFindHelper(helper)) + DEBUGARG(GTF_ICON_METHOD_HDL)); } else { diff --git a/src/coreclr/jit/emitloongarch64.cpp b/src/coreclr/jit/emitloongarch64.cpp index 63b0b0fe1b5a44..ab2cf27b802f5f 100644 --- a/src/coreclr/jit/emitloongarch64.cpp +++ b/src/coreclr/jit/emitloongarch64.cpp @@ -2094,6 +2094,11 @@ void emitter::emitIns_R_AI(instruction ins, id->idOpSize(EA_PTRSIZE); } +#ifdef DEBUG + id->idDebugOnlyInfo()->idMemCookie = targetHandle; + id->idDebugOnlyInfo()->idFlags = gtFlags; +#endif + id->idAddr()->iiaAddr = (BYTE*)addr; id->idCodeSize(8); @@ -3881,6 +3886,12 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp) // for stores, but we ignore those cases here.) if (emitInsMayWriteToGCReg(ins)) // True if "id->idIns()" writes to a register than can hold GC ref. { + if (INS_OPTS_RELOC == id->idInsOpt()) + { + // For relocation case (pcalau12i + addi.d/ld.d), the GCReg should update after calculation completed. + dstRW2 += 4; + } + // We assume that "idReg1" is the primary destination register for all instructions if (id->idGCref() != GCT_NONE) {