Thanks to visit codestin.com
Credit goes to github.com

Skip to content

JIT: Disallow flowgraph modifications during VN opts #115197

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 3 commits into from
Apr 30, 2025

Conversation

amanasifkhalid
Copy link
Member

Early value propagation can invalidate the flowgraph annotations. Make sure downstream opts tolerate this by recomputing them as needed. Fixes #115168.

@Copilot Copilot AI review requested due to automatic review settings April 30, 2025 16:01
@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 Apr 30, 2025
Copy link
Contributor

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

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 issues with flowgraph annotations becoming stale due to early value propagation by recomputing required structures during value numbering optimizations. The changes include:

  • In valuenum.cpp, replacing an unconditional assertion on m_dfsTree with a conditional recomputation of the DFS tree and natural loop discovery.
  • In copyprop.cpp, adding a check to compute the dominator tree if it is missing.
  • In compiler.cpp, removing the redundant dominator tree computation from RecomputeFlowGraphAnnotations.

Reviewed Changes

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

File Description
src/coreclr/jit/valuenum.cpp Recomputes DFS tree and associated loop info if m_dfsTree is missing.
src/coreclr/jit/copyprop.cpp Ensures m_domTree is computed based on a non-null m_dfsTree.
src/coreclr/jit/compiler.cpp Removes duplicate computation of the dominator tree in flowgraph annotation update.

@jakobbotsch
Copy link
Member

What flowgraph changes is it making? Copy prop is meant to closely match SSA. I am not sure we can tolerate flowgraph changes between them.

@amanasifkhalid
Copy link
Member Author

What flowgraph changes is it making? Copy prop is meant to closely match SSA. I am not sure we can tolerate flowgraph changes between them.

Early value prop can fold null checks, which might enable us to fold the containing block into a BBJ_ALWAYS. I suspect that happens rarely though, considering how long it took for us to find such a case. If we can't tolerate flowgraph changes, then maybe we can add a switch to fgMorphBlockStmt to prevent it from folding conditional blocks.

@amanasifkhalid amanasifkhalid changed the title JIT: Recompute flowgraph annotations during VN opts JIT: Disallow flowgraph modifications during VN opts Apr 30, 2025
@amanasifkhalid
Copy link
Member Author

No diffs

@amanasifkhalid
Copy link
Member Author

/ba-g CI is green, but Build Analysis is stuck

@amanasifkhalid amanasifkhalid merged commit 6ee6d40 into dotnet:main Apr 30, 2025
109 checks passed
@amanasifkhalid amanasifkhalid deleted the valuenum-dfs-tree branch April 30, 2025 22:40
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.

JIT: Assertion failed 'm_dfsTree != nullptr'
2 participants