This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Avoid T.NNN names for function clones


Hi!

I know this has been discussed already back in 2005 when IPCP has been
added, but based on
https://bugzilla.redhat.com/show_bug.cgi?id=492003
and a quick discussion with Honza on IRC, I'm proposing to change
the name of the clones anyway.  We already have a precedent, OpenMP outlined
region function names are constructed similarly, see
create_omp_child_function_name.

Ok for 4.5?

2009-03-25  Jakub Jelinek  <jakub@redhat.com>

	* tree-inline.c: Include gt-tree-inline.h.
	(clone_fn_id_num): New variable.
	(clone_function_name): New function.
	(tree_function_versioning): Use it.
	* Makefile.in (GTFILES): Add tree-inline.c.

--- gcc/tree-inline.c.jj	2009-03-09 11:38:55.000000000 +0100
+++ gcc/tree-inline.c	2009-03-25 12:36:54.000000000 +0100
@@ -4268,6 +4268,29 @@ tree_versionable_function_p (tree fndecl
   return true;
 }
 
+/* Create a new name for omp child function.  Returns an identifier.  */
+
+static GTY(()) unsigned int clone_fn_id_num;
+
+static tree
+clone_function_name (tree decl)
+{
+  tree name = DECL_ASSEMBLER_NAME (decl);
+  size_t len = IDENTIFIER_LENGTH (name);
+  char *tmp_name, *prefix;
+
+  prefix = XALLOCAVEC (char, len + strlen ("_clone") + 1);
+  memcpy (prefix, IDENTIFIER_POINTER (name), len);
+  strcpy (prefix + len, "_clone");
+#ifndef NO_DOT_IN_LABEL
+  prefix[len] = '.';
+#elif !defined NO_DOLLAR_IN_LABEL
+  prefix[len] = '$';
+#endif
+  ASM_FORMAT_PRIVATE_NAME (tmp_name, prefix, clone_fn_id_num++);
+  return get_identifier (tmp_name);
+}
+
 /* Create a copy of a function's tree.
    OLD_DECL and NEW_DECL are FUNCTION_DECL tree nodes
    of the original function and the new copied function
@@ -4315,7 +4338,7 @@ tree_function_versioning (tree old_decl,
   /* Generate a new name for the new version. */
   if (!update_clones)
     {
-      DECL_NAME (new_decl) =  create_tmp_var_name (NULL);
+      DECL_NAME (new_decl) = clone_function_name (old_decl);
       SET_DECL_ASSEMBLER_NAME (new_decl, DECL_NAME (new_decl));
       SET_DECL_RTL (new_decl, NULL_RTX);
       id.statements_to_fold = pointer_set_create ();
@@ -4520,3 +4543,5 @@ tree_can_inline_p (tree caller, tree cal
   /* Allow the backend to decide if inlining is ok.  */
   return targetm.target_option.can_inline_p (caller, callee);
 }
+
+#include "gt-tree-inline.h"
--- gcc/Makefile.in.jj	2009-03-23 13:35:06.000000000 +0100
+++ gcc/Makefile.in	2009-03-25 12:37:34.000000000 +0100
@@ -3308,7 +3308,7 @@ GTFILES = $(CPP_ID_DATA_H) $(srcdir)/inp
   $(srcdir)/tree-ssa-propagate.c \
   $(srcdir)/tree-phinodes.c \
   $(srcdir)/ipa-reference.c $(srcdir)/tree-ssa-structalias.h \
-  $(srcdir)/tree-ssa-structalias.c \
+  $(srcdir)/tree-ssa-structalias.c $(srcdir)/tree-inline.c \
   @all_gtfiles@
 
 # Compute the list of GT header files from the corresponding C sources,

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]