aboutsummaryrefslogtreecommitdiff
path: root/gcc/cgraph.h
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2014-12-08 19:31:45 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2014-12-08 19:31:45 +0000
commit2a72a9538fdd3e7ea5de08cbe233e1eb3dc5d44a (patch)
tree717a1d74dbcf55ae4d71c2fc03be956c6157212c /gcc/cgraph.h
parent53b730ff90bc866123609de78bf5247e6ae328cf (diff)
downloadgcc-2a72a9538fdd3e7ea5de08cbe233e1eb3dc5d44a.zip
gcc-2a72a9538fdd3e7ea5de08cbe233e1eb3dc5d44a.tar.gz
gcc-2a72a9538fdd3e7ea5de08cbe233e1eb3dc5d44a.tar.bz2
PR jit/63854: Introduce xstrdup_for_dump
gcc/ChangeLog: PR jit/63854 * cgraph.h (xstrdup_for_dump): New function. * cgraph.c (cgraph_node::get_create): Replace use of xstrdup within fprintf with xstrdup_for_dump. (cgraph_edge::make_speculative): Likewise. (cgraph_edge::resolve_speculation): Likewise. (cgraph_edge::redirect_call_stmt_to_callee): Likewise. (cgraph_node::dump): Likewise. * cgraphclones.c (symbol_table::materialize_all_clones): Likewise. * ipa-cp.c (perhaps_add_new_callers): Likewise. * ipa-inline.c (report_inline_failed_reason): Likewise. (want_early_inline_function_p): Likewise. (edge_badness): Likewise. (update_edge_key): Likewise. (flatten_function): Likewise. (inline_always_inline_functions): Likewise. * ipa-profile.c (ipa_profile): Likewise. * ipa-prop.c (ipa_print_node_jump_functions): Likewise. (ipa_make_edge_direct_to_target): Likewise. (remove_described_reference): Likewise. (propagate_controlled_uses): Likewise. * ipa-utils.c (ipa_merge_profiles): Likewise. From-SVN: r218490
Diffstat (limited to 'gcc/cgraph.h')
-rw-r--r--gcc/cgraph.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index 997414c..891b925 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -2833,4 +2833,32 @@ cgraph_local_p (cgraph_node *node)
return node->local.local && node->instrumented_version->local.local;
}
+/* When using fprintf (or similar), problems can arise with
+ transient generated strings. Many string-generation APIs
+ only support one result being alive at once (e.g. by
+ returning a pointer to a statically-allocated buffer).
+
+ If there is more than one generated string within one
+ fprintf call: the first string gets evicted or overwritten
+ by the second, before fprintf is fully evaluated.
+ See e.g. PR/53136.
+
+ This function provides a workaround for this, by providing
+ a simple way to create copies of these transient strings,
+ without the need to have explicit cleanup:
+
+ fprintf (dumpfile, "string 1: %s string 2:%s\n",
+ xstrdup_for_dump (EXPR_1),
+ xstrdup_for_dump (EXPR_2));
+
+ This is actually a simple wrapper around ggc_strdup, but
+ the name documents the intent. We require that no GC can occur
+ within the fprintf call. */
+
+static inline const char *
+xstrdup_for_dump (const char *transient_str)
+{
+ return ggc_strdup (transient_str);
+}
+
#endif /* GCC_CGRAPH_H */