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]

[gomp] Include name of function containing #pragma omp in omp child function name


Hi!

This patch replaces __omp_fn.NN function names with
foo.omp_parallel.NN where foo is the name of the function
that contains the #pragma omp.  This way it is obvious
which function does the artificial function belong to.

Unfortunately, for nested parallels this means stacking
up the names (so foo.omp_parallel.NN.omp_parallel.MM etc.),
not sure how to find out the name of the original function
though (maybe through cgraph edges or something).

2005-10-29  Jakub Jelinek  <jakub@redhat.com>

	* omp-low.c (tmp_ompfn_id_num): New variable.
	(create_omp_child_function_name): New function.
	(create_omp_child_function): Use it.

--- gcc/omp-low.c.jj	2005-10-28 23:38:44.000000000 +0200
+++ gcc/omp-low.c	2005-10-29 10:31:17.000000000 +0200
@@ -627,6 +627,29 @@ scan_sharing_clauses (tree clauses, omp_
       }
 }
 
+/* Create a new name for omp child function.  Returns an identifier.  */
+
+static GTY(()) unsigned int tmp_ompfn_id_num;
+
+static tree
+create_omp_child_function_name (void)
+{
+  tree name = DECL_ASSEMBLER_NAME (current_function_decl);
+  size_t len = IDENTIFIER_LENGTH (name);
+  char *tmp_name, *prefix;
+
+  prefix = alloca (len + sizeof ("_omp_parallel"));
+  memcpy (prefix, IDENTIFIER_POINTER (name), len);
+  strcpy (prefix + len, "_omp_parallel");
+#ifndef NO_DOT_IN_LABEL
+  prefix[len] = '.';
+#elif !defined NO_DOLLAR_IN_LABEL
+  prefix[len] = '$';
+#endif
+  ASM_FORMAT_PRIVATE_NAME (tmp_name, prefix, tmp_ompfn_id_num++);
+  return get_identifier (tmp_name);
+}
+
 /* Build a decl for the omp child function.  It'll not contain a body
    yet, just the bare decl.  */
 
@@ -637,7 +660,7 @@ create_omp_child_function (omp_context *
 
   ptype = build_pointer_type (ctx->record_type);
 
-  name = create_tmp_var_name ("__omp_fn");
+  name = create_omp_child_function_name ();
   type = build_function_type_list (void_type_node, ptype, NULL_TREE);
 
   decl = build_decl (FUNCTION_DECL, name, type);

	Jakub


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