From: Jeff Law <law@redhat.com>
To: Evgeny Stupachenko <evstupac@gmail.com>
Cc: Bernd Schmidt <bschmidt@redhat.com>,
Bernd Schmidt <bernds_cb1@t-online.de>,
GCC Patches <gcc-patches@gcc.gnu.org>,
Jan Hubicka <hubicka@ucw.cz>
Subject: Re: [PATCH] New attribute to create target clones
Date: Fri, 09 Oct 2015 04:05:00 -0000 [thread overview]
Message-ID: <56173D1F.9060500@redhat.com> (raw)
In-Reply-To: <CAOvf_xzJHV0SKS813XNNMUwztBLWpS_=7eaEWyAGjT1GVYCn-Q@mail.gmail.com>
On 10/08/2015 02:01 PM, Evgeny Stupachenko wrote:
> On Thu, Oct 8, 2015 at 10:00 PM, Jeff Law <law@redhat.com> wrote:
>> On 09/24/2015 04:28 PM, Evgeny Stupachenko wrote:
>>>
>>> I've fixed ICE and review issues.
>>> x86 make check and bootstrap passed.
>>>
>>> Thanks,
>>> Evgeny
>>>
>>> ChangeLog
>>>
>>> 2015-09-25 Evgeny Stupachenko<evstupac@gmail.com>
>>>
>>> gcc/
>>> * Makefile.in (OBJS): Add multiple_target.o.
>>> * multiple_target.c (make_attribute): New.
>>> (create_dispatcher_calls): Ditto.
>>> (expand_target_clones): Ditto.
>>> (ipa_target_clone): Ditto.
>>> * passes.def (pass_target_clone): New ipa pass.
>>> * tree-pass.h (make_pass_target_clone): Ditto.
>>>
>>> gcc/c-family
>>> * c-common.c (handle_target_clones_attribute): New.
>>> * (c_common_attribute_table): Add handle_target_clones_attribute.
>>> * (handle_always_inline_attribute): Add check on target_clones
>>> attribute.
>>> * (handle_target_attribute): Ditto.
>>>
>>> gcc/testsuite
>>> * gcc.dg/mvc1.c: New test for multiple targets cloning.
>>> * gcc.dg/mvc2.c: Ditto.
>>> * gcc.dg/mvc3.c: Ditto.
>>> * gcc.dg/mvc4.c: Ditto.
>>> * gcc.dg/mvc5.c: Ditto.
>>> * gcc.dg/mvc6.c: Ditto.
>>> * gcc.dg/mvc7.c: Ditto.
>>> * g++.dg/ext/mvc1.C: Ditto.
>>> * g++.dg/ext/mvc2.C: Ditto.
>>> * g++.dg/ext/mvc3.C: Ditto.
>>>
>>> gcc/doc
>>> * doc/extend.texi (target_clones): New attribute description.
>>>
>>>
>>
>>>
>>> target_clones.patch
>>
>> Sorry this has taken so long to come back to... As I mentioned a couple
>> months ago, I'd hoped Jan would chime in on the IPA/symtab requirements.
>> But that didn't happen.
>>
>>
>> SO I went back and reviewed the discussion between Jan, Ilya & myself WRT
>> some of the rules around aliases, clones, etc. I think the key question for
>> this patch is whether or not the clones have the same assembler name or not.
>> From looking at expand_target_clones, I'm confident the answer is the clones
>> have different assembler names. In fact, the assembler names are munged
>> with the options used for that specific clone of the original function.
>>
>>
>>>
>>> +/* Makes a function attribute of the form NAME(ARG_NAME) and chains
>>> + it to CHAIN. */
>>> +
>>> +static tree
>>> +make_attribute (const char *name, const char *arg_name, tree chain)
>>> +{
>>> + tree attr_name;
>>> + tree attr_arg_name;
>>> + tree attr_args;
>>> + tree attr;
>>> +
>>> + attr_name = get_identifier (name);
>>> + attr_arg_name = build_string (strlen (arg_name), arg_name);
>>> + attr_args = tree_cons (NULL_TREE, attr_arg_name, NULL_TREE);
>>> + attr = tree_cons (attr_name, attr_args, chain);
>>> + return attr;
>>> +}
>>
>> This seems generic enough that I'd prefer it in attribs.c. I was rather
>> surprised when I looked and didn't find an existing routine to do this.
>>
>>
>>> +
>>> +/* If the call in NODE has multiple target attribute with multiple
>>> fields,
>>> + replace it with dispatcher call and create dispatcher (once). */
>>> +
>>> +static void
>>> +create_dispatcher_calls (struct cgraph_node *node)
>>> +{
>>> + cgraph_edge *e;
>>> + cgraph_edge *e_next;
>>> + for (e = node->callers; e ;e = (e == NULL) ? e_next : e->next_caller)
>>
>> That's a rather strange way to write the loop increment. If I follow the
>> loop logic correctly, it seems that we always end up using e->next_caller,
>> it's just obscured.
>>
>> For the test if we're calling a versioned function, we just "continue". e
>> will be non-null and thus we use e->next_caller to set e for the next
>> iteration.
>>
>> If the test for calling a versioned function falls, we set e_next to
>> e->next_caller, then later set e to NULL. That results in using e_next to
>> set e for the next iteration. But e_next was initialized to e->next_caller.
>>
>> So why not just write the loop increment as e = e->next-caller?
>
> Because of this:
> e->redirect_callee (inode);
> It modifies next_caller field.
> The other way is to remember all what we want to redirect and create
> one more loop through the modifications to apply them.
Seems like a comment would be wise.
>>>
>> I'm slightly concerned with using the pretty printer to build up the new
>> name. Is there precedent for this anywhere else in GCC?
> I don't remember where it exactly came from. However it's not a big
> deal to simplify this to std functions.
Thanks. Not sure why, but I'd appreciate that change.
>>
>> When creating the munged name, don't you also have to make sure that other
>> symbols that aren't supported for names don't sneak through? I see that you
>> replace = and -, but you'd need to replace any symbol that could possibly be
>> used in an option, but which isn't allowed in a function name at the
>> assembler level. I'd be worried about anything that might possibly be seen
>> as an operator by the assembler, '.', and possibly others.
> This restriction comes from "targetm.target_option.valid_attribute_p"
> and it is the same for current implementation of function
> multiversioning.
> It exits with error: "attribute(target("...")) is unknown".
> It looks reasonable to put the check before symtab changes.
Right, but there's nothing inherently that says that a option couldn't
have other operators such as '+' in the option string. So I'm concerned
that if this code were used on a target that had such an option that
we'd end up generating invalid assembly.
I think all you have to do is map a fuller set of invalid characters to
a valid character.
Jeff
next prev parent reply other threads:[~2015-10-09 4:05 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-27 11:35 Evgeny Stupachenko
2015-09-08 11:47 ` Evgeny Stupachenko
2015-09-16 11:42 ` Evgeny Stupachenko
2015-09-21 13:43 ` Bernd Schmidt
2015-09-22 20:24 ` Jeff Law
2015-09-22 21:09 ` Bernd Schmidt
2015-09-22 23:52 ` Evgeny Stupachenko
2015-09-25 0:02 ` Evgeny Stupachenko
2015-10-02 13:18 ` Evgeny Stupachenko
2015-10-08 19:00 ` Jeff Law
2015-10-08 19:23 ` Jan Hubicka
2015-10-08 19:53 ` Jeff Law
2015-10-08 21:36 ` Jan Hubicka
2015-10-09 17:45 ` Jeff Law
2015-10-09 18:27 ` Jan Hubicka
2015-10-09 19:57 ` Evgeny Stupachenko
2015-10-09 20:04 ` Jan Hubicka
2015-10-09 21:44 ` Evgeny Stupachenko
2015-10-12 23:35 ` Evgeny Stupachenko
2015-10-14 21:32 ` Evgeny Stupachenko
2015-10-22 18:07 ` Evgeny Stupachenko
2015-10-26 15:59 ` Jeff Law
2015-10-29 13:42 ` Evgeny Stupachenko
2015-10-29 17:07 ` Jan Hubicka
2015-10-29 18:15 ` Evgeny Stupachenko
2015-10-30 3:55 ` Jan Hubicka
2015-10-30 5:30 ` Jeff Law
2015-10-30 12:30 ` Evgeny Stupachenko
2015-10-08 20:01 ` Evgeny Stupachenko
2015-10-09 4:05 ` Jeff Law [this message]
2015-10-08 16:39 ` Jeff Law
2015-10-31 10:52 Dominique d'Humières
2015-11-02 14:50 ` Evgeny Stupachenko
2015-11-02 15:22 ` Dominique d'Humières
2015-11-02 17:02 ` Jeff Law
2015-11-03 11:45 ` Evgeny Stupachenko
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=56173D1F.9060500@redhat.com \
--to=law@redhat.com \
--cc=bernds_cb1@t-online.de \
--cc=bschmidt@redhat.com \
--cc=evstupac@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=hubicka@ucw.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).