Repository navigation
[AUTOMATED] fix(p4): a variadic call dropped an argument its caller forwards in the register it arrived in - #875
Merged
Merged
Conversation
This was referenced Oct 3, 2026
…ariadic call (WIP) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt
… and spec Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt
… a format Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt
The rebase took main's baseline where both sides recorded new stage tests; this re-records it with SLEIGHHOME set. Only the eight GH829 keys are new and none of main's are missing. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt
mahaloz
force-pushed
the
fix/variadic-forwarded-arg
branch
from
October 3, 2026 02:16
c7bab15 to
125fec6
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.
The problem
A variadic call drops an argument that the caller received as a declared parameter and passes on in the same register, untouched. A wrapper around
openis the usual case:my_openisxor %eax,%eax; jmp open, withmodestill inedx. Main prints:The issue's AArch64 cases fail the same way:
double c2(int k, double x) { return vr(k, x); }printsreturn vr(k);, andvr(k, g(k))printsg(k); return vr(k);, because nothing movesxorg's result out ofd0.The fix
varargforward(default on,p4_calls/kuna_varargforward.rs). In the variable part of a call whose prototype ends in..., an argument register is kept when it holds the caller's own input and the caller declares a parameter there, or the result of a call whose return type is declared. Upstream refuses both: it wants to see a value moved into the register, and never takes another call's result.if (a > 5) return 0; return pr(f, a);compiles the same with or withouta, so it still printspr(f). A parameter counts only when the function's own prototype is declared (DWARF,--assert), not recovered.sqlite3InvalidFunctiondeclares an unusedNotUsed2in the register aftersqlite3_mprintf("... %s ...", zName)'s one argument, and does not gain it. Where the caller states how many floating-point registers it filled (alon x86-64, CR bit 6 on 32-bit PowerPC), that count still decides.int d6(const char *f, int a) { return pr(f); }printspr(f,a). The register holdsawhenprstarts, so the printed call compiles to the same instructions. A forwarded value that is also read elsewhere is still dropped, as before.The tests
tests/stages/gh829-varargforward-{x86,a64}.xmlrun each case with the option off (the bug) and on, plus a parameter that is also compared and stays out. 31 callers built for x86-64 with gcc and clang -O2, compiled back from the printed C with both compilers and run against the source: main mismatches 11 (gcc) and 12 (clang) of them, this branch 2, both the "read elsewhere" shape above. The -O0 builds print the same C as main.decompile-allmain vs this branch changes no function in 17 stripped binaries and 234 DWARF builds (72,183 functions), nor in the sqlite3 amalgamation built for x86-64 and AArch64. Wall time with the option off vs on, interleaved min of 11: numfmt -3.0%, dash +1.1%, kmod -0.8%.Fixes #829
🤖 Generated with Claude Code
https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt