]> git.ipfire.org Git - thirdparty/gcc.git/commit
lto: Add toplevel simple assembly heuristics
authorMichal Jires <mjires@suse.cz>
Sun, 16 Nov 2025 19:16:15 +0000 (20:16 +0100)
committerMichal Jires <mjires@suse.cz>
Sun, 11 Jan 2026 21:48:55 +0000 (22:48 +0100)
commit903bf05caa4ec24f568b887e80d2edf31f92d5d6
tree2b0051e14bce67bb3102c67a26db1031b5de9303
parenta988ab269e2655f352b419efb053c28ee7e39a4d
lto: Add toplevel simple assembly heuristics

This new pass heuristically detects symbols referenced by toplevel
assembly to prevent their optimization.

Heuristics is done by comparing identifiers in assembly to known
symbols.

The pass is split into 2 passes, in LGEN and in WPA.
There must be one pass for WPA to be able to reference any symbol.
However in WPA there may be multiple symbols with the same name,
so we handle those local symbols in LGEN.

gcc/ChangeLog:

* asm-toplevel.cc (mark_fragile_ref_by_asm):
Add marked_local to handle symbol as local.
(ipa_asm_heuristics): New.
(class pass_ipa_asm): New.
(make_pass_ipa_asm_lgen): New.
(make_pass_ipa_asm_wpa): New.
* common.opt: New flto-toplevel-asm-heuristics.
* passes.def: New asm passes.
* timevar.def (TV_IPA_LTO_ASM): New.
* tree-pass.h (make_pass_ipa_asm_lgen): New.
(make_pass_ipa_asm_wpa): New.

gcc/testsuite/ChangeLog:

* gcc.dg/lto/toplevel-simple-asm-1_0.c: New test.
* gcc.dg/lto/toplevel-simple-asm-1_1.c: New test.
* gcc.dg/lto/toplevel-simple-asm-2_0.c: New test.
* gcc.dg/lto/toplevel-simple-asm-2_1.c: New test.
gcc/asm-toplevel.cc
gcc/common.opt
gcc/passes.def
gcc/testsuite/gcc.dg/lto/toplevel-simple-asm-1_0.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/lto/toplevel-simple-asm-1_1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/lto/toplevel-simple-asm-2_0.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/lto/toplevel-simple-asm-2_1.c [new file with mode: 0644]
gcc/timevar.def
gcc/tree-pass.h