Repository navigation
[AUTOMATED] fix(p4): a tail call to a function with no parameters loses its return value - #877
Merged
Merged
Conversation
…ameters WIP: protoorder now states an empty parameter list when passthrough recorded a return value, so a tail call to it keeps that value. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt
…e register first or the callee is declared WIP: the tail-return arm of passthrough now checks only the path from the call to the RETURN, follows the low SUBPIECE heritage reads out of a wider register, and takes a declared callee's single-register output. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt
…that carries no argument Drop the declared-callee arm (its gained returns contradict DWARF far more often than the existing rule's) and keep the whole-function untouched rule for an argument register such as ARM r0. Add the tail_call_returns CLI test. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt
…s callees and return-only registers Spec prose, the passthrough row and options.md; the protoorder cycles probe no longer pins its -O0 callers' return types. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt
…er without overflowing A constant at the top of its space overflowed the end-offset sum under debug assertions. Recapture the phase catalog for the passthrough row, and let the cycles test not pin its -O0 callers' return type. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt
mahaloz
force-pushed
the
fix/tailcall-noparam-return
branch
from
October 3, 2026 02:40
c69a44f to
02fd7cd
Compare
mahaloz
added a commit
to phix33/kuna
that referenced
this pull request
Oct 3, 2026
Brings in Noelo-Lab#872, Noelo-Lab#832 (indexaliasguard global, now the default), Noelo-Lab#875 (varargforward) and Noelo-Lab#877. Heritage::guard keeps the stackstoreguard branch first and main's global STORE guard as the else branch; spec 03 keeps main's global/full paragraphs and notes the stack guard also runs at global. Counts re-derived (254 settables, corpus 392), catalog fixture recaptured, options.md regenerated, stages baseline re-recorded (1795 = main 1792 + the 3 STACK STORE keys). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt
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.
A function that tail-calls a function with no parameters is printed
void, although the same output prints the callee returning a value. On x86-64 the same happens when the function usedraxbefore its tail call.With this change they print
int f(void) { return getv(); }andlong sum2(...) { ... return getk(v1 + v2); }. Thefcase also printsvoidon ARM, AArch64, PowerPC and MIPS builds, and is fixed there too.Fix
protoorderdeclined to state anything for a function with no parameters. It now states that function's return value. An empty list is not an arity claim, so the only reader ispassthrough's tail-call rule.argclobberstill declines an empty list.passthroughgave a function its tail call's result only if the function never touched the return register. A register that carries no argument (x86eax/rax, i386eax, MIPSv0) may now be written before the call, since the call overwrites it. Nothing may read or write it between the call and the RETURN. The RETURN'seaxis followed through the low SUBPIECE that heritage inserts when the function wrote all ofrax.mov r0,#5; b gis as often avoidfunction callingg(5)as anintone returning it: tried on ARM firmware, DWARF confirmed 31 of 97 such returns.Not fixed here: a tail call to a declared libc function (
return strlen(s);) still printsvoidunless a caller reads the result. Taking those returns was DWARF-confirmed for only 43 of 54, becausevoidwrappers ending inputcorclock_gettimeare common. A callee whose own return type is recovered wrongly passes that type to its tail callers, as it already did for callees with parameters (#873, and the MIPS$v1read of #878).Tests
kuna-cli/tests/tail_call_returns.rsbuilds x86-64, ARM and AArch64 objects. A tail call to a callee with no parameters, and x86-64 wrappers that writeraxbefore the call, printvoidon main and return the callee's result now. ARMmov r0,#5; b getkstaysvoid.tests/cli/protoorder-cycles-types-the-callers-of-a-recursive-function.jsonno longer pins its -O0 callers asvoid. They load throughraxbefore their last call and now return its result.decompile-allon 24 debug-stripped decbench binaries (x86-64 O0/O2/O2-noinline, ARM firmware): 126 functions gain a return (DWARF: 97 value, 4void, 25 no entry). Two O0 wrappers widen fromunsigned intto their callee'sunsigned long, and twomains lose a cast. Nothing else changes.decompile-all: coreutilsdate-0.9%, gzip -2.1%, nuttx -2.8%, O0tr-4.9% (noise; no slowdown).Fixes #827
🤖 Generated with Claude Code
https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt