Skip to content
Open
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
13 changes: 12 additions & 1 deletion src/coreclr/jit/scev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1451,7 +1451,18 @@ GenTree* ScalarEvolutionContext::Materialize(Scev* scev)
{
ValueNumPair vnp;
GenTree* result;
return Materialize(scev, true, &result, &vnp) ? result : nullptr;

// Materializing IR may create nodes before failing partway through (e.g.
// when a subexpression cannot be materialized). Snapshot the gen tree ID so
// that we can roll it back and avoid leaking IDs for the orphaned nodes.
INDEBUG(unsigned prevGenTreeID = m_compiler->compGenTreeID);
if (Materialize(scev, true, &result, &vnp))
{
return result;
}

INDEBUG(m_compiler->compGenTreeID = prevGenTreeID);
return nullptr;
}

//------------------------------------------------------------------------
Expand Down
69 changes: 69 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_129527/Runtime_129527.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Runtime_129527;

using System.Runtime.Intrinsics.Arm;
using System.Threading.Tasks;
using Xunit;

public struct S1
{
public long F3;
}

public interface IRuntime
{
void WriteLine<T>(string site, T value);
}

public sealed class Runtime : IRuntime
{
public void WriteLine<T>(string site, T value)
{
}
}

public static class Runtime_129527
{
private static IRuntime s_rt = new Runtime();
private static bool[] s_8 = new bool[1];
private static long s_13;

[Fact]
public static int TestEntryPoint()
{
M0();
return s_13 == 0 ? 100 : 101;
}

private static void M0()
{
uint var9 = default;
S1[] var24 = new S1[1];
ulong var34 = default;
try
{
var9 = 1;
s_8[0] |= false;
}
catch
{
}

for (int lvar31 = -2147483646; lvar31 > -2147483648; lvar31--)
{
ulong vr0 = (ulong)(lvar31 - var9++);
short var33 = Crc32.Arm64.IsSupported ? (short)Crc32.Arm64.ComputeCrc32C(0, vr0) : (short)vr0;
s_13 = var24[0].F3;
M6().GetAwaiter().GetResult();
s_rt.WriteLine("c_122", var34);
s_rt.WriteLine("c_126", var33);
}
}

private static async Task M6()
{
await Task.Yield();
}
}
1 change: 1 addition & 0 deletions src/tests/JIT/Regression/Regression_ro_2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
<Compile Include="JitBlue\Runtime_128801\Runtime_128801.cs" />
<Compile Include="JitBlue\Runtime_129076\Runtime_129076.cs" />
<Compile Include="JitBlue\Runtime_129176\Runtime_129176.cs" />
<Compile Include="JitBlue\Runtime_129527\Runtime_129527.cs" />
<Compile Include="JitBlue\Runtime_10337\Runtime_10337.cs" />
</ItemGroup>
<Import Project="$(TestSourceDir)MergedTestRunner.targets" />
Expand Down
Loading