]> git.ipfire.org Git - thirdparty/gcc.git/commit
i386: Fix up handling of target attribute [PR101180]
authorJakub Jelinek <jakub@redhat.com>
Sun, 21 Nov 2021 20:06:23 +0000 (21:06 +0100)
committerJakub Jelinek <jakub@redhat.com>
Sun, 21 Nov 2021 20:06:23 +0000 (21:06 +0100)
commit364539710f828851b9fac51c39033cd09aa620de
treefbfdd76f246a754c83ac16dc87fc7cca0538a7aa
parent8fef6f720a5a0a056abfa986ba870bb406ab4716
i386: Fix up handling of target attribute [PR101180]

As shown in the testcase below, if a function has multiple target attributes
(rather than a single one with one or more arguments) or if a function
gets one target attribute on one declaration and another one on another
declaration, on x86 their effect is not combined into
DECL_FUNCTION_SPECIFIC_TARGET, but instead only the last processed target
attribute wins.  aarch64 handles this right, the following patch follows
what it does, i.e. only start with target_option_default_node if
DECL_FUNCTION_SPECIFIC_TARGET is previously NULL (i.e. the first target
attribute being processed on a function) and otherwise start from the
previous DECL_FUNCTION_SPECIFIC_TARGET.

2021-11-21  Jakub Jelinek  <jakub@redhat.com>

PR c++/101180
* config/i386/i386-options.c (ix86_valid_target_attribute_p): If
fndecl already has DECL_FUNCTION_SPECIFIC_TARGET, use that as base
instead of target_option_default_node.

* gcc.target/i386/pr101180.c: New test.
gcc/config/i386/i386-options.c
gcc/testsuite/gcc.target/i386/pr101180.c [new file with mode: 0644]