Repository navigation
[AUTOMATED] fix(p3,p6): a value read by a sign-sensitive op is not re-read from a global it is stored to - #758
Merged
Merged
Conversation
mahaloz
force-pushed
the
fix/volreuse
branch
from
September 29, 2026 17:27
631ee5e to
ab3d1ce
Compare
mahaloz
force-pushed
the
fix/volreuse
branch
2 times, most recently
from
September 29, 2026 18:39
405d4ce to
a7514a8
Compare
mahaloz
force-pushed
the
fix/volreuse
branch
from
September 30, 2026 22:52
5baee57 to
d12bc9a
Compare
mahaloz
force-pushed
the
fix/volreuse
branch
3 times, most recently
from
October 2, 2026 00:52
6523d95 to
7790049
Compare
…-read from a global it was stored to (squashed for rebase) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011shDTp2k5iNyyj9TCjt6vg
…eading the global Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011shDTp2k5iNyyj9TCjt6vg
… to keeps printing as the global A load the binary makes of a global after storing a computed value to it is left on the global while the value is read sign-sensitively; otherwise the value and its stores are marked and Merge joins them with the global as before. Fixtures gain w_realias/w_rephi/w_reboth/w_recopy (store, pointer store, load); stage assertions #17-#21, and #5/#6/#9 follow the loads the -O0 binary makes. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011shDTp2k5iNyyj9TCjt6vg
…l stays upstream's; spec 03/06 and module docs describe loads Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011shDTp2k5iNyyj9TCjt6vg
…he global, every changed function classified Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011shDTp2k5iNyyj9TCjt6vg
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011shDTp2k5iNyyj9TCjt6vg
…'s marker as upstream Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011shDTp2k5iNyyj9TCjt6vg
… of this one Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
…on main 363123e (1637 -> 1658) Only the 21 globalvalue keys are new; none of main's keys are missing. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
…'s earlier value is used after it Keeping the store COPY at the binary's position while the global's earlier value is still read after it made Merge copy that earlier value out where it is defined (the entry, a call, a loop head), above a pointer store the binary reads the global after. The decline now checks for such a read first, through the copies a later propagation can fold, and leaves the store to upstream. Witnesses w_ohoist (gcc -O2), w_oif (gcc -O0, clang -O2) and w_oloop (gcc -O0) added to the globalstore fixtures; stage assertions #22-#24. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
…ot by version count The check walked every version of the global with one shared budget and gave up (left the store to upstream) in large functions with many calls. It now first collects the blocks reachable from the store once and skips a version none of whose uses lies there; spec 03 and 06 describe the earlier-value case. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
… (1658 -> 1661); footprint on main 363123e Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
…d after it A version of the global whose definition does not dominate the store cannot be live across it, so the earlier-value check skips it before walking. In large loops (sort's option loop) the per-version walks otherwise ran out of budget and left the store to upstream. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
…er-value stores left to upstream) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
mahaloz
added a commit
that referenced
this pull request
Oct 2, 2026
…ning its spelling The MIPS half of a_float_handed_on_through_wrappers_to_an_integer_round_trips pinned `dat_4120e0 = sub_400898(a0,a1);`. Since #758 the reader keeps the call's result in its own variable before the store and the shift (`v2 = sub_400898(a0,a1); dat_4120e0 = v2; dat_4120e8 = v2 >> 0x10;`), which is right and still float-free. The test now compiles the printed chain with gcc and clang, maps the fixture's float array at a 32-bit address, and checks the reader stores the bits of 2.25f (`40100000 0 4010 0`); the float chain the withdrawal fixes printed stores 2 (`2 0 0 0`). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
mahaloz
added a commit
that referenced
this pull request
Oct 2, 2026
…ning its spelling The MIPS half of a_float_handed_on_through_wrappers_to_an_integer_round_trips pinned `dat_4120e0 = sub_400898(a0,a1);`. Since #758 the reader keeps the call's result in its own variable before the store and the shift (`v2 = sub_400898(a0,a1); dat_4120e0 = v2; dat_4120e8 = v2 >> 0x10;`), which is right and still float-free. The test now compiles the printed chain with gcc and clang, maps the fixture's float array at a 32-bit address, and checks the reader stores the bits of 2.25f (`40100000 0 4010 0`); the float chain the withdrawal fixes printed stores 2 (`2 0 0 0`). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
mahaloz
added a commit
that referenced
this pull request
Oct 2, 2026
…nt, typesweep, speed, gates) Re-measured against main 3c08fcf (#758): castbench 31,989 -> 31,559 (0.846x -> 0.834x IDA); every function #758 leaves alone prints as on the 94ce931 round on both arms, and the ones it changes carry the same delta; typesweep 1,674 -> 1,674 (4 better, 2 worse, grep kwsinit as before); paired speed fmt +3.3%, ls -2.3%, sort +0.8%, bash +0.6% (min of 11). The fixture README row describes the MIPS round trip. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
mahaloz
added a commit
that referenced
this pull request
Oct 2, 2026
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
mahaloz
added a commit
that referenced
this pull request
Oct 2, 2026
…ning its spelling The MIPS half of a_float_handed_on_through_wrappers_to_an_integer_round_trips pinned `dat_4120e0 = sub_400898(a0,a1);`. Since #758 the reader keeps the call's result in its own variable before the store and the shift (`v2 = sub_400898(a0,a1); dat_4120e0 = v2; dat_4120e8 = v2 >> 0x10;`), which is right and still float-free. The test now compiles the printed chain with gcc and clang, maps the fixture's float array at a 32-bit address, and checks the reader stores the bits of 2.25f (`40100000 0 4010 0`); the float chain the withdrawal fixes printed stores 2 (`2 0 0 0`). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
mahaloz
added a commit
that referenced
this pull request
Oct 2, 2026
…nt, typesweep, speed, gates) Re-measured against main 3c08fcf (#758): castbench 31,989 -> 31,559 (0.846x -> 0.834x IDA); every function #758 leaves alone prints as on the 94ce931 round on both arms, and the ones it changes carry the same delta; typesweep 1,674 -> 1,674 (4 better, 2 worse, grep kwsinit as before); paired speed fmt +3.3%, ls -2.3%, sort +0.8%, bash +0.6% (min of 11). The fixture README row describes the MIPS round trip. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
mahaloz
added a commit
that referenced
this pull request
Oct 2, 2026
…ning its spelling The MIPS half of a_float_handed_on_through_wrappers_to_an_integer_round_trips pinned `dat_4120e0 = sub_400898(a0,a1);`. Since #758 the reader keeps the call's result in its own variable before the store and the shift (`v2 = sub_400898(a0,a1); dat_4120e0 = v2; dat_4120e8 = v2 >> 0x10;`), which is right and still float-free. The test now compiles the printed chain with gcc and clang, maps the fixture's float array at a 32-bit address, and checks the reader stores the bits of 2.25f (`40100000 0 4010 0`); the float chain the withdrawal fixes printed stores 2 (`2 0 0 0`). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
mahaloz
added a commit
that referenced
this pull request
Oct 2, 2026
…nt, typesweep, speed, gates) Re-measured against main 3c08fcf (#758): castbench 31,989 -> 31,559 (0.846x -> 0.834x IDA); every function #758 leaves alone prints as on the 94ce931 round on both arms, and the ones it changes carry the same delta; typesweep 1,674 -> 1,674 (4 better, 2 worse, grep kwsinit as before); paired speed fmt +3.3%, ls -2.3%, sort +0.8%, bash +0.6% (min of 11). The fixture README row describes the MIPS round trip. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
mahaloz
added a commit
that referenced
this pull request
Oct 2, 2026
…ning its spelling The MIPS half of a_float_handed_on_through_wrappers_to_an_integer_round_trips pinned `dat_4120e0 = sub_400898(a0,a1);`. Since #758 the reader keeps the call's result in its own variable before the store and the shift (`v2 = sub_400898(a0,a1); dat_4120e0 = v2; dat_4120e8 = v2 >> 0x10;`), which is right and still float-free. The test now compiles the printed chain with gcc and clang, maps the fixture's float array at a 32-bit address, and checks the reader stores the bits of 2.25f (`40100000 0 4010 0`); the float chain the withdrawal fixes printed stores 2 (`2 0 0 0`). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
mahaloz
added a commit
that referenced
this pull request
Oct 2, 2026
…nt, typesweep, speed, gates) Re-measured against main 3c08fcf (#758): castbench 31,989 -> 31,559 (0.846x -> 0.834x IDA); every function #758 leaves alone prints as on the 94ce931 round on both arms, and the ones it changes carry the same delta; typesweep 1,674 -> 1,674 (4 better, 2 worse, grep kwsinit as before); paired speed fmt +3.3%, ls -2.3%, sort +0.8%, bash +0.6% (min of 11). The fixture README row describes the MIPS round trip. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
mahaloz
added a commit
that referenced
this pull request
Oct 2, 2026
…ning its spelling The MIPS half of a_float_handed_on_through_wrappers_to_an_integer_round_trips pinned `dat_4120e0 = sub_400898(a0,a1);`. Since #758 the reader keeps the call's result in its own variable before the store and the shift (`v2 = sub_400898(a0,a1); dat_4120e0 = v2; dat_4120e8 = v2 >> 0x10;`), which is right and still float-free. The test now compiles the printed chain with gcc and clang, maps the fixture's float array at a 32-bit address, and checks the reader stores the bits of 2.25f (`40100000 0 4010 0`); the float chain the withdrawal fixes printed stores 2 (`2 0 0 0`). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
mahaloz
added a commit
that referenced
this pull request
Oct 2, 2026
…nt, typesweep, speed, gates) Re-measured against main 3c08fcf (#758): castbench 31,989 -> 31,559 (0.846x -> 0.834x IDA); every function #758 leaves alone prints as on the 94ce931 round on both arms, and the ones it changes carry the same delta; typesweep 1,674 -> 1,674 (4 better, 2 worse, grep kwsinit as before); paired speed fmt +3.3%, ls -2.3%, sort +0.8%, bash +0.6% (min of 11). The fixture README row describes the MIPS round trip. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
mahaloz
added a commit
that referenced
this pull request
Oct 2, 2026
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
mahaloz
added a commit
that referenced
this pull request
Oct 2, 2026
…ning its spelling The MIPS half of a_float_handed_on_through_wrappers_to_an_integer_round_trips pinned `dat_4120e0 = sub_400898(a0,a1);`. Since #758 the reader keeps the call's result in its own variable before the store and the shift (`v2 = sub_400898(a0,a1); dat_4120e0 = v2; dat_4120e8 = v2 >> 0x10;`), which is right and still float-free. The test now compiles the printed chain with gcc and clang, maps the fixture's float array at a 32-bit address, and checks the reader stores the bits of 2.25f (`40100000 0 4010 0`); the float chain the withdrawal fixes printed stores 2 (`2 0 0 0`). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
mahaloz
added a commit
that referenced
this pull request
Oct 2, 2026
…nt, typesweep, speed, gates) Re-measured against main 3c08fcf (#758): castbench 31,989 -> 31,559 (0.846x -> 0.834x IDA); every function #758 leaves alone prints as on the 94ce931 round on both arms, and the ones it changes carry the same delta; typesweep 1,674 -> 1,674 (4 better, 2 worse, grep kwsinit as before); paired speed fmt +3.3%, ls -2.3%, sort +0.8%, bash +0.6% (min of 11). The fixture README row describes the MIPS round trip. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
mahaloz
added a commit
that referenced
this pull request
Oct 2, 2026
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
mahaloz
added a commit
that referenced
this pull request
Oct 2, 2026
…ning its spelling The MIPS half of a_float_handed_on_through_wrappers_to_an_integer_round_trips pinned `dat_4120e0 = sub_400898(a0,a1);`. Since #758 the reader keeps the call's result in its own variable before the store and the shift (`v2 = sub_400898(a0,a1); dat_4120e0 = v2; dat_4120e8 = v2 >> 0x10;`), which is right and still float-free. The test now compiles the printed chain with gcc and clang, maps the fixture's float array at a 32-bit address, and checks the reader stores the bits of 2.25f (`40100000 0 4010 0`); the float chain the withdrawal fixes printed stores 2 (`2 0 0 0`). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
mahaloz
added a commit
that referenced
this pull request
Oct 2, 2026
…nt, typesweep, speed, gates) Re-measured against main 3c08fcf (#758): castbench 31,989 -> 31,559 (0.846x -> 0.834x IDA); every function #758 leaves alone prints as on the 94ce931 round on both arms, and the ones it changes carry the same delta; typesweep 1,674 -> 1,674 (4 better, 2 worse, grep kwsinit as before); paired speed fmt +3.3%, ls -2.3%, sort +0.8%, bash +0.6% (min of 11). The fixture README row describes the MIPS round trip. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
mahaloz
added a commit
that referenced
this pull request
Oct 2, 2026
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
mahaloz
added a commit
that referenced
this pull request
Oct 2, 2026
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
mahaloz
added a commit
that referenced
this pull request
Oct 3, 2026
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
mahaloz
added a commit
that referenced
this pull request
Oct 3, 2026
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
mahaloz
added a commit
that referenced
this pull request
Oct 3, 2026
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
mahaloz
added a commit
that referenced
this pull request
Oct 3, 2026
…mpile time grow cubically (#820) ## 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: ```sh cat > gen.py <<'PY' import sys n = int(sys.argv[1]) print("int *gi, *gi2;\nint big(int *p, int k, int **pp, int **pp2) {\n int x = 0; int *q;") for i in range(n): print(f" q = p + (k + {i % 7}); gi = q; x += q[{i % 5}]; *pp = p + {i % 3}; x += gi[{i % 4}]; if (x & {1 << (i % 8)}) {{ gi2 = gi; *pp2 = q; }}") print(" return x;\n}") PY python3 gen.py 600 > s600.c && gcc -O2 -c s600.c -o s600.o /usr/bin/time -f "user %U s" kuna decompile s600.o big > /dev/null ``` ``` user 37.01 s ``` The build before #798 takes 15.48 s, and this branch 13.37 s. ## The fix - The store walk #798 added (`old_value_read_after`) asked `dominates()` 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 in `RulePropagateCopy` is main's. - The stores #798 keeps are many COPYs of one register into one variable, and `markRedundantCopies` built 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. - Nothing printed changes. Debug builds check the dominator memo against `dominates()`, the block table against a scan of the block list, and each pair's shortened walk against `check_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-all` of 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 - Unit tests check `dominates_memo` and `dominates_within` against `dominates`, including chains longer than the plain walk, `add_ref_point_until` against the full cover, and the new pair loop against the old one. #798's and #758's stage tests and round trips pass unchanged. - `tests/cli/repeated-global-pointer-stores-decompile-fast.json` decompiles 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 #798 does not print. - CPU seconds, min / median of N runs, interleaved, on a shared machine. Before #798 is 954a5ef; main is 64d21a5. The early-return rows replace the generator's `if` with `if (x == 3*i+1) return x;`; the call-store rows replace `*pp = ...` with a call `ext(x)`. The switch rows store the pointer once and read through it, then switch over n cases that each store the global when `c == 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). | case | N | before #798 | main | this branch | |---|---:|---:|---:|---:| | switch, n=300 | 15 | 3.76 / 4.14 | 4.76 / 5.37 | 4.52 / 5.19 | | switch, n=600 | 7 | 14.99 / 15.53 | 25.82 / 28.06 | 24.93 / 28.88 | | generator, n=300 | 11 | 2.52 / 2.96 | 3.94 / 4.22 | 2.46 / 2.76 | | generator, n=600 | 5 | 14.63 / 15.03 | 37.72 / 38.83 | 12.79 / 13.53 | | early returns, n=300 | 5 | 2.35 / 2.60 | 16.75 / 18.13 | 4.53 / 4.96 | | call stores, n=300 | 21 | 0.47 / 0.48 | 0.60 / 0.62 | 0.54 / 0.57 | | call stores, n=600 | 5 | 1.39 / 1.44 | 2.17 / 2.27 | 1.76 / 1.79 | | probe fixture | 11 | 0.95 / 1.32 | 4.25 / 4.93 | 1.72 / 1.86 | | bash, 11 largest functions | 11 | – | 48.50 / 52.52 | 46.75 / 54.42 | | e2fsck, 11 largest | 11 | – | 15.34 / 16.93 | 14.10 / 17.10 | | tar, 11 largest | 11 | – | 31.26 / 33.71 | 31.18 / 34.58 | | dash, whole binary | 15 | – | 6.30 / 7.46 | 6.13 / 7.04 | | rsyslogd, 10 largest | 15 | – | 13.63 / 14.31 | 13.52 / 14.66 | - Not fixed: a function with hundreds of early returns runs the rule pool again for each return, and every pass still runs the store walk once per reader. The early-return row is still 1.9x the build before #798. Fixes #818 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt
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
A value stored to a global and then read by a sign-sensitive operation was printed as a read of the global, so the result depends on how the global is declared, which kuna never states.
With
sinkdeclared as it really is (volatile int) the shift is arithmetic and the rebuilt function returns-134217728. Widenings, int-to-double, byte compares, and any of these reached through+or^go wrong the same way. The value must still not stand in for a load of the global the binary makes after a pointer store that may alias it:The fix
RulePropagateCopykeeps the store'sCOPYin the global's markers, and keeps every later load of the global reading it, while an operation reads the stored value sign-sensitively (p3_dataflow/kuna_globalstorekeep.rs). kuna's SSA gives a pointer store no effect on a global, so such a load is the store'sCOPY.Mergethen keeps the value apart from the global (p6_variables/kuna_globalvalue.rs), unless a load was already let through to the value: then the value is marked and joined with the global as before, so the load still prints as the global.Mergecopy the earlier value out where it is defined (the entry, a call, a loop head), above a pointer store the binary loads the global after:*p = k; old = g; n = old * 3 + inc; if (n >> 20) return 7; g = n; return old == 5 ? 1 : old;printedv1 = g; *a1 = a2;.>>,/,%, ordered compares, extensions, int-to-float, sub-int==/!=; also through+ - * & | ^ ~ <<, and what later rules make sign-sensitive (a folded short compare, a carry, a concatenation's low half, a range meld).reusenow printsv1 = (unsigned int)(a0 * 3) >> 4;andbothprintsreturn ((int)gi >> 4) + ((unsigned int)(a0 * 3) >> 4);. Strict fix, no option.return a0 * 3 >> 4;; [AUTOMATED] a load of a global after a pointer store prints the parameter or constant stored before it #792,--option indexaliasguard fullprints the load). A store followed by a use of the global's earlier value keeps main's text, so its value can still be read back from the global there. A small value used twice can now print twice (if (a0 * 3 <= -1), kuna'simpliedrefs), which gcc folds as signed overflow; main prints the same shape where no global is involved.The tests
kuna-clia_value_read_by_a_sign_sensitive_op_is_not_re_read_from_a_global: 33 functions in three fixtures (gcc -O0/-O2, clang -O2), globals given their real types, printed C compiled by gcc and clang and run against the binary's ownmain. All three fail on main. Four functions store to a plainint, store through a pointer the harness aims at it, and load it back. Three more (w_ohoist,w_oif,w_oloop) load a global after such a pointer store, store to it and use what they loaded; main prints them right, and the test keeps it that way.tests/stages/kuna-globalvalue.xml: 24 assertions, 10 pass on main. No datatest assertion moved (675/675).docs/features/volreuse/footprint.md.🤖 Generated with Claude Code
https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU