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]

Symbol table 23/many: remove alias_pairs code from LTO streaming


Hi,
this patch removes now dead code to stream alias pairs.
Bootstrapped/regtested x86_64-linux, comitted.

honza 
Index: ChangeLog
===================================================================
*** ChangeLog	(revision 187680)
--- ChangeLog	(working copy)
***************
*** 1,5 ****
--- 1,19 ----
  2012-05-18  Jan Hubicka  <jh@suse.cz>
  
+ 	* cgraphunit.c (handle_alias_pairs): Declare; free alias_pairs
+ 	(cgraph_process_new_functions): Process also aliases.
+ 	* lto-streamer-out.c (struct sets): Remove.
+ 	(trivally_defined_alias): Remove.
+ 	(output_alias_pair_p): Remove.
+ 	(output_unreferenced_globals): Remove.
+ 	(produce_symtab); Do not handle alias pairs.
+ 	(produce_asm_for_decls): Likewise.
+ 	* lto-streamer-in.c (input_alias_pairs): Remove.
+ 	(lto_read_body): Do not input alias pairs.
+ 	(lto_input_constructors_and_inits): Remove.
+ 
+ 2012-05-18  Jan Hubicka  <jh@suse.cz>
+ 
  	* cgraphunit.c (handle_alias_pairs): Cleanup; handle all types of aliases.
  
  2012-05-18  Jan Hubicka  <jh@suse.cz>
Index: lto/ChangeLog
===================================================================
*** lto/ChangeLog	(revision 187679)
--- lto/ChangeLog	(working copy)
***************
*** 1,3 ****
--- 1,8 ----
+ 2012-05-18  Jan Hubicka  <jh@suse.cz>
+ 
+ 	* lto.c (lto_materialize_constructors_and_inits): Remove.
+ 	(read_cgraph_and_symbols): Remove handling of alias pairs.
+ 
  2012-05-17  Jan Hubicka  <jh@suse.cz>
  
  	* lto-partition.c (add_references_to_partition): Handle external vars.
Index: cgraphunit.c
===================================================================
*** cgraphunit.c	(revision 187680)
--- cgraphunit.c	(working copy)
*************** static void expand_all_functions (void);
*** 205,210 ****
--- 205,211 ----
  static void mark_functions_to_output (void);
  static void expand_function (struct cgraph_node *);
  static void cgraph_analyze_function (struct cgraph_node *);
+ static void handle_alias_pairs (void);
  
  FILE *cgraph_dump_file;
  
*************** cgraph_process_new_functions (void)
*** 284,289 ****
--- 285,292 ----
  
    if (!cgraph_new_nodes)
      return false;
+   finish_aliases_1 ();
+   handle_alias_pairs ();
    /*  Note that this queue may grow as its being processed, as the new
        functions may generate new ones.  */
    for (csi = csi_start (cgraph_new_nodes); !csi_end_p (csi); csi_next (&csi))
*************** handle_alias_pairs (void)
*** 1089,1094 ****
--- 1092,1098 ----
  	  VEC_unordered_remove (alias_pair, alias_pairs, i);
  	}
      }
+   VEC_free (alias_pair, gc, alias_pairs);
  }
  
  
Index: lto-streamer-out.c
===================================================================
*** lto-streamer-out.c	(revision 187679)
--- lto-streamer-out.c	(working copy)
*************** output_function (struct cgraph_node *nod
*** 852,966 ****
  }
  
  
