Repository navigation
[AUTOMATED] fix(p4): a tail call's result yields to a float the function computes itself - #772
Merged
Merged
Conversation
…ion computes itself
passthrough's tail-return rule handed a call-then-return function its
callee's integer result whenever the function never touched the integer
return register. A function that computes its own float return after the
call (ARM `bl g; vadd.f32 s0,s16,s16; pop {r11,pc}`, x86-64 `call g;
addss %xmm0,%xmm0; ret`, AArch64, MIPS `add.s $f0,$f0,$f0`) was printed as
`int f(int a0) { return g(a0); }` and lost its float parameter. #752 made
ARM and MIPS reach this through the injected `r0 = r0` / `v0 = v0`; x86-64
and AArch64 had it since passthrough became the default.
Once the return trials are scored, the claim is dropped when the output
model, run over the trials the claim does not own, derives a return value
in another storage class. A same-class register (the r1 of `bl g; mov
r1,#0`) and a value that is zero at every RETURN (the -fzero-call-used-regs
scrub in openssh's forwarders) keep the claim.
Test: kuna-cli/tests/passthrough_own_return.rs (ARM, x86-64, AArch64,
MIPS LE/BE objects built in the test; ARM also with armfloatreturn on).
Base vs head decompile-all changes no function over 274 ELF fixtures and
562 debug-stripped decbench binaries.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TzSHsg8KAakpogyVw5dtjG
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 #752.
Problem
A function that calls something and then computes a float return value is decompiled as returning the callee's integer result, and its float parameter disappears. #752 made this happen on hard-float ARM and MIPS; x86-64 and AArch64 have done the same since
passthroughbecame the default.gcc -O2 -fno-ipa-ra -c f.con x86-64 prints the same (call ise; movss 4(%rsp),%xmm0; addss %xmm0,%xmm0; ret), and so do AArch64 and MIPS builds of it.Fix
passthroughonly hands back a tail call's result when the function returns nothing of its own. Once the return trials are scored, it runs the output model over the trials it does not own, which gives the return value the function would have withpassthrough off. If that value is in another storage class (s0,xmm0,$f0againstr0,rax,$v0), the claim is dropped. The example now printsfloat float_after_i(float a0,int a1) { ise(a1); return a0 + a0; }. That is the pre-[AUTOMATED] fix(p4): passthrough hands back an ARM or MIPS wrapper's call result #752 output, and it is the same witharmfloatreturnon or off.r1inbl g; mov r1,#0, can be the rest of the claimed value, so it keeps the claim.-fzero-call-used-regswrites zero into every call-used register a function does not return in, so openssh'ssshkey_certifyendscall ...; pxor %xmm0,%xmm0; ret, and it still returns itsint. The cost is thatg(); return 0.0;keeps the callee's result, as it does today.passthrough's own rule.Tests
kuna-cli/tests/passthrough_own_return.rsbuilds ARM, x86-64, AArch64 and little- and big-endian MIPS objects inside the test. It fails on main at the first ARM function.armfloatreturnoff and on) and an x86-64 double.r1write, and an x86-64 forwarder that ends in the zeroing epilogue.decompile-allchanges no function over the 274 ELF fixtures and 562 debug-stripped decbench binaries: 98 ARM firmware images at O0, O2 and O2-noinline, also run witharmfloatreturn on, and 464 x86-64 binaries at O2 and O2-noinline. Without the zero rule, the nine copies of openssh'ssshkey_certifyin that set becamereturn 0;.arm_wrapper_returns.rsand thepassthrough-*CLI probes pass unchanged.🤖 Generated with Claude Code
https://claude.ai/code/session_01TzSHsg8KAakpogyVw5dtjG