Skip to content

Commit

Permalink
JIT: Fix reordering with 'backfilled' arguments on x86 (#71940)
Browse files Browse the repository at this point in the history
In a previous change I made the assumption that all register args come
before stack args on x86. This assumption is not true.

Fix #71939
  • Loading branch information
jakobbotsch authored Jul 11, 2022
1 parent 9701c5c commit 52d9d0c
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -820,9 +820,8 @@ void CallArgs::ArgsComplete(Compiler* comp, GenTreeCall* call)
if (prevArg.AbiInfo.GetRegNum() == REG_STK)
{
// All stack args are already evaluated and placed in order
// in this case; we only need to check this for register
// args.
break;
// in this case.
continue;
}
#endif

Expand Down Expand Up @@ -902,7 +901,7 @@ void CallArgs::ArgsComplete(Compiler* comp, GenTreeCall* call)
{
// All stack args are already evaluated and placed in order
// in this case.
break;
continue;
}
#endif

Expand Down Expand Up @@ -965,7 +964,7 @@ void CallArgs::ArgsComplete(Compiler* comp, GenTreeCall* call)
{
// All stack args are already evaluated and placed in order
// in this case.
break;
continue;
}
#endif
// Invariant here is that all nodes that were not
Expand Down
42 changes: 42 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_71939/Runtime_71939.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

// Adapted from:
// Generated by Fuzzlyn v1.5 on 2022-07-10 17:11:48
// Run on X86 Windows
// Seed: 2002556551479521504
// Reduced from 184.6 KiB to 0.9 KiB in 00:03:45
// Debug: Outputs 0
// Release: Outputs -10

using System;
using System.Runtime.CompilerServices;

public class Runtime_71939
{
public static int Main()
{
int v3 = 1;
return Check(0, -v3, Mutate(ref v3));
}

[MethodImpl(MethodImplOptions.NoInlining)]
public static int Mutate(ref int arg)
{
arg = 10;
return 0;
}

[MethodImpl(MethodImplOptions.NoInlining)]
public static int Check(ulong arg0, int arg1, int arg2)
{
if (arg1 != -1)
{
Console.WriteLine("FAIL: mutated arg is {0}", arg1);
return -1;
}

Console.WriteLine("PASS: mutated arg is {0}", arg1);
return 100;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
</Project>

0 comments on commit 52d9d0c

Please sign in to comment.