On 10/31/24 17:51, Kito Cheng wrote:
Could you add a test case for what you try to handle?
After carefully reviewing the code, I think this can be dropped in the next revision.
The intuition of this patch is to handle both target and target_versions specified in the attributes. But after checking all the callers for target_option,valid_attribute_p, I see that this case is already being handled, so it dropped.
On Thu, Oct 24, 2024 at 3:15 PM Yangyu Chen <[email protected]> wrote:To ensure that the target_version attribute is applied after target attributes. gcc/ChangeLog: * config/riscv/riscv-target-attr.cc (riscv_option_valid_attribute_p): Reapply target_version attribute after target attribute --- gcc/config/riscv/riscv-target-attr.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gcc/config/riscv/riscv-target-attr.cc b/gcc/config/riscv/riscv-target-attr.cc index 3042562c66b..7dcff0211ea 100644 --- a/gcc/config/riscv/riscv-target-attr.cc +++ b/gcc/config/riscv/riscv-target-attr.cc @@ -30,6 +30,8 @@ along with GCC; see the file COPYING3. If not see #include "diagnostic.h" #include "opts.h" #include "riscv-subset.h" +#include "stringpool.h" +#include "attribs.h" namespace { class riscv_target_attr_parser @@ -450,6 +452,17 @@ riscv_option_valid_attribute_p (tree fndecl, tree, tree args, int) ret = riscv_process_target_attr (args, loc); if (ret) { + tree version_attr = lookup_attribute ("target_version", + DECL_ATTRIBUTES (fndecl)); + if (version_attr != NULL_TREE) + { + // Reapply any target_version attribute after target attribute. + // This should be equivalent to applying the target_version once + // after processing all target attributes. + tree version_args = TREE_VALUE (version_attr); + riscv_process_target_version_attr (version_args, + DECL_SOURCE_LOCATION (fndecl)); + } riscv_override_options_internal (&global_options); new_target = build_target_option_node (&global_options, &global_options_set); -- 2.45.2
