Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JIT: Account for mixed-enregistered locals when zeroing without block-init #104593

Merged
merged 4 commits into from
Jul 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions src/coreclr/jit/codegencommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4024,9 +4024,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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In genCheckUseBlockInit it looks like the main loop only increases initStkLclCnt when varDsc->lvIsOnFrame.

So couldn't we use that as an early out detection mechanism? Basically:

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

There's then a secondary handler that increments for spill temps containing pointers, but that looks to be independent of this main loop in genZeroInitFrame and is handled in its own subsequent loop.

Copy link
Member Author

@jakobbotsch jakobbotsch Jul 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

genCheckUseBlockInit will set lvMustInit, so I don't think we need more checks here... the logic is that if genCheckUseBlockInit left lvMustInit as 1 and it isn't in a register, then it must be on frame as otherwise we wouldn't need to init it.


// lvMustInit can only be set for GC types or TYP_STRUCT types
// or when compInitMem is true
Expand All @@ -4035,11 +4041,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
Loading