Skip to content

Allow TYP_STRUCT LCL_FLD on the LHS of block copies - #70782

Merged
jakobbotsch merged 2 commits into
dotnet:mainfrom
SingleAccretion:Struct-LclFld-Asg-Lhs
Jun 25, 2022
Merged

jakobbotsch merged 2 commits into
dotnet:mainfrom
SingleAccretion:Struct-LclFld-Asg-Lhs

Conversation

@SingleAccretion

@SingleAccretion SingleAccretion commented Jun 15, 2022 •

Copy link
Copy Markdown
Contributor

For now, we'll do the simple thing and lower it as STORE_OBJ/BLK, completing TYP_STRUCT LCL_FLD support for assignments.

The diffs are minimal and consist of one regression where the GS security logic marks one more parameter as needing a shadow copy (the GS analysis logic treats ASG(LCL_FLD, ...) differently from ASG(OBJ(ADDR(LCL)), ...)), and a couple zero-sized diffs from the same GS logic reordering the stack.

@ghost ghost added area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI community-contribution Indicates that the PR has been added by a community member labels Jun 15, 2022
@ghost

ghost commented Jun 15, 2022

Copy link
Copy Markdown

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

Issue Details

For now, we'll do the simple thing and lower it as STORE_OBJ/BLK, completing TYP_STRUCT LCL_FLD support for assignments.

No diffs are expected.

Author: SingleAccretion
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

For now, we'll do the simple thing and lower it as STORE_OBJ/BLK.

Almost no diffs.
@SingleAccretion
SingleAccretion force-pushed the Struct-LclFld-Asg-Lhs branch from 676f8ed to 5bb4b57 Compare June 15, 2022 17:21
@SingleAccretion
SingleAccretion marked this pull request as ready for review June 16, 2022 19:51
@SingleAccretion

Copy link
Copy Markdown
Contributor Author

@dotnet/jit-contrib

{
assert(!tree->OperIsLocalField() && "do not expect struct local fields.");
lclVarType = GetLayout()->GetRegisterType();
layout = tree->AsLclFld()->GetLayout();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The documentation on this function seems a little misleading now. Generally it feels like the function should maybe be renamed something like GetRegisterTypeForAccess?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The documentation on this function seems a little misleading now.

Do you refer to the "local var" part?

//------------------------------------------------------------------------
// GetRegisterType: Determine register type for this local var. <-- should be "local node"
//
// Arguments:
//    tree - node that uses the local, its type is checked first.
//
// Return Value:
//    TYP_UNDEF if the layout is not enregistrable, the register type otherwise.
//

(The function handled local fields before too, just now we have those struct-typed sometimes as well.)

I don't have an opinion on the name; I can rename it if you think it'd be clearer.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes. I guess most of all it seems like a weird inversion to me that this is a function on LclVarDsc when the local is completely determined by the local node.

Let's leave the potential cleanup to a future change since this handled primitively typed LCL_FLD nodes before as well.

@SingleAccretion SingleAccretion Jun 22, 2022 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I guess most of all it seems like a weird inversion to me that this is a function on LclVarDsc when the local is completely determined by the local node.

Ah yes, this is because we don't have access to the LclVarDsc* from inside GenTree*. The more idiomatic pattern for this problem in the code is to have GenTree::NeedsLclVarDsc(Compiler* compiler), here it was put on LclVarDsc instead, I suppose because it was already available at most callsites.

Let's leave the potential cleanup to a future change since this handled primitively typed LCL_FLD nodes before as well.

Added to my TODO list.

@jakobbotsch
jakobbotsch merged commit 78a4ffa into dotnet:main Jun 25, 2022
@SingleAccretion
SingleAccretion deleted the Struct-LclFld-Asg-Lhs branch June 27, 2022 05:27
@ghost ghost locked as resolved and limited conversation to collaborators Jul 27, 2022
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 community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants