aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAlexandre Oliva <oliva@adacore.com>2024-08-22 01:27:55 -0300
committerAlexandre Oliva <oliva@gnu.org>2024-08-22 01:27:55 -0300
commit23496098bba769044ed352c0d7bdb317477c16ac (patch)
tree87fbb3a4d6c4986460fef41e0b764cf259d5556d /gcc
parentc1aba5e7e7da5f2bd75873d3853f1de85addc2ac (diff)
downloadgcc-23496098bba769044ed352c0d7bdb317477c16ac.zip
gcc-23496098bba769044ed352c0d7bdb317477c16ac.tar.gz
gcc-23496098bba769044ed352c0d7bdb317477c16ac.tar.bz2
Dump aliases in -fcallgraph-info
Dump ICF-unified decls, thunks, aliases and whatnot along with their ultimate targets, with edges from the alias to the target. Add support for dropping the source file's suffix when forming from dump-base, so that auxiliary files can be scanned, such as the .ci files generated by -fcallgraph-info, as in the testcase. for gcc/ChangeLog * toplev.cc (dump_final_alias_vcg): New. (dump_final_node_vcg): Dump aliases along with node. for gcc/testsuite/ChangeLog * lib/scandump.exp (dump-base): Support {} in dump base suffix to drop it. * gcc.dg/callgraph-info-1.c: New.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gcc.dg/callgraph-info-1.c7
-rw-r--r--gcc/testsuite/lib/scandump.exp4
-rw-r--r--gcc/toplev.cc37
3 files changed, 48 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/callgraph-info-1.c b/gcc/testsuite/gcc.dg/callgraph-info-1.c
new file mode 100644
index 0000000..853ff95
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/callgraph-info-1.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "-fcallgraph-info" } */
+
+void f() {}
+void g() __attribute__ ((__alias__ ("f")));
+
+/* { dg-final { scan-dump-times "ci" "triangle" 1 "ci" {{}} } } */
diff --git a/gcc/testsuite/lib/scandump.exp b/gcc/testsuite/lib/scandump.exp
index 14536ae..adf9886 100644
--- a/gcc/testsuite/lib/scandump.exp
+++ b/gcc/testsuite/lib/scandump.exp
@@ -37,6 +37,10 @@ proc dump-base { args } {
# gcc-defs to base compilation dumps only on the source basename.
set dumpbase $src
if { [string length $dumpbase_suf] != 0 } {
+ # Accept {} as dump base suffix to drop the source suffix entirely.
+ if { "$dumpbase_suf" == "{}" } {
+ set dumpbase_suf ""
+ }
regsub {[.][^.]*$} $src $dumpbase_suf dumpbase
}
return $dumpbase
diff --git a/gcc/toplev.cc b/gcc/toplev.cc
index eee4805..f308fb1 100644
--- a/gcc/toplev.cc
+++ b/gcc/toplev.cc
@@ -914,6 +914,37 @@ dump_final_callee_vcg (FILE *f, location_t location, tree callee)
fputs ("\" }\n", f);
}
+/* Callback for cgraph_node::call_for_symbol_thunks_and_aliases to dump to F_ a
+ node and an edge from ALIAS->DECL to CURRENT_FUNCTION_DECL. */
+
+static bool
+dump_final_alias_vcg (cgraph_node *alias, void *f_)
+{
+ FILE *f = (FILE *)f_;
+
+ if (alias->decl == current_function_decl)
+ return false;
+
+ dump_final_node_vcg_start (f, alias->decl);
+ fputs ("\" shape : triangle }\n", f);
+
+ fputs ("edge: { sourcename: \"", f);
+ print_decl_identifier (f, alias->decl, PRINT_DECL_UNIQUE_NAME);
+ fputs ("\" targetname: \"", f);
+ print_decl_identifier (f, current_function_decl, PRINT_DECL_UNIQUE_NAME);
+ location_t location = DECL_SOURCE_LOCATION (alias->decl);
+ if (LOCATION_LOCUS (location) != UNKNOWN_LOCATION)
+ {
+ expanded_location loc;
+ fputs ("\" label: \"", f);
+ loc = expand_location (location);
+ fprintf (f, "%s:%d:%d", loc.file, loc.line, loc.column);
+ }
+ fputs ("\" }\n", f);
+
+ return false;
+}
+
/* Dump final cgraph node in VCG format. */
static void
@@ -950,6 +981,12 @@ dump_final_node_vcg (FILE *f)
dump_final_callee_vcg (f, c->location, c->decl);
vec_free (cfun->su->callees);
cfun->su->callees = NULL;
+
+ cgraph_node *node = cgraph_node::get (current_function_decl);
+ if (!node)
+ return;
+ node->call_for_symbol_thunks_and_aliases (dump_final_alias_vcg, f,
+ true, false);
}
/* Output stack usage and callgraph info, as requested. */