From 7bf9ae2e95ec26b2abf62045cda99e28b613290a Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Tue, 29 Mar 2022 13:10:33 -0700 Subject: [PATCH] JIT: Use small register types for some enregisterable locals (#67274) Fix two cases where small enregisterable locals can't be saved to the stack using actual (widened) types: * small memory args for OSX ARM64 * promoted fields of OSR locals Closes #67152. Closes #67188. --- src/coreclr/jit/lclvars.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/coreclr/jit/lclvars.cpp b/src/coreclr/jit/lclvars.cpp index cd13f96e83d83..9580fd35f22bf 100644 --- a/src/coreclr/jit/lclvars.cpp +++ b/src/coreclr/jit/lclvars.cpp @@ -3825,8 +3825,30 @@ var_types LclVarDsc::GetRegisterType() const // Return Value: // TYP_UNDEF if the layout is not enregistrable, the register type otherwise. // +// Notes: +// Special cases are small OSX ARM64 memory params (where args are not widened) +// and small local promoted fields (which use Tier0 frame space as stack homes). +// var_types LclVarDsc::GetActualRegisterType() const { + if (varTypeIsSmall(TypeGet())) + { + if (compMacOsArm64Abi() && lvIsParam && !lvIsRegArg) + { + return GetRegisterType(); + } + + if (lvIsOSRLocal && lvIsStructField) + { +#if defined(TARGET_X86) + // Revisit when we support OSR on x86 + unreached(); +#else + return GetRegisterType(); +#endif + } + } + return genActualType(GetRegisterType()); }