decomp(ATERM): align option initialization scheduling #1097

Merged
coah80 merged 1 commits from agent/bittle/aterm-option-init-order into main 2026-10-03 12:04:42 +00:00
coah80 commented 2026-10-03 12:04:25 +00:00 (Migrated from github.com)

One focused initialization-order change

Move the existing constant seven-byte optionIds declaration below the existing enabled = SOHtoNs(1) declaration in case 5. All other source bytes, types, assignments, scopes, helpers, configuration and symbol metadata stay fixed. Exactly one candidate was tried.

  • ATERMRunConfigProtocol: 88.19559% → 89.56257%
  • Unit: 97.03666% → 97.307434%
  • Compiled instructions remain 958 versus original 951; this is not an exact match
  • Exact functions 18/26, code 11036/19204, data 18584/18864 and link measures unchanged

Target code loads gAtermRequestOptions, calls SOHtoNs, then initializes the option bytes. This motivates scheduling, not a unique original source-order or semantic-bug claim. The mutable pointer load remains before the call. The array initializer is purely constants; its address is not exposed before initialization. Actual original/current SOHtoNs is pinned to two instructions, masks r3 to16 bits and returns, with no memory or callback effects.

Independent parent verification

Freshly rebuilt on 02d634d30b. Tested tree9171db111effc40975cd574e895247b846f7ade8.

  • All1,027 unit/function reports checked: no regressions, only ATERM changes
  • All sibling function bytes/extents unchanged; allocated non-code bytes/types/flags/sizes/alignment and592 relocations outside the changed span identical
  • Changes confined to20 instructions in one21-instruction initialization span; all123 calls preserve sequence and identities
  • Focused evaluator rerun with five sampled pointer values: same private array/enabled bytes, saved pointer read, SOHtoNs(1) input and next memset arguments
  • Actual SOHtoNs bytes pinned; actual memset/__fill_mem and caller liveness checks show differing volatile r6–r11 values are not consumed before overwrite. This is a bounded observation/input audit, not a general symbolic proof or protocol-runtime test
  • Pool identical. Literal audit:24 functions/6 arguments, zero errors; existing unequal-size skips are DiscoverAccessPoints and RunConfigProtocol. The seven changed-scope constant bytes are separately checked
  • Full default build/progress,43U/ok, main/leaf and diff checks pass
  • DOL SHA1:26116613f624061ba99c8d1a299aaa6efa85670d

No synthetic branches, padding, volatile casts, register forcing, assembly or undefined values. Evidence: tools/decomp-assist/aterm-option-initializer-order.attempts.md. Original binaries/disassembly are not uploaded. Draft for human review; no merge or auto-merge requested.

Note

Reorder option identifier declaration in ATERMRunConfigProtocol

Moves the block-local optionIds array declaration to after the enabled halfword declaration in protocol state case 5 of ATERMRunConfigProtocol in ATERM.c. Array contents and option construction are unchanged. Adds a trial report in aterm-option-initializer-order.attempts.md covering build, comparison, and verification steps.

Macroscope summarized 4105c6a.

## One focused initialization-order change Move the existing constant seven-byte optionIds declaration below the existing enabled = SOHtoNs(1) declaration in case 5. All other source bytes, types, assignments, scopes, helpers, configuration and symbol metadata stay fixed. Exactly one candidate was tried. - ATERMRunConfigProtocol: 88.19559% → 89.56257% - Unit: 97.03666% → 97.307434% - Compiled instructions remain 958 versus original 951; this is not an exact match - Exact functions 18/26, code 11036/19204, data 18584/18864 and link measures unchanged Target code loads gAtermRequestOptions, calls SOHtoNs, then initializes the option bytes. This motivates scheduling, not a unique original source-order or semantic-bug claim. The mutable pointer load remains before the call. The array initializer is purely constants; its address is not exposed before initialization. Actual original/current SOHtoNs is pinned to two instructions, masks r3 to16 bits and returns, with no memory or callback effects. ## Independent parent verification Freshly rebuilt on 02d634d30bdf6e5acd249b5c6b1aa17c7551d646. Tested tree9171db111effc40975cd574e895247b846f7ade8. - All1,027 unit/function reports checked: no regressions, only ATERM changes - All sibling function bytes/extents unchanged; allocated non-code bytes/types/flags/sizes/alignment and592 relocations outside the changed span identical - Changes confined to20 instructions in one21-instruction initialization span; all123 calls preserve sequence and identities - Focused evaluator rerun with five sampled pointer values: same private array/enabled bytes, saved pointer read, SOHtoNs(1) input and next memset arguments - Actual SOHtoNs bytes pinned; actual memset/__fill_mem and caller liveness checks show differing volatile r6–r11 values are not consumed before overwrite. This is a bounded observation/input audit, not a general symbolic proof or protocol-runtime test - Pool identical. Literal audit:24 functions/6 arguments, zero errors; existing unequal-size skips are DiscoverAccessPoints and RunConfigProtocol. The seven changed-scope constant bytes are separately checked - Full default build/progress,43U/ok, main/leaf and diff checks pass - DOL SHA1:26116613f624061ba99c8d1a299aaa6efa85670d No synthetic branches, padding, volatile casts, register forcing, assembly or undefined values. Evidence: tools/decomp-assist/aterm-option-initializer-order.attempts.md. Original binaries/disassembly are not uploaded. Draft for human review; no merge or auto-merge requested. <!-- Macroscope's pull request summary starts here --> <!-- Macroscope will only edit the content between these invisible markers, and the markers themselves will not be visible in the GitHub rendered markdown. --> <!-- If you delete either of the start / end markers from your PR's description, Macroscope will append its summary at the bottom of the description. --> > [!NOTE] > ### Reorder option identifier declaration in ATERMRunConfigProtocol > Moves the block-local `optionIds` array declaration to after the enabled halfword declaration in protocol state case 5 of `ATERMRunConfigProtocol` in [ATERM.c](https://github.com/coah80/wii-ipl/pull/1097/files#diff-e67bb234e10edec28359a3022bc49117cf56df7cd361cea3415fc9a54636e50d). Array contents and option construction are unchanged. Adds a trial report in [aterm-option-initializer-order.attempts.md](https://github.com/coah80/wii-ipl/pull/1097/files#diff-668bc69abcb5e58377edebc146e7089f235aef3c60db2d52bb84b03101b3ccad) covering build, comparison, and verification steps. > > <!-- Macroscope's review summary starts here --> > > <sup><a href="https://app.macroscope.com">Macroscope</a> summarized 4105c6a.</sup> > <!-- Macroscope's review summary ends here --> > <!-- Macroscope's pull request summary ends here -->
coah80 commented 2026-10-03 12:04:39 +00:00 (Migrated from github.com)

Reviewed and merged: rebased on main, full build ok, DOL sha1 26116613f624061ba99c8d1a299aaa6efa85670d, 0 regressions, 0 forbidden patterns.

Reviewed and merged: rebased on main, full build ok, DOL sha1 26116613f624061ba99c8d1a299aaa6efa85670d, 0 regressions, 0 forbidden patterns.
Sign in to join this conversation.