Repository navigation
s8/structure: returndup — duplicate shared bare-epilogue returns for early-return recovery (angr ReturnDuplicatorHigh, decbench F4) - #124
Merged
Conversation
…early-return recovery (angr ReturnDuplicatorHigh, decbench F4)
New option-gated S8 pass `ActionReturnDup` (`s8_structure/kuna_returndup.rs`,
option `returndup`, default-OFF): kuna's analog of angr's SAILR *gotoless*
`ReturnDuplicatorHigh`. At -O0 the classic guard shape
`if (cond) { body; return X; } return Y;` compiles to a single SHARED
epilogue/RETURN block; kuna (like upstream Ghidra) keeps the merged form because
`CollapseStructure::rule_block_or` fuses the guards (they share the epilogue
out-target) into one comma-folded short-circuit condition, and the existing
`ActionReturnSplit` (the goto-driven `ReturnDuplicatorLow` analog) never fires on
goto-free structuring.
The pass reuses, verbatim, the machinery `ActionReturnSplit` drives — the existing
`return_split_is_splittable` bare-epilogue filter and `Funcdata::node_split` (new
driver `returndup_apply` next to `return_split_apply`): for every shared
bare-epilogue RETURN block it splits every in-edge but one, giving each predecessor
its own return so the structurer recovers the source's early returns. Registered in
the `returnsplit` group right after `ActionReturnSplit`. Bounded (<=16 preds, <=64
splits/function) and side-effect-safe (the filter admits only a return-only block).
GED (Joern rescore, decbench venv), --option returndup on:
O0-coreutils-factor-factor 12 -> 0 (perfect); sibling O2-noinline 3 -> 0
O0-e2fsprogs-...-ext4_fc_handle_add_extent 7 -> 0 (perfect); sibling O2-noinline 9 -> 0
Also closes the ghidra-beats-kuna bash `compspec_dispose` shape.
Speed: whole-binary factor +5.3% opt-in only (default-off = 0 cost).
Gates: `make test` 675/675 PARITY OK (byte-identical, default-off, zero opt-outs);
`make test-stages` 248/248 PARITY OK (new two-pass tests/stages/ghangr-returndup.xml);
`cargo test --workspace` failing set identical to main (no new failures);
`kuna catalog --check` OK. Count-tests + pass-tree oracles updated.
Default-off: any O0 function with a shared bare epilogue gains early returns (broad
but correct churn); a later default-on sweep can flip it with per-test opt-outs.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_018DV2MXxQAAWK7xLPBmsq9J
mahaloz
added a commit
that referenced
this pull request
Jul 5, 2026
…icts after returndup #124 merge Serial-merge resolution: returndup (#124) and noreturn_error both bump the shared catalog/corpus counts. Final = base + returndup + noreturn_error: option count 70->71, corpus 158->159, settables 71; noreturn_error is source_decompiler=ghidra / change_kind=correctness-fix so it doesn't touch the angr(#6)/structure-recovery(#7) counts, only use_when(#5)/change_kind(#9). catalog --check OK. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018DV2MXxQAAWK7xLPBmsq9J
mahaloz
added a commit
that referenced
this pull request
Jul 5, 2026
…n_error Per user directive, ship iteregion default-on (angr ITERegionConverter: assignment diamond -> ?: ternary). 0/675 datatests change (byte-identical corpus even default-on — no per-test opt-outs needed), speed -2.6%. Still a runtime choice: an explicit if/else compiles to the SAME object code, so --option iteregion off reverts per function. Merge resolution after returndup (#124) + noreturn_error (#126) landed on main: - stages.toml: split the two [[settable]] blocks the naive union merged into one; iteregion default=on, returndup default=off. - architecture.rs: default-on line (self.iteregion=true, DIV-17) + restored the option-apply match arm's closing the union merge dropped; seam copy already wired (seam.iteregion). - count-tests: option count 70/71->72, corpus 158/159->160, settables 72, catalog JSON commas 71, kuna-catalog.xml #6 angr 27 / #7 structure-recovery 16 (iteregion is both) / #5/#9 max 80. - action-list golden: iteregion re-inserted after dedupitetail in the oracle (0259), leaf count 266->267, tail array; stage_catalog.json + baseline-stages regenerated. - ghangr-iteregion.xml: pass 1 now explicitly 'option iteregion off' to pin the if/else baseline the default-on pass converts. Gates: make test 675/675 PARITY OK (byte-identical), make test-stages 254/254 PARITY OK. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018DV2MXxQAAWK7xLPBmsq9J
This was referenced Jul 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
decbench campaign F4. A kuna analog of angr's
ReturnDuplicatorHigh: an option-gated S8 pass that duplicates a shared bare-epilogue RETURN block into each predecessor before block structuring, so the source's early-returnifs emerge instead of kuna's merged comma-condensed form.s8_structure/kuna_returndup.rs(reuses the existingreturn_split_is_splittablefilter +Funcdata::node_split), registered beforeblockstructureinuniversalaction.rs.factor/ext4_fc_handle_add_extentcases and the ghidra-beats-kunacompspec_dispose/dispose_variablefree-chain shape.Note: the implementing agent was stopped just before it could post the final gate summary here; I verified the critical gate independently (below). The commit does not touch
docs/baseline.json, consistent with a byte-identical default-off feature.🤖 Generated with Claude Code
https://claude.ai/code/session_018DV2MXxQAAWK7xLPBmsq9J