Skip to content

Commit

Permalink
JIT: Account for mixed-enregistered locals when zeroing without block…
Browse files Browse the repository at this point in the history
…-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
  • Loading branch information
jakobbotsch authored Jul 10, 2024
1 parent c52fd37 commit d586986
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/coreclr/jit/codegencommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4055,9 +4055,15 @@ void CodeGen::genZeroInitFrame(int untrLclHi, int untrLclLo, regNumber initReg,
continue;
}

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

noway_assert(varDsc->lvOnFrame);

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

if (!varDsc->lvOnFrame)
{
continue;
}

if ((varDsc->TypeGet() == TYP_STRUCT) && !compiler->info.compInitMem &&
(varDsc->lvExactSize() >= TARGET_POINTER_SIZE))
{
Expand Down

0 comments on commit d586986

Please sign in to comment.