Repository navigation
[AUTOMATED] fix(p3/p6): repeated pointer stores to a global made decompile time grow cubically - #820
Merged
Merged
Conversation
mahaloz
force-pushed
the
fix/pointeestore-walk
branch
7 times, most recently
from
October 3, 2026 03:38
5e8915d to
7b61ebc
Compare
38 of 42 tasks
old_value_read_after asked dominates() once per instance of the global, each a walk up the dominator tree; the answers for the store's block are now kept across the instances. A cover walk resolved every block index by scanning the block list; FuncdataCoverCtx now builds the index table once. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
…rite markRedundantCopies built the full cover between every pair of COPYs from one value into a high, then scanned every instance of the high. The pairs of a group now share the dominator walks, the block table and the high's writes indexed by block, and each range walk stops once it meets a write. A cover block only grows during the walk, so the answer is the same. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
old_value_read_after scanned every input of a MULTIEQUAL once per value of the global it read, so a join of n values cost n squared per walk; it now collects the joins and reads each input once. The dominator memo is a slot map, and debug builds check the shared walks against the reference ones. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
…e the stores fixture Unit tests check dominates_memo against dominates, add_ref_point_until against the full cover, and redundant_in_order against the pair loop. tests/cli/repeated-global-pointer-stores-decompile-fast.json times a function that stores one of two pointers to a global 400 times. Chapters 03 and 06 describe the shared walks. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
RulePropagateCopy asks kuna_pointeestorekeep before kuna_globalstorekeep for every op, so the chapter 03 note now says that instead of the marker order this branch no longer changes. Chapter 06's paragraph on the shared redundant-COPY walk becomes its own paragraph. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
The fixture is now the early-return shape whose decompile time #798 raised from 1.0 s to about 5 s, rather than one #798 never slowed, so the probe's wall bound separates main from this branch by a wide margin on both sides. It also pins the load through the global after the pointer store, which the decompile printed as the register before #798. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
…s notes Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
… function The redundant-COPY helper was inserted between compare_copy_by_in_varnode's doc comment and its function, so the helper took the comparator's header. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt
…aracter limit The probe validator rejects notes longer than 400 characters, so make test-cli failed the probe as invalid. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt
…tore walk The store walk collected the joins of every value of the global, then scanned each joined value's readers for the join, so a switch whose cases each store the global conditionally, after a store of a pointer read as an address, cost the square of the cases per asking: 5.4x main at 600 cases. It now skips a value written at or after the store before it reads the value's readers, and records each join with the earlier values that list it, so no reader list is scanned twice. dominates_memo walks up to 8 steps the plain way before it keeps answers, and reuses its path buffer, so short dominator chains cost what dominates() does. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt
… total is not linear Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt
…g the memo Every dominance question in the store walk and the redundant-copy pairs went through dominates_memo, whose call cost more than the two or three steps most walks take: on a switch whose cases each store the global, the store walk spent 6% more than main's per-value walk. Callers now ask dominates_within for eight blocks first and only a longer walk reaches the memo, which keeps the answer for every block it passes again. On that switch the walk is now 20% faster than main's, and the issue's shapes keep their gains. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt
…chains plainly Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt
mahaloz
force-pushed
the
fix/pointeestore-walk
branch
from
October 3, 2026 06:59
7b61ebc to
6d07197
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
Since #798, a function that stores a pointer to a global many times, with other pointer stores in between, decompiles much more slowly, and the gap grows faster than the function. On main:
The build before #798 takes 15.48 s, and this branch 13.37 s.
The fix
old_value_read_after) askeddominates()once per value of the global, each a walk up the dominator tree, and scanned every input of a join once per value the join reads. It now sets aside the values written at or after the store first, reads only the earlier values' readers, and reads each join among them once. A dominance question walks up the tree plainly for eight blocks, and only a longer walk goes through a memo for the store's block, so a long chain of blocks below the store is climbed once. One walk now costs time linear in the global's values, the earlier values' readers and the blocks of the dominator tree, but the rule pool still runs it once per reader, so the total is not linear. The order of the checks inRulePropagateCopyis main's.markRedundantCopiesbuilt the whole cover between every pair of them, with each step of a cover walk rescanning the block list to find a block by its index. Cover walks now find blocks through a table built once per walk. The pairs of one group share that table, the answers of long dominator walks and the variable's writes listed by block, and each pair's walk stops at the first write it meets. A cover block only grows during a walk, so the answer is the full range's.dominates(), the block table against a scan of the block list, and each pair's shortened walk againstcheck_copy_pair. A build that ran the old store walk beside the new one on every call agreed on all of at least 1.3 million calls, over 13 stripped binaries and 234 small objects.decompile-allof 31 stripped binaries (18,953 functions: x86-64 at O0, O2 and O2-noinline, including bash, dpkg, dash and tar; ARM firmware) is byte-identical to main (b3d0e99), as are 233 small objects built by gcc and clang at -O0 and -O2 for x86-64, aarch64, arm, i386, mips, mipsel, ppc, ppc64le and riscv64.The tests
dominates_memoanddominates_withinagainstdominates, including chains longer than the plain walk,add_ref_point_untilagainst the full cover, and the new pair loop against the old one. [AUTOMATED] fix(p3/p6): dereference a pointer stored to a global through its own variable #798's and [AUTOMATED] fix(p3,p6): a value read by a sign-sensitive op is not re-read from a global it is stored to #758's stage tests and round trips pass unchanged.tests/cli/repeated-global-pointer-stores-decompile-fast.jsondecompiles a fixture with 200 stores, each followed by an early return, in under 3.5 s (min of 3). It also checks that the global is read after the pointer store, which the build before [AUTOMATED] fix(p3/p6): dereference a pointer stored to a global through its own variable #798 does not print.ifwithif (x == 3*i+1) return x;; the call-store rows replace*pp = ...with a callext(x). The switch rows store the pointer once and read through it, then switch over n cases that each store the global whenc == i(gcc -O0); there the store walk itself took 0.41 s on this branch and 0.51 s on main when both were on 72d2e9b (timed inside the process, min of 10).Fixes #818
🤖 Generated with Claude Code
https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt