From: Jason Merrill <jason@redhat.com>
To: "Martin Liška" <mliska@suse.cz>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] C++: target attribute - local decl
Date: Thu, 4 Mar 2021 10:45:36 -0500 [thread overview]
Message-ID: <ba7a384e-7621-cc73-1f95-1f85a1db088c@redhat.com> (raw)
In-Reply-To: <d4e80220-7a2d-49f9-c6ea-e12933edc962@suse.cz>
On 3/4/21 10:39 AM, Martin Liška wrote:
> On 3/4/21 4:03 PM, Jason Merrill wrote:
>> Do you really need to register all these pairs? I was expecting that
>> you'd just look through DECL_LOCAL_DECL_ALIAS and then register the
>> pair you end up with. Local decls shouldn't need a cgraph node.
>
> Well, doing that:
>
>
> commit 662c486edafa467ec41091e84857d594eaf280a2
> Author: Martin Liska <mliska@suse.cz>
> Date: Wed Mar 3 09:38:55 2021 +0100
>
> c++: support target attr for DECL_LOCAL_DECL_P fns
> gcc/cp/ChangeLog:
> PR c++/99108
> * call.c (get_function_version_dispatcher): Understand
> DECL_LOCAL_DECL_ALIAS.
> * decl.c (record_function_versions): New.
> (maybe_version_functions): Call record_function_versions
> for both declarations and DECL_LOCAL_DECL_ALIAS aliases.
> gcc/testsuite/ChangeLog:
> PR c++/99108
> * g++.target/i386/pr99108.C: New test.
>
> diff --git a/gcc/cp/call.c b/gcc/cp/call.c
> index 123f06b1f2b..117f1755191 100644
> --- a/gcc/cp/call.c
> +++ b/gcc/cp/call.c
> @@ -8467,6 +8467,10 @@ get_function_version_dispatcher (tree fn)
> {
> tree dispatcher_decl = NULL;
>
> + if (DECL_LOCAL_DECL_P (fn)
> + && DECL_LOCAL_DECL_ALIAS (fn) != NULL_TREE)
> + fn = DECL_LOCAL_DECL_ALIAS (fn);
> +
> gcc_assert (TREE_CODE (fn) == FUNCTION_DECL
> && DECL_FUNCTION_VERSIONED (fn));
>
> diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
> index 1742e286d9f..a092539bfa0 100644
> --- a/gcc/cp/decl.c
> +++ b/gcc/cp/decl.c
> @@ -1115,6 +1115,14 @@ decls_match (tree newdecl, tree olddecl, bool
> record_versions /* = true */)
> bool
> maybe_version_functions (tree newdecl, tree olddecl, bool record)
> {
> + if (DECL_LOCAL_DECL_P (olddecl)
> + && DECL_LOCAL_DECL_ALIAS (olddecl) != NULL_TREE)
> + olddecl = DECL_LOCAL_DECL_ALIAS (olddecl);
> +
> + if (DECL_LOCAL_DECL_P (newdecl)
> + && DECL_LOCAL_DECL_ALIAS (newdecl) != NULL_TREE)
> + newdecl = DECL_LOCAL_DECL_ALIAS (newdecl);
> +
> if (!targetm.target_option.function_versions (newdecl, olddecl))
> return false;
>
> The compilation then fails:
> /home/marxin/Programming/gcc/gcc/testsuite/g++.target/i386/pr99108.C: In
> member function ‘void A::foo(auto:2)’:
> /home/marxin/Programming/gcc/gcc/testsuite/g++.target/i386/pr99108.C:12:13:
> error: call of overloaded ‘f()’ is ambiguous
> 12 | int b = f();
> | ^
> /home/marxin/Programming/gcc/gcc/testsuite/g++.target/i386/pr99108.C:10:7:
> note: candidate: ‘int f()’
> 10 | int f(void) __attribute__((target("default")));
> | ^
> /home/marxin/Programming/gcc/gcc/testsuite/g++.target/i386/pr99108.C:11:7:
> note: candidate: ‘int f()’
> 11 | int f(void) __attribute__((target("arch=atom")));
> | ^
>
> likely because DECL_FUNCTION_VERSIONED is missing for the local decls.
Sure, I guess you do need to set that flag for the local decls, but that
should be all.
Jason
next prev parent reply other threads:[~2021-03-04 15:45 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-18 12:15 Martin Liška
2021-02-22 22:53 ` Jason Merrill
2021-03-01 12:43 ` Martin Liška
2021-03-01 16:36 ` Jason Merrill
2021-03-01 16:59 ` Martin Liška
2021-03-01 19:58 ` Jason Merrill
2021-03-02 10:34 ` Martin Liška
2021-03-02 17:57 ` Jason Merrill
2021-03-04 8:19 ` Martin Liška
2021-03-04 15:03 ` Jason Merrill
2021-03-04 15:39 ` Martin Liška
2021-03-04 15:45 ` Jason Merrill [this message]
2021-03-04 15:52 ` Martin Liška
2021-03-04 20:54 ` Jason Merrill
2021-03-08 9:33 ` Martin Liška
2021-03-16 20:12 ` Jason Merrill
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ba7a384e-7621-cc73-1f95-1f85a1db088c@redhat.com \
--to=jason@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=mliska@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).