]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ipa-fnsummary.c (analyze_function_body): Do not loeak conds and size_time_table.
authorJan Hubicka <hubicka@ucw.cz>
Sun, 16 Dec 2018 12:05:04 +0000 (13:05 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Sun, 16 Dec 2018 12:05:04 +0000 (12:05 +0000)
* ipa-fnsummary.c (analyze_function_body): Do not loeak conds and
size_time_table.
(ipa_fn_summary_generate): Add prevails parameter; do not allocate
data when symbol is not prevailing.
(inline_read_section): Likewise.

From-SVN: r267185

gcc/ChangeLog
gcc/ipa-fnsummary.c

index f95477fae6346c552c206badf8d5e6751cb6e67d..eda1061497bdb5b76c7b2089fdc968096a5a6ebf 100644 (file)
@@ -1,3 +1,11 @@
+2018-12-15  Jan Hubicka  <hubicka@ucw.cz>
+
+       * ipa-fnsummary.c (analyze_function_body): Do not loeak conds and
+       size_time_table.
+       (ipa_fn_summary_generate): Add prevails parameter; do not allocate
+       data when symbol is not prevailing.
+       (inline_read_section): Likewise.
+
 2018-12-15  Jan Hubicka  <hubicka@ucw.cz>
 
        * cgraph.h (cgraph_node): Add predicate prevailing_p.
index 23b7821dcc1af167d59c682ab5bb44708532f6ba..2f038909ab4677cfaf4eabe12177976ff5a5f5bb 100644 (file)
@@ -1990,7 +1990,9 @@ analyze_function_body (struct cgraph_node *node, bool early)
   gcc_assert (cfun == my_function);
 
   memset(&fbi, 0, sizeof(fbi));
+  vec_free (info->conds);
   info->conds = NULL;
+  vec_free (info->size_time_table);
   info->size_time_table = NULL;
 
   /* When optimizing and analyzing for IPA inliner, initialize loop optimizer
@@ -3193,28 +3195,46 @@ ipa_fn_summary_generate (void)
 /* Write inline summary for edge E to OB.  */
 
 static void
-read_ipa_call_summary (struct lto_input_block *ib, struct cgraph_edge *e)
+read_ipa_call_summary (struct lto_input_block *ib, struct cgraph_edge *e,
+                      bool prevails)
 {
-  struct ipa_call_summary *es = ipa_call_summaries->get_create (e);
+  struct ipa_call_summary *es = prevails
+                               ? ipa_call_summaries->get_create (e) : NULL;
   predicate p;
   int length, i;
 
-  es->call_stmt_size = streamer_read_uhwi (ib);
-  es->call_stmt_time = streamer_read_uhwi (ib);
-  es->loop_depth = streamer_read_uhwi (ib);
+  int size = streamer_read_uhwi (ib);
+  int time = streamer_read_uhwi (ib);
+  int depth = streamer_read_uhwi (ib);
+
+  if (es)
+    {
+      es->call_stmt_size = size;
+      es->call_stmt_time = time;
+      es->loop_depth = depth;
+    }
 
   bitpack_d bp = streamer_read_bitpack (ib);
-  es->is_return_callee_uncaptured = bp_unpack_value (&bp, 1);
+  if (es)
+    es->is_return_callee_uncaptured = bp_unpack_value (&bp, 1);        
+  else
+    bp_unpack_value (&bp, 1);  
 
   p.stream_in (ib);
-  edge_set_predicate (e, &p);
+  if (es)
+    edge_set_predicate (e, &p);
   length = streamer_read_uhwi (ib);
-  if (length)
+  if (length && es && e->possibly_call_in_translation_unit_p ())
     {
       es->param.safe_grow_cleared (length);
       for (i = 0; i < length; i++)
        es->param[i].change_prob = streamer_read_uhwi (ib);
     }
+  else
+    {
+      for (i = 0; i < length; i++)
+       streamer_read_uhwi (ib);
+    }
 }
 
 
@@ -3254,19 +3274,34 @@ inline_read_section (struct lto_file_decl_data *file_data, const char *data,
       encoder = file_data->symtab_node_encoder;
       node = dyn_cast<cgraph_node *> (lto_symtab_encoder_deref (encoder,
                                                                index));
-      info = ipa_fn_summaries->get_create (node);
+      info = node->prevailing_p () ? ipa_fn_summaries->get_create (node) : NULL;
 
-      info->estimated_stack_size
-       = info->estimated_self_stack_size = streamer_read_uhwi (&ib);
-      info->size = info->self_size = streamer_read_uhwi (&ib);
-      info->time = sreal::stream_in (&ib);
+      int stack_size = streamer_read_uhwi (&ib);
+      int size = streamer_read_uhwi (&ib);
+      sreal time = sreal::stream_in (&ib);
+
+      if (info)
+       {
+         info->estimated_stack_size
+           = info->estimated_self_stack_size = stack_size;
+         info->size = info->self_size = size;
+         info->time = time;
+       }
 
       bp = streamer_read_bitpack (&ib);
-      info->inlinable = bp_unpack_value (&bp, 1);
-      info->fp_expressions = bp_unpack_value (&bp, 1);
+      if (info)
+       {
+          info->inlinable = bp_unpack_value (&bp, 1);
+          info->fp_expressions = bp_unpack_value (&bp, 1);
+       }
+      else
+       {
+          bp_unpack_value (&bp, 1);
+          bp_unpack_value (&bp, 1);
+       }
 
       count2 = streamer_read_uhwi (&ib);
-      gcc_assert (!info->conds);
+      gcc_assert (!info || !info->conds);
       for (j = 0; j < count2; j++)
        {
          struct condition c;
@@ -3279,10 +3314,11 @@ inline_read_section (struct lto_file_decl_data *file_data, const char *data,
          c.by_ref = bp_unpack_value (&bp, 1);
          if (c.agg_contents)
            c.offset = streamer_read_uhwi (&ib);
-         vec_safe_push (info->conds, c);
+         if (info)
+           vec_safe_push (info->conds, c);
        }
       count2 = streamer_read_uhwi (&ib);
-      gcc_assert (!info->size_time_table);
+      gcc_assert (!info || !info->size_time_table);
       for (j = 0; j < count2; j++)
        {
          struct size_time_entry e;
@@ -3292,19 +3328,23 @@ inline_read_section (struct lto_file_decl_data *file_data, const char *data,
          e.exec_predicate.stream_in (&ib);
          e.nonconst_predicate.stream_in (&ib);
 
-         vec_safe_push (info->size_time_table, e);
+         if (info)
+           vec_safe_push (info->size_time_table, e);
        }
 
       p.stream_in (&ib);
-      set_hint_predicate (&info->loop_iterations, p);
+      if (info)
+        set_hint_predicate (&info->loop_iterations, p);
       p.stream_in (&ib);
-      set_hint_predicate (&info->loop_stride, p);
+      if (info)
+        set_hint_predicate (&info->loop_stride, p);
       p.stream_in (&ib);
-      set_hint_predicate (&info->array_index, p);
+      if (info)
+        set_hint_predicate (&info->array_index, p);
       for (e = node->callees; e; e = e->next_callee)
-       read_ipa_call_summary (&ib, e);
+       read_ipa_call_summary (&ib, e, info != NULL);
       for (e = node->indirect_calls; e; e = e->next_callee)
-       read_ipa_call_summary (&ib, e);
+       read_ipa_call_summary (&ib, e, info != NULL);
     }
 
   lto_free_section_data (file_data, LTO_section_ipa_fn_summary, NULL, data,