This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Help with TREE_PUBLIC
Hi all,
?I'm writing a plugin that simply prints the IDENTIFIER NODE of global
variable references in the given program. I am using TREE_PUBLIC to
check if the current variable being accessed is a global one. However
it is working for integer and float variables but doesn't seem to work
for data structures that are declared global. Can somebody please help
me in identifying data structures that are global and catch their
names.
I'm using the gimple statement iterator to go through each statement
of the basic blocks, then check if the statement is a gimple
assignment using is_gimple_assign and then check if either lhs or one
of rhs operands are global using TREE_PUBLIC on them. If either of
these operands in the gimple assignment statement is global then i'll
just need to print that variable. The code looks something like
this...
FOR_EACH_BB (bb)
{
for(gsi = gsi_start_bb (bb); !gsi_end_p(gsi);
gsi_next(&gsi))
{
gimple stmt = gsi_stmt(gsi);
if(is_gimple_assign(stmt))
{
if(TREE_PUBLIC(gimple_assign_lhs(stmt)) ||
TREE_PUBLIC(gimple_assign_rhs1(stmt)))
{
tree temp;
if(TREE_PUBLIC(gimple_assign_lhs(stmt)))
temp = gimple_assign_lhs(stmt);
else
temp = gimple_assign_rhs1(stmt);
printf("%s\n",IDENTIFIER_POINTER(DECL_NAME(temp)));
}
}
}
}
This is working fine for normal datatypes but failing for data structures.
Thanks,
Ajay.