-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spilling can overwrite adjacent stack parameters on ARM64 macOS ABI #67188
Comments
Tagging subscribers to this area: @JulieLeeMSFT Issue DetailsReproduction: [MethodImpl(MethodImplOptions.NoInlining)]
private static int Problem(int x0, int x1, int x2, int x3, int x4, int x5, int x6, int x7, short stk0, short stk1)
{
[MethodImpl(MethodImplOptions.NoInlining)]
static int Call(int k) => 0;
stk1 = (short)(stk0 + stk1 + stk0);
Call(stk1);
return stk0 + stk1;
} Compile with CG2: Expected result: spilling of the small stack parameters cannot overwrite anything. Actual result: it can, due to using IN0014: 000008 B94013A1 ldr w1, [fp,#16] // [V08 arg8]
IN0015: 00000C B84123A2 ldr w2, [fp,#18] // [V09 arg9]
...
IN0008: 00002C B90013A1 str w1, [fp,#16] Essentially this is the same issue as in #67152.
|
Similar case #66720 (comment) |
@AndyAyersMS I can't comment in #52039 (comment) because it is locked but I think you are right.
I would try a radical fix first in: runtime/src/coreclr/jit/lclvars.cpp Lines 3820 to 3824 in 6627183
instead do: var_types LclVarDsc::GetActualRegisterType() const
{
#ifdef OSX_ARM64_ABI
if (lclVar->is argument stack slot)
{
return GetRegisterType();
}
#endif
return genActualType(GetRegisterType());
} |
I'll fix this since OSR is seeing a related issue. |
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 dotnet#67152. Closes dotnet#67188.
Reproduction:
Compile with CG2:
--targetarch:arm64 --targetos:OSX --codegenopt NgenDump=Problem --codegenopt JitNoCSE=1 --codegenopt JitStressRegs=2
.Expected result: spilling of the small stack parameters cannot overwrite anything.
Actual result: it can, due to using
TYP_INT
-wide stores:Also see #67152.
The text was updated successfully, but these errors were encountered: