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]

[lto][patch] Simplify the lto-symtab api a bit


This patch updates the lto_symtab_merge_* and global_vector_fixup signature to
make it a bit less confusing. We always use the pointer to the first decl we see
and always store it on LTO_IDENTIFIER_DECL. Just use that as the canonical
location.

This is also a necessary step in moving the fixup to some point after reading
all the objects.

gcc/
2008-10-01 Rafael Espindola  <espindola@google.com>

	* lto-function-in.c (global_vector_fixup): Removed node argument.
	Use lto_symtab_prevailing_decl. Update all uses.
	* lto-tree-in.h (lto_symtab_merge_var, lto_symtab_merge_fn): Return
	void. Update all uses.
	(lto_symtab_prevailing_decl): New.

gcc/lto
2008-10-01 Rafael Espindola  <espindola@google.com>

	* lto-symtab.c (lto_symtab_merge_var, lto_symtab_merge_fn,
	lto_symtab_merge_decl): Return void.
	(lto_symtab_prevailing_decl): New.

Cheers,
-- 
Rafael Avila de Espindola

Google | Gordon House | Barrow Street | Dublin 4 | Ireland
Registered in Dublin, Ireland | Registration Number: 368047
diff --git a/gcc/lto-function-in.c b/gcc/lto-function-in.c
index c51bbb1..a431e7b 100644
--- a/gcc/lto-function-in.c
+++ b/gcc/lto-function-in.c
@@ -2645,13 +2645,16 @@ global_vector_enter (struct data_in *data_in, tree node)
 /* Replace the entry at position INDEX in the globals index vector
    obtained from DATA_IN with NODE. */
 
-static void
-global_vector_fixup (struct data_in *data_in, unsigned index, tree node)
+static tree
+global_vector_fixup (struct data_in *data_in, unsigned index)
 {
+  tree node;
   tree old_node;
-
   gcc_assert (index < VEC_length (tree, data_in->globals_index));
   old_node = VEC_index (tree, data_in->globals_index, index);
+  gcc_assert (old_node);
+
+  node = lto_symtab_canonical_decl (old_node);
   
 #ifdef LTO_GLOBAL_VECTOR_TRACE
   fprintf (stderr, "FIXUP %u: %p [", index, (void *) old_node);
@@ -2674,6 +2677,8 @@ global_vector_fixup (struct data_in *data_in, unsigned index, tree node)
 #ifdef LTO_GLOBAL_VECTOR_TRACE
   fprintf (stderr, "\n");
 #endif
+
+  return node;
 }
 
 static tree
@@ -2880,14 +2885,10 @@ input_function_decl (struct lto_input_block *ib, struct data_in *data_in)
     {
       enum ld_plugin_symbol_resolution resolution =
 	get_resolution (data_in, index);
-      tree merged = lto_symtab_merge_fn (decl, resolution);
-      /* If merge fails, use the original declaraction.  */
-      if (merged != error_mark_node)
-	decl = merged;
+      lto_symtab_merge_fn (decl, resolution);
+      decl = global_vector_fixup (data_in, index);
     }
 
-  global_vector_fixup (data_in, index, decl);
-
   LTO_DEBUG_TOKEN ("end_function_decl");
   return decl;
 }
@@ -2988,14 +2989,10 @@ input_var_decl (struct lto_input_block *ib, struct data_in *data_in)
 	{
 	  enum ld_plugin_symbol_resolution resolution =
 	    get_resolution (data_in, index);
-	  tree merged = lto_symtab_merge_var (decl, resolution);
-	  /* If merge fails, use the original declaraction.  */
-	  if (merged != error_mark_node)
-	    decl = merged;
+	  lto_symtab_merge_var (decl, resolution);
+	  decl = global_vector_fixup (data_in, index);
 	}
     }
-
-  global_vector_fixup (data_in, index, decl);
   
   /* Read initial value expression last, after the global_vector_fixup.  */
   decl->decl_common.initial = input_tree (ib, data_in);
diff --git a/gcc/lto-tree-in.h b/gcc/lto-tree-in.h
index f476928..76c4e0f 100644
--- a/gcc/lto-tree-in.h
+++ b/gcc/lto-tree-in.h
@@ -110,12 +110,13 @@ lto_input_constructors_and_inits (struct lto_file_decl_data* file_data,
    between the declarations), an error message is issued, and
    error_mark_node is returned.  If there is no previous declaration,
    NEW_VAR is returned.  */
-extern tree lto_symtab_merge_var (tree new_var,
+extern void lto_symtab_merge_var (tree new_var,
                                   enum ld_plugin_symbol_resolution resolution);
 
 /* Like lto_symtab_merge_var, but for functions.  */
-extern tree lto_symtab_merge_fn (tree new_fn,
+extern void lto_symtab_merge_fn (tree new_fn,
                                  enum ld_plugin_symbol_resolution resolution);
 
+extern tree lto_symtab_canonical_decl (tree decl);
 
 #endif  /* GCC_LTO_TREE_IN_H  */
diff --git a/gcc/lto/lto-symtab.c b/gcc/lto/lto-symtab.c
index 127c4ba..b8b8223 100644
--- a/gcc/lto/lto-symtab.c
+++ b/gcc/lto/lto-symtab.c
@@ -488,7 +488,7 @@ lto_symtab_overwrite_decl (tree dest, tree src)
    NEW_DECL is the newly found decl. RESOLUTION is the decl's resolution
    provided by the linker. */
 
-static tree
+static void
 lto_symtab_merge_decl (tree new_decl,
 		       enum ld_plugin_symbol_resolution resolution)
 {
@@ -531,12 +531,12 @@ lto_symtab_merge_decl (tree new_decl,
     {
       LTO_IDENTIFIER_DECL (name) = new_decl;
       VEC_safe_push (tree, gc, lto_global_var_decls, new_decl);
-      return new_decl;
+      return;
     }
 
   /* The linker may ask us to combine two incompatible symbols. */
   if (!lto_symtab_compatible (old_decl, new_decl))
-    return error_mark_node;
+    return;
 
   old_resolution = LTO_DECL_RESOLUTION (old_decl);
   gcc_assert (resolution != LDPR_UNKNOWN
@@ -551,12 +551,12 @@ lto_symtab_merge_decl (tree new_decl,
 	  || old_resolution == LDPR_PREVAILING_DEF_IRONLY)
 	{
 	  error ("%qD has already been defined", new_decl);
-	  return error_mark_node;
+	  return;
 	}
       gcc_assert (old_resolution == LDPR_PREEMPTED_IR
 		  || old_resolution ==  LDPR_RESOLVED_IR);
       lto_symtab_overwrite_decl (old_decl, new_decl);
-      return old_decl;
+      return;
     }
 
   if (TREE_CODE (new_decl) == FUNCTION_DECL
@@ -585,17 +585,23 @@ lto_symtab_merge_decl (tree new_decl,
 		|| old_resolution == LDPR_PREEMPTED_IR
 		|| old_resolution == LDPR_RESOLVED_IR);
 
-  return old_decl;
+  return;
 }
 
-tree 
+void
 lto_symtab_merge_var (tree new_var, enum ld_plugin_symbol_resolution resolution)
 {
-  return lto_symtab_merge_decl (new_var, resolution);
+  lto_symtab_merge_decl (new_var, resolution);
 }
  
-tree
+void
 lto_symtab_merge_fn (tree new_fn, enum ld_plugin_symbol_resolution resolution)
 {
-  return lto_symtab_merge_decl (new_fn, resolution);
+  lto_symtab_merge_decl (new_fn, resolution);
+}
+
+tree
+lto_symtab_canonical_decl (tree decl)
+{
+  return LTO_IDENTIFIER_DECL (DECL_ASSEMBLER_NAME (decl));
 }

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