-
Notifications
You must be signed in to change notification settings - Fork 4.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
There needs to be a proper "new, unique" value number for exception sets #63559
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Tagging subscribers to this area: @JulieLeeMSFT Issue DetailsReproduction, run on 32 bit: using System.Runtime.CompilerServices;
Problem(0, 1, false, false, 0);
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
static bool Problem(long a, long b, bool c1, bool c2, int i)
{
var zero = 0;
c1 = ((a / b) * zero) + i == 0;
c2 = ((b / a) * zero) + i == 0;
return c2 & c1;
} Expected result: Cause: in the VN logic, Creating such exception VNs should be "zero-cost", i. e. consume no actual memory as they do not have useful input to store.
|
It is notable that "just" giving a unique value number to helpers that today receive the using System;
using System.Runtime.CompilerServices;
Console.WriteLine(Problem(0, false, false));
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
private static bool Problem(int b, bool c1, bool c2)
{
var zero = 0;
c1 = ClassWithCctorNoThrow.StaticField * zero + b == 0;
c2 = c1;
if (ClassWithCctor.StaticField * zero + b == 0)
{
Console.WriteLine("No exception was thrown...");
return false;
}
return c2;
}
static class ClassWithCctor
{
public static int StaticField;
static ClassWithCctor() => throw new Exception();
}
static class ClassWithCctorNoThrow
{
public static int StaticField;
static ClassWithCctorNoThrow() { }
} |
The problem with this issue was that actually creating "new, unique" exception sets for calls lead to very large memory consumption regression; I don't think I'll have time to think of a way out of that for 7.0. |
The JIT currently models all exceptions thrown by helpers with a singleton VN. This can cause CSE to remove exception side effects incorrectly. This change starts modelling exceptions thrown by the following helpers accurately: - The R2R cast helper - Division helpers - Static constructor base helpers Remaining JIT helpers are modelled conservatively, with an opaque VN in the exception part. Contributes to #63559 Fix #101028
#101062 fixes the issue around JIT helpers. The problem of modelling exception sets for user calls remain. |
There are none. Yeah, no reason to keep it in 9.0 (the issues here were ancient anyway). |
Sounds good. I'll give this back to you (or feel free to unassign yourself...) |
The JIT currently models all exceptions thrown by helpers with a singleton VN. This can cause CSE to remove exception side effects incorrectly. This change starts modelling exceptions thrown by the following helpers accurately: - The R2R cast helper - Division helpers - Static constructor base helpers Remaining JIT helpers are modelled conservatively, with an opaque VN in the exception part. Contributes to dotnet#63559 Fix dotnet#101028
The JIT currently models all exceptions thrown by helpers with a singleton VN. This can cause CSE to remove exception side effects incorrectly. This change starts modelling exceptions thrown by the following helpers accurately: - The R2R cast helper - Division helpers - Static constructor base helpers Remaining JIT helpers are modelled conservatively, with an opaque VN in the exception part. Contributes to dotnet#63559 Fix dotnet#101028
Enable the debug checking and full fidelity exception sets for all calls, including user calls. This would entail optimizing the opaque exception to not consume memory by using a custom chunk kind.
category:implementation
theme:value-numbering
skill-level:intermediate
cost:small
impact:small
The text was updated successfully, but these errors were encountered: