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]

Fix WHOR's logic on what partitions to dump


Hi,
this patch removes logic around lto_mark_file_for_ltrans.  It seems just unnecesary.
The code is used only during WPA and during WPA every nonempty source file gets the
flag.  Then we output partition only if any of callgraph node origins form file
with this flag but since all cgraph nodes origin from some files, all of them have
the flag set.

The partitions theoretically have nothing to do with source units and we need to
output partition as soon as there are any functions or varibales in it to compile.
This can be easilly tested by testing the sets to be nonempty.

I hope this will fix the EON link error since EON contains source unit only with
datastructures, but I did not check specifically (I am at wrong side of the firewall
and don't have access to working sources).

I would also like to get rid of cgraph_node's lto_file_data.  I guess it is wrong
place to annotate it.  The cgraph nodes are processed by IPA passes cloned/modified etc
and we don't really care whre they come from.  We only care where the corresponding
function body is, so I guess this all should go into FUNCTION_DECL driven hash.

Also I wonder why cgraph_node_set is not a bitmap rather than vector+hash?

I would like to avoid cgraph.h polution, what about moving this into ipa-sets.h file?

Bootstrapped/regtested x86_64 and tested on GCC and DLV WHOPR build, OK?

Honza

	* cgraph.h (cgraph_node_set_nonempty_p, varpool_node_set_nonempty_p): New.
	* lto-cgraph.c (input_cgraph): Remove call to lto_mark_file_for_ltrans.
	(get_filename_for_set): Look for cgraph node and if none found, use
	default name.
	(lto_wpa_write_files): Write any non-empty partition.
	* lto-streamer.h (lto_file_decl_data): Remove needs_ltrans_p.
	(lto_file_needs_ltrans_p, lto_mark_file_for_ltrans,
	cgraph_node_set_needs_ltrans_p): Remove.

Index: cgraph.h
===================================================================
*** cgraph.h	(revision 158936)
--- cgraph.h	(working copy)
*************** struct GTY(()) constant_descriptor_tree 
*** 827,832 ****
--- 827,846 ----
    hashval_t hash;
  };
  
+ /* Return true if set is nonempty.  */
+ static inline bool
+ cgraph_node_set_nonempty_p (cgraph_node_set set)
+ {
+   return VEC_length (cgraph_node_ptr, set->nodes);
+ }
+ 
+ /* Return true if set is nonempty.  */
+ static inline bool
+ varpool_node_set_nonempty_p (varpool_node_set set)
+ {
+   return VEC_length (varpool_node_ptr, set->nodes);
+ }
+ 
  /* Return true when function NODE is only called directly.
     i.e. it is not externally visible, address was not taken and
     it is not used in any other non-standard way.  */
Index: lto-cgraph.c
===================================================================
*** lto-cgraph.c	(revision 158938)
--- lto-cgraph.c	(working copy)
*************** input_cgraph (void)
*** 962,971 ****
        input_varpool_1 (file_data, ib);
        lto_destroy_simple_input_block (file_data, LTO_section_varpool,
  				      ib, data, len);
- 
-       /* Assume that every file read needs to be processed by LTRANS.  */
-       if (flag_wpa)
- 	lto_mark_file_for_ltrans (file_data);
      }
  
    /* Clear out the aux field that was used to store enough state to
--- 962,967 ----
Index: lto/lto.c
===================================================================
*** lto/lto.c	(revision 158938)
--- lto/lto.c	(working copy)
*************** get_filename_for_set (cgraph_node_set se
*** 817,873 ****
    char *fname = NULL;
    static const size_t max_fname_len = 100;
  
!   if (cgraph_node_set_needs_ltrans_p (set))
!     {
!       /* Create a new temporary file to store SET.  To facilitate
! 	 debugging, use file names from SET as part of the new
! 	 temporary file name.  */
!       cgraph_node_set_iterator si;
!       struct pointer_set_t *pset = pointer_set_create ();
!       for (si = csi_start (set); !csi_end_p (si); csi_next (&si))
  	{
! 	  struct cgraph_node *n = csi_node (si);
! 	  const char *node_fname;
! 	  char *f;
! 
! 	  /* Don't use the same file name more than once.  */
! 	  if (pointer_set_insert (pset, n->local.lto_file_data))
! 	    continue;
! 
! 	  /* The first file name found in SET determines the output
! 	     directory.  For the remaining files, we use their
! 	     base names.  */
! 	  node_fname = n->local.lto_file_data->file_name;
! 	  if (fname == NULL)
! 	    {
! 	      fname = strip_extension (node_fname);
! 	      continue;
! 	    }
  
! 	  f = strip_extension (lbasename (node_fname));
  
! 	  /* If the new name causes an excessively long file name,
! 	     make the last component "___" to indicate overflow.  */
! 	  if (strlen (fname) + strlen (f) > max_fname_len - 3)
! 	    {
! 	      fname = reconcat (fname, fname, "___", NULL);
! 	      break;
! 	    }
! 	  else
! 	    {
! 	      fname = reconcat (fname, fname, "_", f, NULL);
! 	      free (f);
! 	    }
  	}
  
!       pointer_set_destroy (pset);
  
