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] Fix streaming of clone nodes


This fixes 443 tests that had been broken by the merge of the new
callgraph node clone code.  There were two main problems:

- When streaming summary information in IPA passes, the streamer
  was looking up callgraph nodes from FUNCTION_DECLs.  This is
  incorrect because there is a one-to-many mapping between decls
  and nodes (because of clones).

  The patch modified cgraph streaming so that nodes are encoded
  early and used by the summary writing passes.  Similarly, the
  reader uses the cgraph node encoder to retrieve nodes from disk
  references when reconstructing summary information.

- The generation of summary information in lto1 is preceded by
  the reading of summaries written by the front end.  This was
  causing the node cloning hooks to be registered twice.  Some of
  these hooks cannot be called more than once on the same node.
  This was causing many ICEs in ipa-pure-const.c.


Tested on x86_64.



	* tree-pass.h (pass_ipa_lto_cgraph): Remove.
	* lto-function-out.c (lto_output): Call output_cgraph.
	* ipa-reference.c (ipa_init): Prevent multiple initializations.
	(ipa_reference_write_summary): Rename from write_summary.
	Update all users.
	Call lto_cgraph_encoder_encode to get a reference for NODE.
	(ipa_reference_read_summary): Rename from read_summary.
	Update all users.
	Call lto_cgraph_encoder_deref to retrieve NODE from INDEX.
	* cgraphunit.c (ipa_passes): Prevent lto1 from calling
	ipa_write_summaries.
	* lto-cgraph.c: Include lto-tree-out.h.
	(struct lto_cgraph_encoder_d): Move to lto-tree-out.h
	(lto_cgraph_encoder_t): Likewise.
	(lto_cgraph_encoder_new): Make extern.
	(lto_cgraph_encoder_delete): Likewise.
	(lto_cgraph_encoder_encode): Likewise.
	Return REF.
	(lto_cgraph_encoder_lookup): Make extern.
	(lto_cgraph_encoder_deref): Likewise.
	(output_node): Tidy.
	(output_cgraph): Make extern.
	Use the cgraph node encoder in OB->DECL_STATE.
	Do not call lto_cgraph_encoder_delete.
	(input_cgraph_1): Call lto_cgraph_encoder_encode.
	(input_cgraph): Call lto_cgraph_encoder_new.
	(pass_ipa_lto_cgraph): Remove.
	* lto-header.h: Include target.h and cgraph.h.
	(struct lto_cgraph_encoder_d): Move from lto-cgraph.c.
	(lto_cgraph_encoder_t): Likewise.
	* ipa-pure-const.c (register_hooks): Preven multiple
	initializations.
	(generate_summary): Tidy.
	(pure_const_write_summary): Rename from write_summary.
	Update all users.
	Call lto_cgraph_encoder_encode to get a reference for NODE.
	(pure_const_read_summary): Rename from read_summary.
	Update all users.
	Call lto_cgraph_encoder_deref to get NODE from INDEX.
	* lto-section-in.h: Do not include target.h, cgraph.h and
	lto-header.h.
	Include lto-section.h.
	(struct lto_file_decl_data): Add field cgraph_node_encoder.
	* Makefile.in (LTO_HEADER_H): New.  Update all references
	to lto-header.h.
	* passes.c (init_optimization_passes): Remove 'FIXME lto'
	marker.
	Remove reference to pass_ipa_lto_cgraph.
	* lto-section-out.c (lto_new_out_decl_state): Call
	lto_cgraph_encoder_new.
	(produce_asm_for_decls): Call lto_cgraph_encoder_delete.
	* lto-section-out.h (struct lto_out_decl_state): Add
	field cgraph_node_encoder.

lto/ChangeLog

	* lto.c (read_cgraph_and_symbols): Call input_cgraph.

Index: tree-pass.h
===================================================================
--- tree-pass.h	(revision 148619)
+++ tree-pass.h	(working copy)
@@ -412,7 +412,6 @@ extern struct simple_ipa_opt_pass pass_i
 extern struct simple_ipa_opt_pass pass_early_local_passes;
 
 extern struct ipa_opt_pass_d pass_ipa_lto_gimple_out;
-extern struct ipa_opt_pass_d pass_ipa_lto_cgraph;
 extern struct simple_ipa_opt_pass pass_ipa_increase_alignment;
 extern struct simple_ipa_opt_pass pass_ipa_matrix_reorg;
 extern struct ipa_opt_pass_d pass_ipa_cp;
