Skip to content

Early fgFindJumpTargets inline bail prevents setting DOES_NOT_RETURN flag #6501

@benaadams

Description

@benaadams

This means exception throwing methods are not moved into cold code if they are noted to be non inlinable in prejit and it can cause excessive register work can be done as if the function returns.

Without does not return:

; Assembly listing for method List`1:CopyTo(int,ref,int,int):this
; Lcl frame size = 48
G_M45633_IG01:
       push     r14          ; Unnecessary 
       push     rdi          ; Unnecessary 
       push     rsi          ; Unnecessary 
       push     rbp          ; Unnecessary 
       push     rbx          ; Unnecessary 
       sub      rsp, 48
       mov      rsi, rcx
       mov      edi, edx
       mov      rbx, r8
       mov      ebp, r9d
       mov      r14d, dword ptr [rsp+80H]
G_M45633_IG02:
       mov      ecx, dword ptr [rsi+24]
       sub      ecx, edi
       cmp      ecx, r14d
       jge      SHORT G_M45633_IG03
       mov      ecx, 23
       call     ThrowHelper:ThrowArgumentException(int)
G_M45633_IG03:
       mov      rcx, gword ptr [rsi+8]
       mov      dword ptr [rsp+20H], r14d
       xor      edx, edx
       mov      dword ptr [rsp+28H], edx
       mov      edx, edi
       mov      r8, rbx
       mov      r9d, ebp
       call     Array:Copy(ref,int,ref,int,int,bool)
       nop      
G_M45633_IG04:
       add      rsp, 48
       pop      rbx          ; Unnecessary 
       pop      rbp          ; Unnecessary 
       pop      rsi          ; Unnecessary 
       pop      rdi          ; Unnecessary 
       pop      r14          ; Unnecessary 
       ret      
; Total bytes of code 89, prolog size 10 for method List`1:CopyTo(int,ref,int,int):this

With does not return

; Assembly listing for method List`1:CopyTo(int,ref,int,int):this
; Lcl frame size = 56
G_M45633_IG01:
       sub      rsp, 56
       nop      
       mov      eax, dword ptr [rsp+60H]
G_M45633_IG02:
       mov      r10d, dword ptr [rcx+24]
       sub      r10d, edx
       cmp      r10d, eax
       jl       G_M45633_IG05
G_M45633_IG03:
       mov      rcx, gword ptr [rcx+8]
       mov      dword ptr [rsp+20H], eax
       xor      eax, eax
       mov      dword ptr [rsp+28H], eax
       call     Array:Copy(ref,int,ref,int,int,bool)
       nop      
G_M45633_IG04:
       add      rsp, 56
       ret      
************** Beginning of cold code **************
G_M45633_IG05:
       mov      ecx, 23
       call     ThrowHelper:ThrowArgumentException(int)
       int3     
; Total bytes of code 61, prolog size 5 for method List`1:CopyTo(int,ref,int,int):this

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIoptimization

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions