Repository navigation
[AUTOMATED] fix(p4): a 64-bit return whose high word comes from the low word, or whose low word is the argument, printed void - #879
Merged
Conversation
mahaloz
force-pushed
the
fix/pair-return-ext
branch
2 times, most recently
from
October 3, 2026 03:28
4adb8ce to
5cfd9c9
Compare
38 of 42 tasks
mahaloz
force-pushed
the
fix/pair-return-ext
branch
2 times, most recently
from
October 3, 2026 04:49
329e677 to
e18c9d6
Compare
…ow word, or whose low word is the argument, printed void
On 32-bit targets `long long sx(int a) { return a + 3; }` (ARM `add r0,r0,#3;
asr r1,r0,#31`) and `u64 zx(unsigned a) { return a; }` (ARM `mov r1,#0; bx lr`)
printed as `void f(void)`. The rule that keeps a call's untouched result as
the first register of a pair now also keeps the function's own argument left
in place, and a value read only by the RETURN and by what turns it into the
second register. For these kinds the second register's value must be read by
nothing but the RETURN, so an r1 written to fpscr or cpsr beside an untouched
r0 stays void. The late pair repair keeps the pair when the low half is the
argument reloaded from its spill, instead of returning the high register alone.
Fixes #807
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt
mahaloz
force-pushed
the
fix/pair-return-ext
branch
from
October 3, 2026 05:12
e18c9d6 to
0228789
Compare
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
On 32-bit targets, a function returning a 64-bit integer whose high word is computed from the low word, or whose low word is its own argument left in place, printed as
void f(void), losing both the return value and the parameter.sxis alsovoidon i386 (sar $31,%edx, gcccltd) and MIPS (sra $3,$2,31). With this change they printunsigned long long zx(unsigned int a0) { return a0; }andlong long sx(int a0) { return a0 + 3; }.The fix
-fzero-call-used-regsscrub staysvoid), and a register also handed to a store, a call orvmsr fpscr/msr cpsr_cstaysvoid.-O0printedreturn 5;fora | 5ULL << 32); it keeps the pair now.retinputhalf.Not fixed: RISC-V
li a1,0; ret(no instruction namesa0), a loaded high word beside the argument, a high register that feeds the low one (also how anintdivision by a constant ends), and an ARM conditional return (asrlt r1,r0,#31; bxlt lr) whoser1is also taken as an argument of a later call.Tests
tests/stages/kuna-retpairhalf.xml: 5 of 8 assertions fail on main; the rest are controls (int div7, a stored sign word, a scrubbedr1, ansvcargument,r1written tofpscrorcpsr).kuna-cli/tests/pair_return_halves.rscompiles the ARM, MIPS and i386 output back with gcc and clang at -O0 and -O2 and checks it against the source over 225 input pairs; it fails on main.decompile-allover 38 stripped ARM, i386 and x86-64 decbench binaries (30,964 functions) changes 20:__aeabi_dadd/__aeabi_ddivexits in eight firmware images, which printed the new high word alone and now returnCONCAT44(hi,a0); u-boot'smemcpyand__of_translate_address; and two copies of a betaflighttbbjump table decoded as code. Lua 5.4 for five 32-bit targets at O0 and O2 (12,503 functions) changes none.decompile-allCPU time over betaflight, crazyflie and nuttx (O2), paired runs, min of 11: 70.3 s on main, 69.7 s with the change.Fixes #807
🤖 Generated with Claude Code
https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt