Skip to content

JIT: remove dead BBJ_RETURN-in-loop assertion in loop cloner#128791

Open
AndyAyersMS wants to merge 1 commit into
dotnet:mainfrom
AndyAyersMS:cleanup/remove-bbj-return-assert-in-loop-cloner
Open

JIT: remove dead BBJ_RETURN-in-loop assertion in loop cloner#128791
AndyAyersMS wants to merge 1 commit into
dotnet:mainfrom
AndyAyersMS:cleanup/remove-bbj-return-assert-in-loop-cloner

Conversation

@AndyAyersMS
Copy link
Copy Markdown
Member

Loops no longer have returns, so remove some stale comments and checks.

optIsLoopClonable contained a DEBUG-only walk that asserted no block in the loop was BBJ_RETURN, plus a stale function comment claiming that fgReturnCount would be bumped on success. There is no code anywhere in loopcloning.cpp that adjusts fgReturnCount (verified by grep), and the assertion is redundant: natural loops in RyuJIT can never contain a BBJ_RETURN block, because FlowGraphNaturalLoop discovery uses only regular CFG back-edges and BBJ_RETURN has no successor that can flow back to a loop header. Verified empirically across 23,712 natural loops from the benchmarks.run_pgo.windows SPMI collection (Tier1 + Tier1-OSR + FullOpts + Tier0-FullOpts, clonable + unclonable) — zero loops contained any BBJ_RETURN block. Drop both the assertion and the stale comment. No behavior change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 30, 2026 01:15
@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 May 30, 2026
@AndyAyersMS
Copy link
Copy Markdown
Member Author

@jakobbotsch PTAL
fyi @dotnet/jit-contrib

Copy link
Copy Markdown
Contributor

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

Removes a stale comment about fgReturnCount and a DEBUG-only assertion that no loop block is BBJ_RETURN from optIsLoopClonable. With EH-loop cloning now enabled by default, BBJ_RETURN blocks can legitimately appear in cloneable loops, and the surrounding context (fgReturnCount is never updated here) makes the comment misleading.

Changes:

  • Drop stale fgReturnCount note from optIsLoopClonable header comment.
  • Remove DEBUG VisitLoopBlocks assertion that rejected BBJ_RETURN blocks.

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.

3 participants