Skip to content
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

JIT: more stringent interference checks in forward sub #64933

Merged
merged 3 commits into from
Feb 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/coreclr/jit/forwardsub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,11 @@ class ForwardSubVisitor final : public GenTreeVisitor<ForwardSubVisitor>
}
}
}
}

if (node->OperIsLocal())
{
unsigned const lclNum = node->AsLclVarCommon()->GetLclNum();

// Uses of address-exposed locals are modelled as global refs.
//
Expand Down Expand Up @@ -370,7 +375,7 @@ class EffectsVisitor final : public GenTreeVisitor<EffectsVisitor>
GenTree* const node = *use;
m_flags |= node->gtFlags & GTF_ALL_EFFECT;

if (node->OperIs(GT_LCL_VAR))
if (node->OperIsLocal())
{
unsigned const lclNum = node->AsLclVarCommon()->GetLclNum();
LclVarDsc* const varDsc = m_compiler->lvaGetDesc(lclNum);
Expand Down
55 changes: 55 additions & 0 deletions src/tests/JIT/opt/ForwardSub/callArgInterference2.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

// Generated by Fuzzlyn v1.5 on 2022-02-06 17:06:01
// Run on X86 Windows
// Seed: 7854701479455767355
// Reduced from 192.2 KiB to 0.6 KiB in 00:03:51
// Debug: Outputs 0
// Release: Outputs 1
public struct S0
{
public uint F0;
public ulong F2;
public int F3;
public ushort F6;
public int F8;
public static int s_result;

public int[] M35(int arg0, int[] arg1)
{
this.F3 = arg1[0];
ForwardSubCallArgInterference2.s_rt.WriteLine(arg0);
s_result = arg0 + 100;
return arg1;
}
}

public class ForwardSubCallArgInterference2
{
public static IRT s_rt;
public static int[][] s_28 = new int[][]{new int[]{1}};
public static int Main()
{
s_rt = new C();
var vr3 = new S0();
var vr6 = vr3.F3;
var vr13 = s_28[0];
var vr12 = vr3.M35(0, vr13);
vr3.M35(vr6, vr12);
return S0.s_result;
}
}

public interface IRT
{
void WriteLine<T>(T value);
}

public class C : IRT
{
public void WriteLine<T>(T value)
{
System.Console.WriteLine(value);
}
}
10 changes: 10 additions & 0 deletions src/tests/JIT/opt/ForwardSub/callArgInterference2.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<DebugType />
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
</Project>
72 changes: 72 additions & 0 deletions src/tests/JIT/opt/ForwardSub/callArgInterference3.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

// Generated by Fuzzlyn v1.5 on 2022-02-06 16:34:36
// Run on X86 Windows
// Seed: 15345211054104247945
// Reduced from 56.7 KiB to 1.1 KiB in 00:00:55
// Debug: Outputs 0
// Release: Outputs -1
public struct S0
{
public ulong F1;
public int F2;
public byte F3;
public short F5;
public long F6;
public static int s_result;
public void M4(int arg0, sbyte[] arg1)
{
ForwardSubCallArgInterference3.s_rt.WriteLine(arg0);
s_result = arg0 + 100;
}

public sbyte[] M6(ref int arg0, bool arg1, ref S0 arg2, ref byte arg3)
{
var vr0 = ForwardSubCallArgInterference3.s_5;
ForwardSubCallArgInterference3.M7(arg2, vr0, ref ForwardSubCallArgInterference3.s_6, ref ForwardSubCallArgInterference3.s_10, arg0);
var vr1 = arg2.F6;
ForwardSubCallArgInterference3.M8(arg2, vr1);
arg0 = this.F2--;
return new sbyte[]{1};
}
}

public class ForwardSubCallArgInterference3
{
public static IRT s_rt;
public static bool s_2;
public static S0 s_4;
public static uint[] s_5;
public static byte s_6;
public static S0[] s_10;
public static S0[, ] s_20 = new S0[, ]{{new S0()}};
public static int Main()
{
s_rt = new C();
S0 vr2 = default(S0);
new S0().M4(vr2.F2, vr2.M6(ref s_4.F2, s_2, ref s_20[0, 0], ref s_4.F3));
return S0.s_result;
}

public static void M8(S0 arg0, long arg1)
{
}

public static void M7(S0 argThis, uint[] arg0, ref byte arg1, ref S0[] arg2, int arg3)
{
}
}

public interface IRT
{
void WriteLine<T>(T value);
}

public class C : IRT
{
public void WriteLine<T>(T value)
{
System.Console.WriteLine(value);
}
}
10 changes: 10 additions & 0 deletions src/tests/JIT/opt/ForwardSub/callArgInterference3.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<DebugType />
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
</Project>