]> git.ipfire.org Git - thirdparty/gcc.git/commit
fmv: c++: Add check_target_clone hook for filtering target_clone versions.
authorAlfie Richards <alfie.richards@arm.com>
Mon, 24 Mar 2025 15:04:38 +0000 (15:04 +0000)
committerAlfie Richards <alfie.richards@arm.com>
Tue, 23 Sep 2025 09:47:43 +0000 (09:47 +0000)
commit3cc894e7c38c6ffaaa79ae92181b32c248f0d837
tree1f2db616b3a07fa7e49b432f4c43877c7d39c04d
parent2564e45b3bd3391ebca0be24866f01001480c0ff
fmv: c++: Add check_target_clone hook for filtering target_clone versions.

This patch introduces the TARGET_CHECK_TARGET_CLONE_VERSION hook
which is used to determine if a target_clones version string parses.

The hook has a flag to enable emitting diagnostics.

This is as specified in the Arm C Language Extension. The purpose of this
is to be able to ignore invalid versions to allow some portability of code
using target_clones attributes.

Currently this is only properly implemented for the Aarch64 backend.

For riscv which is the only other backend which uses target_version
semantics a partial implementation is present, where this hook is used
to check parsing, in which errors will be emitted on a failed parse
rather than warnings. A refactor of the riscv parsing logic would be
required to enable this functionality fully.

This fixes PR 118339 where parse failures could cause ICE in Aarch64.

gcc/ChangeLog:

PR target/118339
* target.def: Add check_target_clone_version hook.
* tree.cc (get_clone_attr_versions): Add filter argument.
(get_clone_versions): Add filter argument.
* tree.h (get_clone_attr_versions): Add filter.
(get_clone_versions): Add filter argument.
* config/aarch64/aarch64.cc (aarch64_check_target_clone_version):
New function
(TARGET_CHECK_TARGET_CLONE_VERSION): New define.
* config/riscv/riscv.cc (riscv_check_target_clone_version):
New function.
(TARGET_CHECK_TARGET_CLONE_VERSION): New define.
* doc/tm.texi: Regenerated.
* doc/tm.texi.in: Add documentation for new hook.
* hooks.h (hook_stringslice_locationtptr_true): New function.
* hooks.cc (hook_stringslice_locationtptr_true): New function.

gcc/c-family/ChangeLog:

* c-attribs.cc (handle_target_clones_attribute): Update to use new hook.
gcc/c-family/c-attribs.cc
gcc/config/aarch64/aarch64.cc
gcc/config/riscv/riscv.cc
gcc/doc/tm.texi
gcc/doc/tm.texi.in
gcc/hooks.cc
gcc/hooks.h
gcc/target.def
gcc/tree.cc
gcc/tree.h