- /* Used to pass data to trivally_defined_alias callback.  */
- struct sets {
-   cgraph_node_set set;
-   varpool_node_set vset;
- };
- 
- 
- /* Return true if alias pair P belongs to the set of cgraph nodes in
-    SET.  If P is a an alias for a VAR_DECL, it can always be emitted.
-    However, for FUNCTION_DECL aliases, we should only output the pair
-    if it belongs to a function whose cgraph node is in SET.
-    Otherwise, the LTRANS phase will get into trouble when finalizing
-    aliases because the alias will refer to a function not defined in
-    the file processed by LTRANS.  */
- 
- static bool
- trivally_defined_alias (tree decl ATTRIBUTE_UNUSED,
- 			tree target, void *data)
- {
-   struct sets *set = (struct sets *) data;
-   struct cgraph_node *fnode = NULL;
-   struct varpool_node *vnode = NULL;
- 
-   fnode = cgraph_node_for_asm (target);
-   if (fnode)
-     return cgraph_node_in_set_p (fnode, set->set);
-   vnode = varpool_node_for_asm (target);
-   return vnode && varpool_node_in_set_p (vnode, set->vset);
- }
- 
- /* Return true if alias pair P should be output in the current
-    partition contains cgrpah nodes SET and varpool nodes VSET.
-    DEFINED is set of all aliases whose targets are defined in
-    the partition.
- 
-    Normal aliases are output when they are defined, while WEAKREF
-    aliases are output when they are used.  */
- 
- static bool
- output_alias_pair_p (alias_pair *p, symbol_alias_set_t *defined,
- 		     cgraph_node_set set, varpool_node_set vset)
- {
-   struct cgraph_node *node;
-   struct varpool_node *vnode;
- 
-   if (lookup_attribute ("weakref", DECL_ATTRIBUTES (p->decl)))
-     {
-       if (TREE_CODE (p->decl) == VAR_DECL)
- 	{
- 	  vnode = varpool_get_node (p->decl);
- 	  return (vnode
- 		  && referenced_from_this_partition_p (&vnode->symbol.ref_list,
- 						      set, vset));
- 	}
-       node = cgraph_get_node (p->decl);
-       return (node
- 	      && (referenced_from_this_partition_p (&node->symbol.ref_list,
- 						    set, vset)
- 		  || reachable_from_this_partition_p (node, set)));
-     }
-   else
-     return symbol_alias_set_contains (defined, p->decl);
- }
- 
- /* Output any unreferenced global symbol defined in SET, alias pairs
-    and labels.  */
- 
- static void
- output_unreferenced_globals (cgraph_node_set set, varpool_node_set vset)
- {
-   struct output_block *ob;
-   alias_pair *p;
-   unsigned i;
-   symbol_alias_set_t *defined;
-   struct sets setdata;
- 
-   setdata.set = set;
-   setdata.vset = vset;
- 
-   ob = create_output_block (LTO_section_static_initializer);
-   ob->cgraph_node = NULL;
- 
-   clear_line_info (ob);
- 
-   /* Make string 0 be a NULL string.  */
-   streamer_write_char_stream (ob->string_stream, 0);
- 
-   /* We really need to propagate in both directoins:
-      for normal aliases we propagate from first defined alias to
-      all aliases defined based on it.  For weakrefs we propagate in
-      the oposite direction.  */
-   defined = propagate_aliases_backward (trivally_defined_alias, &setdata);
- 
-   /* Emit the alias pairs for the nodes in SET.  */
-   FOR_EACH_VEC_ELT (alias_pair, alias_pairs, i, p)
-     if (output_alias_pair_p (p, defined, set, vset))
-       {
- 	stream_write_tree (ob, p->decl, true);
- 	stream_write_tree (ob, p->target, true);
-       }
-   symbol_alias_set_destroy (defined);
- 
-   streamer_write_record_start (ob, LTO_null);
- 
-   produce_asm (ob, NULL);
-   destroy_output_block (ob);
- }
- 
- 
  /* Emit toplevel asms.  */
  
  void
