Skip to content

s8/structure: returndup — duplicate shared bare-epilogue returns for early-return recovery (angr ReturnDuplicatorHigh, decbench F4) - #124

Merged
mahaloz merged 1 commit into
mainfrom
feat/decbench-returndup
Jul 5, 2026
Merged

mahaloz merged 1 commit into
mainfrom
feat/decbench-returndup

Conversation

@mahaloz

@mahaloz mahaloz commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

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-return ifs emerge instead of kuna's merged comma-condensed form.

  • New s8_structure/kuna_returndup.rs (reuses the existing return_split_is_splittable filter + Funcdata::node_split), registered before blockstructure in universalaction.rs.
  • Default OFF (broad-but-correct output churn — any O0 function with a shared bare epilogue gains early returns); a later default-on sweep can flip it with per-test opt-outs.
  • Closes the angr factor / ext4_fc_handle_add_extent cases and the ghidra-beats-kuna compspec_dispose / dispose_variable free-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

…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
mahaloz merged commit 932fe74 into main Jul 5, 2026
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
@mahaloz
mahaloz deleted the feat/decbench-returndup branch July 29, 2026 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant