re PR middle-end/53136 (Use after free in ipa_make_edge_direct_to_target, cxx_printab...
authorUros Bizjak <ubizjak@gmail.com>
Mon, 30 Apr 2012 21:34:35 +0000 (23:34 +0200)
committerUros Bizjak <uros@gcc.gnu.org>
Mon, 30 Apr 2012 21:34:35 +0000 (23:34 +0200)
PR middle-end/53136
* ipa-prop.c (ipa_print_node_jump_functions): Wrap multiple
calls to cgraph_node_name in xstrdup.
(ipa_make_edge_direct_to_target): Ditto.
* cgraph.c (dump_cgraph_node): Ditto.
* tree-sra.c (convert_callers_for_node): Ditto.
* lto-symtab.c (lto_cgraph_replace_node): Ditto.
* ipa-cp.c (perhaps_add_new_callers): Ditto.
* cgraphunit.c (cgraph_redirect_edge_call_stmt_to_callee): Ditto.
(cgraph_materialize_all_clones): Ditto.
* ipa-inline.c (report_inline_failed_reason): Ditto.
(want_early_inline_function_p): Ditto.
(edge_badness): Ditto.
(update_edge_key): Ditto.
(flatten_function): Ditto.
(ipa_inline): Ditto.
(inlinw_always_inline_functions): Ditto.
(early_inline_small_functions): Ditto.

From-SVN: r187001

gcc/ChangeLog
gcc/cgraph.c
gcc/cgraphunit.c
gcc/ipa-cp.c
gcc/ipa-inline.c
gcc/ipa-prop.c
gcc/lto-symtab.c
gcc/tree-sra.c

index a020376d3c4ff51e653d32bbeaecb87af3ecbd63..478ba87686a43052773bec2dea02c8e3b5a9644a 100644 (file)
@@ -1,3 +1,24 @@
+2012-04-30  Uros Bizjak  <ubizjak@gmail.com>
+
+       PR middle-end/53136
+       * ipa-prop.c (ipa_print_node_jump_functions): Wrap multiple
+       calls to cgraph_node_name in xstrdup.
+       (ipa_make_edge_direct_to_target): Ditto.
+       * cgraph.c (dump_cgraph_node): Ditto.
+       * tree-sra.c (convert_callers_for_node): Ditto.
+       * lto-symtab.c (lto_cgraph_replace_node): Ditto.
+       * ipa-cp.c (perhaps_add_new_callers): Ditto.
+       * cgraphunit.c (cgraph_redirect_edge_call_stmt_to_callee): Ditto.
+       (cgraph_materialize_all_clones): Ditto.
+       * ipa-inline.c (report_inline_failed_reason): Ditto.
+       (want_early_inline_function_p): Ditto.
+       (edge_badness): Ditto.
+       (update_edge_key): Ditto.
+       (flatten_function): Ditto.
+       (ipa_inline): Ditto.
+       (inlinw_always_inline_functions): Ditto.
+       (early_inline_small_functions): Ditto.
+
 2012-04-30  Uros Bizjak  <ubizjak@gmail.com>
 
        PR target/53141
index ebba1b767c7d6868e25ef591c0f9cb1d92475806..c765b3179b572701b7a304f8f645fe3e6f115bfc 100644 (file)
@@ -1476,9 +1476,9 @@ dump_cgraph_node (FILE *f, struct cgraph_node *node)
 
   if (node->global.inlined_to)
     fprintf (f, "  Function %s/%i is inline copy in %s/%i\n",
-            cgraph_node_name (node),
+            xstrdup (cgraph_node_name (node)),
             node->symbol.order,
-            cgraph_node_name (node->global.inlined_to),
+            xstrdup (cgraph_node_name (node->global.inlined_to)),
             node->global.inlined_to->symbol.order);
   if (node->clone_of)
     fprintf (f, "  Clone of %s/%i\n",
index f922a5e0bfd9251c908cb4d0ad31f882416a5554..ee69afa0e8cd92f5abe7e2118cf168f410ca88fe 100644 (file)
@@ -2146,8 +2146,8 @@ cgraph_redirect_edge_call_stmt_to_callee (struct cgraph_edge *e)
   if (cgraph_dump_file)
     {
       fprintf (cgraph_dump_file, "updating call of %s/%i -> %s/%i: ",
-              cgraph_node_name (e->caller), e->caller->uid,
-              cgraph_node_name (e->callee), e->callee->uid);
+              xstrdup (cgraph_node_name (e->caller)), e->caller->uid,
+              xstrdup (cgraph_node_name (e->callee)), e->callee->uid);
       print_gimple_stmt (cgraph_dump_file, e->call_stmt, 0, dump_flags);
       if (e->callee->clone.combined_args_to_skip)
        {
@@ -2233,8 +2233,8 @@ cgraph_materialize_all_clones (void)
                  if (cgraph_dump_file)
                    {
                      fprintf (cgraph_dump_file, "cloning %s to %s\n",
-                              cgraph_node_name (node->clone_of),
-                              cgraph_node_name (node));
+                              xstrdup (cgraph_node_name (node->clone_of)),
+                              xstrdup (cgraph_node_name (node)));
                      if (node->clone.tree_map)
                        {
                          unsigned int i;
index 4826c582c832e4c87348da266cc5438b71fc15b9..eb8d20d94f644acc15b7c54bea1b91c0ecd199b8 100644 (file)
@@ -2180,8 +2180,9 @@ perhaps_add_new_callers (struct cgraph_node *node, struct ipcp_value *val)
                  if (dump_file)
                    fprintf (dump_file, " - adding an extra caller %s/%i"
                             " of %s/%i\n",
-                            cgraph_node_name (cs->caller), cs->caller->uid,
-                            cgraph_node_name (val->spec_node),
+                            xstrdup (cgraph_node_name (cs->caller)),
+                            cs->caller->uid,
+                            xstrdup (cgraph_node_name (val->spec_node)),
                             val->spec_node->uid);
 
                  cgraph_redirect_edge_callee (cs, val->spec_node);
index 451bd6176034fa692ea8584b9ce81ac95337bc84..eb3d42d25d6e014c3a983dfa3277917a2f6904e9 100644 (file)
@@ -220,8 +220,8 @@ report_inline_failed_reason (struct cgraph_edge *e)
   if (dump_file)
     {
       fprintf (dump_file, "  not inlinable: %s/%i -> %s/%i, %s\n",
-              cgraph_node_name (e->caller), e->caller->uid,
-              cgraph_node_name (e->callee), e->callee->uid,
+              xstrdup (cgraph_node_name (e->caller)), e->caller->uid,
+              xstrdup (cgraph_node_name (e->callee)), e->callee->uid,
               cgraph_inline_failed_string (e->inline_failed));
     }
 }
@@ -423,8 +423,8 @@ want_early_inline_function_p (struct cgraph_edge *e)
          if (dump_file)
            fprintf (dump_file, "  will not early inline: %s/%i->%s/%i, "
                     "call is cold and code would grow by %i\n",
-                    cgraph_node_name (e->caller), e->caller->uid,
-                    cgraph_node_name (callee), callee->uid,
+                    xstrdup (cgraph_node_name (e->caller)), e->caller->uid,
+                    xstrdup (cgraph_node_name (callee)), callee->uid,
                     growth);
          want_inline = false;
        }
@@ -434,8 +434,8 @@ want_early_inline_function_p (struct cgraph_edge *e)
          if (dump_file)
            fprintf (dump_file, "  will not early inline: %s/%i->%s/%i, "
                     "callee is not leaf and code would grow by %i\n",
-                    cgraph_node_name (e->caller), e->caller->uid,
-                    cgraph_node_name (callee), callee->uid,
+                    xstrdup (cgraph_node_name (e->caller)), e->caller->uid,
+                    xstrdup (cgraph_node_name (callee)), callee->uid,
                     growth);
          want_inline = false;
        }
@@ -444,8 +444,8 @@ want_early_inline_function_p (struct cgraph_edge *e)
          if (dump_file)
            fprintf (dump_file, "  will not early inline: %s/%i->%s/%i, "
                     "growth %i exceeds --param early-inlining-insns\n",
-                    cgraph_node_name (e->caller), e->caller->uid,
-                    cgraph_node_name (callee), callee->uid,
+                    xstrdup (cgraph_node_name (e->caller)), e->caller->uid,
+                    xstrdup (cgraph_node_name (callee)), callee->uid,
                     growth);
          want_inline = false;
        }
