Patchwork [PR,47162] Do not stream optimization info for edges that are not streamed themselves

login
register
mail settings
Submitter Martin Jambor
Date Jan. 4, 2011, 6:38 p.m.
Message ID <20110104183849.GA3363@virgil.arch.suse.de>
Download mbox | patch
Permalink /patch/77509/
State New
Headers show

Comments

Martin Jambor - Jan. 4, 2011, 6:38 p.m.
Hi,

my fix for 46984 streams optimization info even for edges that are not
outgoing from a node in the current set and which we therefore do not
stream as such.  This makes the call graph optimization info reader
misrepresent stuff in the stream.  Fixed by making sure we don't
stream the info out in the first place.

Bootstrapped and tested on x86_64-linux, I have also successfully
compiled and run SPECINT 2000 with lto with this patch.  OK for trunk?

Thanks,

Martin



2011-01-04  Martin Jambor  <mjambor@suse.cz>

	PR lto/47162
	* lto-cgraph.c (output_cgraph_opt_summary_p): Also check for thunk
	deltas on streamed outgoing edges.
	(output_node_opt_summary): Output info for outgoing edges only when
	the node is in new parameter set.
	(output_cgraph_opt_summary): New parameter set, passed to the two
	aforementioned functions.  Update its forward declaration and its
	callee too.
Jan Hubicka - Jan. 5, 2011, 1:40 p.m.
> 2011-01-04  Martin Jambor  <mjambor@suse.cz>
> 
> 	PR lto/47162
> 	* lto-cgraph.c (output_cgraph_opt_summary_p): Also check for thunk
> 	deltas on streamed outgoing edges.
> 	(output_node_opt_summary): Output info for outgoing edges only when
> 	the node is in new parameter set.
> 	(output_cgraph_opt_summary): New parameter set, passed to the two
> 	aforementioned functions.  Update its forward declaration and its
> 	callee too.

OK.

Thanks,
Honza
H.J. Lu - Jan. 5, 2011, 2:52 p.m.
On Wed, Jan 5, 2011 at 5:40 AM, Jan Hubicka <hubicka@ucw.cz> wrote:
>> 2011-01-04  Martin Jambor  <mjambor@suse.cz>
>>
>>       PR lto/47162
>>       * lto-cgraph.c (output_cgraph_opt_summary_p): Also check for thunk
>>       deltas on streamed outgoing edges.
>>       (output_node_opt_summary): Output info for outgoing edges only when
>>       the node is in new parameter set.
>>       (output_cgraph_opt_summary): New parameter set, passed to the two
>>       aforementioned functions.  Update its forward declaration and its
>>       callee too.
>
> OK.

I checked it to unlock my LTO tests.

Thanks.

Patch

Index: icln/gcc/lto-cgraph.c
===================================================================
--- icln.orig/gcc/lto-cgraph.c
+++ icln/gcc/lto-cgraph.c
@@ -46,7 +46,7 @@  along with GCC; see the file COPYING3.
 #include "gcov-io.h"
 
 static void output_varpool (cgraph_node_set, varpool_node_set);
-static void output_cgraph_opt_summary (void);
+static void output_cgraph_opt_summary (cgraph_node_set set);
 static void input_cgraph_opt_summary (VEC (cgraph_node_ptr, heap) * nodes);
 
 
@@ -861,7 +861,7 @@  output_cgraph (cgraph_node_set set, varp
   static bool asm_nodes_output = false;
 
   if (flag_wpa)
-    output_cgraph_opt_summary ();
+    output_cgraph_opt_summary (set);
 
   ob = lto_create_simple_output_block (LTO_section_cgraph);
 
@@ -1596,13 +1596,26 @@  input_cgraph (void)
 /* True when we need optimization summary for NODE.  */
 
 static int
-output_cgraph_opt_summary_p (struct cgraph_node *node)
+output_cgraph_opt_summary_p (struct cgraph_node *node, cgraph_node_set set)
 {
-  if (!node->clone_of)
-    return false;
-  return (node->clone.tree_map
-          || node->clone.args_to_skip
-          || node->clone.combined_args_to_skip);
+  struct cgraph_edge *e;
+
+  if (cgraph_node_in_set_p (node, set))
+    {
+      for (e = node->callees; e; e = e->next_callee)
+	if (e->indirect_info
+	    && e->indirect_info->thunk_delta != 0)
+	  return true;
+
+      for (e = node->indirect_calls; e; e = e->next_callee)
+	if (e->indirect_info->thunk_delta != 0)
+	  return true;
+    }
+
+  return (node->clone_of
+	  && (node->clone.tree_map
+	      || node->clone.args_to_skip
+	      || node->clone.combined_args_to_skip));
 }
 
 /* Output optimization summary for EDGE to OB.  */
@@ -1621,7 +1634,8 @@  output_edge_opt_summary (struct output_b
 
 static void
 output_node_opt_summary (struct output_block *ob,
-			 struct cgraph_node *node)
+			 struct cgraph_node *node,
+			 cgraph_node_set set)
 {
   unsigned int index;
   bitmap_iterator bi;
@@ -1659,17 +1673,21 @@  output_node_opt_summary (struct output_b
       bp_pack_value (&bp, map->ref_p, 1);
       lto_output_bitpack (&bp);
     }
-  for (e = node->callees; e; e = e->next_callee)
-    output_edge_opt_summary (ob, e);
-  for (e = node->indirect_calls; e; e = e->next_callee)
-    output_edge_opt_summary (ob, e);
+
+  if (cgraph_node_in_set_p (node, set))
+    {
+      for (e = node->callees; e; e = e->next_callee)
+	output_edge_opt_summary (ob, e);
+      for (e = node->indirect_calls; e; e = e->next_callee)
+	output_edge_opt_summary (ob, e);
+    }
 }
 
 /* Output optimization summaries stored in callgraph.
    At the moment it is the clone info structure.  */
 
 static void
-output_cgraph_opt_summary (void)
+output_cgraph_opt_summary (cgraph_node_set set)
 {
   struct cgraph_node *node;
   int i, n_nodes;
@@ -1681,16 +1699,17 @@  output_cgraph_opt_summary (void)
   encoder = ob->decl_state->cgraph_node_encoder;
   n_nodes = lto_cgraph_encoder_size (encoder);
   for (i = 0; i < n_nodes; i++)
-    if (output_cgraph_opt_summary_p (lto_cgraph_encoder_deref (encoder, i)))
+    if (output_cgraph_opt_summary_p (lto_cgraph_encoder_deref (encoder, i),
+				     set))
       count++;
   lto_output_uleb128_stream (ob->main_stream, count);
   for (i = 0; i < n_nodes; i++)
     {
       node = lto_cgraph_encoder_deref (encoder, i);
-      if (output_cgraph_opt_summary_p (node))
+      if (output_cgraph_opt_summary_p (node, set))
 	{
 	  lto_output_uleb128_stream (ob->main_stream, i);
-	  output_node_opt_summary (ob, node);
+	  output_node_opt_summary (ob, node, set);
 	}
     }
   produce_asm (ob, NULL);