Skip to content

Commit e0e7bfc

Browse files
authored
Only look for exceptVars when resolving live-out EH vars (#58243)
* Only look for exceptVars * Add test case
1 parent 0ab41f6 commit e0e7bfc

File tree

3 files changed

+123
-1
lines changed

3 files changed

+123
-1
lines changed

src/coreclr/jit/lsra.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8215,7 +8215,7 @@ void LinearScan::resolveEdge(BasicBlock* fromBlock,
82158215
if ((resolveType == ResolveJoin) && (compiler->compHndBBtabCount > 0))
82168216
{
82178217
VARSET_TP extraLiveSet(VarSetOps::Diff(compiler, block->bbLiveOut, toBlock->bbLiveIn));
8218-
VarSetOps::IntersectionD(compiler, extraLiveSet, registerCandidateVars);
8218+
VarSetOps::IntersectionD(compiler, extraLiveSet, exceptVars);
82198219
VarSetOps::Iter iter(compiler, extraLiveSet);
82208220
unsigned extraVarIndex = 0;
82218221
while (iter.NextElem(&extraVarIndex))
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
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+
// Note: In this repro, we accidently mark a non-EH variable as needing a spill which
5+
// corrupts the value stored on stack. The problem repros only on linux/arm64.
6+
class C0
7+
{
8+
public short F0;
9+
public byte F1;
10+
public ushort F2;
11+
public ulong F3;
12+
}
13+
14+
struct S0
15+
{
16+
public C0 F0;
17+
public uint F1;
18+
public S0(C0 f0) : this()
19+
{
20+
F0 = f0;
21+
}
22+
}
23+
24+
class C1
25+
{
26+
public ulong F0;
27+
public bool F1;
28+
public sbyte F2;
29+
public sbyte F3;
30+
public C0 F4;
31+
public sbyte F5;
32+
public uint F6;
33+
public C1(C0 f4, bool f7)
34+
{
35+
F4 = f4;
36+
}
37+
}
38+
39+
class C2
40+
{
41+
public ulong F0;
42+
}
43+
44+
class C3
45+
{
46+
public int F0;
47+
public C3(int f0)
48+
{
49+
}
50+
}
51+
52+
public class Program
53+
{
54+
internal static bool[][][] s_9 = new bool[][][] { new bool[][] { new bool[] { true } } };
55+
internal static C1[,] s_12 = new C1[,] { { new C1(new C0(), true) } };
56+
internal static S0 s_17 = new S0(new C0());
57+
internal static C1[,][] s_21 = new C1[,][] { { new C1[] { new C1(new C0(), false) } } };
58+
internal static short s_32;
59+
internal static C1 s_34 = new C1(new C0(), false);
60+
internal static C2 s_35 = new C2();
61+
internal static C1 s_114 = new C1(new C0(), false);
62+
internal static ushort[][] s_133 = new ushort[][] { new ushort[] { 0 }, new ushort[] { 0 }, new ushort[] { 0 }, new ushort[] { 1, 1, 1 }, new ushort[] { 0 }, new ushort[] { 0 }, new ushort[] { 0 }, new ushort[] { 0 }, new ushort[] { 0 } };
63+
internal static long[] s_138 = new long[] { 0 };
64+
65+
public static int Main()
66+
{
67+
s_32 = s_32;
68+
M64(new C3(0));
69+
return 100;
70+
}
71+
72+
internal static S0 M64(C3 argThis)
73+
{
74+
if (argThis.F0 <= 0)
75+
{
76+
short var1 = s_32;
77+
try
78+
{
79+
var vr8 = new bool[][] { new bool[] { true }, new bool[] { false }, new bool[] { false }, new bool[] { true }, new bool[] { false } };
80+
}
81+
finally
82+
{
83+
ushort var13 = s_12[0, 0].F4.F2;
84+
}
85+
86+
System.GC.KeepAlive(var1);
87+
}
88+
89+
long[][] var16 = new long[][] { new long[] { -1, 0, 0, -1, -1, 0, 0, 0, 0 }, new long[] { 1, 0, -1, 0, 0, 0, 0, 0, 1, 0 }, new long[] { 1, 0, 0, 1, -1, 0 }, new long[] { 1, 1, -1, 0 } };
90+
C2 var17 = s_35;
91+
S0 var18 = s_17;
92+
var vr6 = new bool[][] { new bool[] { true, true, true, false, false, false, false, false, true }, new bool[] { false, false, true, false, true, false }, new bool[] { true }, new bool[] { true }, new bool[] { false }, new bool[] { false, false, true }, new bool[] { true }, new bool[] { false, true, false } };
93+
if (0 >= var17.F0)
94+
{
95+
var18.F0.F1 = 1;
96+
}
97+
98+
var18.F0 = new C0();
99+
C1[] var22 = new C1[] { new C1(new C0(), false) };
100+
C3[][][] var24;
101+
System.GC.KeepAlive(argThis.F0);
102+
System.GC.KeepAlive(var18.F0.F2);
103+
System.GC.KeepAlive(var18.F0.F3);
104+
System.GC.KeepAlive(10);
105+
System.GC.KeepAlive(var22[0].F0);
106+
System.GC.KeepAlive(var22[0].F4.F3);
107+
System.GC.KeepAlive(var22[0].F5);
108+
return var18;
109+
}
110+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
</PropertyGroup>
5+
<PropertyGroup>
6+
<DebugType>None</DebugType>
7+
<Optimize>True</Optimize>
8+
</PropertyGroup>
9+
<ItemGroup>
10+
<Compile Include="$(MSBuildProjectName).cs" />
11+
</ItemGroup>
12+
</Project>

0 commit comments

Comments
 (0)