The code does not properly mark the parent struct as address exposed,
but also doing so would completely disable any tracking/optimization for
these locals which we do not want to do.
Fix #81739
void Compiler::lvaSetVarAddrExposed(unsigned varNum DEBUGARG(AddressExposedReason reason))
{
LclVarDsc* varDsc = lvaGetDesc(varNum);
+ assert(!varDsc->lvIsStructField);
varDsc->SetAddressExposed(true DEBUGARG(reason));
if (!omitCopy && fgGlobalMorph)
{
- omitCopy = !varDsc->lvPromoted && ((lcl->gtFlags & GTF_VAR_DEATH) != 0);
+ omitCopy = !varDsc->lvPromoted && !varDsc->lvIsStructField && ((lcl->gtFlags & GTF_VAR_DEATH) != 0);
}
if (!omitCopy && (totalAppearances == 1))
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System.Numerics;
+using System.Runtime.CompilerServices;
+
+public class Runtime_81739
+{
+ public static int Main()
+ {
+ Plane p;
+ p.Normal = default;
+ Consume(p.Normal);
+ return 100;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static void Consume<T>(T v)
+ {
+ }
+}
--- /dev/null
+<Project Sdk="Microsoft.NET.Sdk">
+ <PropertyGroup>
+ <OutputType>Exe</OutputType>
+ <Optimize>True</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="$(MSBuildProjectName).cs" />
+ </ItemGroup>
+</Project>
\ No newline at end of file