From 3713514135e17480b9d00585c4d8caac4a2a21be Mon Sep 17 00:00:00 2001 From: Timur Mustafin Date: Tue, 9 Apr 2024 20:15:11 +0300 Subject: [PATCH] Restore StubSecretArg from stack Issue #100301 Co-authored-by: Jakob Botsch Nielsen --- src/coreclr/jit/lower.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/coreclr/jit/lower.cpp b/src/coreclr/jit/lower.cpp index 05d32ad..546f95e 100644 --- a/src/coreclr/jit/lower.cpp +++ b/src/coreclr/jit/lower.cpp @@ -5183,8 +5183,16 @@ void Lowering::InsertPInvokeMethodProlog() call->gtArgs.PushBack(comp, frameAddrArg); // for x86/arm32 don't pass the secretArg. #if !defined(TARGET_X86) && !defined(TARGET_ARM) - NewCallArg stubParamArg = - NewCallArg::Primitive(PhysReg(REG_SECRET_STUB_PARAM)).WellKnown(WellKnownArg::SecretStubParam); + GenTree* argNode; + if (comp->info.compPublishStubParam) + { + argNode = comp->gtNewLclvNode(comp->lvaStubArgumentVar, TYP_I_IMPL); + } + else + { + argNode = comp->gtNewIconNode(0, TYP_I_IMPL); + } + NewCallArg stubParamArg = NewCallArg::Primitive(argNode).WellKnown(WellKnownArg::SecretStubParam); call->gtArgs.PushBack(comp, stubParamArg); #endif -- 2.7.4