public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jan Hubicka <hubicka@ucw.cz>
To: Jeff Law <law@redhat.com>
Cc: Evgeny Stupachenko <evstupac@gmail.com>,
	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: Thu, 08 Oct 2015 19:23:00 -0000	[thread overview]
Message-ID: <20151008192349.GB90964@kam.mff.cuni.cz> (raw)
In-Reply-To: <5616BD37.2000307@redhat.com>

> 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.

Sorry for that.  I had bit too many real life things this summer
and I am still trying to catch up.
> 
> 
> 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

Ilya's code seems different from what this patch does. Ilya simply needs
multiple declarations for one physical assembler name (this is not an alias).
This is not currently supported by symtab (support for that was removed long
time ago as part of the one decl project) and I have some perliminary patches
to push out, but since they add basic sanity checking that the different
declarations of the same thing looks compatible I get too many positives I need
to walk through.  Those seems real bugs in glibc (which uses duplicated decls
for checking) and the pointer bounds code.

> expand_target_clones, I'm confident the answer is the clones have
> different assembler names.  In fact, the assembler names are munged

Yes, here you have different names for different variants of the function
body. Basically this pass takes ctarget attribute and creates bunch of verisons
of the functions and assigns them the proper target attributes, right?

One thing I am confused about is why this does not happen early?
What happens to inlines of functions with specific taret requirements? I.e.
if I compile with AVX enabled have function body with AVX code but then, at
late compilation, force a clone with -mno-avx?

I would expect cloning to happen early, perhaps even before early optimizations...
Switching random target flags mid optimization queue seems dangerous.

As for the patch itself:
+      if (node->definition)
+	{
+	  if (!node->has_gimple_body_p ())
+	    return false;
+	  node->get_body ();
+
+	  /* Replacing initial function with clone only for 1st ctarget.  */
+	  new_node = node->create_version_clone_with_body (vNULL, NULL,
+							   NULL, false,
+							   NULL, NULL,
+							   "target_clone");
+	  new_node->externally_visible = node->externally_visible;
+	  new_node->address_taken = node->address_taken;
+	  new_node->thunk = node->thunk;
+	  new_node->alias = node->alias;
+	  new_node->weakref = node->weakref;
+	  new_node->cpp_implicit_alias = node->cpp_implicit_alias;
+	  new_node->local.local = node->local.local;
+	  TREE_PUBLIC (new_node->decl) = TREE_PUBLIC (node->decl);
+	}
Since you test it has gimple body, then you don't need to worry about
alias/thunk/weakrefs/implicit_alias properties. Those will be never set.
How does the dispatcher look like?  Can the function be considered local
in a sense that one can change calling conventions of one clone but not another?

On the other hand, node->create_version_clone_with_body creates a function
that is local, if we want to create globally visible clones, I think we should
add a parameter there and avoid the localization followed by unlocalization.
(I know we already have too many parameters here, perhaps we could add a flags
parameter that will also handle the existing skip_return flag.)
For exmaple, I think you want to have all functions with same WEAK attributes
or in the same COMDAT group.

Also when you are copying a function, you probably want to copy the associated
thunks and version them, too?

+      id = get_identifier (new_asm_name);
+      symtab->change_decl_assembler_name (new_node->decl, id);

here I think you can just pass new_asm_name as clone_name. I.e. replace
the current use of "target_clone" string.

+      targetm.target_option.valid_attribute_p (new_node->decl, NULL,
+					       TREE_VALUE (attributes), 0);

looks like return value should not be ignored. If attribute is not valid,
we need to error and do something sane.

Honza

  reply	other threads:[~2015-10-08 19:23 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 [this message]
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
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=20151008192349.GB90964@kam.mff.cuni.cz \
    --to=hubicka@ucw.cz \
    --cc=bernds_cb1@t-online.de \
    --cc=bschmidt@redhat.com \
    --cc=evstupac@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=law@redhat.com \
    /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).