@@ -754,8 +754,8 @@ edge_badness (struct cgraph_edge *edge, bool dump)
   if (dump)
     {
       fprintf (dump_file, "    Badness calculation for %s -> %s\n",
-              cgraph_node_name (edge->caller),
-              cgraph_node_name (callee));
+              xstrdup (cgraph_node_name (edge->caller)),
+              xstrdup (cgraph_node_name (callee)));
       fprintf (dump_file, "      size growth %i, time growth %i\n",
               growth,
               time_growth);
@@ -910,8 +910,10 @@ update_edge_key (fibheap_t heap, struct cgraph_edge *edge)
            {
              fprintf (dump_file,
                       "  decreasing badness %s/%i -> %s/%i, %i to %i\n",
-                      cgraph_node_name (edge->caller), edge->caller->uid,
-                      cgraph_node_name (edge->callee), edge->callee->uid,
+                      xstrdup (cgraph_node_name (edge->caller)),
+                      edge->caller->uid,
+                      xstrdup (cgraph_node_name (edge->callee)),
+                      edge->callee->uid,
                       (int)n->key,
                       badness);
            }
@@ -925,8 +927,10 @@ update_edge_key (fibheap_t heap, struct cgraph_edge *edge)
         {
           fprintf (dump_file,
                    "  enqueuing call %s/%i -> %s/%i, badness %i\n",
-                   cgraph_node_name (edge->caller), edge->caller->uid,
-                   cgraph_node_name (edge->callee), edge->callee->uid,
+                   xstrdup (cgraph_node_name (edge->caller)),
+                   edge->caller->uid,
+                   xstrdup (cgraph_node_name (edge->callee)),
+                   edge->callee->uid,
                    badness);
         }
       edge->aux = fibheap_insert (heap, badness, edge);