Index: lto-function-out.c
===================================================================
--- lto-function-out.c	(revision 148619)
+++ lto-function-out.c	(working copy)
@@ -2494,6 +2494,13 @@ lto_output (cgraph_node_set set)
 	  lto_record_function_out_decl_state (node->decl, decl_state);
 	}
     }
+
+  /* Emit the callgraph after emitting function bodies.  This needs to
+     be done now to make sure that all the statements in every function
+     have been renumbered so that edges can be associated with call
+     statements using the statement UIDs.  */
+  output_cgraph (set);
+
   lto_bitmap_free (output);
 }
 
Index: ipa-reference.c
===================================================================
--- ipa-reference.c	(revision 148619)
+++ ipa-reference.c	(working copy)
@@ -584,6 +584,13 @@ propagate_bits (ipa_reference_global_var
 static void 
 ipa_init (void) 
 {
+  static bool init_p = false;
+
+  if (init_p)
+    return;
+
+  init_p = true;
+
   memory_identifier_string = build_string(7, "memory");
 
   reference_vars_to_consider =
@@ -1011,7 +1018,7 @@ write_node_summary_p (struct cgraph_node
 /* Serialize the ipa info for lto.  */
 
 static void 
-write_summary (cgraph_node_set set)
+ipa_reference_write_summary (cgraph_node_set set)
 {
   struct cgraph_node *node;
   struct lto_simple_output_block *ob
@@ -1035,9 +1042,12 @@ write_summary (cgraph_node_set set)
 	    = get_reference_vars_info (node)->local;
 	  unsigned int index;
 	  bitmap_iterator bi;
+	  lto_cgraph_encoder_t encoder;
+	  int node_ref;
 
-	  lto_output_fn_decl_index (ob->decl_state, ob->main_stream,
-				    node->decl);
+	  encoder = ob->decl_state->cgraph_node_encoder;
+	  node_ref = lto_cgraph_encoder_encode (encoder, node);
+	  lto_output_uleb128_stream (ob->main_stream, node_ref);
 
 	  /* Stream out the statics read.  */
 	  lto_output_uleb128_stream (ob->main_stream,
@@ -1061,7 +1071,7 @@ write_summary (cgraph_node_set set)
 /* Deserialize the ipa info for lto.  */
 
 static void 
-read_summary (void)
+ipa_reference_read_summary (void)
 {
   struct lto_file_decl_data ** file_data_vec 
     = lto_get_file_decl_data ();
@@ -1085,15 +1095,19 @@ read_summary (void)
 
 	  for (i = 0; i < f_count; i++)
 	    {
-	      unsigned int fn_index = lto_input_uleb128 (ib);
-	      tree fn_decl = lto_file_decl_data_get_fn_decl (file_data,
-							     fn_index);
-	      unsigned int j;
-	      struct cgraph_node *node = cgraph_node (fn_decl);
-	      ipa_reference_local_vars_info_t l = init_function_info (node);
+	      unsigned int j, index;
+	      struct cgraph_node *node;
+	      ipa_reference_local_vars_info_t l;
+	      unsigned int v_count;
+	      lto_cgraph_encoder_t encoder;
+
+	      index = lto_input_uleb128 (ib);
+	      encoder = file_data->cgraph_node_encoder;
+	      node = lto_cgraph_encoder_deref (encoder, index);
+	      l = init_function_info (node);
 
 	      /* Set the statics read.  */
-	      unsigned int v_count = lto_input_uleb128 (ib);
+	      v_count = lto_input_uleb128 (ib);
 	      for (j = 0; j < v_count; j++)
 		{
 		  unsigned int var_index = lto_input_uleb128 (ib);
@@ -1408,8 +1422,8 @@ struct ipa_opt_pass_d pass_ipa_reference
   0                                     /* todo_flags_finish */
  },
  generate_summary,		        /* generate_summary */
- write_summary,				/* write_summary */
- read_summary,				/* read_summary */
+ ipa_reference_write_summary,		/* write_summary */
+ ipa_reference_read_summary,		/* read_summary */
  NULL,					/* function_read_summary */
  0,					/* TODOs */
  NULL,			                /* function_transform */
Index: cgraphunit.c
===================================================================
--- cgraphunit.c	(revision 148619)
+++ cgraphunit.c	(working copy)
@@ -1320,7 +1320,8 @@ ipa_passes (void)
   execute_ipa_summary_passes ((struct ipa_opt_pass_d *) all_regular_ipa_passes);
   execute_ipa_summary_passes ((struct ipa_opt_pass_d *) all_lto_gen_passes);
 
-  ipa_write_summaries ();
+  if (!in_lto_p)
+    ipa_write_summaries ();
 
   execute_ipa_pass_list (all_regular_ipa_passes);
 
Index: lto-cgraph.c
===================================================================
--- lto-cgraph.c	(revision 148619)
+++ lto-cgraph.c	(working copy)
@@ -52,24 +52,12 @@ Boston, MA 02110-1301, USA.  */
 #include "lto-section-out.h"
 #include "pointer-set.h"
 #include "lto-tree-in.h"
+#include "lto-tree-out.h"
 #include "lto-utils.h"
 
-/* Encoder data structure used to stream callgraph nodes.  */
-struct lto_cgraph_encoder_d
-{
-  /* Map nodes to reference number. */
-  struct pointer_map_t *map;
-
-  /* Map reference number to node. */
-  VEC(cgraph_node_ptr,heap) *nodes;
-};
-
-typedef struct lto_cgraph_encoder_d *lto_cgraph_encoder_t;
-
-
 /* Create a new cgraph encoder.  */
 
-static lto_cgraph_encoder_t
+lto_cgraph_encoder_t
 lto_cgraph_encoder_new (void)
 {
   lto_cgraph_encoder_t encoder = XCNEW (struct lto_cgraph_encoder_d);
@@ -81,7 +69,7 @@ lto_cgraph_encoder_new (void)
 
 /* Delete ENCODER and its components.  */
 
-static void
+void
 lto_cgraph_encoder_delete (lto_cgraph_encoder_t encoder)
 {
    VEC_free (cgraph_node_ptr, heap, encoder->nodes);
@@ -90,41 +78,47 @@ lto_cgraph_encoder_delete (lto_cgraph_en
 }
 
 
-/* Return the existing reference number of NODE in ENCODER or assign one
-   if NODE has not been seen.  */
+/* Return the existing reference number of NODE in the cgraph encoder in
+   output block OB.  Assign a new reference if this is the first time
+   NODE is encoded.  */
 
-static void
+int
 lto_cgraph_encoder_encode (lto_cgraph_encoder_t encoder,
 			   struct cgraph_node *node)
 {
-  void **slot = pointer_map_contains (encoder->map, node);
-
+  int ref;
+  void **slot;
+  
+  slot = pointer_map_contains (encoder->map, node);
   if (!slot)
     {
-      intptr_t ref = VEC_length (cgraph_node_ptr, encoder->nodes);
+      ref = VEC_length (cgraph_node_ptr, encoder->nodes);
       slot = pointer_map_insert (encoder->map, node);
-      *slot = (void *) ref;
+      *slot = (void *) (intptr_t) ref;
       VEC_safe_push (cgraph_node_ptr, heap, encoder->nodes, node);
     }
+  else
+    ref = (int) (intptr_t) *slot;
+
+  return ref;
 }
 
 
 /* Look up NODE in encoder.  Return NODE's reference if it has been encoded
    or LCC_NOT_FOUND if it is not there.  */
 
-static intptr_t
+int
 lto_cgraph_encoder_lookup (lto_cgraph_encoder_t encoder,
 			   struct cgraph_node *node)
 {
   void **slot = pointer_map_contains (encoder->map, node);
-
-  return (slot ? (intptr_t) *slot : LCC_NOT_FOUND);
+  return (slot ? (int) (intptr_t) *slot : LCC_NOT_FOUND);
 }
 
 
 /* Return the cgraph node corresponding to REF using ENCODER.  */
 
-static struct cgraph_node *
+struct cgraph_node *
 lto_cgraph_encoder_deref (lto_cgraph_encoder_t encoder, int ref)
 {
   if (ref == LCC_NOT_FOUND)
@@ -308,8 +302,9 @@ output_node (struct lto_simple_output_bl
 				 node->local.inline_summary.time_inlining_benefit);
     }
 
-  /* FIXME: Outputting global info is not neccesary until after inliner was run
-     Global structure holds results of propagation done by inliner.  */
+  /* FIXME lto: Outputting global info is not neccesary until after
+     inliner was run.  Global structure holds results of propagation
+     done by inliner.  */
   LTO_DEBUG_TOKEN ("estimated_stack_size");
   lto_output_sleb128_stream (ob->main_stream,
 			     node->global.estimated_stack_size);
@@ -344,24 +339,25 @@ output_node (struct lto_simple_output_bl
 }
 
 
-/* Output the part of the cgraph in SET.  This is a little tricky now
-   as we need to handle clones as well.  To simplify things we first
-   write the nodes and then the edges.  This make the streamed data a
-   bit larger.  */
+/* Output the part of the cgraph in SET.  */
 
-static void
+void
 output_cgraph (cgraph_node_set set)
 {
   struct cgraph_node *node;
   struct lto_simple_output_block *ob;
   cgraph_node_set_iterator csi;
   struct cgraph_edge *edge;
-  lto_cgraph_encoder_t encoder;
   int i, n_nodes;
   bitmap written_decls;
+  lto_cgraph_encoder_t encoder;
 
   ob = lto_create_simple_output_block (LTO_section_cgraph);
-  encoder = lto_cgraph_encoder_new ();
+
+  /* An encoder for cgraph nodes should have been created by
+     ipa_write_summaries_1.  */
+  gcc_assert (ob->decl_state->cgraph_node_encoder);
+  encoder = ob->decl_state->cgraph_node_encoder;
 
   /* The FUNCTION_DECLs for which we have written a node.  The first
      node found is written as the "original" node, the remaining nodes
@@ -418,7 +414,6 @@ output_cgraph (cgraph_node_set set)
   lto_output_uleb128_stream (ob->main_stream, 0);
 
   lto_destroy_simple_output_block (ob);
-  lto_cgraph_encoder_delete (encoder);
 }
 
 
@@ -694,6 +689,7 @@ input_cgraph_1 (struct lto_file_decl_dat
 	  gcc_assert (node);
 	  gcc_assert (node->decl);
 	  VEC_safe_push (cgraph_node_ptr, heap, nodes, node);
+	  lto_cgraph_encoder_encode (file_data->cgraph_node_encoder, node);
 	}
 
       LTO_DEBUG_UNDENT();
@@ -733,7 +729,7 @@ input_cgraph_1 (struct lto_file_decl_dat
 /* Input and merge the cgraph from each of the .o files passed to
    lto1.  */
 
-static void
+void
 input_cgraph (void)
 {
   struct lto_file_decl_data **file_data_vec = lto_get_file_decl_data ();
@@ -753,7 +749,8 @@ input_cgraph (void)
       struct lto_input_block *ib;
 
       ib = lto_create_simple_input_block (file_data, LTO_section_cgraph, 
-					 &data, &len);
+					  &data, &len);
+      file_data->cgraph_node_encoder = lto_cgraph_encoder_new ();
       input_cgraph_1 (file_data, ib);
       lto_destroy_simple_input_block (file_data, LTO_section_cgraph, 
 				      ib, data, len);
@@ -776,30 +773,3 @@ input_cgraph (void)
 	node->aux = NULL;
     }
 }
-
-
-struct ipa_opt_pass_d pass_ipa_lto_cgraph =
-{
- {
-  IPA_PASS,
-  "lto_cgraph",	                        /* name */
-  gate_lto_out,			        /* gate */
-  NULL,		                        /* execute */
-  NULL,					/* sub */
-  NULL,					/* next */
-  0,					/* static_pass_number */
-  TV_IPA_LTO_CGRAPH_IO,	        	/* tv_id */
-  0,	                                /* properties_required */
-  0,					/* properties_provided */
-  0,					/* properties_destroyed */
-  0,            			/* todo_flags_start */
-  TODO_dump_func                        /* todo_flags_finish */
- },
- NULL,		                        /* generate_summary */
- output_cgraph,				/* write_summary */
- input_cgraph,				/* read_summary */
- NULL,					/* function_read_summary */
- 0,					/* TODOs */
- NULL,			                /* function_transform */
- NULL					/* variable_transform */
-};
Index: lto-header.h
===================================================================
--- lto-header.h	(revision 148619)
+++ lto-header.h	(working copy)
@@ -23,6 +23,9 @@
 #ifndef GCC_LTO_HEADER_H
 #define GCC_LTO_HEADER_H
 
+#include "target.h"
+#include "cgraph.h"
+
 /* The string that is the prefix on the section names we make for lto.
    For decls the DECL_ASSEMBLER_NAME is appended to make the section
    name for the functions and static_initializers.  For other types of
@@ -179,4 +182,16 @@ extern void lto_debug_wide (struct lto_d
 #endif
 
 
+/* Encoder data structure used to stream callgraph nodes.  */
+struct lto_cgraph_encoder_d
+{
+  /* Map nodes to reference number. */
+  struct pointer_map_t *map;
+
+  /* Map reference number to node. */
+  VEC(cgraph_node_ptr,heap) *nodes;
+};
+
+typedef struct lto_cgraph_encoder_d *lto_cgraph_encoder_t;
+
 #endif /* lto-header.h */
Index: ipa-pure-const.c
===================================================================
--- ipa-pure-const.c	(revision 148619)
+++ ipa-pure-const.c	(working copy)
@@ -609,6 +609,13 @@ remove_node_data (struct cgraph_node *no
 static void
 register_hooks (void)
 {
+  static bool init_p = false;
+
+  if (init_p)
+    return;
+
+  init_p = true;
+
   node_removal_hook_holder =
       cgraph_add_node_removal_hook (&remove_node_data, NULL);
   node_duplication_hook_holder =
@@ -625,6 +632,7 @@ generate_summary (void)
   struct cgraph_node *node;
 
   register_hooks ();
+
   /* There are some shared nodes, in particular the initializers on
      static declarations.  We do not need to scan them more than once
      since all we would be interested in are the addressof
@@ -649,7 +657,7 @@ generate_summary (void)
 /* Serialize the ipa info for lto.  */
 
 static void
-write_summary (cgraph_node_set set)
+pure_const_write_summary (cgraph_node_set set)
 {
   struct cgraph_node *node;
   struct lto_simple_output_block *ob
@@ -673,10 +681,15 @@ write_summary (cgraph_node_set set)
       if (node->analyzed && get_function_state (node) != NULL)
 	{
 	  unsigned HOST_WIDEST_INT flags = 0;
-	  funct_state fs = get_function_state (node);
+	  funct_state fs;
+	  int node_ref;
+	  lto_cgraph_encoder_t encoder;
+	  
+	  fs = get_function_state (node);
 
-	  lto_output_fn_decl_index (ob->decl_state, ob->main_stream,
-				    node->decl);
+	  encoder = ob->decl_state->cgraph_node_encoder;
+	  node_ref = lto_cgraph_encoder_encode (encoder, node);
+	  lto_output_uleb128_stream (ob->main_stream, node_ref);
 	
 	  /* Note that flags will need to be read in the opposite
 	     order as we are pushing the bitflags into FLAGS.  */
@@ -697,10 +710,10 @@ write_summary (cgraph_node_set set)
 /* Deserialize the ipa info for lto.  */
 
 static void 
-read_summary (void)
+pure_const_read_summary (void)
 {
-  struct lto_file_decl_data ** file_data_vec = lto_get_file_decl_data ();
-  struct lto_file_decl_data * file_data;
+  struct lto_file_decl_data **file_data_vec = lto_get_file_decl_data ();
+  struct lto_file_decl_data *file_data;
   unsigned int j = 0;
 
   register_hooks ();
@@ -719,16 +732,22 @@ read_summary (void)
 
 	  for (i = 0; i < count; i++)
 	    {
-	      unsigned int index = lto_input_uleb128 (ib);
-	      tree fn_decl = lto_file_decl_data_get_fn_decl (file_data, index);
-	      unsigned HOST_WIDEST_INT flags = lto_input_widest_uint_uleb128 (ib);
-	      funct_state fs = XCNEW (struct funct_state_d);
+	      unsigned int index;
+	      struct cgraph_node *node;
+	      unsigned HOST_WIDEST_INT flags;
+	      funct_state fs;
+	      lto_cgraph_encoder_t encoder;
 
-	      set_function_state (cgraph_node (fn_decl), fs);
+	      fs = XCNEW (struct funct_state_d);
+	      index = lto_input_uleb128 (ib);
+	      encoder = file_data->cgraph_node_encoder;
+	      node = lto_cgraph_encoder_deref (encoder, index);
+	      set_function_state (node, fs);
 
 	      /* Note that the flags must be read in the opposite
 		 order in which they were written (the bitflags were
 		 pushed into FLAGS).  */
+	      flags = lto_input_widest_uint_uleb128 (ib);
 	      fs->can_throw = lto_get_flag (&flags);
 	      fs->looping = lto_get_flag (&flags);
 	      fs->looping_previously_known = lto_get_flag (&flags);
@@ -1002,8 +1021,8 @@ struct ipa_opt_pass_d pass_ipa_pure_cons
   0                                     /* todo_flags_finish */
  },
  generate_summary,		        /* generate_summary */
- write_summary,				/* write_summary */
- read_summary,				/* read_summary */
+ pure_const_write_summary,		/* write_summary */
+ pure_const_read_summary,		/* read_summary */
  NULL,					/* function_read_summary */
  0,					/* TODOs */
  NULL,			                /* function_transform */
Index: lto-section-in.h
===================================================================
--- lto-section-in.h	(revision 148619)
+++ lto-section-in.h	(working copy)
@@ -21,9 +21,7 @@ along with GCC; see the file COPYING3.  
 #ifndef GCC_LTO_SECTION_IN_H
 #define GCC_LTO_SECTION_IN_H
 
-#include "target.h"
-#include "cgraph.h"
-#include "lto-header.h"
+#include "lto-section.h"
 
 struct lto_input_block 
 {
@@ -79,6 +77,9 @@ struct lto_file_decl_data
      in the compilation unit. */
   struct lto_in_decl_state *global_decl_state;
 
+  /* Table of cgraph nodes present in this file.  */
+  lto_cgraph_encoder_t cgraph_node_encoder;
+
   /* Hash table maps lto-related section names to location in file.  */
   htab_t function_decl_states;
 
Index: lto/lto.c
===================================================================
--- lto/lto.c	(revision 148619)
+++ lto/lto.c	(working copy)
@@ -1671,6 +1671,9 @@ read_cgraph_and_symbols (unsigned nfiles
   /* Each pass will set the appropriate timer.  */
   timevar_pop (TV_IPA_LTO_DECL_IO);
 
+  /* Read the callgraph.  */
+  input_cgraph ();
+
   ipa_read_summaries ();
 
   timevar_push (TV_IPA_LTO_DECL_IO);
Index: Makefile.in
===================================================================
--- Makefile.in	(revision 148619)
+++ Makefile.in	(working copy)
@@ -904,9 +904,10 @@ IRA_INT_H = ira.h ira-int.h $(CFGLOOP_H)
 DBGCNT_H = dbgcnt.h dbgcnt.def
 EBIMAP_H = ebitmap.h sbitmap.h
 LTO_TAGS_H = lto-tags.h tree.h sbitmap.h lto-header.h
-LTO_SECTION_H = lto-section.h lto-header.h
-LTO_SECTION_IN_H = lto-section-in.h lto-header.h $(TARGET_H) $(CGRAPH_H)
-LTO_SECTION_OUT_H = lto-section-out.h lto-section.h lto-header.h
+LTO_HEADER_H = lto-header.h $(TARGET_H) $(CGRAPH_H)
+LTO_SECTION_H = lto-section.h $(LTO_HEADER_H)
+LTO_SECTION_IN_H = lto-section-in.h $(LTO_SECTION_H)
+LTO_SECTION_OUT_H = lto-section-out.h $(LTO_SECTION_H)
 LTO_TREE_IN_H = lto-tree-in.h $(LTO_SECTION_IN_H) $(PLUGIN_API_H)
 LTO_OPTS_H = lto-section-in.h lto-opts.h
 TREE_VECTORIZER_H = tree-vectorizer.h $(TREE_DATA_REF_H)
@@ -2122,12 +2123,13 @@ double-int.o: double-int.c $(CONFIG_H) $
 
 # lto-compress.o needs $(ZLIBINC) added to the include flags.
 lto-compress.o: lto-compress.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
-	$(TREE_H) langhooks.h lto-header.h $(LTO_SECTION_OUT_H) lto-compress.h
+	$(TREE_H) langhooks.h $(LTO_HEADER_H) $(LTO_SECTION_OUT_H) \
+	lto-compress.h
 	$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(ZLIBINC) $< $(OUTPUT_OPTION)
 
 lto-stream-debug.o : lto-stream-debug.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
    $(TOPLEV_H) $(FLAGS_H) $(PARAMS_H) input.h debug.h  $(TREE_H) \
-   lto-header.h 
+   $(LTO_HEADER_H)
 lto-cgraph.o: lto-cgraph.c $(CONFIG_H) $(SYSTEM_H) coretypes.h   \
    $(TM_H) $(TOPLEV_H) $(EXPR_H) $(FLAGS_H) $(PARAMS_H) input.h \
    $(VARRAY_H) $(HASHTAB_H) langhooks.h $(BASIC_BLOCK_H) tree-iterator.h \
@@ -2147,7 +2149,7 @@ lto-function-out.o : lto-function-out.c 
    $(VARRAY_H) $(HASHTAB_H) langhooks.h $(BASIC_BLOCK_H) tree-iterator.h \
    tree-pass.h tree-flow.h $(CGRAPH_H) $(FUNCTION_H) $(GGC_H) $(DIAGNOSTIC_H) \
    except.h debug.h $(TIMEVAR_H) $(LTO_TAGS_H) lto-tree-flags.def \
-   lto-tree-tags.def lto-tags.h lto-header.h $(LTO_SECTION_OUT_H) output.h \
+   lto-tree-tags.def lto-tags.h $(LTO_HEADER_H) $(LTO_SECTION_OUT_H) output.h \
    dwarf2asm.h dwarf2out.h $(LTO_SECTION_IN_H) lto-utils.h
 lto-section-in.o: lto-section-in.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
    $(TOPLEV_H) $(EXPR_H) $(FLAGS_H) $(PARAMS_H) input.h $(VARRAY_H) \
@@ -2159,7 +2161,7 @@ lto-section-out.o : lto-section-out.c $(
    $(TM_H) $(TOPLEV_H) $(TREE_H) $(EXPR_H) $(FLAGS_H) $(PARAMS_H) input.h \
    $(VARRAY_H) $(HASHTAB_H) langhooks.h $(BASIC_BLOCK_H) tree-iterator.h \
    tree-pass.h tree-flow.h $(CGRAPH_H) $(FUNCTION_H) $(GGC_H) $(DIAGNOSTIC_H) \
-   except.h debug.h $(TIMEVAR_H) lto-header.h $(LTO_SECTION_OUT_H) output.h \
+   except.h debug.h $(TIMEVAR_H) $(LTO_HEADER_H) $(LTO_SECTION_OUT_H) output.h \
    dwarf2asm.h dwarf2out.h  $(BITMAP_H) lto-utils.h $(LTO_OPTS_H) lto-compress.h
 lto-symtab.o: lto-symtab.c $(LTO_TREE_IN_H) $(CONFIG_H) coretypes.h \
    $(SYSTEM_H) toplev.h $(LTO_TREE_H) $(GGC_H) $(LAMBDA_H) \
@@ -2169,7 +2171,7 @@ lto-opts.o: lto-opts.c $(CONFIG_H) $(SYS
    $(TARGET_H) $(TOPLEV_H) $(LTO_SECTION_OUT_H) $(LTO_SECTION_IN_H) \
    lto-utils.h $(LTO_OPTS_H)
 lto-utils.o: lto-utils.c $(CONFIG_H) $(SYSTEM_H) coretypes.h   \
-   $(TM_H) $(TREE_H) $(BITMAP_H) vec.h lto-header.h lto-utils.h \
+   $(TM_H) $(TREE_H) $(BITMAP_H) vec.h $(LTO_HEADER_H) lto-utils.h \
    $(GIMPLE_H)
 lto-wpa-fixup.o: lto-wpa-fixup.c $(CONFIG_H) $(SYSTEM_H) coretypes.h   \
    $(TM_H) $(TOPLEV_H) $(TREE_H) $(EXPR_H) $(FLAGS_H) tree-pass.h \
@@ -2602,7 +2604,7 @@ passes.o : passes.c $(CONFIG_H) $(SYSTEM
    langhooks.h insn-flags.h $(CFGLAYOUT_H) $(REAL_H) $(CFGLOOP_H) \
    hosthooks.h $(CGRAPH_H) $(COVERAGE_H) $(TREE_PASS_H) $(TREE_DUMP_H) \
    $(GGC_H) $(INTEGRATE_H) $(CPPLIB_H) opts.h $(TREE_FLOW_H) $(TREE_INLINE_H) \
-   gt-passes.h $(DF_H) $(PREDICT_H) lto-header.h $(LTO_SECTION_OUT_H)
+   gt-passes.h $(DF_H) $(PREDICT_H) $(LTO_HEADER_H) $(LTO_SECTION_OUT_H)
 
 plugin.o : plugin.c $(PLUGIN_H) $(CONFIG_H) $(SYSTEM_H) coretypes.h \
    $(TOPLEV_H) $(TREE_H) $(TREE_PASS_H) intl.h $(PLUGIN_VERSION_H) $(GGC_H)
Index: passes.c
===================================================================
--- passes.c	(revision 148619)
+++ passes.c	(working copy)
@@ -587,8 +587,6 @@ init_optimization_passes (void)
   *p = NULL;
 
   p = &all_regular_ipa_passes;
-  /* FIXME lto: ipa-reference was modified to ignore node duplication
-     hook.  This means that we ICE first time real clone is created.  */
   NEXT_PASS (pass_ipa_cp);
   NEXT_PASS (pass_ipa_inline);
   NEXT_PASS (pass_ipa_reference);
@@ -600,7 +598,6 @@ init_optimization_passes (void)
 
   p = &all_lto_gen_passes;
   NEXT_PASS (pass_ipa_lto_gimple_out);
-  NEXT_PASS (pass_ipa_lto_cgraph);
   NEXT_PASS (pass_ipa_lto_wpa_fixup);
   NEXT_PASS (pass_ipa_lto_finish_out);  /* This must be the last IPA_PASS.  */
   *p = NULL;
Index: lto-section-out.c
===================================================================
--- lto-section-out.c	(revision 148619)
+++ lto-section-out.c	(working copy)
@@ -709,9 +709,11 @@ lto_new_out_decl_state (void)
 	  hash_fn = lto_hash_decl_slot_node;
 	  eq_fn = lto_eq_decl_slot_node;
 	}
-    lto_init_tree_ref_encoder (&state->streams[i], hash_fn, eq_fn);
+      lto_init_tree_ref_encoder (&state->streams[i], hash_fn, eq_fn);
     }
 
+  state->cgraph_node_encoder = lto_cgraph_encoder_new ();
+
   return state;
 }
 
@@ -1330,8 +1332,7 @@ produce_asm_for_decls (cgraph_node_set s
   header.debug_main_size = ob->debug_main_stream->total_size;
 #endif
 
-  header_stream = ((struct lto_output_stream *)
-		   xcalloc (1, sizeof (struct lto_output_stream)));
+  header_stream = XCNEW (struct lto_output_stream);
   lto_output_data_stream (header_stream, &header, sizeof header);
   lto_write_stream (header_stream);
   free (header_stream);
@@ -1368,10 +1369,10 @@ produce_asm_for_decls (cgraph_node_set s
   /* Write command line opts.  */
   lto_write_options ();
 
+  /* Deallocate memory and clean up.  */
+  lto_cgraph_encoder_delete (ob->decl_state->cgraph_node_encoder);
   VEC_free (lto_out_decl_state_ptr, heap, lto_function_decl_states);
   lto_function_decl_states = NULL;
-
-  /* Deallocate memory and clean up.  */
   destroy_output_block (ob);
 }
 
Index: lto-section-out.h
===================================================================
--- lto-section-out.h	(revision 148619)
+++ lto-section-out.h	(working copy)
@@ -84,8 +84,9 @@ struct lto_tree_ref_encoder
   VEC(tree,heap) *trees;	/* Maps indices to pointers. */
 };
 
-/* The structure that holds all of the vectors of global types and
-   decls used in lto serialization for this file.  */
+
+/* The structure that holds all of the vectors of global types,
+   decls and cgraph nodes used in lto serialization for this file.  */
 
 struct lto_out_decl_state
 {
@@ -93,6 +94,9 @@ struct lto_out_decl_state
      seen so far and the indexes assigned to them.  */
   struct lto_tree_ref_encoder streams[LTO_N_DECL_STREAMS];
 
+  /* Encoder for cgraph nodes.  */
+  lto_cgraph_encoder_t cgraph_node_encoder;
+
   /* If this out-decl state belongs to a function, fn_decl points to that
      function.  Otherwise, it is NULL. */
   tree fn_decl;
@@ -223,4 +227,13 @@ void lto_delete_extern_inline_states (vo
 void lto_force_functions_extern_inline (bitmap decls);
 bool lto_forced_extern_inline_p (tree fn_decl);
 
+/* In lto-cgraph.c  */
+struct cgraph_node *lto_cgraph_encoder_deref (lto_cgraph_encoder_t, int);
+int lto_cgraph_encoder_lookup (lto_cgraph_encoder_t, struct cgraph_node *);
+lto_cgraph_encoder_t lto_cgraph_encoder_new (void);
+int lto_cgraph_encoder_encode (lto_cgraph_encoder_t, struct cgraph_node *);
+void lto_cgraph_encoder_delete (lto_cgraph_encoder_t encoder);
+void output_cgraph (cgraph_node_set);
+void input_cgraph (void);
+
 #endif  /* GCC_LTO_SECTION_OUT_H  */


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