public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Martin Liska <marxin@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc(refs/users/marxin/heads/target_clone-use-non-numbered-clones)] Use non-numbered clones for target_clones.
Date: Wed, 25 Aug 2021 11:20:56 +0000 (GMT)	[thread overview]
Message-ID: <20210825112056.AC7E8385C41F@sourceware.org> (raw)

https://gcc.gnu.org/g:c101d6616a2977ea46d4fb6be30dd01abd70f2d8

commit c101d6616a2977ea46d4fb6be30dd01abd70f2d8
Author: Martin Liska <mliska@suse.cz>
Date:   Fri Aug 20 16:35:18 2021 +0200

    Use non-numbered clones for target_clones.
    
    gcc/ChangeLog:
    
            * cgraph.h (create_version_clone_with_body): Add new parameter.
            * cgraphclones.c: Likewise.
            * multiple_target.c (create_dispatcher_calls): Do not use
            numbered suffixes.
            (create_target_clone): Likewise here.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/i386/mvc5.c: Scan assembly names.
            * gcc.target/i386/mvc7.c: Likewise.
    
    Co-Authored-By: Stefan Kneifel <stefan.kneifel@bluewin.ch>

Diff:
---
 gcc/cgraph.h                         |  5 ++++-
 gcc/cgraphclones.c                   | 11 ++++++++---
 gcc/multiple_target.c                | 16 +++++++---------
 gcc/testsuite/gcc.target/i386/mvc5.c |  4 ++++
 gcc/testsuite/gcc.target/i386/mvc7.c |  8 ++++++--
 5 files changed, 29 insertions(+), 15 deletions(-)

diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index d54a258c2ee..4cdb3738b4d 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -1006,13 +1006,16 @@ struct GTY((tag ("SYMTAB_FUNCTION"))) cgraph_node : public symtab_node
      that will promote value of the attribute DECL_FUNCTION_SPECIFIC_TARGET
      of the declaration.
 
+     If VERSION_DECL is set true, use clone_function_name_numbered for the
+     function clone.  Otherwise, use clone_function_name.
+
      Return the new version's cgraph node.  */
   cgraph_node *create_version_clone_with_body
     (vec<cgraph_edge *> redirect_callers,
      vec<ipa_replace_map *, va_gc> *tree_map,
      ipa_param_adjustments *param_adjustments,
      bitmap bbs_to_copy, basic_block new_entry_block, const char *clone_name,
-     tree target_attributes = NULL_TREE);
+     tree target_attributes = NULL_TREE, bool version_decl = true);
 
   /* Insert a new cgraph_function_version_info node into cgraph_fnver_htab
      corresponding to cgraph_node.  */
diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c
index b16e68194e1..ae91dccd31d 100644
--- a/gcc/cgraphclones.c
+++ b/gcc/cgraphclones.c
@@ -987,6 +987,9 @@ cgraph_node::create_version_clone (tree new_decl,
    that will promote value of the attribute DECL_FUNCTION_SPECIFIC_TARGET
    of the declaration.
 
+   If VERSION_DECL is set true, use clone_function_name_numbered for the
+   function clone.  Otherwise, use clone_function_name.
+
    Return the new version's cgraph node.  */
 
 cgraph_node *
@@ -995,7 +998,7 @@ cgraph_node::create_version_clone_with_body
    vec<ipa_replace_map *, va_gc> *tree_map,
    ipa_param_adjustments *param_adjustments,
    bitmap bbs_to_copy, basic_block new_entry_block, const char *suffix,
-   tree target_attributes)
+   tree target_attributes, bool version_decl)
 {
   tree old_decl = decl;
   cgraph_node *new_version_node = NULL;
@@ -1016,8 +1019,10 @@ cgraph_node::create_version_clone_with_body
     new_decl = copy_node (old_decl);
 
   /* Generate a new name for the new version. */
-  DECL_NAME (new_decl) = clone_function_name_numbered (old_decl, suffix);
-  SET_DECL_ASSEMBLER_NAME (new_decl, DECL_NAME (new_decl));
+  tree fnname = (version_decl ? clone_function_name_numbered (old_decl, suffix)
+		: clone_function_name (old_decl, suffix));
+  DECL_NAME (new_decl) = fnname;
+  SET_DECL_ASSEMBLER_NAME (new_decl, fnname);
   SET_DECL_RTL (new_decl, NULL);
 
   DECL_VIRTUAL_P (new_decl) = 0;
diff --git a/gcc/multiple_target.c b/gcc/multiple_target.c
index 6c0565880c5..28d5f95dca5 100644
--- a/gcc/multiple_target.c
+++ b/gcc/multiple_target.c
@@ -166,9 +166,8 @@ create_dispatcher_calls (struct cgraph_node *node)
 	}
     }
 
