Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Fix spill check for struct lclVars #23570

Merged
merged 2 commits into from
Apr 2, 2019
Merged

Conversation

CarolEidt
Copy link

With the 1st class struct changes, the SPILL_APPEND check for the case of an assignment to a lclVar needs to handle block ops as well as lclVar lhs.

Fix #23545

@CarolEidt
Copy link
Author

/azp run coreclr-outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@CarolEidt
Copy link
Author

@dotnet/jit-contrib PTAL

With the 1st class struct changes, the `SPILL_APPEND` check for the case of an assignment to a lclVar needs to handle block ops as well as lclVar lhs.

Fix #23545
@CarolEidt
Copy link
Author

I ran PMI diffs on x64, and there are zero diffs. I'm running x86 diffs now.

@CarolEidt
Copy link
Author

Zero x86 diffs as well

@CarolEidt
Copy link
Author

@dotnet-bot test Windows_NT arm64 Cross Checked Innerloop Build and Test

@CarolEidt
Copy link
Author

@dotnet/dnceng - I'm getting "download failure" errors on the "Test pri0 Linux arm64 checked" leg, on several retries (e.g. 88d45f1d-2938-4d52-b7ac-a2f18683e194). And along with the failure, the "Publish logs" job gives "Artifact testbuild_Linux_arm64_checked_innerloop_Logs already exists for build 139295."

@CarolEidt
Copy link
Author

@dotnet/jit-contrib ping - I'd really like to get Linux arm64 testing on this, but so far I have no reason to believe it will fail. Can I get a review of this?

Copy link

@jashook jashook left a comment

Choose a reason for hiding this comment

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

lgtm

}
else if (lhs->OperIsBlk())
{
lclVar = lhs->AsBlk()->Addr()->IsLocalAddrExpr();
Copy link

Choose a reason for hiding this comment

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

Is IsLocalAddrExpr really the right function to use here? There are a few that attempt to detect local addresses and they differ in the trees that they recognize. This one recognizes something like ADD(ADDR(LCL_VAR, 2) but that's less common during import. There's also impIsAddressInLocal that does something similar but instead of ADD nodes it looks for FIELD nodes, which of course are more common during import.

Copy link
Author

Choose a reason for hiding this comment

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

Yes, I think you're right. IsLocalAddrExpr() would be the right thing to call after morph, but at this point we might see a FIELD. I'm going to try to get a repro case for that.

Copy link
Author

Choose a reason for hiding this comment

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

Having spent some time on this, I'm fairly certain that this only needs to handle full assignments. The FIELD case is handled here: https://github.com/dotnet/coreclr/blob/master/src/jit/importer.cpp#L14507, and explicit stloc cases here: https://github.com/dotnet/coreclr/blob/master/src/jit/importer.cpp#L11103
.In the failure case the "assignment" is an initobj. The block cases handle this with a goto SPILL_APPEND which lands here. Pretty much anything else that would modify a local would involve explicitly taking its address (not just in the context of doing a field store).

I gave some thought to whether an assert could be added, but I was unable to do so. So, I'm actually going to simplify this check.

// This is done for non-block assignments in the handling of stloc.
if ((op1->OperGet() == GT_ASG) && varTypeIsStruct(op1->gtOp.gtOp1) &&
(op1->gtOp.gtOp1->gtOper == GT_LCL_VAR))
if ((op1->OperGet() == GT_ASG) && varTypeIsStruct(op1->gtGetOp1()))
Copy link
Member

Choose a reason for hiding this comment

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

Would be nice to also describe why we need to spill in the first place.

Copy link
Author

Choose a reason for hiding this comment

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

OK, will do.

@CarolEidt
Copy link
Author

I added a comment to the offending PR (https://github.com/dotnet/coreclr/pull/22255/files#diff-edc46b80f57431489a82311948a8234d) that shows where this case was previously being handled.

@CarolEidt
Copy link
Author

@dotnet-bot test Windows_NT x64 Checked CoreFX Tests

@CarolEidt
Copy link
Author

@dotnet/dnceng - another isntance of the "Test pri0 Linux arm checked" leg being cancelled.

@CarolEidt
Copy link
Author

I can't figure out how to retry that leg. I'm going to merge this without that leg.

@CarolEidt CarolEidt merged commit f036d23 into dotnet:master Apr 2, 2019
CarolEidt added a commit to CarolEidt/coreclr that referenced this pull request Apr 3, 2019
The assert introduced in dotnet#23570 was overly aggressive, and didn't account for the fact that pointer arithmetic can exist in the IL, not just introduced by morph.

Fix #23693
CarolEidt added a commit that referenced this pull request Apr 4, 2019
The assert introduced in #23570 was overly aggressive, and didn't account for the fact that pointer arithmetic can exist in the IL, not just introduced by morph.

Fix #23693
@CarolEidt CarolEidt deleted the Fix23545 branch September 19, 2019 21:20
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
* Fix spill check for struct lclVars

With the 1st class struct changes, the `SPILL_APPEND` check for the case of an assignment to a lclVar needs to handle block ops as well as lclVar lhs.

Fix dotnet/coreclr#23545


Commit migrated from dotnet/coreclr@f036d23
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
The assert introduced in dotnet/coreclr#23570 was overly aggressive, and didn't account for the fact that pointer arithmetic can exist in the IL, not just introduced by morph.

Fix dotnet/coreclr#23693

Commit migrated from dotnet/coreclr@abec165
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants