Created this patch to add GCC version to the graph data for the options: -fdump-rtl-all-graph -fdump-tree-all-graph -fdump-ipq-all-graph -fcallgraph-info -fdump-analyzer-callgraph -fdump-analyzer-exploded-graph -fdump-analyzer-supergraph -fdump-analyzer-state-purge -fdump-analyzer-feasibility
using gcc git version 4 july 2021 git describe basepoints/gcc-12-1999-gd07092a61d5 gcc --version gcc (GCC) 12.0.0 20210704 (experimental) Copyright (C) 2021 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. The start of the gcc -fcallgraph-info output now looks like this: /* callgraph generated by GNU GCC Compiler -fcallgraph-info option version * GNU C17 (GCC) version 12.0.0 20210704 (experimental) (x86_64-pc-linux-gnu) * compiled by GNU C version 12.0.0 20210704 (experimental), GMP version 6.2.0, MPFR version 4.0.2, MPC version 1.1.0, isl version none * GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 */ graph: { title: "foo.c" node: { title: "hello_GCC" label: "hello_GCC\nfoo.c:3:6" } ... } There are more routines in GCC generating graph data but do not know the options how to use it. See also in bugzilla : https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83711 diff --git a/gcc/analyzer/analysis-plan.cc b/gcc/analyzer/analysis-plan.cc index 7dfc48e9c3e..223eba37761 100644 --- a/gcc/analyzer/analysis-plan.cc +++ b/gcc/analyzer/analysis-plan.cc @@ -40,6 +40,7 @@ along with GCC; see the file COPYING3. If not see #include "basic-block.h" #include "gimple.h" #include "gimple-iterator.h" +#include "toplev.h" #include "digraph.h" #include "analyzer/supergraph.h" diff --git a/gcc/analyzer/call-string.cc b/gcc/analyzer/call-string.cc index 9f4f77ab3a9..1489b687966 100644 --- a/gcc/analyzer/call-string.cc +++ b/gcc/analyzer/call-string.cc @@ -34,6 +34,7 @@ along with GCC; see the file COPYING3. If not see #include "basic-block.h" #include "gimple.h" #include "gimple-iterator.h" +#include "toplev.h" #include "digraph.h" #include "analyzer/supergraph.h" diff --git a/gcc/analyzer/checker-path.cc b/gcc/analyzer/checker-path.cc index e10c8e2bb7c..0d1e3f9bdd0 100644 --- a/gcc/analyzer/checker-path.cc +++ b/gcc/analyzer/checker-path.cc @@ -33,6 +33,7 @@ along with GCC; see the file COPYING3. If not see #include "cgraph.h" #include "function.h" #include "cfg.h" +#include "toplev.h" #include "digraph.h" #include "alloc-pool.h" #include "fibonacci_heap.h" diff --git a/gcc/analyzer/complexity.cc b/gcc/analyzer/complexity.cc index ece4272ff6e..4d6d0900eda 100644 --- a/gcc/analyzer/complexity.cc +++ b/gcc/analyzer/complexity.cc @@ -48,6 +48,7 @@ along with GCC; see the file COPYING3. If not see #include "options.h" #include "cgraph.h" #include "cfg.h" +#include "toplev.h" #include "digraph.h" #include "analyzer/call-string.h" #include "analyzer/program-point.h" diff --git a/gcc/analyzer/constraint-manager.cc b/gcc/analyzer/constraint-manager.cc index 51cf52258a9..b62e91bf28d 100644 --- a/gcc/analyzer/constraint-manager.cc +++ b/gcc/analyzer/constraint-manager.cc @@ -37,6 +37,7 @@ along with GCC; see the file COPYING3. If not see #include "options.h" #include "cgraph.h" #include "cfg.h" +#include "toplev.h" #include "digraph.h" #include "analyzer/supergraph.h" #include "sbitmap.h" diff --git a/gcc/analyzer/diagnostic-manager.cc b/gcc/analyzer/diagnostic-manager.cc index 7eb4ed8a4f2..db548191313 100644 --- a/gcc/analyzer/diagnostic-manager.cc +++ b/gcc/analyzer/diagnostic-manager.cc @@ -53,6 +53,7 @@ along with GCC; see the file COPYING3. If not see #include "gimple.h" #include "gimple-iterator.h" #include "cgraph.h" +#include "toplev.h" #include "digraph.h" #include "analyzer/supergraph.h" #include "analyzer/program-state.h" diff --git a/gcc/analyzer/engine.cc b/gcc/analyzer/engine.cc index 4456d9b828b..c6f44adc42e 100644 --- a/gcc/analyzer/engine.cc +++ b/gcc/analyzer/engine.cc @@ -54,6 +54,7 @@ along with GCC; see the file COPYING3. If not see #include "gimple-iterator.h" #include "gimple-pretty-print.h" #include "cgraph.h" +#include "toplev.h" #include "digraph.h" #include "analyzer/supergraph.h" #include "analyzer/program-state.h" diff --git a/gcc/analyzer/feasible-graph.cc b/gcc/analyzer/feasible-graph.cc index 675bda9e7e5..426c2d46c28 100644 --- a/gcc/analyzer/feasible-graph.cc +++ b/gcc/analyzer/feasible-graph.cc @@ -53,6 +53,7 @@ along with GCC; see the file COPYING3. If not see #include "gimple.h" #include "gimple-iterator.h" #include "cgraph.h" +#include "toplev.h" #include "digraph.h" #include "analyzer/supergraph.h" #include "analyzer/program-state.h" diff --git a/gcc/analyzer/program-point.cc b/gcc/analyzer/program-point.cc index d8cfc61975e..de6aa13ae1c 100644 --- a/gcc/analyzer/program-point.cc +++ b/gcc/analyzer/program-point.cc @@ -34,6 +34,7 @@ along with GCC; see the file COPYING3. If not see #include "basic-block.h" #include "gimple.h" #include "gimple-iterator.h" +#include "toplev.h" #include "digraph.h" #include "analyzer/analyzer.h" #include "analyzer/analyzer-logging.h" diff --git a/gcc/analyzer/program-state.cc b/gcc/analyzer/program-state.cc index 6d60c0449ce..1bda91b6912 100644 --- a/gcc/analyzer/program-state.cc +++ b/gcc/analyzer/program-state.cc @@ -51,6 +51,7 @@ along with GCC; see the file COPYING3. If not see #include "gimple.h" #include "gimple-iterator.h" #include "cgraph.h" +#include "toplev.h" #include "digraph.h" #include "analyzer/supergraph.h" #include "analyzer/program-state.h" diff --git a/gcc/analyzer/region-model-impl-calls.cc b/gcc/analyzer/region-model-impl-calls.cc index 466d397ec49..f6a5602aac0 100644 --- a/gcc/analyzer/region-model-impl-calls.cc +++ b/gcc/analyzer/region-model-impl-calls.cc @@ -49,6 +49,7 @@ along with GCC; see the file COPYING3. If not see #include "options.h" #include "cgraph.h" #include "cfg.h" +#include "toplev.h" #include "digraph.h" #include "analyzer/supergraph.h" #include "sbitmap.h" diff --git a/gcc/analyzer/region-model-manager.cc b/gcc/analyzer/region-model-manager.cc index 55acb90da73..1f511d8610a 100644 --- a/gcc/analyzer/region-model-manager.cc +++ b/gcc/analyzer/region-model-manager.cc @@ -49,6 +49,7 @@ along with GCC; see the file COPYING3. If not see #include "options.h" #include "cgraph.h" #include "cfg.h" +#include "toplev.h" #include "digraph.h" #include "analyzer/supergraph.h" #include "sbitmap.h" diff --git a/gcc/analyzer/region-model-reachability.cc b/gcc/analyzer/region-model-reachability.cc index e165cda014f..29e2dbcef6d 100644 --- a/gcc/analyzer/region-model-reachability.cc +++ b/gcc/analyzer/region-model-reachability.cc @@ -46,6 +46,7 @@ along with GCC; see the file COPYING3. If not see #include "options.h" #include "cgraph.h" #include "cfg.h" +#include "toplev.h" #include "digraph.h" #include "json.h" #include "analyzer/call-string.h" diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc index 4fb6bc9f747..ddd8370def4 100644 --- a/gcc/analyzer/region-model.cc +++ b/gcc/analyzer/region-model.cc @@ -49,6 +49,7 @@ along with GCC; see the file COPYING3. If not see #include "options.h" #include "cgraph.h" #include "cfg.h" +#include "toplev.h" #include "digraph.h" #include "analyzer/supergraph.h" #include "sbitmap.h" diff --git a/gcc/analyzer/region.cc b/gcc/analyzer/region.cc index 46337179162..c340c448ba7 100644 --- a/gcc/analyzer/region.cc +++ b/gcc/analyzer/region.cc @@ -51,6 +51,7 @@ along with GCC; see the file COPYING3. If not see #include "options.h" #include "cgraph.h" #include "cfg.h" +#include "toplev.h" #include "digraph.h" #include "analyzer/supergraph.h" #include "sbitmap.h" diff --git a/gcc/analyzer/sm-signal.cc b/gcc/analyzer/sm-signal.cc index 42be8094997..f1e0aed380a 100644 --- a/gcc/analyzer/sm-signal.cc +++ b/gcc/analyzer/sm-signal.cc @@ -48,6 +48,7 @@ along with GCC; see the file COPYING3. If not see #include "analyzer/region-model.h" #include "analyzer/program-state.h" #include "analyzer/checker-path.h" +#include "toplev.h" #include "digraph.h" #include "cfg.h" #include "gimple-iterator.h" diff --git a/gcc/analyzer/state-purge.cc b/gcc/analyzer/state-purge.cc index 70a09ed581f..9a72c68f277 100644 --- a/gcc/analyzer/state-purge.cc +++ b/gcc/analyzer/state-purge.cc @@ -40,6 +40,7 @@ along with GCC; see the file COPYING3. If not see #include "json.h" #include "analyzer/analyzer.h" #include "analyzer/call-string.h" +#include "toplev.h" #include "digraph.h" #include "ordered-hash-map.h" #include "cfg.h" diff --git a/gcc/analyzer/store.cc b/gcc/analyzer/store.cc index a65c7415b1b..91b2aaf5d34 100644 --- a/gcc/analyzer/store.cc +++ b/gcc/analyzer/store.cc @@ -49,6 +49,7 @@ along with GCC; see the file COPYING3. If not see #include "options.h" #include "cgraph.h" #include "cfg.h" +#include "toplev.h" #include "digraph.h" #include "analyzer/supergraph.h" #include "sbitmap.h" diff --git a/gcc/analyzer/supergraph.cc b/gcc/analyzer/supergraph.cc index 8611d0f8689..2d9b914423e 100644 --- a/gcc/analyzer/supergraph.cc +++ b/gcc/analyzer/supergraph.cc @@ -49,6 +49,7 @@ along with GCC; see the file COPYING3. If not see #include "options.h" #include "cgraph.h" #include "cfg.h" +#include "toplev.h" #include "digraph.h" #include "analyzer/supergraph.h" #include "analyzer/analyzer-logging.h" diff --git a/gcc/analyzer/svalue.cc b/gcc/analyzer/svalue.cc index 6c8afef461b..8b44dd02652 100644 --- a/gcc/analyzer/svalue.cc +++ b/gcc/analyzer/svalue.cc @@ -48,6 +48,7 @@ along with GCC; see the file COPYING3. If not see #include "options.h" #include "cgraph.h" #include "cfg.h" +#include "toplev.h" #include "digraph.h" #include "analyzer/call-string.h" #include "analyzer/program-point.h" diff --git a/gcc/analyzer/trimmed-graph.cc b/gcc/analyzer/trimmed-graph.cc index 2e23a0960b6..0a517d86981 100644 --- a/gcc/analyzer/trimmed-graph.cc +++ b/gcc/analyzer/trimmed-graph.cc @@ -53,6 +53,7 @@ along with GCC; see the file COPYING3. If not see #include "gimple.h" #include "gimple-iterator.h" #include "cgraph.h" +#include "toplev.h" #include "digraph.h" #include "analyzer/supergraph.h" #include "analyzer/program-state.h" diff --git a/gcc/digraph.cc b/gcc/digraph.cc index e6966b076ca..162d58b98d1 100644 --- a/gcc/digraph.cc +++ b/gcc/digraph.cc @@ -23,6 +23,7 @@ along with GCC; see the file COPYING3. If not see #include "coretypes.h" #include "diagnostic.h" #include "graphviz.h" +#include "toplev.h" #include "digraph.h" #include "shortest-paths.h" #include "selftest.h" diff --git a/gcc/digraph.h b/gcc/digraph.h index 8b71b64a739..d1e13b7ab7f 100644 --- a/gcc/digraph.h +++ b/gcc/digraph.h @@ -217,6 +217,9 @@ digraph<GraphTraits>::dump_dot (const char *path, const dump_args_t &args) const { FILE *fp = fopen (path, "w"); + fprintf (fp, "/* graph generated by GNU GCC Compiler version\n"); + print_version (fp, " *", true); + fprintf (fp, "*/\n"); dump_dot_to_file (fp, root_cluster, args); fclose (fp); } diff --git a/gcc/graph.c b/gcc/graph.c index ce8de33ffe1..ee3b0c39613 100644 --- a/gcc/graph.c +++ b/gcc/graph.c @@ -30,6 +30,7 @@ along with GCC; see the file COPYING3. If not see #include "cfgloop.h" #include "graph.h" #include "dumpfile.h" +#include "toplev.h" /* DOT files with the .dot extension are recognized as document templates by a well-known piece of word processing software out of Redmond, WA. @@ -354,6 +355,9 @@ start_graph_dump (FILE *fp, const char *base) pretty_printer graph_slim_pp; graph_slim_pp.buffer->stream = fp; pretty_printer *const pp = &graph_slim_pp; + fprintf (fp, "/* graph generated by GNU GCC Compiler version\n"); + print_version (fp, " *", true); + fprintf (fp, "*/\n"); pp_string (pp, "digraph \""); pp_write_text_to_stream (pp); pp_string (pp, base); diff --git a/gcc/toplev.c b/gcc/toplev.c index 43f1f7d345e..adbb56f1681 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -1930,6 +1930,9 @@ lang_dependent_init (const char *name) { callgraph_info_file = open_auxiliary_file ("ci"); /* Write the file header. */ + fprintf (callgraph_info_file,"/* callgraph generated by GNU GCC Compiler -fcallgraph-info option version\n"); + print_version (callgraph_info_file, " *", true); + fprintf (callgraph_info_file, "*/\n"); fprintf (callgraph_info_file, "graph: { title: \"%s\"\n", main_input_filename); bitmap_obstack_initialize (NULL);