Skip to content

Commit 2a5602d

Browse files
authored
JIT: clear lvMustInit from dependent locals (#64877)
Their initialization is handled by the parent local. Closes #64808.
1 parent 3610ac1 commit 2a5602d

File tree

3 files changed

+95
-0
lines changed

3 files changed

+95
-0
lines changed

src/coreclr/jit/codegencommon.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4631,6 +4631,7 @@ void CodeGen::genCheckUseBlockInit()
46314631
if (!varDsc->lvIsInReg() && !varDsc->lvOnFrame)
46324632
{
46334633
noway_assert(varDsc->lvRefCnt() == 0);
4634+
varDsc->lvMustInit = 0;
46344635
continue;
46354636
}
46364637

@@ -4643,6 +4644,7 @@ void CodeGen::genCheckUseBlockInit()
46434644

46444645
if (compiler->fgVarIsNeverZeroInitializedInProlog(varNum))
46454646
{
4647+
varDsc->lvMustInit = 0;
46464648
continue;
46474649
}
46484650

@@ -4651,6 +4653,7 @@ void CodeGen::genCheckUseBlockInit()
46514653
// For Compiler::PROMOTION_TYPE_DEPENDENT type of promotion, the whole struct should have been
46524654
// initialized by the parent struct. No need to set the lvMustInit bit in the
46534655
// field locals.
4656+
varDsc->lvMustInit = 0;
46544657
continue;
46554658
}
46564659

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System;
5+
using System.Runtime.CompilerServices;
6+
7+
// Generated by Fuzzlyn v1.5 on 2022-02-03 20:05:52
8+
// Run on X64 Linux
9+
// Seed: 17645686525285880576
10+
// Reduced from 66.2 KiB to 1.0 KiB in 00:04:27
11+
// Hits JIT assert in Release:
12+
// Assertion failed 'compiler->opts.IsOSR() || ((genInitStkLclCnt > 0) == hasUntrLcl)' in 'Program:M8():S0' during 'Generate code' (IL size 110)
13+
//
14+
// File: /__w/1/s/src/coreclr/jit/codegencommon.cpp Line: 7256
15+
//
16+
17+
public class C0
18+
{
19+
public int F0;
20+
public ulong F1;
21+
public sbyte F2;
22+
}
23+
24+
public struct S0
25+
{
26+
public int F0;
27+
public S0(int f0): this()
28+
{
29+
}
30+
}
31+
32+
public class Runtime_64808
33+
{
34+
private static IRT s_rt;
35+
public static long[] s_16;
36+
public static bool s_23;
37+
public static int s_result;
38+
public static int Main()
39+
{
40+
s_16 = new long[1];
41+
s_rt = new C();
42+
s_result = -1;
43+
M8();
44+
return s_result;
45+
}
46+
47+
public static S0 M8()
48+
{
49+
try
50+
{
51+
var vr0 = new ushort[]{0};
52+
C0[] vr3 = default(C0[]);
53+
return M15(vr0, ref s_23, vr3);
54+
}
55+
finally
56+
{
57+
var vr2 = new S0[]{new S0(0), new S0(0), new S0(0), new S0(0), new S0(0), new S0(0)};
58+
}
59+
}
60+
61+
[MethodImpl(MethodImplOptions.NoInlining)]
62+
public static S0 M15(ushort[] arg0, ref bool arg1, C0[] arg2)
63+
{
64+
s_result = 100;
65+
S0 vr5 = default(S0);
66+
return vr5;
67+
}
68+
}
69+
70+
public interface IRT
71+
{
72+
void WriteLine<T>(string a, T value);
73+
}
74+
75+
public class C : IRT
76+
{
77+
public void WriteLine<T>(string a, T value)
78+
{
79+
System.Console.WriteLine(value);
80+
}
81+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
<Optimize>True</Optimize>
5+
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
6+
</PropertyGroup>
7+
<ItemGroup>
8+
<ProjectReference Include="$(TestSourceDir)Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
9+
<Compile Include="$(MSBuildProjectName).cs" />
10+
</ItemGroup>
11+
</Project>

0 commit comments

Comments
 (0)