--- 852,857 ----
*************** write_symbol (struct streamer_tree_cache
*** 1387,1394 ****
     SET and VSET are cgraph/varpool node sets we are outputting.  */
  
  static void
! produce_symtab (struct output_block *ob,
! 	        cgraph_node_set set, varpool_node_set vset)
  {
    struct streamer_tree_cache_d *cache = ob->writer_cache;
    char *section_name = lto_get_section_name (LTO_section_symtab, NULL, NULL);
--- 1278,1284 ----
     SET and VSET are cgraph/varpool node sets we are outputting.  */
  
  static void
! produce_symtab (struct output_block *ob)
  {
    struct streamer_tree_cache_d *cache = ob->writer_cache;
    char *section_name = lto_get_section_name (LTO_section_symtab, NULL, NULL);
*************** produce_symtab (struct output_block *ob,
*** 1399,1410 ****
    lto_varpool_encoder_t varpool_encoder = ob->decl_state->varpool_node_encoder;
    lto_cgraph_encoder_t encoder = ob->decl_state->cgraph_node_encoder;
    int i;
-   alias_pair *p;
-   struct sets setdata;
-   symbol_alias_set_t *defined;
- 
-   setdata.set = set;
-   setdata.vset = vset;
  
    lto_begin_section (section_name, false);
    free (section_name);
--- 1289,1294 ----
*************** produce_symtab (struct output_block *ob,
*** 1478,1490 ****
        write_symbol (cache, &stream, vnode->symbol.decl, seen, false);
      }
  
-   /* Write all aliases.  */
-   defined = propagate_aliases_backward (trivally_defined_alias, &setdata);
-   FOR_EACH_VEC_ELT (alias_pair, alias_pairs, i, p)
-     if (output_alias_pair_p (p, defined, set, vset))
-       write_symbol (cache, &stream, p->decl, seen, true);
-   symbol_alias_set_destroy (defined);
- 
    lto_write_stream (&stream);
    pointer_set_destroy (seen);
  
--- 1362,1367 ----
*************** produce_symtab (struct output_block *ob,
*** 1499,1505 ****
     recover these on other side.  */
  
  static void
! produce_asm_for_decls (cgraph_node_set set, varpool_node_set vset)
  {
    struct lto_out_decl_state *out_state;
    struct lto_out_decl_state *fn_out_state;
--- 1376,1383 ----
     recover these on other side.  */
  
  static void
! produce_asm_for_decls (cgraph_node_set set ATTRIBUTE_UNUSED,
! 		       varpool_node_set vset ATTRIBUTE_UNUSED)
  {
    struct lto_out_decl_state *out_state;
    struct lto_out_decl_state *fn_out_state;
*************** produce_asm_for_decls (cgraph_node_set s
*** 1514,1524 ****
    ob = create_output_block (LTO_section_decls);
    ob->global = true;
  
-   /* Write out unreferenced globals, alias pairs and labels.  We defer
-      doing this until now so that we can write out only what is
-      needed.  */
-   output_unreferenced_globals (set, vset);
- 
    memset (&header, 0, sizeof (struct lto_decl_header));
  
    section_name = lto_get_section_name (LTO_section_decls, NULL, NULL);
--- 1392,1397 ----
*************** produce_asm_for_decls (cgraph_node_set s
*** 1528,1533 ****
--- 1401,1408 ----
    /* Make string 0 be a NULL string.  */
    streamer_write_char_stream (ob->string_stream, 0);
  
+   gcc_assert (!alias_pairs);
+ 
    /* Write the global symbols.  */
    out_state = lto_get_out_decl_state ();
    num_fns = VEC_length (lto_out_decl_state_ptr, lto_function_decl_states);
*************** produce_asm_for_decls (cgraph_node_set s
*** 1591,1597 ****
    /* Write the symbol table.  It is used by linker to determine dependencies
       and thus we can skip it for WPA.  */
    if (!flag_wpa)
!     produce_symtab (ob, set, vset);
  
    /* Write command line opts.  */
    lto_write_options ();
--- 1466,1472 ----
    /* Write the symbol table.  It is used by linker to determine dependencies
       and thus we can skip it for WPA.  */
    if (!flag_wpa)
!     produce_symtab (ob);
  
    /* Write command line opts.  */
    lto_write_options ();
Index: lto-streamer-in.c
===================================================================
*** lto-streamer-in.c	(revision 187679)
--- lto-streamer-in.c	(working copy)
*************** input_function (tree fn_decl, struct dat
*** 931,969 ****
  }
  
  
- /* Read initializer expressions for public statics.  DATA_IN is the
-    file being read.  IB is the input block used for reading.  */
- 
- static void
- input_alias_pairs (struct lto_input_block *ib, struct data_in *data_in)
- {
-   tree var;
- 
-   clear_line_info (data_in);
- 
-   var = stream_read_tree (ib, data_in);
-   while (var)
-     {
-       const char *orig_name, *new_name;
-       alias_pair *p;
- 
-       p = VEC_safe_push (alias_pair, gc, alias_pairs, NULL);
-       p->decl = var;
-       p->target = stream_read_tree (ib, data_in);
- 
-       /* If the target is a static object, we may have registered a
- 	 new name for it to avoid clashes between statics coming from
- 	 different files.  In that case, use the new name.  */
-       orig_name = IDENTIFIER_POINTER (p->target);
-       new_name = lto_get_decl_name_mapping (data_in->file_data, orig_name);
-       if (strcmp (orig_name, new_name) != 0)
- 	p->target = get_identifier (new_name);
- 
-       var = stream_read_tree (ib, data_in);
-     }
- }
- 
- 
  /* Read the body from DATA for function FN_DECL and fill it in.
     FILE_DATA are the global decls and types.  SECTION_TYPE is either
     LTO_section_function_body or LTO_section_static_initializer.  If
--- 931,936 ----
*************** lto_read_body (struct lto_file_decl_data
*** 1059,1068 ****
  
        pop_cfun ();
      }
-   else
-     {
-       input_alias_pairs (&ib_main, data_in);
-     }
  
    clear_line_info (data_in);
    lto_data_in_delete (data_in);
--- 1026,1031 ----
*************** lto_input_function_body (struct lto_file
*** 1081,1097 ****
  }
  
  
- /* Read in VAR_DECL using DATA.  FILE_DATA holds the global decls and
-    types.  */
- 
- void
- lto_input_constructors_and_inits (struct lto_file_decl_data *file_data,
- 				  const char *data)
- {
-   lto_read_body (file_data, NULL, data, LTO_section_static_initializer);
- }
- 
- 
  /* Read the physical representation of a tree node with tag TAG from
     input block IB using the per-file context in DATA_IN.  */
  
--- 1044,1049 ----
Index: lto/lto.c
===================================================================
*** lto/lto.c	(revision 187679)
--- lto/lto.c	(working copy)
*************** lto_splay_tree_new (void)
*** 156,175 ****
  			 NULL);
  }
  
- /* Read the constructors and inits.  */
- 
- static void
- lto_materialize_constructors_and_inits (struct lto_file_decl_data * file_data)
- {
-   size_t len;
-   const char *data = lto_get_section_data (file_data, 
- 					   LTO_section_static_initializer,
- 					   NULL, &len);
-   lto_input_constructors_and_inits (file_data, data);
-   lto_free_section_data (file_data, LTO_section_static_initializer, NULL,
- 			 data, len);
- }
- 
  /* Return true when NODE has a clone that is analyzed (i.e. we need
     to load its body even if the node itself is not needed).  */
  
--- 156,161 ----
*************** read_cgraph_and_symbols (unsigned nfiles
*** 1883,1897 ****
  
    timevar_push (TV_IPA_LTO_DECL_INIT_IO);
  
-   /* FIXME lto. This loop needs to be changed to use the pass manager to
-      call the ipa passes directly.  */
-   if (!seen_error ())
-     for (i = 0; i < last_file_ix; i++)
-       {
- 	struct lto_file_decl_data *file_data = all_file_decl_data [i];
- 	lto_materialize_constructors_and_inits (file_data);
-       }
- 
    /* Indicate that the cgraph is built and ready.  */
    cgraph_function_flags_ready = true;
  
--- 1869,1874 ----


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