-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exception sets: debug checker & fixes (#63539)
* Add a simple exception sets checker * Add asserts to catch missing nodes * Fix normal VN printing * Fix JTRUE VNs * Fix PHI VNs * Update VNs for "this" ARGPLACE node * Tolerate missing VNs on PHI_ARGs We do not update them after numbering the loops. (Though perhaps we should) * Tolerate unreachable blocks * Fix exception sets for VNF_PtrTo VNFuncs * Add VNUniqueWithExc * Add VNPUniqueWithExc * Fix arrays * Consistently give location nodes VNForVoid And always add exception sets for them. This will simplify the exception set propagation code for assignments. * Fix CSE * Fix GT_RETURN * Fix LCLHEAP * Fix GT_ARR_ELEM * Fix unique HWI * Fix unique SIMD * Fix GT_SWITCH * Fix CKFINITE * Fix HWI loads * Fix fgValueNumberAddExceptionSetForIndirection The method does not need to add the exception set for the base address. Additionally, the way it did add the sets, by unioning with normal value numbers, lost all exceptions not coming from the base address. This was fine for the unary loads, but broke the HWI loads that could have exceptions coming from not just the address. * Fix GT_RETFILT * Fix INIT_VAL * Fix DYN_BLK * Fix FIELD_LIST * De-pessimize CkFinite * Add a test for HWIs * Add a test for LCLHEAP
- Loading branch information
1 parent
1fc2352
commit 9bc4439
Showing
8 changed files
with
500 additions
and
214 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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
40 changes: 40 additions & 0 deletions
40
src/tests/JIT/opt/ValueNumbering/ExceptionSetsPropagation_Hwi.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,40 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Runtime.Intrinsics; | ||
using System.Runtime.CompilerServices; | ||
|
||
// We're testing whether HWI nodes with > 2 operands propagate exception sets correctly. | ||
// | ||
class ExceptionSetsPropagation_Hwi | ||
{ | ||
public static int Main() | ||
{ | ||
try | ||
{ | ||
Problem(-1, false, false); | ||
} | ||
catch (OverflowException) | ||
{ | ||
return 100; | ||
} | ||
|
||
return 101; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private static bool Problem(int a, bool c1, bool c2) | ||
{ | ||
var zero = 0; | ||
c1 = a == 0; | ||
c2 = c1; | ||
|
||
if ((Vector128.Create((int)checked((uint)a), a, a, a).GetElement(0) * zero) + a == 0) | ||
{ | ||
return false; | ||
} | ||
|
||
return c2; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/tests/JIT/opt/ValueNumbering/ExceptionSetsPropagation_Hwi.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,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<CLRTestPriority>1</CLRTestPriority> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<DebugType>None</DebugType> | ||
<Optimize>True</Optimize> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildProjectName).cs" /> | ||
</ItemGroup> | ||
</Project> |
75 changes: 75 additions & 0 deletions
75
src/tests/JIT/opt/ValueNumbering/ExceptionSetsPropagation_LclHeap.il
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,75 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
.assembly extern xunit.core { } | ||
.assembly extern System.Runtime { } | ||
.assembly extern System.Console { } | ||
|
||
.assembly ExceptionSetsPropagation_LclHeap { } | ||
|
||
.class ExceptionSetsPropagation_LclHeap extends [System.Runtime]System.Object | ||
{ | ||
.method public static int32 Main() | ||
{ | ||
.custom instance void [xunit.core]Xunit.FactAttribute::.ctor() = (01 00 00 00) | ||
.entrypoint | ||
|
||
.try | ||
{ | ||
ldc.i4 300 | ||
conv.i | ||
call bool ExceptionSetsPropagation_LclHeap::Problem(native int) | ||
pop | ||
leave FAIL | ||
} | ||
catch [System.Runtime]System.OverflowException | ||
{ | ||
pop | ||
leave SUCCESS | ||
} | ||
|
||
SUCCESS: | ||
ldc.i4 100 | ||
ret | ||
|
||
FAIL: | ||
ldc.i4 101 | ||
ret | ||
} | ||
|
||
.method private static bool Problem(native int a) | ||
{ | ||
.locals (bool c1, bool c2) | ||
|
||
ldarg a | ||
localloc | ||
ldc.i4 0 | ||
conv.i | ||
and | ||
ldarg a | ||
ceq | ||
stloc c1 | ||
|
||
ldloc c1 | ||
stloc c2 | ||
|
||
ldarg a | ||
conv.ovf.i1 | ||
conv.i | ||
localloc | ||
ldc.i4 0 | ||
conv.i | ||
and | ||
ldarg a | ||
ceq | ||
brtrue RET | ||
|
||
ldstr "The expected OverflowException was not thrown!" | ||
call void [System.Console]System.Console::WriteLine(string) | ||
|
||
RET: | ||
ldloc c2 | ||
ret | ||
} | ||
} | ||
|
13 changes: 13 additions & 0 deletions
13
src/tests/JIT/opt/ValueNumbering/ExceptionSetsPropagation_LclHeap.ilproj
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,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.IL"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<CLRTestPriority>1</CLRTestPriority> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<DebugType>None</DebugType> | ||
<Optimize>True</Optimize> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildProjectName).il" /> | ||
</ItemGroup> | ||
</Project> |