Skip to content

JIT: fix issue in assertion prop phi inference #116326

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

Merged
merged 2 commits into from
Jun 9, 2025

Conversation

AndyAyersMS
Copy link
Member

Unreachable preds may give conflicting assertions; check both for an assertion that agrees and the absence of one that disagrees.

Also add the ability to dump the flow graph via hash.

Fixes #116212.

Unreachable preds may give conflicting assertions; check both for an
assertion that agrees and the absence of one that disagrees.

Also add the ability to dump the flow graph via hash.

Fixes dotnet#116212.
@Copilot Copilot AI review requested due to automatic review settings June 5, 2025 00:29
@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 Jun 5, 2025
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

@EgorBo PTAL
cc @dotnet/jit-contrib

Open to other ideas on how to fix this, though this one has fairly minimal diffs.

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 resolves an assertion propagation bug by checking for both null and non-null assertions and adds new JIT configuration flags to dump the flow graph by method hash or tier-0 compilations.

  • Introduce JitDumpFgHash and JitDumpFgTier0 flags and wire them into the flow-graph dump logic.
  • Add Compiler::CanPropNull() and update assertion propagation to handle conflicting null assertions correctly.
  • Add a JIT regression test (Runtime_116212) to reproduce and guard against the original issue.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/tests/JIT/Regression/JitBlue/Runtime_116212/Runtime_116212.csproj Add project file for the new regression test
src/tests/JIT/Regression/JitBlue/Runtime_116212/Runtime_116212.cs Add test case invoking the problematic pattern
src/coreclr/jit/jitconfigvalues.h Add JitDumpFgHash and JitDumpFgTier0 configuration flags
src/coreclr/jit/fgdiagnostic.cpp Include hash and tier-0 checks in flow-graph dump decision
src/coreclr/jit/compiler.h Add CanPropNull() helper alongside CanPropNonNull()
src/coreclr/jit/assertionprop.cpp Refactor null/non-null assertion logic in optAssertionVNIsNonNull
Comments suppressed due to low confidence (3)

src/coreclr/jit/jitconfigvalues.h:266

  • [nitpick] The comment for JitDumpFgHash is generic; clarify that this flag filters dumps by matching the method hash (e.g., "Only dump flowgraphs when method hash equals the configured value").
CONFIG_INTEGER(JitDumpFgHash, "JitDumpFgHash", 0)   // Dumps Xml/Dot Flowgraph for specified method

src/coreclr/jit/compiler.h:7876

  • [nitpick] Add a brief comment above CanPropNull() explaining its purpose and how it pairs with CanPropNonNull(), to improve maintainability and API clarity.
        bool CanPropNull()

src/coreclr/jit/fgdiagnostic.cpp:414

  • The current tier-0 check only gates dumping for tier-0 compilations, but does not prevent dumping on non-tier0 when JitDumpFgTier0 is zero. Consider inverting or expanding this logic so that setting JitDumpFgTier0==0 disables dumps for non-tier0 as well.
    if (opts.IsTier0())

@AndyAyersMS
Copy link
Member Author

@EgorBo @jakobbotsch I changed this up a bit, take another look?

//
for (BasicBlock* const pred : ssaDef->GetBlock()->PredBlocks())
{
if (!BitVecOps::IsMember(&traits, visitedBlocks, pred->bbNum))
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't it mean the SSA is basically stale?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, RBO messes up SSA, though in the past we've argued that it generally doesn't lead to making bad assumptions. This is one case where it does.

@AndyAyersMS
Copy link
Member Author

/ba-g installer build and test failed with no log.

@AndyAyersMS AndyAyersMS merged commit 1edd69c into dotnet:main Jun 9, 2025
113 of 115 checks passed
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.

[libraries-pgo] Microsoft.Extensions.Hosting.Unit.Tests fails in OSR stress
2 participants