Skip to content

Commit e591fbf

Browse files
authored
Arm: Fix the base register used for restoring register from stack (dotnet#107564)
* Use correct baseReg for vstr, similar to vldr * add test cases * Mark internal test methods private
1 parent 51c350c commit e591fbf

File tree

3 files changed

+208
-4
lines changed

3 files changed

+208
-4
lines changed

src/coreclr/jit/emitarm.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3914,10 +3914,7 @@ void emitter::emitIns_S_R(instruction ins, emitAttr attr, regNumber reg1, int va
39143914
{
39153915
regNumber rsvdReg = codeGen->rsGetRsvdReg();
39163916
emitIns_genStackOffset(rsvdReg, varx, offs, /* isFloatUsage */ true, &baseRegUsed);
3917-
3918-
// Ensure the baseReg calculated is correct.
3919-
assert(baseRegUsed == reg2);
3920-
emitIns_R_R(INS_add, EA_4BYTE, rsvdReg, reg2);
3917+
emitIns_R_R(INS_add, EA_4BYTE, rsvdReg, baseRegUsed);
39213918
emitIns_R_R_I(ins, attr, reg1, rsvdReg, 0);
39223919
return;
39233920
}
Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
// Generated by Fuzzlyn v2.1 on 2024-07-28 20:48:11
5+
// Run on Arm Linux
6+
// Seed: 7638843082097772896
7+
// Reduced from 1010.6 KiB to 5.3 KiB in 00:18:13
8+
// Hits JIT assert in Release:
9+
// Assertion failed 'baseRegUsed == reg2' in 'Program:M48(S0,S3,S2,S2)' during 'Generate code' (IL size 2164; hash 0x03983244; FullOpts)
10+
//
11+
// File: /__w/1/s/src/coreclr/jit/emitarm.cpp Line: 3919
12+
//
13+
using System;
14+
using System.Runtime.CompilerServices;
15+
using Xunit;
16+
17+
public struct S0
18+
{
19+
public ulong F0;
20+
public int F1;
21+
public long F2;
22+
public uint F3;
23+
public byte F4;
24+
public float F5;
25+
public sbyte F6;
26+
public double F7;
27+
public sbyte F8;
28+
}
29+
30+
public struct S1
31+
{
32+
public double F0;
33+
public short F1;
34+
public bool F2;
35+
public S0 F3;
36+
public sbyte F4;
37+
public ushort F5;
38+
public ulong F6;
39+
public int F7;
40+
public S0 F8;
41+
}
42+
43+
public struct S2
44+
{
45+
public double F0;
46+
public S0 F1;
47+
public S1 F2;
48+
public ushort F4;
49+
public S2(S1 f2)
50+
{
51+
F2 = f2;
52+
}
53+
}
54+
55+
public class C0
56+
{
57+
}
58+
59+
public struct S3
60+
{
61+
public double F0;
62+
public float F1;
63+
public ushort F2;
64+
public long F3;
65+
public S1 F4;
66+
public S2 F5;
67+
public S2 F6;
68+
public uint F7;
69+
public S2 F8;
70+
public S3(S2 f5, S2 f8) : this()
71+
{
72+
F5 = f5;
73+
F8 = f8;
74+
}
75+
}
76+
77+
public struct S4
78+
{
79+
public double F0;
80+
public double F1;
81+
public float F2;
82+
public ulong F3;
83+
public bool F4;
84+
public int F5;
85+
public bool F6;
86+
public S3 F7;
87+
public float F8;
88+
public S4(S3 f7)
89+
{
90+
F7 = f7;
91+
}
92+
}
93+
94+
public class Program
95+
{
96+
public static IRuntime s_rt;
97+
public static S4 s_2;
98+
public static S4 s_3;
99+
public static S4[][] s_6;
100+
public static S3[] s_23 = new S3[]
101+
{
102+
new S3(new S2(new S1()), new S2(new S1()))
103+
};
104+
105+
[Fact]
106+
public static void TestEntryPoint()
107+
{
108+
try
109+
{
110+
var vr8 = new S4(new S3(new S2(new S1()), new S2(new S1())));
111+
var vr9 = s_23[0].F6.F1;
112+
var vr13 = s_2.F7;
113+
var vr14 = vr8.F7.F6;
114+
var vr15 = vr8.F7.F6;
115+
M48(vr9, vr13, vr14, vr15);
116+
} catch {}
117+
}
118+
119+
private static void M48(S0 argThis, S3 arg0, S2 arg1, S2 arg2)
120+
{
121+
arg2.F2.F0 = arg2.F2.F0;
122+
S4 var1 = new S4(new S3(new S2(new S1()), new S2(new S1())));
123+
var1.F7.F5.F2.F8.F5 = s_6[0][0].F7.F8.F2.F3.F5;
124+
var vr2 = new C0();
125+
M49(0, vr2, ref arg2.F2.F1, ref s_3.F7, ref arg1.F1.F8);
126+
S4 var2 = var1;
127+
s_rt.WriteLine(System.BitConverter.DoubleToUInt64Bits(var2.F7.F0));
128+
s_rt.WriteLine(System.BitConverter.SingleToUInt32Bits(var2.F7.F1));
129+
s_rt.WriteLine(var2.F7.F2);
130+
s_rt.WriteLine(var2.F7.F3);
131+
s_rt.WriteLine(System.BitConverter.DoubleToUInt64Bits(var2.F7.F4.F0));
132+
s_rt.WriteLine(var2.F7.F4.F1);
133+
s_rt.WriteLine(var2.F7.F4.F2);
134+
s_rt.WriteLine(var2.F7.F4.F3.F0);
135+
s_rt.WriteLine(var2.F7.F4.F3.F1);
136+
s_rt.WriteLine(var2.F7.F4.F3.F2);
137+
s_rt.WriteLine(var2.F7.F4.F3.F3);
138+
s_rt.WriteLine(var2.F7.F4.F3.F4);
139+
s_rt.WriteLine(System.BitConverter.SingleToUInt32Bits(var2.F7.F4.F3.F5));
140+
s_rt.WriteLine(var2.F7.F4.F3.F6);
141+
s_rt.WriteLine(System.BitConverter.DoubleToUInt64Bits(var2.F7.F4.F3.F7));
142+
s_rt.WriteLine(var2.F7.F4.F3.F8);
143+
s_rt.WriteLine(var2.F7.F4.F4);
144+
s_rt.WriteLine(var2.F7.F4.F5);
145+
s_rt.WriteLine(var2.F7.F4.F6);
146+
s_rt.WriteLine(var2.F7.F4.F7);
147+
s_rt.WriteLine(var2.F7.F4.F8.F0);
148+
s_rt.WriteLine(var2.F7.F4.F8.F1);
149+
s_rt.WriteLine(var2.F7.F4.F8.F2);
150+
s_rt.WriteLine(var2.F7.F4.F8.F3);
151+
s_rt.WriteLine(var2.F7.F4.F8.F4);
152+
s_rt.WriteLine(System.BitConverter.SingleToUInt32Bits(var2.F7.F4.F8.F5));
153+
s_rt.WriteLine(var2.F7.F4.F8.F6);
154+
s_rt.WriteLine(System.BitConverter.DoubleToUInt64Bits(var2.F7.F4.F8.F7));
155+
s_rt.WriteLine(var2.F7.F4.F8.F8);
156+
s_rt.WriteLine(System.BitConverter.DoubleToUInt64Bits(var2.F7.F5.F0));
157+
s_rt.WriteLine(var2.F7.F5.F1.F0);
158+
s_rt.WriteLine(var2.F7.F5.F1.F1);
159+
s_rt.WriteLine(var2.F7.F5.F1.F2);
160+
s_rt.WriteLine(var2.F7.F5.F1.F3);
161+
s_rt.WriteLine(var2.F7.F5.F1.F4);
162+
s_rt.WriteLine(System.BitConverter.SingleToUInt32Bits(var2.F7.F5.F1.F5));
163+
s_rt.WriteLine(var2.F7.F5.F1.F6);
164+
s_rt.WriteLine(System.BitConverter.DoubleToUInt64Bits(var2.F7.F5.F1.F7));
165+
s_rt.WriteLine(var2.F7.F5.F1.F8);
166+
s_rt.WriteLine(System.BitConverter.DoubleToUInt64Bits(var2.F7.F5.F2.F0));
167+
s_rt.WriteLine(var2.F7.F5.F2.F1);
168+
s_rt.WriteLine(var2.F7.F5.F2.F2);
169+
s_rt.WriteLine(var2.F7.F5.F2.F3.F0);
170+
s_rt.WriteLine(var2.F7.F5.F2.F3.F1);
171+
s_rt.WriteLine(var2.F7.F5.F2.F3.F2);
172+
s_rt.WriteLine(var2.F7.F5.F2.F3.F3);
173+
s_rt.WriteLine(var2.F7.F5.F2.F3.F4);
174+
s_rt.WriteLine(System.BitConverter.SingleToUInt32Bits(var2.F7.F5.F2.F3.F5));
175+
s_rt.WriteLine(var2.F7.F5.F2.F3.F6);
176+
s_rt.WriteLine(System.BitConverter.DoubleToUInt64Bits(var2.F7.F5.F2.F3.F7));
177+
s_rt.WriteLine(var2.F7.F5.F2.F3.F8);
178+
s_rt.WriteLine(var2.F7.F5.F2.F4);
179+
s_rt.WriteLine(var2.F7.F5.F2.F5);
180+
s_rt.WriteLine(var2.F7.F5.F2.F6);
181+
s_rt.WriteLine(var2.F7.F5.F2.F7);
182+
s_rt.WriteLine(var2.F7.F5.F2.F8.F0);
183+
}
184+
185+
private static void M49(short arg0, C0 arg2, ref short arg3, ref S3 arg4, ref sbyte arg5)
186+
{
187+
s_rt.WriteLine(arg0);
188+
}
189+
}
190+
191+
public interface IRuntime
192+
{
193+
void WriteLine<T>(T value);
194+
}
195+
196+
public class Runtime : IRuntime
197+
{
198+
public void WriteLine<T>(T value) => System.Console.WriteLine(value);
199+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<Optimize>True</Optimize>
4+
</PropertyGroup>
5+
<ItemGroup>
6+
<Compile Include="$(MSBuildProjectName).cs" />
7+
</ItemGroup>
8+
</Project>

0 commit comments

Comments
 (0)