Skip to content

Conversation

AndyAyersMS
Copy link
Member

We now eagerly create inlinee contexts when we try and inline, so in post-inline debug when we go to scan the trees for the calls that remain, we need to remember which ones were failed inline candidates and which ones we were never inline candidates.

We now eagerly create inlinee contexts when we try and inline, so in post-inline
debug when we go to scan the trees for the calls that remain, we need to remember
which ones were failed inline candidates and which ones we were never inline
candidates.
@Copilot Copilot AI review requested due to automatic review settings August 19, 2025 20:16
@github-actions github-actions bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Aug 19, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug in the JIT compiler where some inline failures were being double-reported in debug builds. The fix adds tracking to distinguish between calls that were considered for inlining but failed versus calls that were never inline candidates.

Key changes:

  • Adds a new debug flag to track failed inline candidates
  • Updates inline failure handling to mark calls that were attempted but failed
  • Modifies post-inline debug scanning to avoid double-reporting

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/coreclr/jit/gentree.h Adds GTF_CALL_MD_WAS_CANDIDATE flag and accessor methods for tracking failed inline candidates
src/coreclr/jit/fginline.cpp Sets the new flag on inline failures and updates debug scanning logic to check for it

Copy link
Contributor

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

@AndyAyersMS
Copy link
Member Author

AndyAyersMS commented Aug 19, 2025

For a simple test case

#using System.Runtime.CompilerServices;

X.Test();

class X
{
    static int sum()
    {
        int sum = 0;

        for (int i = 0; i < 100; i++)
        {
            sum += i;
        }

        return sum;
    }

    [MethodImpl(MethodImplOptions.NoInlining)]
    static int bar() => 3;

    [MethodImpl(MethodImplOptions.NoInlining)]
    public static int Test()
    {
        return sum() + bar() + sum();
    }
}

and with a checked build and

set DOTNET_JitPrintInlinedMethods=X:Test
set DOTNET_JitPrintInlinedMethodsVerbose=1
set DOTNET_TieredCompilation=0

we used to print

Inlines into X:Test():int:
  [FAILED: unprofitable inline] X:sum():int
  [FAILED: unprofitable inline] X:sum():int
  [FAILED: noinline per IL/cached result] X:bar():int
  [FAILED: unprofitable inline] X:sum():int
  [FAILED: unprofitable inline] X:sum():int

and now print

Inlines into X:Test():int:
  [FAILED: unprofitable inline] X:sum():int
  [FAILED: noinline per IL/cached result] X:bar():int
  [FAILED: unprofitable inline] X:sum():int

@dotnet/jit-contrib PTAL

Debug only change; no diffs.

@AndyAyersMS
Copy link
Member Author

/ba-g host activation tests failed but no log to match on in one case

@AndyAyersMS AndyAyersMS merged commit 1f4a061 into main Aug 20, 2025
109 of 112 checks passed
@jkotas jkotas deleted the FixInlineTree branch August 28, 2025 21:05
@github-actions github-actions bot locked and limited conversation to collaborators Sep 28, 2025
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.

2 participants