From 480647803953d3581210c8b38cf38463d26bbab8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomek=20Sowi=C5=84ski?= Date: Thu, 25 Apr 2024 17:16:24 +0200 Subject: [PATCH] Call genHomeStackParams(true) in prolog generation for RISC-V to avoid garbage GC pointers --- src/coreclr/jit/codegencommon.cpp | 7 +++++++ src/coreclr/jit/codegenlinear.cpp | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/coreclr/jit/codegencommon.cpp b/src/coreclr/jit/codegencommon.cpp index c5bcb12537322..06ea36515c859 100644 --- a/src/coreclr/jit/codegencommon.cpp +++ b/src/coreclr/jit/codegencommon.cpp @@ -5555,6 +5555,13 @@ void CodeGen::genFnProlog() genEnregisterIncomingStackArgs(); } +#ifdef TARGET_RISCV64 + if (compiler->fgFirstBBisScratch() && compiler->lvaHasAnyStackParamToReassemble()) + { + genHomeStackParams(/* handleStack */ true); + } +#endif + /* Initialize any must-init registers variables now */ if (initRegs) diff --git a/src/coreclr/jit/codegenlinear.cpp b/src/coreclr/jit/codegenlinear.cpp index 320c82170c0ea..32e20061e652c 100644 --- a/src/coreclr/jit/codegenlinear.cpp +++ b/src/coreclr/jit/codegenlinear.cpp @@ -386,7 +386,7 @@ void CodeGen::genCodeForBBlist() compiler->compCurStmt = nullptr; compiler->compCurLifeTree = nullptr; -#if defined(SWIFT_SUPPORT) || defined(TARGET_RISCV64) +#ifdef SWIFT_SUPPORT // Reassemble split struct parameters on the local stack frame in the // scratch BB right after the prolog. There can be arbitrary amounts of // codegen related to doing this, so it cannot be done in the prolog.