-  symtab->change_decl_assembler_name (node->decl,
-				      clone_function_name_numbered (
-					  node->decl, "default"));
+  tree fname = clone_function_name (node->decl, "default");
+  symtab->change_decl_assembler_name (node->decl, fname);
 
   if (node->definition)
     {
@@ -309,9 +308,9 @@ create_target_clone (cgraph_node *node, bool definition, char *name,
 
   if (definition)
     {
-      new_node = node->create_version_clone_with_body (vNULL, NULL,
-    						       NULL, NULL,
-						       NULL, name, attributes);
+      new_node
+	= node->create_version_clone_with_body (vNULL, NULL, NULL, NULL, NULL,
+						name, attributes, false);
       if (new_node == NULL)
 	return NULL;
       new_node->force_output = true;
@@ -322,9 +321,8 @@ create_target_clone (cgraph_node *node, bool definition, char *name,
       new_node = cgraph_node::get_create (new_decl);
       DECL_ATTRIBUTES (new_decl) = attributes;
       /* Generate a new name for the new version.  */
-      symtab->change_decl_assembler_name (new_node->decl,
-					  clone_function_name_numbered (
-					      node->decl, name));
+      tree fname = clone_function_name (node->decl, name);
+      symtab->change_decl_assembler_name (new_node->decl, fname);
     }
   return new_node;
 }
diff --git a/gcc/testsuite/gcc.target/i386/mvc5.c b/gcc/testsuite/gcc.target/i386/mvc5.c
index 677f79f3fd0..0e02bf661ae 100644
--- a/gcc/testsuite/gcc.target/i386/mvc5.c
+++ b/gcc/testsuite/gcc.target/i386/mvc5.c
@@ -3,6 +3,10 @@
 /* { dg-options "-fno-inline" } */
 /* { dg-final { scan-assembler "foo,foo.resolver" } } */
 
+/* Verify that foo clones are not numbered.  */
+/* { dg-final { scan-assembler "foo.default:" } } */
+/* { dg-final { scan-assembler "foo.avx:" } } */
+
 __attribute__((target_clones("default","avx","avx2")))
 int
 foo ()
diff --git a/gcc/testsuite/gcc.target/i386/mvc7.c b/gcc/testsuite/gcc.target/i386/mvc7.c
index a3697ba9b75..7fb9dded849 100644
--- a/gcc/testsuite/gcc.target/i386/mvc7.c
+++ b/gcc/testsuite/gcc.target/i386/mvc7.c
@@ -1,7 +1,11 @@
 /* { dg-do compile } */
 /* { dg-require-ifunc "" } */
-/* { dg-final { scan-assembler "foo.resolver" } } */
-/* { dg-final { scan-assembler "avx" } } */
+
+/* Verify that foo clones are not numbered.  */
+/* { dg-final { scan-assembler "foo.resolver," } } */
+/* { dg-final { scan-assembler "foo.default," } } */
+/* { dg-final { scan-assembler "foo.avx," } } */
+
 /* { dg-final { scan-assembler "slm" } } */
 /* { dg-final { scan-assembler "foo,foo.resolver" } } */


             reply	other threads:[~2021-08-25 11:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-25 11:20 Martin Liska [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-08-25 12:08 Martin Liska
2021-08-20 14:37 Martin Liska

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=20210825112056.AC7E8385C41F@sourceware.org \
    --to=marxin@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /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).