Hello,
I am trying to find out the arguments of functions which are undefined
during LTO.
Basically:
gcc_assert(in_lto_p && !cnode->definition)
// Do we have arguments?
gcc_assert(DECL_ARGUMENTS(cnode->decl)) // fails
// No, we don't.
As I understand it, functions which are not defined are ones which have
have been declared external.
I believe that, when building an application with -flto, the only
functions which are not visible during LTO **and** are declared external
are functions defined in libraries which have not been compiled with
-flto. An example of this is glibc.
Indeed, I have implemented an analysis pass in gcc which prints out
undefined functions, and it prints out the following:
undefined function __gcov_merge_add
undefined function fopen
undefined function printf
undefined function __builtin_putchar
undefined function calloc
undefined function __gcov_merge_topn
undefined function strtol
undefined function free
... and more
Now, I am not interested in the bodies of these. I am only interested in
determining the type of the arguments passed to these functions.
However, when I call the following function:
```
void
print_parameters_undefined_functions(const cgraph_node *cnode)
{
gcc_assert(cnode);
gcc_assert(in_lto_p);
gcc_assert(!cnode->definition);
tree function = cnode->decl;
gcc_assert(function);
enum tree_code code = TREE_CODE (function);
bool is_function_decl = FUNCTION_DECL == code;
gcc_assert (is_function_decl);
log("about to print decl_arguments(%s)\n", cnode->name());
for (tree parm = DECL_ARGUMENTS (function); parm; parm =
DECL_CHAIN(parm))
{
log("hello world\n");
}
```
I never see "hello world" but I do see "about to print...".
Does anyone have any idea on how to obtain the arguments to undefined
functions?
The only way I see to do this, is to walk through the gimple
instructions, find GIMPLE_CALL statements and look at the argument list
at that moment. But I was wondering if there's a more efficient way to
do it.
Thanks!