-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issues with EH in unexecuted loops
Fix two problems with code in loops that are determined to not execute that have exception handling clauses: 1. Be more specific in loop unrolling to avoid unrolling even zero-count loops (which causes the loop to be removed) if there is a block in the loop with a different handler region than the handler region of the "top" block. This should only kick in for x86, where handlers are not extracted as funclets. 2. In Value Numbering, before actually value numbering nodes, `optComputeLoopSideEffectsOfBlock()` walks all the blocks of all top-level loops collecting data. Unfortunately, it sets the Value Number of certain nodes as a way to pass information "up the tree" during processing. Presumably these "fake" value numbers actually get replaced during actual value numbering for the tree. However, when we go to actually value number the IR, we only walk reachable blocks. Thus, in some cases, we would end up with a top-level "fake" value number on an unreachable statement root, thus leading `fgDebugCheckExceptionSets()` to check the tree and assert. To fix this, at the end of the `optComputeLoopSideEffectsOfBlock()`, clear the VN in case it was previously set. Fixes #81675
- Loading branch information
1 parent
5ec100a
commit 8102f00
Showing
3 changed files
with
90 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
src/tests/JIT/Regression/JitBlue/Runtime_81675/Runtime_81675.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// 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 2023-02-06 00:41:34 | ||
// Run on X86 Windows | ||
// Seed: 12611629827253727687 | ||
// Reduced from 444.9 KiB to 1.1 KiB in 00:13:23 | ||
// Hits JIT assert in Release: | ||
// Assertion failed '!"Jump into the middle of handler region"' in 'Program:Main(Fuzzlyn.ExecutionServer.IRuntime)' during 'Unroll loops' (IL size 131; hash 0xade6b36b; FullOpts) | ||
// | ||
// File: D:\a\_work\1\s\src\coreclr\jit\fgdiagnostic.cpp Line: 2609 | ||
// | ||
public interface I0 | ||
{ | ||
} | ||
|
||
public class C0 : I0 | ||
{ | ||
public sbyte F3; | ||
} | ||
|
||
public class Runtime_81675 | ||
{ | ||
public static ushort s_11; | ||
public static bool[][] s_18; | ||
public static C0 s_26; | ||
public static short[] s_42; | ||
public static int Main() | ||
{ | ||
short vr7 = default(short); | ||
for (int vr8 = 0; vr8 < 0; vr8++) | ||
{ | ||
try | ||
{ | ||
System.Console.WriteLine(32767); | ||
} | ||
finally | ||
{ | ||
I0 vr9 = new C0(); | ||
} | ||
} | ||
|
||
for (int vr10 = 0; vr10 < 0; vr10++) | ||
{ | ||
if (s_18[0][0]) | ||
{ | ||
var vr11 = s_26.F3; | ||
} | ||
else | ||
{ | ||
System.Console.WriteLine(0); | ||
} | ||
|
||
if (!((ushort)(-s_11++) >= 0)) | ||
{ | ||
vr7 = vr7; | ||
try | ||
{ | ||
vr7 = 0; | ||
} | ||
finally | ||
{ | ||
vr7 = s_42[0]; | ||
} | ||
} | ||
} | ||
|
||
return 100; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/tests/JIT/Regression/JitBlue/Runtime_81675/Runtime_81675.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<Optimize>True</Optimize> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildProjectName).cs" /> | ||
</ItemGroup> | ||
</Project> |