Skip to content

refactor(recompiler): share the control flow helpers - #1493

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
LeandroLP23:refactor/controlflow-shared-helpers
Oct 10, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
LeandroLP23:refactor/controlflow-shared-helpers

Conversation

@LeandroLP23

Copy link
Copy Markdown
Contributor

What

Eight helpers were defined with identical bodies in the anonymous namespaces of two of the three control flow sources:

Helper Copies
addUnique, sortUnique, remapId, remapIds, rebuildPredecessors GraphBuilder.cpp, Structurizer.cpp
contains, intersectSorted ControlFlowGraph.cpp, Structurizer.cpp
toHexString ControlFlowGraph.cpp, GraphBuilder.cpp
  • They are declared in a new ControlFlow/ControlFlowHelpers.hpp and defined once in ControlFlowGraph.cpp; bodies are unchanged
  • Only ControlFlowGraph.cpp, GraphBuilder.cpp and Structurizer.cpp include the header. It is not added to ControlFlowGraph.hpp, which eight recompiler sources include, since generic names such as contains would then meet the helpers and calls of that name in other components
  • RdnaDecoder keeps its own toHexString, which is in an anonymous namespace and does not clash

No behaviour change.

Tested

Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release with BUILD_TESTING=ON. No title or homebrew.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

🤖 Generated with Claude Code

toHexString, contains, intersectSorted, addUnique, sortUnique, remapId,
remapIds and rebuildPredecessors were defined with identical bodies in
the anonymous namespaces of two of ControlFlowGraph.cpp, GraphBuilder.cpp
and Structurizer.cpp. They are now declared in ControlFlowHelpers.hpp,
which only these three files include, and defined in ControlFlowGraph.cpp.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the shader core/shader label Oct 8, 2026

@klosixgaming-arch klosixgaming-arch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good refactoring that extracts common control flow helper functions into a dedicated header file. This eliminates code duplication across GraphBuilder.cpp, Structurizer.cpp, and ControlFlowGraph.cpp.

Strengths:

  • Clean separation of concerns with dedicated helper functions (toHexString, contains, intersectSorted, addUnique, sortUnique, remapId, remapIds, rebuildPredecessors)
  • Proper use of existing standard library algorithms
  • No behavioral changes, just code organization improvement
  • Good header file design with appropriate includes

This will improve code maintainability by centralizing common control flow utilities. Ready to merge.

@adriadam10

Copy link
Copy Markdown
Collaborator

Checked that every removed body is identical to the moved one, only the three control flow sources include the new header, and there is no behaviour change. Built on top of current main and ran the AGC/AgcDriver ctest set on Linux: all green. Merges cleanly with #2276, #2257, #2201, #2105 and #1836; CI is green on the head. Merging.

@adriadam10
adriadam10 merged commit 7703fda into boykopovar:main Oct 10, 2026
4 checks passed
SleglJan pushed a commit to SleglJan/AnyPS5 that referenced this pull request Oct 10, 2026
…low-shared-helpers

refactor(recompiler): share the control flow helpers
@LeandroLP23
LeandroLP23 deleted the refactor/controlflow-shared-helpers branch October 10, 2026 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants