diff --git a/src/coreclr/jit/codegenarm64.cpp b/src/coreclr/jit/codegenarm64.cpp index 1f03af9313ae30..b13c11c50d6681 100644 --- a/src/coreclr/jit/codegenarm64.cpp +++ b/src/coreclr/jit/codegenarm64.cpp @@ -1377,10 +1377,12 @@ void CodeGen::genFuncletProlog(BasicBlock* block) if (genFuncletInfo.fiFrameType == 1) { - // With OSR we may see large values for fiSpDelta1 - // (we really need to probe the frame, sigh) if (compiler->opts.IsOSR()) { + // With OSR we may see large values for fiSpDelta1. + // We repurpose genAllocLclFram to do the necessary probing. + bool scratchRegIsZero = false; + genAllocLclFrame(-genFuncletInfo.fiSpDelta1, REG_SCRATCH, &scratchRegIsZero, maskArgRegsLiveIn); genStackPointerAdjustment(genFuncletInfo.fiSpDelta1, REG_SCRATCH, nullptr, /* reportUnwindData */ true); GetEmitter()->emitIns_R_R_R_I(INS_stp, EA_PTRSIZE, REG_FP, REG_LR, REG_SPBASE, 0); compiler->unwindSaveRegPair(REG_FP, REG_LR, 0); @@ -1416,10 +1418,12 @@ void CodeGen::genFuncletProlog(BasicBlock* block) } else if (genFuncletInfo.fiFrameType == 3) { - // With OSR we may see large values for fiSpDelta1 - // (we really need to probe the frame, sigh) if (compiler->opts.IsOSR()) { + // With OSR we may see large values for fiSpDelta1 + // We repurpose genAllocLclFram to do the necessary probing. + bool scratchRegIsZero = false; + genAllocLclFrame(-genFuncletInfo.fiSpDelta1, REG_SCRATCH, &scratchRegIsZero, maskArgRegsLiveIn); genStackPointerAdjustment(genFuncletInfo.fiSpDelta1, REG_SCRATCH, nullptr, /* reportUnwindData */ true); GetEmitter()->emitIns_R_R_R_I(INS_stp, EA_PTRSIZE, REG_FP, REG_LR, REG_SPBASE, 0); compiler->unwindSaveRegPair(REG_FP, REG_LR, 0); @@ -1450,6 +1454,10 @@ void CodeGen::genFuncletProlog(BasicBlock* block) if (compiler->opts.IsOSR()) { + // With OSR we may see large values for fiSpDelta1. + // We repurpose genAllocLclFram to do the necessary probing. + bool scratchRegIsZero = false; + genAllocLclFrame(-genFuncletInfo.fiSpDelta1, REG_SCRATCH, &scratchRegIsZero, maskArgRegsLiveIn); genStackPointerAdjustment(genFuncletInfo.fiSpDelta1, REG_SCRATCH, nullptr, /* reportUnwindData */ true); } else