[Amd64] tailcall_v4/smallFrame failure should fail on all platforms
The test JIT/Methodical/tailcall_v4/smallFrame/smallFrame.exe is failing on ARM64 with the following message.
Unhandled Exception: System.InvalidProgramException: Common Language Runtime detected an invalid program.
at RetBufferBug.TailCaller()
at RetBufferBug.Main()
I tried ildasm and comparing to the original il.
ildasm relevant output.
.method private hidebysig static void TailCaller() cil managed
{
// Code size 9 (0x9)
.maxstack 8
IL_0000: tail.
IL_0002: call valuetype RetBuff RetBufferBug::TailCallee()
IL_0007: pop
IL_0008: ret
} // end of method RetBufferBug::TailCaller
The line IL_0000: tail. looks suspicious. As the orignal il https://github.com/dotnet/coreclr/blob/master/tests/src/JIT/Methodical/tailcall_v4/smallFrame.il#L361 looks like
.method private hidebysig static void TailCaller() cil managed
{
// Code size 7 (0x7)
.maxstack 8
//.line 114,114 : 3,16 ''
IL_0000: tail. call valuetype RetBuff RetBufferBug::TailCallee()
IL_0005: pop
//.line 115,115 : 2,3 ''
IL_0006: ret
} // end of method RetBufferBug::TailCaller
@janvorli @jkotas I am not sure who to engage in this issue.
This test is testing compat quirk - look for isCallPopAndRet in src\jit\flowgraph.cpp
This compat quirk is enabled for AMD64 only right now. @dotnet/jit-contrib Should be enable this compat quirk for all platforms (it would be my choice); or should we disable this test on everything except AMD64?
That quirk was put in place for Legacy Jit64 compatibility on Desktop. In case of CoreCLR or Arm64 we don't have such a compat issue. It should be fine to enable tail.call+pop+ret tail call pattern on Arm64 as well.
@sivarv I'm confused: if we don't have a compat issue, why would we want to enable that pattern (and thus "create" a compat issue)? Why wouldn't we just enable that test only for AMD64? In fact, maybe that quirk should be under #if !defined(FEATURE_CORECLR)?
@BruceForstall - to clarify I am suggesting that we can enable this new tail call pattern on all targets on CoreCLR. This not only drives towards uniformity in tail call recognition but also will lead to more implicit tail calls on Arm64/Amd64.
But on desktop - we can enable this for Amd64 and Arm64 only but not x86 because Jit32 doesn't support such a tail call pattern. The reason we can support on Desktop Arm64 is that we don't have a compat burden as on Amd64.
Enabling these tail calls on for all targets on CoreCLR might require more work for the reason that we also test legacy Jit32 which doesn't support this tail call pattern. So we need a way to enable/disable tests separately for Legacy Jit32 and RyuJIT x86.
CC @RussKeldorph
To be ECMA conformant, this test should fail on ALL platforms per @RussKeldorph's comments in discussion of dotnet/coreclr#10198.
The test is currently disabled on x86 in https://github.com/dotnet/coreclr/blob/master/tests/issues.targets#L207
@RussKeldorph please remove the arch-arm64 label and adjust the milestone for the new title.
@RussKeldorph I restored the dotnet/coreclr#10198 branch in case it is helpful to you for reference. As I realize the amd64 patch is probably roughly the inverse of dotnet/coreclr#10198.
@sdmaclea I was thinking the same thing, but I assumed PRs lived forever, so thanks if that's not the case! :)
FIxed