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

Keep the volatility of CLS_VARs in rationalization #65919

Merged
merged 1 commit into from
Mar 4, 2022
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
12 changes: 12 additions & 0 deletions src/coreclr/jit/rationalize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,11 +453,18 @@ void Rationalizer::RewriteAssignment(LIR::Use& use)

case GT_CLS_VAR:
{
bool isVolatile = (location->gtFlags & GTF_CLS_VAR_VOLATILE) != 0;

location->gtFlags &= ~GTF_CLS_VAR_VOLATILE;
Copy link
Member

Choose a reason for hiding this comment

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

is it required to reset GTF_CLS_VAR_VOLATILE ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not strictly, no one will look at it once it becomes CLS_VAR_ADDR, but it's good practice to clear flags when bashing to an oper that doesn't support them.

location->SetOper(GT_CLS_VAR_ADDR);
location->gtType = TYP_BYREF;

assignment->SetOper(GT_STOREIND);
assignment->AsStoreInd()->SetRMWStatusDefault();
if (isVolatile)
{
assignment->gtFlags |= GTF_IND_VOLATILE;
}

// TODO: JIT dump
Copy link
Member

Choose a reason for hiding this comment

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

wonder what that is supposed to mean 😄

}
Expand Down Expand Up @@ -691,7 +698,12 @@ Compiler::fgWalkResult Rationalizer::RewriteNode(GenTree** useEdge, Compiler::Ge
if (!isLHSOfAssignment)
{
GenTree* ind = comp->gtNewOperNode(GT_IND, node->TypeGet(), node);
if ((node->gtFlags & GTF_CLS_VAR_VOLATILE) != 0)
{
ind->gtFlags |= GTF_IND_VOLATILE;
}

node->gtFlags &= ~GTF_CLS_VAR_VOLATILE;
node->SetOper(GT_CLS_VAR_ADDR);
node->gtType = TYP_BYREF;

Expand Down