-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[Jit] Overzealous w/ do-not-enreg in presence of EH #9514
Comments
The two functions differ by the presence of
Even though in ; Assembly listing for method Program:Func1(ref,ref):int:this
; Emitting BLENDED_CODE for X64 CPU with AVX
; optimized code
; rbp based frame
; fully interruptible
; Final local variable assignments
;
; V00 this [V00,T00] ( 4, 4 ) ref -> [rbp+0x10] do-not-enreg[H] this class-hnd
; V01 arg1 [V01,T01] ( 3, 3 ) ref -> rdx class-hnd
; V02 arg2 [V02,T02] ( 3, 3 ) ref -> r8 class-hnd
; V03 loc0 [V03,T05] ( 2, 2 ) int -> [rbp-0x04] do-not-enreg[H]
; V04 loc1 [V04,T04] ( 4, 2 ) ref -> [rbp-0x10] do-not-enreg[H] class-hnd
+; V05 loc2 [V05,T06] ( 2, 2 ) int -> rax
; V06 tmp0 [V06,T07] ( 2, 0 ) ref -> rcx class-hnd
; V07 OutArgs [V07 ] ( 1, 1 ) lclBlk (32) [rsp+0x00]
; V08 PSPSym [V08 ] ( 1, 1 ) long -> [rbp-0x20] do-not-enreg[X] addr-exposed
; V09 rat0 [V09,T03] ( 2, 4 ) ref -> rax
;
; Lcl frame size = 64 ; Assembly listing for method Program:Func2(ref,ref):int:this
; Emitting BLENDED_CODE for X64 CPU with AVX
; optimized code
; rbp based frame
; fully interruptible
; Final local variable assignments
;
; V00 this [V00,T00] ( 4, 4 ) ref -> [rbp+0x10] do-not-enreg[H] this class-hnd
; V01 arg1 [V01,T01] ( 3, 3 ) ref -> rdx class-hnd
; V02 arg2 [V02,T02] ( 3, 3 ) ref -> r8 class-hnd
; V03 loc0 [V03,T05] ( 2, 2 ) int -> [rbp-0x04] do-not-enreg[H]
; V04 loc1 [V04,T04] ( 4, 2 ) ref -> [rbp-0x10] do-not-enreg[H] class-hnd
-; V05 loc2 [V05,T06] ( 2, 2 ) int -> rax
; V05 tmp0 [V05,T06] ( 2, 0 ) ref -> rcx class-hnd
; V06 OutArgs [V06 ] ( 1, 1 ) lclBlk (32) [rsp+0x00]
; V07 PSPSym [V07 ] ( 1, 1 ) long -> [rbp-0x20] do-not-enreg[X] addr-exposed
; V08 rat0 [V08,T03] ( 2, 4 ) ref -> rax
;
; Lcl frame size = 64 |
Not sure the exact terminology but is the analysis correct @mikedn ? |
Looks like a variant of #7775? @CarolEidt |
Interesting, |
In
Note In It could be that fixing the jit to handle never-written locals in the presence of EH would be a nice incremental improvement and would be less complex than full write-through. In particular |
Could it only consider candidate merges if they have the same |
Not quite sure what "it" you have in mind here. |
Not sure which stage; but at the start of the dump it starts with Which would be fine; if they could both either be registers or both could not be registers. However, since one can be a register and the other cannot, currently, that should block them being merged? (unless there aren't enough registers already) |
The IL I see for
|
Ah, you are correct! Sorry, I was completely misreading the output 😦 |
@AndyAyersMS thanks for pointing that out! A solution seems to be to introduce extra variables before and after the EH and to use those; then use a set to only cross EH and to reload the second set of variables from dotnet/coreclr#15629 (comment) |
Given the following code
In both
Func1
andFunc2
as the variablei
's lifetime crosses exception handling it is marked asdo-not-enreg
In neither
Func1
norFunc2
does the variableii
's lifetime cross exception handling.In
Func1
ii
's lifetime crossesi
's lifetime so they cannot share a register; soii
is not marked asdo-not-enreg
👍In
Func2
ii
's lifetime does not crossi
's lifetime so they can share a register; which meansii
inheritsi
sdo-not-enreg
👎Seen in "Reduce Execution Context Save+Restore" dotnet/coreclr#15629
category:cq
theme:eh
skill-level:expert
cost:medium
The text was updated successfully, but these errors were encountered: