Skip to content

Commit 2201628

Browse files
AndyAyersMSpull[bot]
authored andcommitted
JIT: handle nested try case in empty try removal (#111129)
When we remove a try region, the try entry block may still be a try entry for enclosing try regions, so we can't unconditionally drop the DONT_REMOVE flag. Fixes #110958
1 parent 40dcb7f commit 2201628

File tree

3 files changed

+100
-2
lines changed

3 files changed

+100
-2
lines changed

src/coreclr/jit/fgehopt.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,9 +1037,13 @@ PhaseStatus Compiler::fgRemoveEmptyTryCatchOrTryFault()
10371037
//
10381038
fgRemoveEHTableEntry(XTnum);
10391039

1040-
// (6) The old try entry no longer needs special protection.
1040+
// (6) The old try entry may no longer need special protection.
1041+
// (it may still be an entry of an enclosing try)
10411042
//
1042-
firstTryBlock->RemoveFlags(BBF_DONT_REMOVE);
1043+
if (!bbIsTryBeg(firstTryBlock))
1044+
{
1045+
firstTryBlock->RemoveFlags(BBF_DONT_REMOVE);
1046+
}
10431047

10441048
// Another one bites the dust...
10451049
emptyCount++;
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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+
// Found by Antigen
5+
// Reduced from 17.57 KB to 2.06 KB.
6+
7+
using System.Collections.Generic;
8+
using System.Runtime.Intrinsics.Arm;
9+
using Xunit;
10+
11+
public class Runtime_110958
12+
{
13+
long long_30 = 5;
14+
ulong ulong_36 = 0;
15+
SveMaskPattern SveMaskPattern_37 = SveMaskPattern.VectorCount1;
16+
private static List<string> toPrint = new List<string>();
17+
private void Method0()
18+
{
19+
unchecked
20+
{
21+
ulong ulong_77 = 2;
22+
SveMaskPattern SveMaskPattern_78 = SveMaskPattern_37;
23+
try
24+
{
25+
try
26+
{
27+
ulong_36 -= ulong_77;
28+
}
29+
catch (System.FieldAccessException)
30+
{ }
31+
catch (System.ExecutionEngineException)
32+
{ }
33+
}
34+
catch (System.RankException)
35+
{
36+
}
37+
catch (System.MemberAccessException)
38+
{
39+
do
40+
{
41+
try
42+
{
43+
switch ((15 << 4) * long_30)
44+
{
45+
case -1:
46+
{
47+
break;
48+
}
49+
default:
50+
{
51+
break;
52+
}
53+
}
54+
}
55+
catch (System.InvalidProgramException)
56+
{
57+
}
58+
catch (System.InvalidCastException)
59+
{
60+
}
61+
}
62+
while (15 < 4);
63+
}
64+
catch (System.AggregateException)
65+
{
66+
}
67+
finally
68+
{
69+
}
70+
return;
71+
}
72+
}
73+
74+
[Fact]
75+
public static void Problem0()
76+
{
77+
new Runtime_110958().Method0();
78+
}
79+
}
80+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<Optimize>True</Optimize>
4+
<!-- Needed for CLRTestEnvironmentVariable -->
5+
<RequiresProcessIsolation>true</RequiresProcessIsolation>
6+
</PropertyGroup>
7+
<ItemGroup>
8+
<Compile Include="$(MSBuildProjectName).cs" />
9+
10+
<CLRTestEnvironmentVariable Include="DOTNET_TieredCompilation" Value="0" />
11+
<CLRTestEnvironmentVariable Include="DOTNET_JitStress" Value="2" />
12+
<CLRTestEnvironmentVariable Include="DOTNET_JitRandomEdgeCounts" Value="1" />
13+
</ItemGroup>
14+
</Project>

0 commit comments

Comments
 (0)