public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [lto][patch] Simplify the lto-symtab api a bit
@ 2008-10-01 14:46 Rafael Espindola
  2008-10-01 16:36 ` Diego Novillo
  0 siblings, 1 reply; 2+ messages in thread
From: Rafael Espindola @ 2008-10-01 14:46 UTC (permalink / raw)
  To: gcc-patches; +Cc: Diego Novillo

[-- Attachment #1: Type: text/plain, Size: 1001 bytes --]

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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: symtab.patch --]
[-- Type: text/x-diff; name=symtab.patch, Size: 5254 bytes --]

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));
 }

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [lto][patch] Simplify the lto-symtab api a bit
  2008-10-01 14:46 [lto][patch] Simplify the lto-symtab api a bit Rafael Espindola
@ 2008-10-01 16:36 ` Diego Novillo
  0 siblings, 0 replies; 2+ messages in thread
From: Diego Novillo @ 2008-10-01 16:36 UTC (permalink / raw)
  To: Rafael Espindola; +Cc: gcc-patches

On Wed, Oct 1, 2008 at 10:40, Rafael Espindola <espindola@google.com> wrote:

> -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)

The comment needs updating.  NODE doesn't exist anymore.

> -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));
>  }

Since you're here, could you add comments to all these functions?
We have many that need commenting, but we can do this little by
little.

OK with those changes.


Thanks.  Diego.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-10-01 16:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-01 14:46 [lto][patch] Simplify the lto-symtab api a bit Rafael Espindola
2008-10-01 16:36 ` Diego Novillo

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).