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

Do not report inlining decision to runtime in DEBUG mode #113700

Merged
merged 1 commit into from
Mar 20, 2025

Conversation

kunalspathak
Copy link
Member

We should report inlining decisions to the runtime only in non-DEBUG mode. If done in DEBUG mode, we can see discrepancies in inlining decisions that can further diverge the code produced in RELEASE vs. DEBUG mode. The inlining reporting happened at below code. The fix is to not report the inlining decision.

#if defined(DEBUG)
// In debug builds we want the inline tree to show all failed
// inlines.
fgWalkTreePre(stmt->GetRootNodePointer(), fgFindNonInlineCandidate, stmt);
#endif

Fixes: #113546

@Copilot Copilot bot review requested due to automatic review settings March 19, 2025 17:19
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.

Copilot wasn't able to review any files in this pull request.

Files not reviewed (1)
  • src/coreclr/jit/fginline.cpp: Language not supported

@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 Mar 19, 2025
@AndyAyersMS
Copy link
Member

Note this code is trying to reconstruct (after the fact) why we didn't inline something. The initial inline attempt happened (and failed) and (if necessary) was reported before we even built the set of inline candidates. So there is no need to report it again here.

Now, reporting failure a second time normally would be harmless and not lead to codegen diffs.

But what is happening here is that the debug-only reconstruction comes up with a different explanation for why the inline failed, and that explanation is one that precludes ever inlining the method, and so if we end up reporting on the reconstructed failure it triggers a divergence in debug and release.

As for why we even bother reconstruction -- the idea was that in debug the inline tree should reflect all the inline decisions, both successes and failures, and since some inlines "fail early" we need to recover why they failed later when building the tree, and evidently this reconstruction process is a bit shaky.

@kunalspathak
Copy link
Member Author

/azp run runtime-coreclr superpmi-asmdiffs-checked-release

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@kunalspathak
Copy link
Member Author

/ba-g failure is unrelated, one of them is #112264

@kunalspathak kunalspathak merged commit f285289 into dotnet:main Mar 20, 2025
113 of 116 checks passed
@kunalspathak kunalspathak deleted the naot-checked-release branch March 20, 2025 04:51
medhatiwari pushed a commit to medhatiwari/runtime that referenced this pull request Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.

Test Failure: superpmi-asmdiffs-checked-release for smoke_tests.nativeaot
2 participants