-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Prepare JIT backend for structs in registers. #52039
Conversation
7b81072
to
408fda0
Compare
/azp run runtime-coreclr jitstress |
Azure Pipelines successfully started running 1 pipeline(s). |
f0cc1f9
to
9452b92
Compare
/azp run runtime-coreclr jitstress |
Azure Pipelines successfully started running 1 pipeline(s). |
9452b92
to
66f562a
Compare
PTAL @BruceForstall @dotnet/jit-contrib |
So this change is only for xarch? Any changes this (or next PRs) will help handle one of these problems in Arm64 - #41704 (comment)? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few questions.
Did you run x86 diffs, too?
@@ -517,6 +517,9 @@ CONFIG_INTEGER(JitSaveFpLrWithCalleeSavedRegisters, W("JitSaveFpLrWithCalleeSave | |||
#endif // defined(TARGET_ARM64) | |||
#endif // DEBUG | |||
|
|||
// Allow to enregister locals with struct type. | |||
CONFIG_INTEGER(JitEnregStructLocals, W("JitEnregStructLocals"), 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You want this to be available in Release?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
src/coreclr/jit/lclvars.cpp
Outdated
// tree - node that uses the local, its type is checked first. | ||
// | ||
// Return Value: | ||
// TYP_UNDEF if the layout is enregistrable, register type otherwise. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it the opposite? That is, return TYP_UNDEF if the layout is NOT enregistrable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixed.
src/coreclr/jit/lclvars.cpp
Outdated
// Ensure that lclVar nodes are typed correctly. | ||
if (tree->OperIs(GT_STORE_LCL_VAR) && lvNormalizeOnStore()) | ||
{ | ||
// TODO: update that assert to work with TypeGet() == TYP_STRUCT case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you going to fix this "TODO" now, or later? Or should the whole block be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall
src/coreclr/jit/codegenlinear.cpp
Outdated
@@ -864,14 +864,14 @@ void CodeGen::genSpillVar(GenTree* tree) | |||
// therefore be store-normalized (rather than load-normalized). In fact, not performing store normalization | |||
// can lead to problems on architectures where a lclVar may be allocated to a register that is not | |||
// addressable at the granularity of the lclVar's defined type (e.g. x86). | |||
var_types lclTyp = genActualType(varDsc->TypeGet()); | |||
emitAttr size = emitTypeSize(lclTyp); | |||
var_types lclType = genActualType(varDsc->GetRegisterType()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are going to have lot of patterns like genActualType(varDsc->GetRegisterType())
, probably worth adding an override to genActualType(varDsc)
that does the GetRegisterType()
part?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this, added.
For @BruceForstall :
Yes, no diffs as well. For @kunalspathak :
These changes are for all platforms.
The struct enreg will help arm64 but not the problems listed there. |
The PR prepares our backend to see
LCL_VAR struct
in registers, part of #43867.It has 0 diffs as expected because
JitEnregStructLocals
is set to 0.The main change is around spilling/reloading code because for direct usages we replace "struct" type with platform-specific type during lowering (like for "calls()" and "returns").