!       /* Add the extension .wpa.o to indicate that this file has been
! 	 produced by WPA.  */
!       fname = reconcat (fname, fname, ".wpa.o", NULL);
!       gcc_assert (fname);
!     }
!   else
      {
        /* Since SET does not need to be processed by LTRANS, use
  	 the original file name and mark it with a '*' prefix so that
--- 817,866 ----
    char *fname = NULL;
    static const size_t max_fname_len = 100;
  
!   /* Create a new temporary file to store SET.  To facilitate
!      debugging, use file names from SET as part of the new
!      temporary file name.  */
!   cgraph_node_set_iterator si;
!   struct pointer_set_t *pset = pointer_set_create ();
!   for (si = csi_start (set); !csi_end_p (si); csi_next (&si))
!     {
!       struct cgraph_node *n = csi_node (si);
!       const char *node_fname;
!       char *f;
! 
!       /* Don't use the same file name more than once.  */
!       if (pointer_set_insert (pset, n->local.lto_file_data))
! 	continue;
! 
!       /* The first file name found in SET determines the output
! 	 directory.  For the remaining files, we use their
! 	 base names.  */
!       node_fname = n->local.lto_file_data->file_name;
!       if (fname == NULL)
  	{
! 	  fname = strip_extension (node_fname);
! 	  continue;
! 	}
  
!       f = strip_extension (lbasename (node_fname));
  
!       /* If the new name causes an excessively long file name,
! 	 make the last component "___" to indicate overflow.  */
!       if (strlen (fname) + strlen (f) > max_fname_len - 3)
! 	{
! 	  fname = reconcat (fname, fname, "___", NULL);
! 	  break;
! 	}
!       else
! 	{
! 	  fname = reconcat (fname, fname, "_", f, NULL);
! 	  free (f);
  	}
+     }
  
!   pointer_set_destroy (pset);
  
!   if (!fname)
      {
        /* Since SET does not need to be processed by LTRANS, use
  	 the original file name and mark it with a '*' prefix so that
*************** get_filename_for_set (cgraph_node_set se
*** 876,881 ****
--- 869,881 ----
        struct cgraph_node *first = csi_node (si);
        fname = prefix_name_with_star (first->local.lto_file_data->file_name);
      }
+   else
+     {
+       /* Add the extension .wpa.o to indicate that this file has been
+ 	 produced by WPA.  */
+       fname = reconcat (fname, fname, ".wpa.o", NULL);
+       gcc_assert (fname);
+     }
  
    return fname;
  }
*************** lto_wpa_write_files (void)
*** 933,939 ****
        temp_filename = get_filename_for_set (set);
        output_files[i] = temp_filename;
  
!       if (cgraph_node_set_needs_ltrans_p (set))
  	{
  	  /* Write all the nodes in SET to TEMP_FILENAME.  */
  	  file = lto_obj_file_open (temp_filename, true);
--- 933,939 ----
        temp_filename = get_filename_for_set (set);
        output_files[i] = temp_filename;
  
!       if (cgraph_node_set_nonempty_p (set) || varpool_node_set_nonempty_p (vset))
  	{
  	  /* Write all the nodes in SET to TEMP_FILENAME.  */
  	  file = lto_obj_file_open (temp_filename, true);
Index: lto-streamer.h
===================================================================
*** lto-streamer.h	(revision 158936)
--- lto-streamer.h	(working copy)
*************** struct GTY(()) lto_file_decl_data
*** 552,560 ****
    /* The .o file that these offsets relate to.  */
    const char *GTY((skip)) file_name;
  
-   /* Nonzero if this file should be recompiled with LTRANS.  */
-   unsigned needs_ltrans_p : 1;
- 
    /* Hash table maps lto-related section names to location in file.  */
    htab_t GTY((skip)) section_hash_table;
  
--- 552,557 ----
*************** lto_tag_to_tree_code (enum LTO_tags tag)
*** 922,959 ****
    return (enum tree_code) ((unsigned) tag - 1);
  }
  
- 
- /* Return true if FILE needs to be compiled with LTRANS.  */
- static inline bool
- lto_file_needs_ltrans_p (struct lto_file_decl_data *file)
- {
-   return file->needs_ltrans_p != 0;
- }
- 
- 
- /* Mark FILE to be compiled with LTRANS.  */
- static inline void
- lto_mark_file_for_ltrans (struct lto_file_decl_data *file)
- {
-   file->needs_ltrans_p = 1;
- }
- 
- 
- /* Return true if any files in node set SET need to be compiled
-    with LTRANS.  */
- static inline bool
- cgraph_node_set_needs_ltrans_p (cgraph_node_set set)
- {
-   cgraph_node_set_iterator csi;
- 
-   for (csi = csi_start (set); !csi_end_p (csi); csi_next (&csi))
-     if (lto_file_needs_ltrans_p (csi_node (csi)->local.lto_file_data))
-       return true;
- 
-   return false;
- }
- 
- 
  /* Initialize an lto_out_decl_buffer ENCODER.  */
  static inline void
  lto_init_tree_ref_encoder (struct lto_tree_ref_encoder *encoder,
--- 919,924 ----


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