Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
24 changes: 10 additions & 14 deletions src/coreclr/jit/assertionprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5776,6 +5776,8 @@ bool Compiler::optCreateJumpTableImpliedAssertions(BasicBlock* switchBb)

void Compiler::optImpliedByTypeOfAssertions(ASSERT_TP& activeAssertions)
{
assert(!optLocalAssertionProp);

if (BitVecOps::IsEmpty(apTraits, activeAssertions))
{
return;
Expand Down Expand Up @@ -5804,31 +5806,25 @@ void Compiler::optImpliedByTypeOfAssertions(ASSERT_TP& activeAssertions)
{
AssertionDsc* impAssertion = optGetAssertion(impIndex);

// The impAssertion must be different from the chkAssertion
// The impAssertion must be different from the chkAssertion
if (impIndex == chkAssertionIndex)
{
continue;
}

// impAssertion must be a Non Null assertion on lclNum
if ((impAssertion->assertionKind != OAK_NOT_EQUAL) || (impAssertion->op1.kind != O1K_LCLVAR) ||
(impAssertion->op2.kind != O2K_CONST_INT) || (impAssertion->op1.vn != chkAssertion->op1.vn))
// impAssertion must be a Non Null assertion on op1.vn
if ((impAssertion->assertionKind != OAK_NOT_EQUAL) || !impAssertion->CanPropNonNull() ||
(impAssertion->op1.vn != chkAssertion->op1.vn))
{
continue;
}

// The bit may already be in the result set
if (!BitVecOps::IsMember(apTraits, activeAssertions, impIndex - 1))
if (BitVecOps::TryAddElemD(apTraits, activeAssertions, impIndex - 1))
{
BitVecOps::AddElemD(apTraits, activeAssertions, impIndex - 1);
#ifdef DEBUG
if (verbose)
{
printf("\nCompiler::optImpliedByTypeOfAssertions: %s Assertion #%02d, implies assertion #%02d",
(chkAssertion->op1.kind == O1K_SUBTYPE) ? "Subtype" : "Exact-type", chkAssertionIndex,
impIndex);
}
#endif
JITDUMP("\nCompiler::optImpliedByTypeOfAssertions: %s Assertion #%02d, implies assertion #%02d",
(chkAssertion->op1.kind == O1K_SUBTYPE) ? "Subtype" : "Exact-type", chkAssertionIndex,
impIndex);
}

// There is at most one non-null assertion that is implied by the current chkIndex assertion
Expand Down
28 changes: 28 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_120792/Runtime_120792.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// 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.CompilerServices;
using System.Threading;
using Xunit;

public class Runtime_120792
{
[Fact]
public static void TestEntryPoint()
{
for (int i = 0; i < 300; i++)
{
Problem(42);
Thread.Sleep(16);
}
}

[MethodImpl(MethodImplOptions.NoInlining)]
private static void Problem(object value)
{
Type tt = value == null ? typeof(object) : value.GetType();
if (!tt.Equals(typeof(int)) || value == null)
throw new InvalidOperationException();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<DebugType>None</DebugType>
<Optimize>True</Optimize>
<!-- Needed for CLRTestEnvironmentVariable -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
<CLRTestEnvironmentVariable Include="DOTNET_TieredCompilation" Value="1" />
<CLRTestEnvironmentVariable Include="DOTNET_TieredPGO" Value="1" />
</ItemGroup>
</Project>
Loading