-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Fix issue with devirtualization and tailcalls #21804
Conversation
@AndyAyersMS FYI |
You should make it clearer that this restriction is for explicit tail calls only, where presumably the IL producer is confident that at the point of the explicit tail call there aren't any live references to the caller frame, and if we undo the box, we will introduce one. And I think this could also happen for late devirt though it would require a different kind of test case. Seems like you could just check for |
The flag GTF_CALL_M_EXPLICIT_TAILCALL is currently not yet set by the importer when we reach this method. |
The IL for the method with the tailcall is:
This IL doesn't contain any live references to the caller frame, however the JIT compiler introduces one via:
Source code:
|
Hmm, ok. We should still fix the late devirt path, and that one needs to work with the call flags. So we need to adapt for one convention or the other. If it was me I'd probably handle this by passing in a bool |
…ization and a tail call optimization Explicit tail calls are now checked for and blocked from performing an unboxing operation in impDevirtualizeCall If late devirtualization calls impDevirtualizeCall with an IMPLICIT_TAILCALL we will clear this flag if we decide to perform the unboxing operation.
92bbf5a
to
8c12e27
Compare
@AndyAyersMS @jashook PTAL |
|
||
if (info.compCompHnd->canTailCall(info.compMethodHnd, methHnd, exactCalleeHnd, explicitTailCall)) | ||
{ | ||
canTailCall = true; |
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.
This assignment was redundant (see line 8736 above)
@dotnet-bot Test Ubuntu x64 Checked Innerloop Build and Test |
@dotnet-bot test Ubuntu x64 Checked Innerloop Build and Test (Jit - TieredCompilation=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.
Looks good overall, just two small nits.
Would be nice to have a test case here too (probably an IL case...)
src/jit/importer.cpp
Outdated
|
||
if (isTailCall) | ||
{ | ||
JITDUMP("Call is an explcit tail call, we cannot perform an unbox\n"); |
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.
Typo: explcit
src/jit/importer.cpp
Outdated
// contextHandle -- [IN/OUT] context handle for the call. Updated iff call devirtualized. | ||
// exactContextHnd -- [OUT] updated context handle iff call devirtualized | ||
// isLateDevirtualization -- if devirtualization is happening after importation | ||
// isTailCall -- [IN/OUT] true if we plan on using a tail call |
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.
This is no longer [in/out] -- also rename to isExplictTailCall
Yes, I do have an IL test case that I will add |
src/jit/compiler.h
Outdated
CORINFO_CONTEXT_HANDLE* exactContextHandle, | ||
bool isLateDevirtualization); | ||
bool isLateDevirtualization, | ||
bool isTailCall); |
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.
Is the compiler global isTailCall
used?
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.
This parameter is used and it is also renamed as isExplicitTailCall
Change test priority to 0
@dotnet-bot Test OSX10.12 x64 Checked Innerloop Build and Test |
@dotnet-bot Test Windows_NT arm Cross Checked Innerloop Build and Test |
Back patching #21804 to the 2.2 branch
Fix issue with devirtualization and tailcalls Commit migrated from dotnet/coreclr@df88b1f
When performing devirtualization we can not do both an unboxing optimization and a tail call optimization