perf(relinker): reuse decoded control-flow instructions #18432
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/18432"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by bipinkrish on 2026-11-11T14:13:02Z.
What
Pass decoded x86 instruction metadata from the control-flow walk to
CodeInstructionCollector. The collector reuses the decode for root discovery and retains the final instruction-boundary validation and lowest-address diagnostic ordering.The overlap check found shared edits with #13716 at the include list and with #14107 at the control-flow call. Manual review of #10861 found a shared control-flow interface and collector loop. Those PRs change which code the collector reaches. This change reuses the decoded metadata after the walker reaches an instruction. The branches can merge independently, with a rebase if a shared edit lands first.
Tested
Ubuntu 24.04.4 LTS, Ryzen 7 7735HS, GCC 13.3, Release,
-DANYPS5_RELINKER_ONLY=ON. Compared upstream03522377c3fwith2c2563d23ed. Each row reports median wall time over 20 alternating pairs pinned to CPU 15. The CLI workloads use the same 2.55 MB compiler-generated ELF with many branches.--function-symbol-rootsThe million-instruction fixture went from 3,000,000 to 2,000,000 decoder calls. On the generated ELF, calls fell from 2,594,406 to 2,201,104. Both revisions found the same 409,686 instruction offsets and 32,769 roots. Every emitted PE and Mach-O matched its baseline byte for byte.
Both revisions passed the same 46 focused CTest cases covering conversion, control-flow graphs, code and data scanning, function-symbol roots, and Windows and macOS TLS. These measurements cover conversion on fixtures. Same-scene title captures are pending.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-12T14:26:07Z.
Review: COMMENTED
Reviewed decode reuse in the control-flow walk — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
Head
2c2563d23ed37a092978256ccc17eaa6dca30946, basemain. No build and no compile in this pass. Source-level review of the diff and of the code around it, read through the repository reader at the head.Results
Commands and output
The commands are listed under What I ran. Output is not quoted here.
Findings
Blocking
None.
Non-blocking
core/relinker/relinker/src/analysis/CodeInstructionCollector.cpp:577: the deferred-failure path (lines 566–578) has no test. Nothing undercore/relinker/relinker/testsasserts the messages "branch target is not executable and file-backed" or "fall-through is not executable and file-backed". A change that rethrows the first failure in walk order instead of the lowest address would not be caught by the tree's tests.Sources
github.com/boykopovar/AnyPS5@2c2563d23e/core/relinker/relinker/src/analysis/CodeInstructionCollector.cpp (L566-L580)github.com/boykopovar/AnyPS5@2c2563d23e/core/relinker/relinker/src/analysis/UnusedNidFilter/ControlFlowGraph.cpp (L97-L116)Not verified
main": I compared against the base in the manifest and did not check livemainon GitHub.core/relinker/relinker/include/relinker/analysis/UnusedNidFilter/IControlFlowGraph.hppwas read as diff hunks only, not as full text. The forward declaration ofCodegen::DecodedInstructionInfomatches itsstructdefinition.usingalias) are checked by reading only.To get this to a good state
Nothing is required.
Optional: add a test where two instructions fail analysis in reverse address order and check that the lower address is reported. Attach the same-scene title captures that the performance form asks for.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T17:06:12Z.
Review: COMMENTED
In a Linux relinker-only build from this head,
dynamic_segmentandsce_code_extentpassed. This head conflicts with current main inCodeInstructionCollector.cpp. Main now follows code addresses only when both the SCE and the other function inventories are empty. Preserve that condition when passing the decoded-instruction visitor into the current traversal.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.