Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

PGO: simple generic method is not inlined #88299

Closed

Description

@EgorBo
for (int i = 0; i < 100; i++)
{
    Test(new ObjImpl<string>());
    Thread.Sleep(16);
}

[MethodImpl(MethodImplOptions.NoInlining)]
static object Test(IObj o) => o.GetObj();


public interface IObj
{
    object GetObj();
}

public class ObjImpl<T> : IObj
{
    public object GetObj() => typeof(T);
}

Codegen for Test in Tier1:

; Assembly listing for method Program:<<Main>$>g__Test|0_0(IObj):System.Object (Tier1)
       sub      rsp, 40
       mov      rax, 0xD1FFAB1E  ; ObjImpl`1[System.String]
       cmp      qword ptr [rcx], rax
       jne      SHORT G_M33634_IG06
       call     [ObjImpl`1[System.__Canon]:GetObj():System.Object:this]
G_M33634_IG04:
       nop      
       add      rsp, 40
       ret      
G_M33634_IG06:
       mov      r11, 0xD1FFAB1E      ; code for IObj:GetObj():System.Object:this
       call     [r11]IObj:GetObj():System.Object:this
       jmp      SHORT G_M33634_IG04
; Total bytes of code 46,

GDV is applied but the method is not inlined, presumably, the root cause is the same as in #87597 - generic context from the GDV candidate is not kept (but I am not sure, decided to file since I noticed a similiar pattern in real code)

Activity

  1. ghost added
    area-CodeGen-coreclr
    on Jul 2, 2023
  2. ghost added
    untriaged
    on Jul 2, 2023
  3. added this to the 8.0.0 milestone on Jul 2, 2023
  4. ghost removed
    untriaged
    on Jul 2, 2023
  5. self-assigned this
    on Jul 2, 2023
  6. EgorBo commented on Jul 22, 2023

    @EgorBo
    MemberAuthor

    Just checked, this issue will be closed by #87847
    codegen diff (Main vs that PR): https://www.diffchecker.com/iyxpsemY/ (method is inlined now)
    cc @davidwrighton @AndyAyersMS

  7. ghost locked as resolved and limited conversation to collaborators on Aug 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclr

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions