Repository navigation
returndup: make it selective like angr (const-return gate) — cut the over-eager variable-return splits - #137
Merged
Merged
Conversation
…over-eager variable-return splits
kuna's returndup duplicated EVERY splittable shared bare-epilogue return, including
`return <variable>`. The decbench re-run showed that unselective form regressing the
aggregate GED-perfect count ~976 (21768 firings) — early-return recovery diverges from
the source's merged short-circuit form when the source did not write an early return.
angr's ReturnDuplicatorHigh is selective: `_should_duplicate_dst = dst_is_const_ret` —
it only duplicates a SIMPLE CONST-RETURN region. Port that gate: returndup_apply now
skips any candidate whose returned value does not resolve to a constant (literal /
annotation / COPY-chain / phi-of-constants, depth-bounded). Const-return guard clauses
(`if (c) return 0;`) are the early-return shape the source actually wrote.
Effect (coreutils b2sum, returndup on): firings 45 -> 26 (-42%, the dropped ones are the
variable-return splits); the wins survive (factor still recovers const early-returns on
36 functions). Sets up re-evaluating returndup default-on without the aggregate regression.
Gates: make test 675/675 PARITY OK, make test-stages 254/254 PARITY OK (the returndup
fixture is a phi-of-constants {1,2,3} — correctly still admitted by the recursive gate).
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
Aug 2, 2026
… no gate exists, keep it (#245) The kuna-only re-run on the optimized datasets reported 411/189 (O2-noinline) and 293/114 (O2) with a return/tail-duplication transform on most functions whose score moved. Triaged in three steps; the code is unchanged. WHICH TRANSFORM. `taildup:` and `returndup:` render as the SAME `return-dupe` slug (PrintC::warning_slug), so the reported correlation lumped two passes. They separate by warning sink: returndup uses warning_header (prototype line), taildup uses warning(addr) (statement line). Classified that way, returndup covers 86% of wins and 66% of regressions; taildup 2-3%. The July artifacts carry 5,183 `taildup:` banners and ZERO `returndup:` — taildup never moved. WHY IT STARTED. returndup is default-OFF; `aggressive` turns it on, and DIV-40 made `auto` (=aggressive under 500 KiB) the front-end default. The July artifacts predate the mode system entirely. #228/DIV-47 is refuted directly: with returndup forced on, the fire count is identical at #228 and its parent on all six probe binaries (17/17, 52/52, 410/410, 699/699, 76/76, 35/35), and 0 with returndup off. NO DISCRIMINATOR. An isolating A/B on the same 36641d3 build over 536 slices / 52,862 functions (validated: the 46,005 non-firing functions score identically, and the harness reproduces a published artifact byte-for-byte) puts returndup at +417 GED-perfect and -7,756 aggregate GED — 608 perfects created vs 191 destroyed. Nine candidate gates were partitioned causally (split count, void vs value return, distinct return values, return count, switch, all-returns-identical, body size, project, opt level): every cell is net-positive. The void-return escape hatch in returndup_is_const_ret, which explains xmalloc and do_statx, is MORE profitable than the value case, not less. The single net-negative cell — the split de-structures a loop (cleanflight nextArg loses its `for` header) — was implemented as a gate and measured, not left as theory: +2 GED-perfect / -209 GED. Not kept, and reverted here. Also corrects docs/modes.md, which told readers `aggressive` enables an option "known to regress aggregate GED (DIV-18)" — superseded by #137's const-return gate — and annotates the DIV-18 row. returndup as a default now also passes the datatest gate (675/675, PARITY OK); promoting it is left as a separate DIV. Gates: make test PARITY OK 675/675; make test-stages PARITY OK 356/356; make check-spec OK; kuna catalog --check OK. Claude-Session: https://claude.ai/code/session_011RXVU58TKJxb518oViChwo Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
mahaloz
added a commit
that referenced
this pull request
Aug 3, 2026
…vert (DIV-54) (#246) `returndup` (angr SAILR gotoless ReturnDuplicatorHigh, p8_structure/kuna_returndup.rs) becomes a shipped default again. WHY THE OLD NUMBER IS STALE. DIV-18 first made it a default and it was reverted on 2026-07-05 after decbench measured -976 aggregate GED-perfect across 21,768 firings. That measurement described the UNSELECTIVE pass, which also split `return <variable>` epilogues. #137 then ported angr's `_should_duplicate_dst` const-return gate (`Funcdata::returndup_is_const_ret`), which declines every share whose return value is not a literal / COPY chain / phi-of-constants and drops ~40-60% of firings -- exactly the over-eager class the -976 was counting. The revert's justification no longer describes the code, so the option is re-measured from scratch here rather than reinstated on the old evidence. THE NEW MEASUREMENT. Isolating decbench A/B, same binary in both arms, 536 slices / 52,862 scored functions: ON 804,689 aggregate GED / 18,036 GED-perfect versus OFF 812,445 / 17,619 -- +417 perfect and -7,756 GED, 608 perfects created against 191 destroyed (3.2:1). The 46,005 functions the pass never fires on score identically in both arms. Net-positive in all nine partitions tested causally; the one net-negative cell (a split that de-structures a loop) had a gate built and scored at +2 perfect / -209 GED and was not kept. Analysis: docs/decbench/returndup-regression-triage.md. ABLATION. The raw flip moves 16 datatest assertions across 9 upstream files. Those files take a per-test `option returndup off` (the standing convention, as DIV-14/17/ 23/25/51 did) and the gate is then 675/675 PARITY OK with NO baseline re-pin. A 10th datatest (condconst.xml) takes the opt-out for the w10 byte-parity oracle that drives it. Stages: 356/356 PARITY OK with the same opt-out on 5 two-pass isolation tests, and no baseline re-record. SPEED. Interleaved A/B on one binary, `decompile-all --mode reliable`, medians: update-passwd +1.74%, coreutils factor +0.74%, coreutils ls +1.14%, gzip -O0 +2.66%, gzip -O2 -1.18%, coreutils sort -O2 +0.02% -- worst case +2.96%, inside the +5% budget. (The blocked `scripts.pipeline.timeit` form is unusable on this host: it reported ls::main at +57.3% where the interleaved measurement gives +2.45%.) `--mode aggressive` deliberately keeps naming the option so the preset re-enables it after an explicit `--option returndup off`; modes-aggressive.xml pins that. Also records the worktree spec-resolution trap in docs/agents.md: KUNA_SPECS/ SLEIGHHOME do not reach the cargo workspace suite, which resolves specs as <repo>/specs. Gates: make test PARITY OK 675/675; make test-stages PARITY OK 356/356; make rust-test green; make check-spec OK; kuna catalog --check OK. Claude-Session: https://claude.ai/code/session_011RXVU58TKJxb518oViChwo Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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.
Follow-up to #136 (the returndup default-off revert). The decbench re-run showed the unselective returndup regressing the aggregate GED-perfect count ~976 across 21,768 firings — early-return recovery diverges from the source's merged short-circuit form when the source did not write an early return.
angr is selective; kuna was not
angr's
ReturnDuplicatorHigh._should_duplicate_dst = dst_is_const_ret— it only duplicates a simple const-return region (_is_simple_return_graph). kuna duplicated every splittable shared bare-epilogue return, includingreturn <variable>, which is exactly the over-eager case that diverges from source.The gate
returndup_applynow skips any candidate whose returned value does not resolve to a constant — literal / annotation / COPY-chain / phi-of-constants (depth-bounded, never admits afreevarnode). Const-return guard clauses (if (c) return 0;) are the early-return shape the source actually wrote.Effect
The dropped ones are the variable-return splits; the wins survive (factor still recovers const early-returns on 36 functions). This sets up re-evaluating
returndupdefault-on without the aggregate regression — the "returndup may be the future, but less aggressive like angr's" direction.Gates
make test675/675 PARITY OK (returndup still default-off → byte-identical),make test-stages254/254 PARITY OK (the fixture is a phi-of-constants{1,2,3}— correctly still admitted by the recursive gate),make rust-testgreen.🤖 Generated with Claude Code
https://claude.ai/code/session_018DV2MXxQAAWK7xLPBmsq9J