-
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
Change gtGetThisArg not to return nullptr. #44398
Conversation
f1158f0
to
84b1152
Compare
if ((tree->gtFlags & GTF_CALL_NULLCHECK) || tree->AsCall()->IsVirtual()) | ||
// Ignore tail calls because they have 'this` pointer in the regular arg list and an implicit null check. | ||
GenTreeCall* const call = tree->AsCall(); | ||
if (call->NeedsNullCheck() || (call->IsVirtual() && !call->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.
In fgMorphTailCallViaJitHelper
we clear NeedsNullCheck
, should not we also clear IsVirtual
?
Then this condition will be just if (call->NeedsNullCheck() || call->IsVirtual())
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.
@jakobbotsch could you please advise me here?
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.
Sorry I don't know. fgMorphTailCallViaJitHelper
is the old (from before #341) tailcall mechanism used only on x86. This mechanism might be used directly for virtual calls (or VSDs), but I don't remember how the address is computed in those cases.
PTAL @dotnet/jit-contrib |
84b1152
to
671fedd
Compare
/azp run runtime-coreclr outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
src/coreclr/src/jit/morph.cpp
Outdated
@@ -7783,6 +7783,12 @@ GenTree* Compiler::fgMorphTailCallViaHelpers(GenTreeCall* call, CORINFO_TAILCALL | |||
call->gtFlags &= ~GTF_CALL_VIRT_STUB; |
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.
We do it for stub
and in my understanding for vtable
we should do the same, let's see what ci thinks.
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 fgMorphTailCallViaHelpers
which is for the new mechanism. Indeed those turn into normal direct calls always.
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.
it looks like I will need the same fix for fgMorphTailCallViaJitHelper
: sandreenko@53cea4e , but I want to see if our ci catches it.
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.
It looks like we remove all virtual kinds below:
runtime/src/coreclr/src/jit/morph.cpp
Lines 7917 to 7921 in dc3101b
// This is now a direct call to the store args stub and not a tailcall. | |
call->gtCallType = CT_USER_FUNC; | |
call->gtCallMethHnd = help.hStoreArgs; | |
call->gtFlags &= ~GTF_CALL_VIRT_KIND_MASK; | |
call->gtCallMoreFlags &= ~(GTF_CALL_M_TAILCALL | GTF_CALL_M_DELEGATE_INV | GTF_CALL_M_WRAPPER_DELEGATE_INV); |
I guess this line is not required but doesn't hurt since this is where we remove the arg for virtual stubs.
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 see, thank you. I removed changes in fgMorphTailCallViaHelpers
and fixed fgMorphTailCallViaJitHelper
in the same way.
It was probably an old workaround for another Jit bug, it is most likely fixed by now.
53cea4e
to
2ae10db
Compare
There was only 1 case where a null return was tolerated - for a tail call in `optAssertionGen` marked as virtual. However, a transformed tail call is never a virtual, fix `fgMorphTailCallViaJitHelper` to unset virtual flag.
2ae10db
to
8663da9
Compare
/azp run runtime-coreclr outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
@@ -8435,6 +8435,10 @@ void Compiler::fgMorphTailCallViaJitHelper(GenTreeCall* call) | |||
thisPtr = objp; | |||
} | |||
|
|||
// TODO-Cleanup: we leave it as a virtual stub call to |
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 made a try to clear GTF_CALL_VIRT_KIND_MASK
here but it caused failures because logic in LowerCall
depends on this flag to be set in some cases, so I reverted that change.
It would be nice to clear it and fix the failures but it is out of the scope of this bug fix for CoreRT.
ping @dotnet/jit-contrib |
Thanks @BruceForstall for the review! |
bb0c5dc: Don't wrap string literal const as nop for CoreRT.
It was probably an old workaround for another Jit bug, it is most likely fixed by now.
2ae10db1383: Change
gtGetThisArg
not to returnnullptr
.There was only 1 case where a null return was tolerated - for a tail call marked as virtual in
optAssertionGen
.Check this case before we call
gtGetThisArg
.Fixes dotnet/runtimelab#298