Skip to content
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

Surgical fix for bad assertion generation #55626

Merged
merged 3 commits into from
Jul 15, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/coreclr/jit/assertionprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,10 @@ AssertionIndex Compiler::optCreateAssertion(GenTree* op1,
}

toType = op2->CastToType();
if (toType == TYP_UINT)
SingleAccretion marked this conversation as resolved.
Show resolved Hide resolved
{
toType = TYP_INT;
}
SUBRANGE_COMMON:
if ((assertionKind != OAK_SUBRANGE) && (assertionKind != OAK_EQUAL))
{
Expand Down
32 changes: 32 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_54842/Runtime_54842.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Runtime.CompilerServices;

public class Runtime_54842
{
public static int Main()
{
try
{
DoubleCheckedConvert(uint.MaxValue);
}
catch (OverflowException)
{
return 100;
}

return 101;
}

[MethodImpl(MethodImplOptions.NoInlining)]
private static uint DoubleCheckedConvert(ulong a)
{
var b = (int)checked((uint)a);

// Make sure the importer spills "b" to a local.
Use(b);

return checked((uint)b);
}

private static void Use(int value) { }
}
SingleAccretion marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>
<PropertyGroup>
<DebugType>None</DebugType>
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
</Project>