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

Conservative fix for struct stores in optRemoveRedundantZeroInits #102580

Merged
merged 8 commits into from
May 28, 2024

Conversation

EgorBo
Copy link
Member

@EgorBo EgorBo commented May 22, 2024

Fixes #102577

@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 May 22, 2024
Copy link
Contributor

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

@EgorBo EgorBo marked this pull request as ready for review May 23, 2024 11:35
@EgorBo
Copy link
Member Author

EgorBo commented May 23, 2024

Diffs a bit conservative with a risk to introduce a gc hole (Thanks @SingleAccretion for spotting this issue!). Technically, in many cases such stores won't be converted to calls but any assumptions we can make here are too fragile. I propose we merge this as is and address dotnet/performance regressions if there will be any. We can consider introducing new flags to guarantee that a store won't be converted into a call etc.

cc @SingleAccretion @dotnet/jit-contrib

Copy link
Contributor

@SingleAccretion SingleAccretion left a comment

Choose a reason for hiding this comment

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

A test needs to be added.

src/coreclr/jit/optimizer.cpp Outdated Show resolved Hide resolved
@EgorBo
Copy link
Member Author

EgorBo commented May 23, 2024

/azp list

This comment was marked as resolved.

@EgorBo
Copy link
Member Author

EgorBo commented May 23, 2024

/azp run runtime-coreclr outerloop, runtime-coreclr jitstress, runtime-coreclr gcstress0x3-gcstress0xc, runtime-coreclr gcstress-extra

Copy link

Azure Pipelines successfully started running 4 pipeline(s).

@EgorBo
Copy link
Member Author

EgorBo commented May 23, 2024

/azp run runtime-coreclr outerloop, runtime-coreclr jitstress, runtime-coreclr gcstress0x3-gcstress0xc, runtime-coreclr gcstress-extra

Copy link

Azure Pipelines successfully started running 4 pipeline(s).

@VSadov
Copy link
Member

VSadov commented May 26, 2024

When I added the original not refactored commit to #102415, the GC stress results have improved considerably. There were still a few failures, but a lot less than before.

It seems the original issue could be responsible for a noticeable fraction of random failures.

@EgorBo
Copy link
Member Author

EgorBo commented May 27, 2024

@VSadov @jakobbotsch can I get a green approval then? I hope it will indeed reduce number of random gc hole asserts

// This is quite a conservative fix as it's hard to prove Lower won't do it at this point.
if (tree->OperIsLocalStore())
{
return lvaTable[tree->AsLclVarCommon()->GetLclNum()].TypeGet() == TYP_STRUCT;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return lvaTable[tree->AsLclVarCommon()->GetLclNum()].TypeGet() == TYP_STRUCT;
return lvaGetDesc(tree->AsLclVarCommon())->TypeGet() == TYP_STRUCT;

Feel free to include it in a future change...

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should check the tree type instead of the local's type, i. e. return tree->TypeIs(TYP_STRUCT). One can have struct stores for primitive locals.

Copy link
Member

Choose a reason for hiding this comment

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

Looks simpler so I'm all for it, but it seems unlikely those would end up lowered to calls.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, changed

@EgorBo EgorBo merged commit a50ba06 into dotnet:main May 28, 2024
110 of 113 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.

optRemoveRedundantZeroInits doesn't know about some safe points
4 participants