From 4e85471628214a3e6257132cadd8f7fd33299eb0 Mon Sep 17 00:00:00 2001 From: SingleAccretion <62474226+SingleAccretion@users.noreply.github.com> Date: Sun, 23 Oct 2022 02:54:51 +0300 Subject: [PATCH] Set DNER for all local fields (#77341) Not just the promoted ones. --- src/coreclr/jit/morph.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/coreclr/jit/morph.cpp b/src/coreclr/jit/morph.cpp index b7b4766b387d5..f9110161d9f19 100644 --- a/src/coreclr/jit/morph.cpp +++ b/src/coreclr/jit/morph.cpp @@ -16386,10 +16386,6 @@ void Compiler::fgMorphLocalField(GenTree* tree, GenTree* parent) } else { - // There is no existing field that has all the parts that we need - // So we must ensure that the struct lives in memory. - lvaSetVarDoNotEnregister(lclNum DEBUGARG(DoNotEnregisterReason::LocalField)); - #ifdef DEBUG // We can't convert this guy to a float because he really does have his // address taken.. @@ -16405,6 +16401,12 @@ void Compiler::fgMorphLocalField(GenTree* tree, GenTree* parent) JITDUMP("Replacing GT_LCL_FLD of struct with local var V%02u\n", lclNum); } } + + // If we haven't replaced the field, make sure to set DNER on the local. + if (tree->OperIs(GT_LCL_FLD)) + { + lvaSetVarDoNotEnregister(lclNum DEBUGARG(DoNotEnregisterReason::LocalField)); + } } //------------------------------------------------------------------------