Skip to content

PGO: don't instrument edges for known cold places #81774

Description

@EgorBo
static void Foo(object o)
{
    if (o == null)
        throw new ArgumentNullException();

    // other code
}
; Method Prog:Foo(System.Object)
G_M6323_IG01:
       push     rbp
       sub      rsp, 48
       lea      rbp, [rsp+30H]
       xor      eax, eax
       mov      qword ptr [rbp-08H], rax
       mov      gword ptr [rbp+10H], rcx
       cmp      gword ptr [rbp+10H], 0
       jne      SHORT G_M6323_IG04
G_M6323_IG03:
       inc      dword ptr [(reloc)]    ;;; <------------
       mov      rcx, 0xD1FFAB1E
       call     CORINFO_HELP_NEWSFAST
       mov      gword ptr [rbp-08H], rax
       mov      rcx, gword ptr [rbp-08H]
       call     [System.ArgumentNullException:.ctor():this]
       mov      rcx, gword ptr [rbp-08H]
       call     CORINFO_HELP_THROW
G_M6323_IG04:
       inc      dword ptr [(reloc)]    ;;; <------------
       ...

Currently, we emit 2 edge counters for such patterns. If we assume that throw new is always cold we can skip the other edge too and then re-construct missing weights from other blocks

cc @AndyAyersMS the idea we discussed last week

If the throw new is actually hot then 🤷‍♂️ presumably savings/bad decisions from PGO will be not noticeable compared to EH

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions