-
Notifications
You must be signed in to change notification settings - Fork 2.7k
JIT: improve return types in cases with spill temps #15766
JIT: improve return types in cases with spill temps #15766
Conversation
If the jit sees that an inlinee has multiple return sites or has gc ref locals it will choose to return the inline result via a temp. The jit was not assigning a type to that temp and so losing track of some type information. So, for inlinees returning ref types, initially type the return spill temp with the declared return type of the method. When importing we may discover that particular return sites will return more specific types. If all discovered return sites agree, we can update the return type for the spill temp to match the consensus improved type. This can lead to removal of some type checks and also to devirtualization. Addresses issues discussed in #9908 and dotnet#15743.
@briansull PTAL Jit-diffs with Ben's prospectve changes to
All the corelib changes are devirtualizations of |
Think there is maybe some potential for skew between updating arm tests and updating the jit...? Not sure how else to explain this arm failure and this armlb failure @dotnet-bot test Windows_NT arm Cross Checked Innerloop Build and Test |
Seems happy now; could it have been the myget outage? https://github.com/dotnet/coreclr/issues/15769 |
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
With the if it doesn't do the sharpening yet?
|
This is now likely hitting the issue of extracting a type from a static field access. Because the static is in a generic type the static field expansion is complex and the jit doesn't see the type. In one of your variants you had these static caches factored out into a non-generic helper class; that might work better here. |
Beautiful 😄
|
Doesn't always work; will see if I can get more info mov rax, qword ptr [rax+64]
call gword ptr [rax+32]ArrayPool`1:Rent(int):ref:this
mov gword ptr [rbp-48H], rax
G_M32816_IG03:
; ...
G_M32816_IG13:
mov rdx, gword ptr [rbp-48H]
xor r8d, r8d
cmp dword ptr [rcx], ecx
call TlsOverPerCoreLockedStacksArrayPool`1:Return(ref,bool):this
mov eax, esi |
1439 calls currently devirtualise in |
If the jit sees that an inlinee has multiple return sites or has gc ref locals
it will choose to return the inline result via a temp. The jit was not assigning
a type to that temp and so losing track of some type information.
So, for inlinees returning ref types, initially type the return spill temp with
the declared return type of the method.
When importing we may discover that particular return sites will return more
specific types. If all discovered return sites agree, we can update the return
type for the spill temp to match the consensus improved type.
This can lead to removal of some type checks and also to devirtualization.
Addresses issues discussed in #9908 and #15743.