This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Obtaining a list of a function's aliases in GCC-4.7+
- From: "Bertram, Alexander" <alex at bedatadriven dot com>
- To: gcc-help <gcc-help at gcc dot gnu dot org>
- Date: Thu, 6 Oct 2016 10:53:51 +0200
- Subject: Obtaining a list of a function's aliases in GCC-4.7+
- Authentication-results: sourceware.org; auth=none
Hi all,
I'm starting the process of upgrading gcc-bridge's GCC plugin from
gcc-4.6 first to gcc-4.7 and possibly to gcc-4.8.
In moving to 4.7, the only thing I can't quite figure out is how to
obtain a list of aliases for a given function. For 4.6, this worked:
struct cgraph_node *cgn = cgraph_node(cfun->decl);
struct cgraph_node *n;
for (n = cgn->same_body; n; n = n->next)
json_string_value(IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(n->decl)));
I've managed to update this to the following for 4.7:
struct cgraph_node *cgn = cgraph_get_node(cfun->decl);
struct cgraph_node *n;
FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(n)
if(cgraph_alias_aliased_node(n) == cgn) {
if(DECL_ASSEMBLER_NAME_SET_P(n->decl)) {
json_string_value(IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(n->decl)));
}
}
But the expression DECL_ASSEMBLER_NAME(n->decl) leads to a segfault.
I think I must be misunderstanding something critical here. Is the
call graph still the best place to find a function's aliases? Is
DECL_ASSEMBLER_NAME_SET_P the wrong predicate?
Many thanks for any pointers!!
Alex