@@ -1610,8 +1614,8 @@ flatten_function (struct cgraph_node *node, bool early)
          if (dump_file)
            fprintf (dump_file,
                     "Not inlining %s into %s to avoid cycle.\n",
-                    cgraph_node_name (callee),
-                    cgraph_node_name (e->caller));
+                    xstrdup (cgraph_node_name (callee)),
+                    xstrdup (cgraph_node_name (e->caller)));
          e->inline_failed = CIF_RECURSIVE_INLINING;
          continue;
        }
@@ -1651,8 +1655,8 @@ flatten_function (struct cgraph_node *node, bool early)
          recursing through the original node if the node was cloned.  */
       if (dump_file)
        fprintf (dump_file, " Inlining %s into %s.\n",
-                cgraph_node_name (callee),
-                cgraph_node_name (e->caller));
+                xstrdup (cgraph_node_name (callee)),
+                xstrdup (cgraph_node_name (e->caller)));
       orig_callee = callee;
       inline_call (e, true, NULL, NULL);
       if (e->callee != orig_callee)
@@ -1754,7 +1758,8 @@ ipa_inline (void)
                    {
                      fprintf (dump_file,
                               "\nInlining %s size %i.\n",
-                              cgraph_node_name (node), inline_summary (node)->size);
+                              cgraph_node_name (node),
+                              inline_summary (node)->size);
                      fprintf (dump_file,
                               " Called once from %s %i insns.\n",
                               cgraph_node_name (node->callers->caller),
@@ -1817,8 +1822,8 @@ inline_always_inline_functions (struct cgraph_node *node)
 
       if (dump_file)
        fprintf (dump_file, "  Inlining %s into %s (always_inline).\n",
-                cgraph_node_name (e->callee),
-                cgraph_node_name (e->caller));
+                xstrdup (cgraph_node_name (e->callee)),
+                xstrdup (cgraph_node_name (e->caller)));
       inline_call (e, true, NULL, NULL);
       inlined = true;
     }
