Skip to content

JIT: Unify block successor iteration logic #117743

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

Conversation

amanasifkhalid
Copy link
Member

Follow-up to #117423.

  • Collapse BBSuccList and BBSuccEdgeList into one templatized type, where the template specifies the iterator kind
  • Remove BasicBlock::NumSucc(Compiler*) et al
  • Have BasicBlock::NumSucc() et al deal only with unique successors, now that they're always available
    • For the occasional case where we have a switch block, and we want to iterate its cases with duplicates, we don't rely on the general successor iteration pattern, anyway
  • (unrelated) Remove BasicBlock::bbFallsThrough

@Copilot Copilot AI review requested due to automatic review settings July 17, 2025 02:43
@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 Jul 17, 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 consolidates the successor‐iteration APIs by collapsing the two non‐templated lists into a single BBSuccList<IteratorType>, removes the old BasicBlock::NumSucc(Compiler*)/GetSucc(Compiler*) overloads, and updates all call sites accordingly. It also removes bbFallsThrough and its uses.

  • Introduces a templated BBSuccList<IteratorType> in block.h/block.cpp
  • Deletes Succs(this)/SuccEdges(this) and replaces them with Succs()/SuccEdges()
  • Removes BasicBlock::NumSucc(Compiler*), updates call sites to NumSucc() and GetSucc()

Reviewed Changes

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

Show a summary per file
File Description
src/coreclr/jit/promotion.cpp Updated dspBlockHeader calls to drop the Compiler*
src/coreclr/jit/lsrabuild.cpp Replaced NumSucc(compiler) with NumSucc()
src/coreclr/jit/lsra.cpp Swapped NumSucc(compiler), Succs(compiler) to new APIs
src/coreclr/jit/importer.cpp Replaced Succs(this) with Succs()
src/coreclr/jit/flowgraph.cpp Removed bbFallsThrough assertion
src/coreclr/jit/fgprofilesynthesis.cpp Updated SuccEdges(m_comp) and NumSucc() calls
src/coreclr/jit/fgprofile.cpp Swapped NumSucc(this), GetSucc(i,this), SuccEdges
src/coreclr/jit/fgopt.cpp Replaced Succs(this) iterations
src/coreclr/jit/fgdiagnostic.cpp Updated dspSuccs and Succs(this) calls
src/coreclr/jit/fgbasic.cpp Swapped Succs(this) uses
src/coreclr/jit/compiler.cpp Updated debug comment and dspSuccs call
src/coreclr/jit/codegenlinear.cpp Adjusted dspBlockHeader usage
src/coreclr/jit/block.h Added templated BBSuccList, removed old overloads
src/coreclr/jit/block.cpp Implemented BBSuccList constructor, removed old code
Comments suppressed due to low confidence (1)

src/coreclr/jit/block.h:1929

  • [nitpick] Consider marking SuccEdges() as a const method to match Succs() (which is const) and allow iterating edges on const BasicBlock instances.
    BBSuccList<FlowEdgeArrayIterator> SuccEdges()

@amanasifkhalid
Copy link
Member Author

@dotnet/jit-contrib PTAL. No diffs. Thanks!

Copy link
Member

@AndyAyersMS AndyAyersMS left a comment

Choose a reason for hiding this comment

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

Nice to see this get cleaned up.

@amanasifkhalid
Copy link
Member Author

/ba-g build timeouts

@amanasifkhalid amanasifkhalid merged commit b6d294d into dotnet:main Jul 17, 2025
108 of 116 checks passed
@amanasifkhalid amanasifkhalid deleted the simplify-successor-enumeration branch July 17, 2025 14:38
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.

2 participants