Skip to content
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

Fix some missing debug info #62018

Merged

Conversation

jakobbotsch
Copy link
Member

@jakobbotsch jakobbotsch commented Nov 24, 2021

  • Propagate debug info in loop cloning

  • Do not consume debug info on the standalone call statement created for
    inline candidates. This would lead to the loss of debugging
    information for failed inline candidates, since those statements are
    dropped and expanded in the upcoming GT_RET_EXPR node instead. In some
    cases it would also lead to the loss of debugging information for
    successful inlines.
    In the new logic we allow the same debugging information to be
    attached to the upcoming statement using the GT_RET_EXPR.

This change adds around 40 KB (~0.5%) to SPC.

Extracted from #61846.

* Propagate debug info in loop cloning

* Do not consume debug info on the standalone call statement created for
  inline candidates. This would lead to the loss of debugging
  information for failed inline candidates, since those statements are
  dropped and expanded in the upcoming GT_RET_EXPR node instead. In some
  cases it would also lead to the loss of debugging information for
  successful inlines.
  In the new logic we allow the same debugging information to be
  attached to the upcoming statement using the GT_RET_EXPR.

This change adds around 40 KB (~0.5%) to SPC.
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Nov 24, 2021
@ghost
Copy link

ghost commented Nov 24, 2021

Tagging subscribers to this area: @JulieLeeMSFT
See info in area-owners.md if you want to be subscribed.

Issue Details
  • Propagate debug info in loop cloning

  • Do not consume debug info on the standalone call statement created for
    inline candidates. This would lead to the loss of debugging
    information for failed inline candidates, since those statements are
    dropped and expanded in the upcoming GT_RET_EXPR node instead. In some
    cases it would also lead to the loss of debugging information for
    successful inlines.
    In the new logic we allow the same debugging information to be
    attached to the upcoming statement using the GT_RET_EXPR.

This change adds around 40 KB (~0.5%) to SPC.

Author: jakobbotsch
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@jakobbotsch
Copy link
Member Author

Same question as in the other PR: any concerns about the size increase?

cc @dotnet/jit-contrib @jkotas

@jkotas
Copy link
Member

jkotas commented Nov 24, 2021

I thought that the size increase in other PR came from the 3rd change (Allow generating more native<->IL mappings mapping) that is dropped in this PR. Is it not the case? What is a good example of debug info delta that leads to the size increase?

@jakobbotsch
Copy link
Member Author

jakobbotsch commented Nov 24, 2021

The 3rd point in that PR accounted only for ~5 KB size increase. The vast majority of the size increase is coming because, before this change, we completely lose debug information for any inline candidate that fails to inline sufficiently late in the JIT's analysis. For example:

using System;

public static class Program
{
    public static void Main()
    {
        NotInlinedByAnalysis(0);
        NotInlinedByAnalysis(1);
        NotInlinedByAnalysis(2);
        NotInlinedByAnalysis(3);
        NotInlinedByAnalysis(4);
    }

    private static int NotInlinedByAnalysis(int foo)
    {
        for (int i = 0; i < -Environment.TickCount; i++)
        {
            for (int j = 0; j < -Environment.TickCount; j++)
            {
                for (int k = 0; k < -Environment.TickCount; k++)
                {
                    for (int l = 0; l < -Environment.TickCount; l++)
                    {
                        System.Console.WriteLine("{0} {1} {2} {3}", i, j, k, l);
                    }
                }
            }
        }

        return 5;
    }
}

The diff with this change is:

 ; Assembly listing for method Program:Main()
 ; Emitting BLENDED_CODE for X64 CPU with AVX - Windows
 ; optimized code
 ; rsp based frame
 ; partially interruptible
 ; No PGO data
 ; Final local variable assignments
 ;
 ;  V00 OutArgs      [V00    ] (  1,  1   )  lclBlk (32) [rsp+00H]   "OutgoingArgSpace"
 ;
 ; Lcl frame size = 40
 
 G_M27646_IG01:
        sub      rsp, 40
 						;; bbWeight=1    PerfScore 0.25
 G_M27646_IG02:
+       ; INLRT @ 0x000[E-]
        xor      ecx, ecx
        call     Program:NotInlinedByAnalysis(int):int
+       ; INLRT @ 0x007[E-]
        mov      ecx, 1
        call     Program:NotInlinedByAnalysis(int):int
+       ; INLRT @ 0x00E[E-]
        mov      ecx, 2
        call     Program:NotInlinedByAnalysis(int):int
+       ; INLRT @ 0x015[E-]
        mov      ecx, 3
        call     Program:NotInlinedByAnalysis(int):int
+       ; INLRT @ 0x01C[E-]
        mov      ecx, 4
        call     Program:NotInlinedByAnalysis(int):int
        ; INLRT @ 0x023[E-]
        nop      
 						;; bbWeight=1    PerfScore 6.50
 G_M27646_IG03:
        add      rsp, 40
        ret      
 						;; bbWeight=1    PerfScore 1.25
 
 ; Total bytes of code 57, prolog size 4, PerfScore 13.70, instruction count 14, allocated bytes for code 57 (MethodHash=cb019401) for method Program:Main()
 ; ============================================================
 
-IP mapping count : 3
+IP mapping count : 8
 IL offs PROLOG : 0x00000000 ( STACK_EMPTY )
+IL offs 0x0000 : 0x00000004 ( STACK_EMPTY )
+IL offs 0x0007 : 0x0000000B ( STACK_EMPTY )
+IL offs 0x000E : 0x00000015 ( STACK_EMPTY )
+IL offs 0x0015 : 0x0000001F ( STACK_EMPTY )
+IL offs 0x001C : 0x00000029 ( STACK_EMPTY )
 IL offs 0x0023 : 0x00000033 ( STACK_EMPTY )
 IL offs EPILOG : 0x00000033 ( STACK_EMPTY )
 
 ; Variable debug info: 0 live ranges, 0 vars for method Program:Main()

@jkotas
Copy link
Member

jkotas commented Nov 24, 2021

Ah ok. No concerns about the size increase from me.

@jakobbotsch jakobbotsch merged commit ee3b77d into dotnet:main Dec 1, 2021
@jakobbotsch jakobbotsch deleted the inlining-and-loop-cloning-debug-info branch December 1, 2021 10:25
@ghost ghost locked as resolved and limited conversation to collaborators Dec 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants