Skip to content

Commit

Permalink
Call impStoreStruct in impStoreNullableFields (dotnet#105529)
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorBo committed Jul 26, 2024
1 parent 360569f commit ebbebac
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3012,6 +3012,12 @@ GenTree* Compiler::impStoreNullableFields(CORINFO_CLASS_HANDLE nullableCls, GenT
ClassLayout* layout = valueType == TYP_STRUCT ? typGetObjLayout(valueStructCls) : nullptr;
GenTree* valueStore = gtNewStoreLclFldNode(resultTmp, valueType, layout, valueOffset, value);

// ABI handling for struct values
if (varTypeIsStruct(valueStore))
{
valueStore = impStoreStruct(valueStore, CHECK_SPILL_ALL);
}

impAppendTree(hasValueStore, CHECK_SPILL_ALL, impCurStmtDI);
impAppendTree(valueStore, CHECK_SPILL_ALL, impCurStmtDI);
return gtNewLclvNode(resultTmp, TYP_STRUCT);
Expand Down
20 changes: 20 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_105518/Runtime_105518.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.CompilerServices;
using Xunit;

public class Runtime_105518
{
[Fact]
public static void TestEntryPoint()
{
Problem<decimal?, decimal>();
}

[MethodImpl(MethodImplOptions.NoInlining)]
private static T GetValue<T>() => (T)(object)100M;

[MethodImpl(MethodImplOptions.NoInlining)]
private static TTo Problem<TTo, TFrom>() => (TTo)(object)GetValue<TFrom>();
}
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>

0 comments on commit ebbebac

Please sign in to comment.