Repository navigation
[AUTOMATED] Fold a chain of tests into one ordinary error block in optimized code (condfold auto) - #1983
Merged
Conversation
…ters in optimized functions [AUTOMATED] Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013BBaWVABMswm9QwjnywGWU
… is decompiled again without it [AUTOMATED] Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013BBaWVABMswm9QwjnywGWU
… counters and pins [AUTOMATED] Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013BBaWVABMswm9QwjnywGWU
…up after one failed ordinary fold [AUTOMATED] Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013BBaWVABMswm9QwjnywGWU
[AUTOMATED] Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013BBaWVABMswm9QwjnywGWU
[AUTOMATED] Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013BBaWVABMswm9QwjnywGWU
[AUTOMATED] Under the default auto the callmechanisms-on chain folds too: the store kept after each call does not print, it only made the first structuring call the test complex. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013BBaWVABMswm9QwjnywGWU
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.
In optimized code, a run of calls whose failures all go to one error block,
if ((r = put(b, x)) != 0 || (r = put(b, 2 * x)) != 0) { note(r); return; }, prints as a ladder of nestedifs. #1982 fixed this when the error block ends in a call that does not return; this does the same when it is an ordinary block (a return, the target of agoto out), in functions that are not compiled without optimization.(the fixture is added here; it is
chainfold.cbuilt with gcc 11.4-O2 -fno-reorder-blocks-and-partition)Before:
After:
condfoldgets a valueauto, the new default: everythingnoreturndoes, plus, in a function the unoptimized detector does not flag, a chain into any block only the chain enters.noreturnkeeps its meaning, so the old print is--option condfold noreturn. In unoptimized code authors nest these tests often enough that the fold loses there, so it stays off.condstmtswidth cap, the comment check, and replacing a structuring that prints a goto. A later print-tree pass can still leave a goto (taildupdid on one function), so a function whose fold into an ordinary block prints a goto at the end is decompiled again without it, and the copy with fewer gotos wins (the unfolded one on a tie).noreturnin the same build: 73 more functions at O2 without inlining match the source's control flow exactly (102 gained, 29 lost), positive on both project halves; 14 more at O0 from functions the detector does not flag; no function gains a goto. The losses are sources that really nest the second test, mostly because they use its value afterwards.noreturnon sshd, bash and ls: +1.0%, +2.4%, +3.1%. To keep it there, the goto fallback only re-structures when a relaxed test actually folded, and a large function (64 blocks or more) stops relaxing once such a fold has fallen back.Tests:
tests/stages/kuna-chainfold.xmldecompiles the fixture withcondfold noreturn(the -O2 ladder) and the default (one condition), and checks that the -O0 build keeps its ladder under both. The round-trip test gains a second case that compiles the printed functions beside the source with gcc and clang at -O0 and -O2, withputfailing at each call in turn, and compares the results, stored values and call order.gh6904-ppc-e500-concat44.xml,structsynth-locals.xmland the ELFv1callmechanismsCLI test now pincondfold noreturn, since they check other features (undercallmechanisms onthe chain now folds as it does by default: the TOC store it keeps after each call does not print). No datatest assertion moves.Model:
anthropic/claude-opus-5-5🤖 Generated with Claude Code
https://claude.ai/code/session_013BBaWVABMswm9QwjnywGWU