From 001b87b5a0d969c9e1e16bc1ca8ed943f5ddf497 Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Wed, 28 Jan 2026 16:45:35 -0800 Subject: [PATCH] JIT: fix retyping issue in object stack allocation In cases where we stack allocated an object referred to by local structs, and one of these struct locals was stored to under the value side of a comma, the object allocation phase would inadvertently try and retype the comma, and this retyping ended up cascading back down onto the store and retyping it as well. To fix this, do not run ancestor type propagation for struct stores. Closes #123718 --- src/coreclr/jit/objectalloc.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/coreclr/jit/objectalloc.cpp b/src/coreclr/jit/objectalloc.cpp index 0c5110d8f28ffb..426d610b7feacb 100644 --- a/src/coreclr/jit/objectalloc.cpp +++ b/src/coreclr/jit/objectalloc.cpp @@ -2649,6 +2649,14 @@ void ObjectAllocator::RewriteUses() } else if (newType == TYP_STRUCT) { + // For struct stores there is no upwards type propagation. + // These nodes and any ancestors will remain TYP_STRUCT. + // + if (tree->OperIs(GT_STORE_LCL_VAR, GT_STORE_LCL_FLD)) + { + return Compiler::fgWalkResult::WALK_CONTINUE; + } + newLayout = lclVarDsc->GetLayout(); newType = newLayout->HasGCPtr() ? TYP_BYREF : TYP_I_IMPL; retypeFields = true;