Repository navigation
[AUTOMATED] Name an address read at two types once, keep walk bounds as addresses, and name Cortex-M flash data - #2143
Merged
Merged
Conversation
A caller that refused or withdrew its callee's callrettype statement still compared the result against an unknown of its width, so it printed `v1 = (long *)xalloc(0x18)` beside `void * xalloc(..)` and `v2 = (char *)savestr(a0)` beside `char * savestr(..)`. The output token is now the caller's own type when it is the type the callee states, or when an assigned result meets a `void *` on one side and an object pointer on the other. Variable types are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0179iMKNAQaUNYkq7CbbU1yT
…and Cortex-M flash data `option globalref` gains a value, `views`, now the default. An address the function uses at more than one pointed-to type, or at another type than it reads the storage at directly, is named once: the object is declared at the type its direct accesses agree on (or as the unknown byte) and each reader of another type reads it through a cast. An integer direct access at the object's start and width whose uses keep their bits under any integer type does not block an integer declaration. The end bound of a pointer walk is no longer named as the object after the array. On an M-profile (Thumb-only) ARM image, even addresses in the executable flash sections can hold objects. Work in progress: options.md, the stages baseline and measurements follow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0179iMKNAQaUNYkq7CbbU1yT
…stages baseline Re-records docs/baseline-stages.json for the new kuna-globalref-views stage test and the two kuna-globalref assertions the default changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0179iMKNAQaUNYkq7CbbU1yT
…stage test Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0179iMKNAQaUNYkq7CbbU1yT
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0179iMKNAQaUNYkq7CbbU1yT
…eclared type Drop the rule that let a direct integer read whose uses looked bit-agnostic take the type of a reader of another type. It declared the read at the reader's type, dropped it from the function's direct objects, and let the header pick a wider type another function took the address at (an 8-byte compare of a 4-byte read), an array (a scalar compare against a decayed array), or the other signedness (an unsigned int passed to a long parameter sign-extended). It also let an indexed base through as the scalar's address, `(&dat_X)[i]`. Every direct access now stays an object of its own type, and a reader of another type takes the cast; an indexed base keeps on's verdict. The views fixture gains the four shapes, run natively by the round trip, and the stage test pins the cast on the reader and on the indexed base. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0179iMKNAQaUNYkq7CbbU1yT
C converts a `void *` to or from a pointer to an object on assignment, but Rust and Go do not: under `--option outlang rust` a refused call result printed `v1 = xalloc(0x18);` into a `*mut i64` (E0308), and under `outlang go` `v1 = xalloc(0x18)` into a `*int64`. The `void *` case now applies to C output only; a result held at the callee's own type still prints no cast in every language. The arms of a conditional expression are brought to one type before the assignment, so a `char *` arm beside a `struct_0 *` arm is not valid C. A call that is an arm of a diamond `iteregion` prints as `?:` keeps its cast: `v2 = (a0 & 1) ? (void *)mk_str(a0) : (void *)mk_pt(a0);`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0179iMKNAQaUNYkq7CbbU1yT
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0179iMKNAQaUNYkq7CbbU1yT
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0179iMKNAQaUNYkq7CbbU1yT
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0179iMKNAQaUNYkq7CbbU1yT
Corpus file count 1032; stage baseline merged by key (6,366). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0179iMKNAQaUNYkq7CbbU1yT
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0179iMKNAQaUNYkq7CbbU1yT
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 constant address that a function uses at two pointer types, or at another type than it reads the global at directly, keeps a raw
(T *)0x...cast, and the end bound of a pointer walk is named as whatever object follows the array:globalrefgets a third value,views, now the default (onis the previous default,offthe raw casts). Underviewsan address used at several types is named once and declared at the type its direct accesses agree on (int dat_4030above), or as the unknown byte when the function never reads it directly; each reader of another type reads the name through a cast. A view never changes the type a direct access is declared at, since that type is what the access computes with (a compare's width, the extension of an argument passed to a wider parameter).viewsadds nothing whereonrefuses an indexed base, an address added to or subtracted from (tab - 1need not start an object), or storage a direct access overlaps at another start or type: those keep their cast, e.g.((short *)0x4018)[i]for a table also read directly asunsigned short.p != &headstill names the head..textsection, somix((void *)0x1012c,a0)stayed a cast; even addresses there can now hold objects (mix(&dat_1012c,a0)), odd ones are Thumb code pointers and keep their spelling. Other targets are unaffected.--option globalref onreproduces the previous output byte for byte on the decbench corpus.On that corpus (87,514 functions, x86-64 and Cortex-M, O0/O2/O2-noinline) 1,702 bodies change and no variable or type does: 893 constant-address casts become a bare
&dat_X, 2,740 more addresses are named under the cast their reader needs, and 460 walk bounds keep their address; 421 fewer casts in all, and the 308 functions with more casts are all walk bounds. No newly named address is a function entry or inside a function (checked against the unstripped builds), no constant spelled as an integer changes, and the crazyflie project headers declare no directly read global at another width or signedness than before. Instruction counts move by at most +0.07%.Limits: a Thumb function's own bytes read as data (a checksum over code) are named
&dat_Xtoo, since the flash sections hold code as well; a string in Cortex-M flash prints as&dat_X, not as the literal; and in adecompile-projectexport a function that only takes an address at two pointer types now names it, while the header still leaves an address read at two types undeclared, so that function needs the name declared to compile (asonalready does for a one-type reader; no function of the decbench corpus that compiled before is affected).Tests:
tests/stages/kuna-globalref-views.xml(two passes,onthen the default, on an x86-64 and a Cortex-M fixture);an_address_read_at_two_types_round_trips_through_the_printed_ccompiles the printed callers underonandviewswith gcc and clang and runs them, including a narrow read of a wider global, anunsigned intpassed to along, an indexedunsigned shorttable and a table read as a scalar; the existingglobalrefround trip gains aviewsarm; unit tests for the flash ranges, the direct-object list and the option values.Model:
anthropic/claude-opus-5-5🤖 Generated with Claude Code
https://claude.ai/code/session_0179iMKNAQaUNYkq7CbbU1yT