diff mbox series

[v3] Avoid unnecessarily numbered clone symbols

Message ID 9a7e062e-016e-451d-7c3d-5a4abaad3b43@oracle.com
State New
Headers show
Series [v3] Avoid unnecessarily numbered clone symbols | expand

Commit Message

Michael Ploujnikov Oct. 23, 2018, 3:42 p.m. UTC
On 2018-10-21 09:14 PM, Michael Ploujnikov wrote:
> Continuing from https://gcc.gnu.org/ml/gcc-patches/2018-10/msg01258.html
> 
> Fixed up the code after the change to concat suggested by Bernhard
> Reutner.
> 
> Outstanding question still remains:
> 
> To write an exact replacement for numbered_clone_function_name (apart
> from the numbering) I also need to copy the double underscore
> prefixing behaviour done by ASM_PN_FORMAT (right?)  which is used by
> ASM_FORMAT_PRIVATE_NAME. Does that mean that I can't use my
> suffixed_function_name to replace the very similar looking code in
> cgraph_node::create_virtual_clone? Or is it just missing the double
> underscore prefix by mistake?

I found https://gcc.gnu.org/ml/gcc-patches/2013-08/msg01028.html which
answered my question so now I'm just simplifying
cgraph_node::create_virtual_clone with ACONCAT.


- Michael
diff mbox series

Patch

From 3efc4e1d96a382ed00f7e529d1f5a5a844c7fa69 Mon Sep 17 00:00:00 2001
From: Michael Ploujnikov <michael.ploujnikov@oracle.com>
Date: Mon, 13 Aug 2018 13:59:46 -0400
Subject: [PATCH 4/4] Use ACONCAT in cgraph_node::create_virtual_clone.

gcc:
2018-10-23  Michael Ploujnikov  <michael.ploujnikov@oracle.com>

       * cgraphclones.c (cgraph_node::create_virtual_clone): Use
         ACONCAT for the DECL_NAME.
---
 gcc/cgraphclones.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git gcc/cgraphclones.c gcc/cgraphclones.c
index bb8be79..c98b0ed 100644
--- gcc/cgraphclones.c
+++ gcc/cgraphclones.c
@@ -585,9 +585,8 @@  cgraph_node::create_virtual_clone (vec<cgraph_edge *> redirect_callers,
   tree old_decl = decl;
   cgraph_node *new_node = NULL;
   tree new_decl;
-  size_t len, i;
+  size_t i;
   ipa_replace_map *map;
-  char *name;
 
   gcc_checking_assert (local.versionable);
   gcc_assert (local.can_change_signature || !args_to_skip);
@@ -609,11 +608,8 @@  cgraph_node::create_virtual_clone (vec<cgraph_edge *> redirect_callers,
      sometimes storing only clone decl instead of original.  */
 
   /* Generate a new name for the new version. */
-  len = IDENTIFIER_LENGTH (DECL_NAME (old_decl));
-  name = XALLOCAVEC (char, len + strlen (suffix) + 2);
-  memcpy (name, IDENTIFIER_POINTER (DECL_NAME (old_decl)), len);
-  strcpy (name + len + 1, suffix);
-  name[len] = '.';
+  char *name = ACONCAT ((IDENTIFIER_POINTER (DECL_NAME (old_decl)),
+			 ".", suffix, (char *)0));
   DECL_NAME (new_decl) = get_identifier (name);
   SET_DECL_ASSEMBLER_NAME (new_decl,
 			   numbered_clone_function_name (old_decl, suffix));
-- 
2.7.4