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

Fix enregistered lclFld bug#18418

Merged
CarolEidt merged 3 commits into
dotnet:masterfrom
CarolEidt:Fix18408
Jun 13, 2018
Merged

Fix enregistered lclFld bug#18418
CarolEidt merged 3 commits into
dotnet:masterfrom
CarolEidt:Fix18408

Conversation

@CarolEidt
Copy link
Copy Markdown

In impFixupStructReturnType(), don't transform to GT_LCL_FLD if we have a scalar lclVar.
Also, to avoid future bad codegen, add verification and recovery code to Lowering.

Fix #18408

@CarolEidt
Copy link
Copy Markdown
Author

The reason this was not encountered previously is that, prior to #17996, the IND(ADDR) wasn't folded away due to a cast.

In `impFixupStructReturnType()`, don't transform to `GT_LCL_FLD` if we have a scalar lclVar.
Also, to avoid future bad codegen, add verification and recovery code to Lowering.

Fix #18408
@AndyAyersMS
Copy link
Copy Markdown
Member

Is this something we could catch earlier with some kind of IR check?

@CarolEidt
Copy link
Copy Markdown
Author

Is this something we could catch earlier with some kind of IR check?

Possibly; I thought it best to add a check just prior to where it matters - i.e. in Lowering. However, apparently this has caused a failure in one of the HW intrinsics tests. Working now on trying to repro.

…so it can be called from the assert in Lowering.
@CarolEidt CarolEidt closed this Jun 12, 2018
@CarolEidt CarolEidt reopened this Jun 12, 2018
@CarolEidt
Copy link
Copy Markdown
Author

@dotnet/jit-contrib PTAL

Comment thread src/jit/lsra.cpp
return false;
}

// Don't enregister if the ref count is zero.
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.

This section of code, and the above check for !enregisterLocalVars were extracted from identifyCandidates() so that isRegCandidate can be called from the assert in Lowering.

Comment thread src/jit/importer.cpp Outdated
op->ChangeOper(GT_LCL_FLD);
// It is possible that we now have a lclVar of scalar type.
// If so, don't transform it to GT_LCL_FLD.
if (varTypeIsStruct(lvaTable[op->AsLclVarCommon()->gtLclNum].lvType))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Could be AsLclVar but I guess it doesn't really matter.

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.

Yes, I think I'm programmed to use AsLclVarCommon

Comment thread src/jit/lower.h Outdated
// Any tracked lclVar accessed by a LCL_FLD or STORE_LCL_FLD should be marked doNotEnregister.
// This method checks, and asserts in the DEBUG case if it is not so marked,
// but in the non-DEBUG case (asserts disabled) set the flag so that we don't generate bad code.
// Thie ensures that the local's value is valid on-stack as expected for a *LCL_FLD.
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

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.

Thanks will fix

Comment thread src/jit/lsra.cpp Outdated
#if CPU_HAS_FP_SUPPORT
case TYP_FLOAT:
case TYP_DOUBLE:
if (compiler->opts.compDbgCode)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think the whole switch would be more readable if this and other similar cases below are changed to return !compiler->opts.compDbgCode;.

Comment thread src/jit/lsra.cpp Outdated
{
return false;
}
break;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Braces and break not necessary.

@CarolEidt
Copy link
Copy Markdown
Author

@dotnet/jit-contrib ping - I'd like to get this merged to unblock corert moving to the latest

Copy link
Copy Markdown

@briansull briansull left a comment

Choose a reason for hiding this comment

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

Looks Good

@CarolEidt CarolEidt merged commit 82134a0 into dotnet:master Jun 13, 2018
jkotas added a commit to jkotas/coreclr that referenced this pull request Jun 14, 2018
@CarolEidt CarolEidt deleted the Fix18408 branch January 23, 2019 01:11
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
* Fix enregistered lclFld bug

In `impFixupStructReturnType()`, don't transform to `GT_LCL_FLD` if we have a scalar lclVar.
Also, to avoid future bad codegen, add verification and recovery code to Lowering.

Fix dotnet/coreclr#18408

* Extract the full conditions for whether a lclVar is a reg candidate, so it can be called from the assert in Lowering.

* Review feedback


Commit migrated from dotnet/coreclr@82134a0
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