From 30211c5b4e6820ea8a21d66c2b68c40d7cb07020 Mon Sep 17 00:00:00 2001 From: xuliangyu Date: Fri, 4 Jul 2025 11:28:17 +0800 Subject: [PATCH] [LoongArch64] Adjust the order of genPopCalleeSavedRegisters() and instGen_Set_Reg_To_Imm() in Epilog to fix the GC interruptible range. --- src/coreclr/jit/codegenloongarch64.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/coreclr/jit/codegenloongarch64.cpp b/src/coreclr/jit/codegenloongarch64.cpp index 4111afcafd9b53..5372b7f62f3d93 100644 --- a/src/coreclr/jit/codegenloongarch64.cpp +++ b/src/coreclr/jit/codegenloongarch64.cpp @@ -632,6 +632,8 @@ void CodeGen::genFnEpilog(BasicBlock* block) compiler->unwindBegEpilog(); + genPopCalleeSavedRegisters(); + if (jmpEpilog) { SetHasTailCalls(true); @@ -644,7 +646,6 @@ void CodeGen::genFnEpilog(BasicBlock* block) #if !FEATURE_FASTTAILCALL noway_assert(jmpNode->OperIs(GT_JMP)); #else // FEATURE_FASTTAILCALL - // armarch // If jmpNode is GT_JMP then gtNext must be null. // If jmpNode is a fast tail call, gtNext need not be null since it could have embedded stmts. noway_assert(!jmpNode->OperIs(GT_JMP) || (jmpNode->gtNext == nullptr)); @@ -699,28 +700,20 @@ void CodeGen::genFnEpilog(BasicBlock* block) NO_WAY("Unsupported JMP indirection"); } - /* Simply emit a jump to the methodHnd. This is similar to a call so we can use - * the same descriptor with some minor adjustments. - */ - - genPopCalleeSavedRegisters(true); - + // Simply emit a jump to the methodHnd. This is similar to a call so we can use + // the same descriptor with some minor adjustments. params.isJump = true; - genEmitCallWithCurrentGC(params); } #if FEATURE_FASTTAILCALL else { - genPopCalleeSavedRegisters(true); genCallInstruction(jmpNode->AsCall()); } #endif // FEATURE_FASTTAILCALL } else { - genPopCalleeSavedRegisters(false); - GetEmitter()->emitIns_R_R_I(INS_jirl, EA_PTRSIZE, REG_R0, REG_RA, 0); compiler->unwindReturn(REG_RA); }