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: Add a stress mode that poisons implicit byrefs #80691

Merged
merged 7 commits into from
Jan 18, 2023

Conversation

jakobbotsch
Copy link
Member

This stress mode poisons all implicit byrefs before returns from the method. GC pointers are nulled out and other parts of the structs are filled with 0xcd bytes.

This should help expose incorrectly elided copies in the recently added last-use copy elision optimization.

This stress mode poisons all implicit byrefs before returns from the
method. GC pointers are nulled out and other parts of the structs are
filled with 0xcd bytes.

This should help expose incorrectly elided copies in the recently added
last-use copy elision optimization.
@ghost ghost assigned jakobbotsch Jan 16, 2023
@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 Jan 16, 2023
@ghost
Copy link

ghost commented Jan 16, 2023

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

Issue Details

This stress mode poisons all implicit byrefs before returns from the method. GC pointers are nulled out and other parts of the structs are filled with 0xcd bytes.

This should help expose incorrectly elided copies in the recently added last-use copy elision optimization.

Author: jakobbotsch
Assignees: jakobbotsch
Labels:

area-CodeGen-coreclr

Milestone: -

@dotnet dotnet deleted a comment from azure-pipelines bot Jan 16, 2023
@jakobbotsch
Copy link
Member Author

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

Comment on lines 11254 to 11264
GenTree* addr;
if (start > 0)
{
addr = gtNewLclFldAddrNode(lclNum, start, TYP_BYREF);
}
else
{
addr = gtNewLclVarAddrNode(lclNum, TYP_BYREF);
}

GenTree* blk = new (this, GT_BLK) GenTreeBlk(GT_BLK, TYP_STRUCT, addr, typGetBlkLayout(count));
Copy link
Contributor

Choose a reason for hiding this comment

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

GLOB_REFs are missing for this assignment and the one below.

Nit: this can use block-based TYP_STRUCT LCL_FLD.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, addressed I think. Can you take another look?

Comment on lines 11214 to 11218
//------------------------------------------------------------------------
// impPoisonImplicitByrefsBeforeReturn:
// Spill the stack and insert IR that poisons all implicit byrefs.
//
void Compiler::impPoisonImplicitByrefsBeforeReturn()
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: a little comment for why do we want to do this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

@jakobbotsch
Copy link
Member Author

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

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@jakobbotsch
Copy link
Member Author

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

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@jakobbotsch
Copy link
Member Author

The failures are known or will be fixed by #80734.

cc @dotnet/jit-contrib PTAL @AndyAyersMS

Copy link
Member

@AndyAyersMS AndyAyersMS left a comment

Choose a reason for hiding this comment

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

Thanks for adding this, it looks like a good safeguard.

@jakobbotsch
Copy link
Member Author

Failures are #80666 and #80773

@jakobbotsch jakobbotsch merged commit 559aa0e into dotnet:main Jan 18, 2023
@jakobbotsch jakobbotsch deleted the stress-write-implicit-byrefs branch January 18, 2023 09:18
@ghost ghost locked as resolved and limited conversation to collaborators Feb 17, 2023
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.

3 participants