@@ -1867,8 +1872,8 @@ early_inline_small_functions (struct cgraph_node *node)
 
       if (dump_file)
        fprintf (dump_file, " Inlining %s into %s.\n",
-                cgraph_node_name (callee),
-                cgraph_node_name (e->caller));
+                xstrdup (cgraph_node_name (callee)),
+                xstrdup (cgraph_node_name (e->caller)));
       inline_call (e, true, NULL, NULL);
       inlined = true;
     }
index 97a6a5cb0cf95f931527973692fe5f6362a4c4f4..02d6c3162766d4b1d867bdb26315d21ea3bd4c57 100644 (file)
@@ -230,8 +230,8 @@ ipa_print_node_jump_functions (FILE *f, struct cgraph_node *node)
        continue;
 
       fprintf (f, "    callsite  %s/%i -> %s/%i : \n",
-              cgraph_node_name (node), node->uid,
-              cgraph_node_name (cs->callee), cs->callee->uid);
+              xstrdup (cgraph_node_name (node)), node->uid,
+              xstrdup (cgraph_node_name (cs->callee)), cs->callee->uid);
       ipa_print_node_jump_functions_for_edge (f, cs);
     }
 
@@ -1780,8 +1780,8 @@ ipa_make_edge_direct_to_target (struct cgraph_edge *ie, tree target)
       fprintf (dump_file, "ipa-prop: Discovered %s call to a known target "
               "(%s/%i -> %s/%i), for stmt ",
               ie->indirect_info->polymorphic ? "a virtual" : "an indirect",
-              cgraph_node_name (ie->caller), ie->caller->uid,
-              cgraph_node_name (ie->callee), ie->callee->uid);
+              xstrdup (cgraph_node_name (ie->caller)), ie->caller->uid,
+              xstrdup (cgraph_node_name (ie->callee)), ie->callee->uid);
       if (ie->call_stmt)
        print_gimple_stmt (dump_file, ie->call_stmt, 2, TDF_SLIM);
       else
index 12e1b95e4da8609c7bb0b42bd44cbad4da60e5c9..a371c0a7f111d02848bfe033857c57df1246dbac 100644 (file)
@@ -215,8 +215,8 @@ lto_cgraph_replace_node (struct cgraph_node *node,
     {
       fprintf (cgraph_dump_file, "Replacing cgraph node %s/%i by %s/%i"
               " for symbol %s\n",
-              cgraph_node_name (node), node->uid,
-              cgraph_node_name (prevailing_node),
+              xstrdup (cgraph_node_name (node)), node->uid,
+              xstrdup (cgraph_node_name (prevailing_node)),
               prevailing_node->uid,
               IDENTIFIER_POINTER ((*targetm.asm_out.mangle_assembler_name)
                 (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (node->symbol.decl)))));
index 70b241d52376f498f5aead18f4a6e30dd0dba90e..110990a211a5351aac1df8d0d843d2def7f58ad4 100644 (file)
@@ -4612,8 +4612,8 @@ convert_callers_for_node (struct cgraph_node *node,
       if (dump_file)
        fprintf (dump_file, "Adjusting call (%i -> %i) %s -> %s\n",
                 cs->caller->uid, cs->callee->uid,
-                cgraph_node_name (cs->caller),
-                cgraph_node_name (cs->callee));
+                xstrdup (cgraph_node_name (cs->caller)),
+                xstrdup (cgraph_node_name (cs->callee)));
 
       ipa_modify_call_arguments (cs, cs->call_stmt, adjustments);