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
4 changes: 2 additions & 2 deletions src/coreclr/jit/morphblock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,6 @@ void MorphInitBlockHelper::PropagateBlockAssertions()
//
void MorphInitBlockHelper::PropagateExpansionAssertions()
{
// Consider doing this for FieldByField as well
//
if (m_comp->optLocalAssertionProp && (m_transformationDecision == BlockTransformation::OneStoreBlock))
{
m_comp->fgAssertionGen(m_store);
Expand Down Expand Up @@ -408,6 +406,7 @@ void MorphInitBlockHelper::TryInitFieldByField()
if (m_comp->fgGlobalMorph && m_dstLclNode->IsLastUse(i))
{
JITDUMP("Field-by-field init skipping write to dead field V%02u\n", fieldLclNum);
m_comp->fgKillDependentAssertionsSingle(m_dstLclNum DEBUGARG(m_store));
continue;
}

Expand Down Expand Up @@ -1236,6 +1235,7 @@ GenTree* MorphCopyBlockHelper::CopyFieldByField()
{
INDEBUG(unsigned dstFieldLclNum = m_comp->lvaGetDesc(m_dstLclNum)->lvFieldLclStart + i);
JITDUMP("Field-by-field copy skipping write to dead field V%02u\n", dstFieldLclNum);
m_comp->fgKillDependentAssertionsSingle(m_dstLclNum DEBUGARG(m_store));
continue;
}

Expand Down
34 changes: 34 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_113658/Runtime_113658.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// 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 Xunit;

public static class Runtime_113658
{
[Fact]
public static int TestEntryPoint()
{
FillStackWithGarbage();
long? nullable = FaultyDefaultNullable<long?>();
return (int)(100 + nullable.GetValueOrDefault());
}

[MethodImpl(MethodImplOptions.NoInlining)]
private static void FillStackWithGarbage()
{
stackalloc byte[256].Fill(0xcc);
}

[MethodImpl(MethodImplOptions.NoInlining)]
[SkipLocalsInit]
private static T FaultyDefaultNullable<T>()
{
// When T is a Nullable<T> (and only in that case), we support returning null
if (default(T) is null && typeof(T).IsValueType)
return default!;

throw new InvalidOperationException("Not nullable");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
</Project>