Skip to content

Commit d586986

Browse files
authored
JIT: Account for mixed-enregistered locals when zeroing without block-init (#104593)
Locals that are in registers at the beginning of a function do not need to have their stack home zeroed. `genFnProlog` already skips these locals when computing the range of bytes to zero; however, `genZeroInitFrame` was not doing the same in the non-block init case, which does not make use of the range computed by `genFnProlog`. This could cause an unbounded amount of (unnecessary) codegen during zero-initing, which is not legal to have in the prolog. Fix #104570
1 parent c52fd37 commit d586986

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/coreclr/jit/codegencommon.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4055,9 +4055,15 @@ void CodeGen::genZeroInitFrame(int untrLclHi, int untrLclLo, regNumber initReg,
40554055
continue;
40564056
}
40574057

4058-
// TODO-Review: I'm not sure that we're correctly handling the mustInit case for
4059-
// partially-enregistered vars in the case where we don't use a block init.
4060-
noway_assert(varDsc->lvIsInReg() || varDsc->lvOnFrame);
4058+
// Locals that are (only) in registers to begin with do not need
4059+
// their stack home zeroed. Their register will be zeroed later in
4060+
// the prolog.
4061+
if (varDsc->lvIsInReg() && !varDsc->lvLiveInOutOfHndlr)
4062+
{
4063+
continue;
4064+
}
4065+
4066+
noway_assert(varDsc->lvOnFrame);
40614067

40624068
// lvMustInit can only be set for GC types or TYP_STRUCT types
40634069
// or when compInitMem is true
@@ -4066,11 +4072,6 @@ void CodeGen::genZeroInitFrame(int untrLclHi, int untrLclLo, regNumber initReg,
40664072
noway_assert(varTypeIsGC(varDsc->TypeGet()) || (varDsc->TypeGet() == TYP_STRUCT) ||
40674073
compiler->info.compInitMem || compiler->opts.compDbgCode);
40684074

4069-
if (!varDsc->lvOnFrame)
4070-
{
4071-
continue;
4072-
}
4073-
40744075
if ((varDsc->TypeGet() == TYP_STRUCT) && !compiler->info.compInitMem &&
40754076
(varDsc->lvExactSize() >= TARGET_POINTER_SIZE))
40764077
{

0 commit comments

Comments
 (0)