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
18 changes: 15 additions & 3 deletions src/coreclr/jit/lsra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1348,10 +1348,22 @@ void LinearScan::recordVarLocationsAtStartOfBB(BasicBlock* bb)
count++;

#ifdef USING_VARIABLE_LIVE_RANGE
if (bb->bbPrev != nullptr && VarSetOps::IsMember(compiler, bb->bbPrev->bbLiveOut, varIndex))
BasicBlock* prevReportedBlock = bb->bbPrev;
if (bb->bbPrev != nullptr && bb->bbPrev->isBBCallAlwaysPairTail())
{
// varDsc was alive on previous block end ("bb->bbPrev->bbLiveOut"), so it has an open
// "VariableLiveRange" which should change to be according "getInVarToRegMap"
// For callf+always pair we generate the code for the always
// block in genCallFinally and skip it, so we don't report
// anything for it (it has only trivial instructions, so that
// does not matter much). So whether we need to rehome or not
// depends on what we reported at the end of the callf block.
prevReportedBlock = bb->bbPrev->bbPrev;
}

if (prevReportedBlock != nullptr && VarSetOps::IsMember(compiler, prevReportedBlock->bbLiveOut, varIndex))
{
// varDsc was alive on previous block end so it has an open
// "VariableLiveRange" which should change to be according to
// "getInVarToRegMap"
compiler->codeGen->getVariableLiveKeeper()->siUpdateVariableLiveRange(varDsc, varNum);
}
#endif // USING_VARIABLE_LIVE_RANGE
Expand Down
95 changes: 95 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_57752/Runtime_57752_1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

// Generated by Fuzzlyn v1.3 on 2021-08-19 15:47:06
// Run on .NET 6.0.0-dev on X64 Windows
// Seed: 16489483397161801783
// Reduced from 251.9 KiB to 1.7 KiB in 02:46:36
//
// Assert failure(PID 27840 [0x00006cc0], Thread: 1464 [0x05b8]): Assertion failed '!m_VariableLiveRanges->back().m_EndEmitLocation.Valid()' in 'Program:M51(System.Boolean[],System.UInt16[],System.Boolean[],long,System.Int32[],byref)' during 'Generate code' (IL size 140)
//
// File: D:\dev\dotnet\runtime\src\coreclr\jit\codegencommon.cpp Line: 11990
// Image: D:\dev\Fuzzlyn\Fuzzlyn\publish\windows-x64\Fuzzlyn.exe
//
//
public class Runtime_57752_1
{
internal static I s_rt;
internal static long s_10;
internal static bool[] s_27 = new[]{true};
internal static short s_28;
internal static bool s_33;
internal static bool s_53;
internal static int[][] s_56;
public static int Main()
{
s_rt = new C();
var vr9 = new ushort[]{0};
var vr10 = new bool[]{true};
var vr11 = new int[]{0};
M51(s_27, vr9, vr10, 0, vr11, ref s_28);
return 100;
}

internal static void M51(bool[] arg0, ushort[] arg5, bool[] arg9, ulong arg10, int[] arg11, ref short arg12)
{
if (arg0[0])
{
if (arg0[0])
{
arg11[0] = arg11[0];
}
else
{
try
{
}
finally
{
arg9[0] = arg9[0];
}

try
{
arg0[0] = true;
}
finally
{
for (int var4 = 0; var4 < 2; var4++)
{
s_53 = arg0[0];
arg10 = 0;
ushort var6 = arg5[0];
long var8 = 0;
s_rt.Write(s_56[0][0]);
s_rt.Write(var8);
}

s_33 = false;
try
{
s_10 = s_10;
}
finally
{
arg12 = ref arg12;
}
}
}

bool vr1 = arg9[0];
}
}
}

public interface I
{
void Write<T>(T val);
}

public class C : I
{
public void Write<T>(T val)
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup>
<DebugType>None</DebugType>
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
</Project>
57 changes: 57 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_57752/Runtime_57752_2.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

// Generated by Fuzzlyn v1.3 on 2021-08-23 02:35:43
// Run on .NET 6.0.0-dev on X64 Windows
// Seed: 13788434105727734599
// Reduced from 365.1 KiB to 0.9 KiB in 02:25:35
// Exits with error:
//
// Assert failure(PID 11828 [0x00002e34], Thread: 24792 [0x60d8]): Assertion failed 'm_VariableLiveRanges != nullptr && !m_VariableLiveRanges->empty()' in 'Program:M53(byref,byref)' during 'Generate code' (IL size 177)
//
// File: D:\dev\dotnet\runtime\src\coreclr\jit\codegencommon.cpp Line: 11987
// Image: D:\dev\Fuzzlyn\Fuzzlyn\publish\windows-x64\Fuzzlyn.exe
//
//
public class Runtime_57752_2
{
internal static ulong s_46;
public static int Main()
{
M53(ref s_46, ref s_46);
return 100;
}

internal static void M53(ref ulong arg0, ref ulong arg1)
{
int var11 = default(int);
for (int var0 = 0; var0 < 1; var0++)
{
return;
}

try
{
bool vr0 = arg1 >= 0;
bool vr6 = vr0;
}
finally
{
for (int var2 = 0; var2 < -1; var2++)
{
}

try
{
}
finally
{
System.Console.WriteLine(var11);
}

var vr7 = new uint[][]{new uint[]{0}, new uint[]{0}, new uint[]{0}, new uint[]{0}, new uint[]{0}, new uint[]{0}, new uint[]{0}, new uint[]{0}, new uint[]{0}, new uint[]{0}};
}

System.Console.WriteLine(arg0);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup>
<DebugType>None</DebugType>
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
</Project>