From 6b43fd7c0773bd97c4bd80145a17d67062afd4ea Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Tue, 7 Jul 2026 23:15:00 +0200 Subject: Preserve the 'accessed' member on macro arguments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Macro arguments get tampered with every time a new call has to be bundled. Deep down this is done by cloning the underlying object, but this resets any increase on the 'accessed' member, giving always the impression that macro arguments are never accessed. Fix this by at least preserving this member when cloning a macro argument. Note that this is neither the most elegant solution, and probably not the most correct. As in, it will probably get into a non-precise count after some calls. But at least it will be a non-zero value, which is more than enough to what this is actually used for. Signed-off-by: Miquel Sabaté Solà --- tests/expected/unused_macro_arg.nes | Bin 0 -> 27 bytes tests/expected/unused_macro_arg.txt | 0 tests/unused_macro_arg.s | 27 +++++++++++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 tests/expected/unused_macro_arg.nes create mode 100644 tests/expected/unused_macro_arg.txt create mode 100644 tests/unused_macro_arg.s (limited to 'tests') diff --git a/tests/expected/unused_macro_arg.nes b/tests/expected/unused_macro_arg.nes new file mode 100644 index 0000000..4a14648 Binary files /dev/null and b/tests/expected/unused_macro_arg.nes differ diff --git a/tests/expected/unused_macro_arg.txt b/tests/expected/unused_macro_arg.txt new file mode 100644 index 0000000..e69de29 diff --git a/tests/unused_macro_arg.s b/tests/unused_macro_arg.s new file mode 100644 index 0000000..fe4d7f0 --- /dev/null +++ b/tests/unused_macro_arg.s @@ -0,0 +1,27 @@ +.segment "HEADER" + .byte 'N', 'E', 'S', $1A + .byte $02, $01 + .byte $00 + .byte $00 + +.segment "CODE" + +;;; asan:stack full + +.macro BCD_ADD ADDR + adc ADDR + bcc :+ + nop +: +.endmacro + +.proc add_to_player_y + BCD_ADD additions + + rts + +additions: + .byte $FF +.endproc + +jsr add_to_player_y -- cgit v1.2.3