Repository navigation
Inline double parameter bound from memory: LOAD every 64-bit lvalue argument - #27
Merged
Merged
Conversation
…ue argument before its STORE An inline expansion binds each parameter with a STORE of the argument. A 64-bit lvalue argument (`*p`, `s->d`) left the STORE with a DEREF source, which the 64-bit STORE lowering cannot split (mach_make_hi_half: invalid r1=31 ICE at -O1/-O2/-Os). call.c loaded long long arguments into a temp first; double and long double now get the same LOAD. Reached through -finline-functions-called-once, e.g. cake's json_write_number(file, value->number). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Fixes an internal compiler error at -O1/-O2/-Os:
Minimal reproducer:
Found while compiling cake (
json.c,json_write_number(file, value->number)).Cause
An inline expansion (here
-finline-functions-called-once) binds each parameter with aSTOREof the argument. A 64-bit lvalue argument (*p,s->d) left thatSTOREwith a DEREF source, which the 64-bit STORE lowering can't split viamach_make_hi_half.call.calready loadedlong longlvalue arguments into a temp first;double/long doubleskipped that step. The inline return path (stmt/block.c) already loads every lvalue, so the parameter binding was the only gap.Fix
The pre-LOAD condition now uses
tcc_is_64bit_type()instead of== VT_LLONG.Tests
bug_inline_double_deref_argcovers*p, struct member,p[i],long double, mixed int + double, and a parameter the callee modifies. It also checks thelong long,floatand by-valuedoublecases, which already worked. Before the fix it failed at -O1/-O2/-Os; with the fix it passes at -O0/-O1/-O2/-Os.make test-ir -j16: 18,203 passed (incl. mibench), 0 failed.🤖 Generated with Claude Code