Skip to content

Commit

Permalink
Arm: Fix the base register used for restoring register from stack (do…
Browse files Browse the repository at this point in the history
…tnet#107564)

* Use correct baseReg for vstr, similar to vldr

* add test cases

* Mark internal test methods private
  • Loading branch information
kunalspathak authored and jtschuster committed Sep 17, 2024
1 parent 791c574 commit a2fbb6a
Show file tree
Hide file tree
Showing 3 changed files with 208 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/coreclr/jit/emitarm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3914,10 +3914,7 @@ void emitter::emitIns_S_R(instruction ins, emitAttr attr, regNumber reg1, int va
{
regNumber rsvdReg = codeGen->rsGetRsvdReg();
emitIns_genStackOffset(rsvdReg, varx, offs, /* isFloatUsage */ true, &baseRegUsed);

// Ensure the baseReg calculated is correct.
assert(baseRegUsed == reg2);
emitIns_R_R(INS_add, EA_4BYTE, rsvdReg, reg2);
emitIns_R_R(INS_add, EA_4BYTE, rsvdReg, baseRegUsed);
emitIns_R_R_I(ins, attr, reg1, rsvdReg, 0);
return;
}
Expand Down
199 changes: 199 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_105620/Runtime_105620.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
// 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 v2.1 on 2024-07-28 20:48:11
// Run on Arm Linux
// Seed: 7638843082097772896
// Reduced from 1010.6 KiB to 5.3 KiB in 00:18:13
// Hits JIT assert in Release:
// Assertion failed 'baseRegUsed == reg2' in 'Program:M48(S0,S3,S2,S2)' during 'Generate code' (IL size 2164; hash 0x03983244; FullOpts)
//
// File: /__w/1/s/src/coreclr/jit/emitarm.cpp Line: 3919
//
using System;
using System.Runtime.CompilerServices;
using Xunit;

public struct S0
{
public ulong F0;
public int F1;
public long F2;
public uint F3;
public byte F4;
public float F5;
public sbyte F6;
public double F7;
public sbyte F8;
}

public struct S1
{
public double F0;
public short F1;
public bool F2;
public S0 F3;
public sbyte F4;
public ushort F5;
public ulong F6;
public int F7;
public S0 F8;
}

public struct S2
{
public double F0;
public S0 F1;
public S1 F2;
public ushort F4;
public S2(S1 f2)
{
F2 = f2;
}
}

public class C0
{
}

public struct S3
{
public double F0;
public float F1;
public ushort F2;
public long F3;
public S1 F4;
public S2 F5;
public S2 F6;
public uint F7;
public S2 F8;
public S3(S2 f5, S2 f8) : this()
{
F5 = f5;
F8 = f8;
}
}

public struct S4
{
public double F0;
public double F1;
public float F2;
public ulong F3;
public bool F4;
public int F5;
public bool F6;
public S3 F7;
public float F8;
public S4(S3 f7)
{
F7 = f7;
}
}

public class Program
{
public static IRuntime s_rt;
public static S4 s_2;
public static S4 s_3;
public static S4[][] s_6;
public static S3[] s_23 = new S3[]
{
new S3(new S2(new S1()), new S2(new S1()))
};

[Fact]
public static void TestEntryPoint()
{
try
{
var vr8 = new S4(new S3(new S2(new S1()), new S2(new S1())));
var vr9 = s_23[0].F6.F1;
var vr13 = s_2.F7;
var vr14 = vr8.F7.F6;
var vr15 = vr8.F7.F6;
M48(vr9, vr13, vr14, vr15);
} catch {}
}

private static void M48(S0 argThis, S3 arg0, S2 arg1, S2 arg2)
{
arg2.F2.F0 = arg2.F2.F0;
S4 var1 = new S4(new S3(new S2(new S1()), new S2(new S1())));
var1.F7.F5.F2.F8.F5 = s_6[0][0].F7.F8.F2.F3.F5;
var vr2 = new C0();
M49(0, vr2, ref arg2.F2.F1, ref s_3.F7, ref arg1.F1.F8);
S4 var2 = var1;
s_rt.WriteLine(System.BitConverter.DoubleToUInt64Bits(var2.F7.F0));
s_rt.WriteLine(System.BitConverter.SingleToUInt32Bits(var2.F7.F1));
s_rt.WriteLine(var2.F7.F2);
s_rt.WriteLine(var2.F7.F3);
s_rt.WriteLine(System.BitConverter.DoubleToUInt64Bits(var2.F7.F4.F0));
s_rt.WriteLine(var2.F7.F4.F1);
s_rt.WriteLine(var2.F7.F4.F2);
s_rt.WriteLine(var2.F7.F4.F3.F0);
s_rt.WriteLine(var2.F7.F4.F3.F1);
s_rt.WriteLine(var2.F7.F4.F3.F2);
s_rt.WriteLine(var2.F7.F4.F3.F3);
s_rt.WriteLine(var2.F7.F4.F3.F4);
s_rt.WriteLine(System.BitConverter.SingleToUInt32Bits(var2.F7.F4.F3.F5));
s_rt.WriteLine(var2.F7.F4.F3.F6);
s_rt.WriteLine(System.BitConverter.DoubleToUInt64Bits(var2.F7.F4.F3.F7));
s_rt.WriteLine(var2.F7.F4.F3.F8);
s_rt.WriteLine(var2.F7.F4.F4);
s_rt.WriteLine(var2.F7.F4.F5);
s_rt.WriteLine(var2.F7.F4.F6);
s_rt.WriteLine(var2.F7.F4.F7);
s_rt.WriteLine(var2.F7.F4.F8.F0);
s_rt.WriteLine(var2.F7.F4.F8.F1);
s_rt.WriteLine(var2.F7.F4.F8.F2);
s_rt.WriteLine(var2.F7.F4.F8.F3);
s_rt.WriteLine(var2.F7.F4.F8.F4);
s_rt.WriteLine(System.BitConverter.SingleToUInt32Bits(var2.F7.F4.F8.F5));
s_rt.WriteLine(var2.F7.F4.F8.F6);
s_rt.WriteLine(System.BitConverter.DoubleToUInt64Bits(var2.F7.F4.F8.F7));
s_rt.WriteLine(var2.F7.F4.F8.F8);
s_rt.WriteLine(System.BitConverter.DoubleToUInt64Bits(var2.F7.F5.F0));
s_rt.WriteLine(var2.F7.F5.F1.F0);
s_rt.WriteLine(var2.F7.F5.F1.F1);
s_rt.WriteLine(var2.F7.F5.F1.F2);
s_rt.WriteLine(var2.F7.F5.F1.F3);
s_rt.WriteLine(var2.F7.F5.F1.F4);
s_rt.WriteLine(System.BitConverter.SingleToUInt32Bits(var2.F7.F5.F1.F5));
s_rt.WriteLine(var2.F7.F5.F1.F6);
s_rt.WriteLine(System.BitConverter.DoubleToUInt64Bits(var2.F7.F5.F1.F7));
s_rt.WriteLine(var2.F7.F5.F1.F8);
s_rt.WriteLine(System.BitConverter.DoubleToUInt64Bits(var2.F7.F5.F2.F0));
s_rt.WriteLine(var2.F7.F5.F2.F1);
s_rt.WriteLine(var2.F7.F5.F2.F2);
s_rt.WriteLine(var2.F7.F5.F2.F3.F0);
s_rt.WriteLine(var2.F7.F5.F2.F3.F1);
s_rt.WriteLine(var2.F7.F5.F2.F3.F2);
s_rt.WriteLine(var2.F7.F5.F2.F3.F3);
s_rt.WriteLine(var2.F7.F5.F2.F3.F4);
s_rt.WriteLine(System.BitConverter.SingleToUInt32Bits(var2.F7.F5.F2.F3.F5));
s_rt.WriteLine(var2.F7.F5.F2.F3.F6);
s_rt.WriteLine(System.BitConverter.DoubleToUInt64Bits(var2.F7.F5.F2.F3.F7));
s_rt.WriteLine(var2.F7.F5.F2.F3.F8);
s_rt.WriteLine(var2.F7.F5.F2.F4);
s_rt.WriteLine(var2.F7.F5.F2.F5);
s_rt.WriteLine(var2.F7.F5.F2.F6);
s_rt.WriteLine(var2.F7.F5.F2.F7);
s_rt.WriteLine(var2.F7.F5.F2.F8.F0);
}

private static void M49(short arg0, C0 arg2, ref short arg3, ref S3 arg4, ref sbyte arg5)
{
s_rt.WriteLine(arg0);
}
}

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

public class Runtime : IRuntime
{
public void WriteLine<T>(T value) => System.Console.WriteLine(value);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
</Project>

0 comments on commit a2fbb6a

Please sign in to comment.