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

Update full-struct references to promoted IBR args#11883

Merged
JosephTremoulet merged 2 commits into
dotnet:masterfrom
JosephTremoulet:PromotedStructRefs
May 24, 2017
Merged

Update full-struct references to promoted IBR args#11883
JosephTremoulet merged 2 commits into
dotnet:masterfrom
JosephTremoulet:PromotedStructRefs

Conversation

@JosephTremoulet
Copy link
Copy Markdown

@JosephTremoulet JosephTremoulet commented May 24, 2017

Update fgMorphImplicitByRefArgs to rewrite references to struct-promoted
implicit-by-reference parameters as references to the new struct temps
created in fgRetypeImplicitByRefArgs; fgMorphStructField isn't updating
these because it's only interested in field references, and runs upstream
of fgRetypeImplicitByRefArgs where the full struct temp is created,
anyway.
Invert the sense of lvPromoted for implicit byref args in the interim
between fgRetypeImplicitByRefArgs and fgMarkDemotedImplicitByRefArgs,
since now fgMarkDemotedImplicitByRefArgs needs to update both and would
look horribly backwards the other way around.

Fixes #11814.

Update fgMorphImplicitByRefArgs to rewrite references to struct-promoted
implicit-by-reference parameters as references to the new struct temps
created in fgRetypeImplicitByRefArgs; fgMorphStructField isn't updating
these because it's only interested in field references, and runs upstream
of fgRetypeImplicitByRefArgs where the full struct temp is created,
anyway.
Invert the sense of lvPromoted for implicit byref args in the interim
between fgRetypeImplicitByRefArgs and fgMarkDemotedImplicitByRefArgs,
since now fgMarkDemotedImplicitByRefArgs needs to update both and would
look horribly backwards the other way around.

Fixes #11814.
@JosephTremoulet
Copy link
Copy Markdown
Author

@briansull PTAL.
/cc @dotnet/jit-contrib, @stephentoub

I've verified that this fixes the repro from dotnet/corefx#20025 in addittion to #11814, though it doesn't fix #11831

Copy link
Copy Markdown

@CarolEidt CarolEidt left a comment

Choose a reason for hiding this comment

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

LGTM modulo some comments and a question

Comment thread src/jit/morph.cpp
// have these fields.
varDsc->lvFieldCnt = 0;

// Hijack lvPromoted to communicate to fgMorphImplicitByRefArgs
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Please add comments on these fields in compiler.h, even though these are transient.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment thread src/jit/morph.cpp Outdated
{
if (varDsc->lvPromoted)
{
// The parameter is simply a pointer now, so clear lvPromoted.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is something that could be confusing if viewed in isolation. You might also mention here that this field has been used temporarily to communicate between fgRetypeImplicitByRefArgs() and this method.

Comment thread src/jit/morph.cpp
// Here we have an arg that was simply never promoted, so make sure it doesn't
// have nonzero lvFieldLclStart, since that would confuse fgMorphImplicitByRefArgs
// and fgMarkDemotedImplicitByRefArgs.
assert(varDsc->lvFieldLclStart == 0);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is really applicable to the previous checkin, but I'm wondering why you're not using BAD_VAR_NUM for these, since 0 is a valid varNum (not that it could ever be a valid lvFieldLclStart)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

That's just the way it gets initialized when the node is created, the ones with 0 for lvFieldLclStart are the ones I'm not touching at all.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ah I see. Thanks.

A number of fields on the LclVarDsc get hijacked during the multi-stage
rewrite of implicit-by-reference parameters; add comments at the fields'
declarations as well as the hijacking uses.
@JosephTremoulet
Copy link
Copy Markdown
Author

Comments updated.

@JosephTremoulet JosephTremoulet merged commit ce0170d into dotnet:master May 24, 2017
@JosephTremoulet JosephTremoulet deleted the PromotedStructRefs branch May 24, 2017 21:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants