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

Conversation

jakobbotsch
Copy link
Member

@jakobbotsch jakobbotsch commented Jul 9, 2024

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 ignores 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

…-init

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 dotnet#104570
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jul 9, 2024
Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

@jakobbotsch
Copy link
Member Author

/azp run runtime-coreclr jitstress, runtime-coreclr libraries-jitstress

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

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.

Copy link
Member

@tannergooding tannergooding left a comment

Choose a reason for hiding this comment

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

LGTM. It's somewhat hard to correlate the logic done in genCheckUseBlockInit in contrast to the logic done in genZeroInitFrame, I think long term it'd be ideal if these could be more explicit between the two to make it very clear that we're handling the right things.

@jakobbotsch
Copy link
Member Author

jakobbotsch commented Jul 9, 2024

LGTM. It's somewhat hard to correlate the logic done in genCheckUseBlockInit in contrast to the logic done in genZeroInitFrame, I think long term it'd be ideal if these could be more explicit between the two to make it very clear that we're handling the right things.

Yeah... @AndyAyersMS has had musings about creating an actual object model of the stack frame, which would also make this stuff harder to get wrong.

@jakobbotsch jakobbotsch marked this pull request as ready for review July 9, 2024 19:44
@jakobbotsch
Copy link
Member Author

cc @dotnet/jit-contrib

libraries-jitstress failures look like #104613, #104605, #102706, #104269/#103940/#103630/#103549, #104366
Other failures look like infra issues.

@jakobbotsch jakobbotsch merged commit d586986 into dotnet:main Jul 10, 2024
122 of 132 checks passed
@jakobbotsch jakobbotsch deleted the fix-104570 branch July 10, 2024 06:45
matouskozak added a commit to matouskozak/runtime that referenced this pull request Jul 11, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Aug 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

superpmi-replay failing with Assertion failed 'emitCurIG != emitPrologIG'
2 participants