Hi,
I am developing plugins for the GCC-4.8.2. I am a newbie in plugins.
I wrote a plugin and tried to count and see the Goto Statements using
the gimple_stmt_iterator. I get gimple statements printed on my
stdout, but I am not able to find the line which has goto statements.
I only get other lines such as variable declaration and logic
statements, but no goto statements.
When I open the Gimple/SSA/CFG file seperately using the vim editor
I find the goto statements are actually present.
So, can anyone help me. How can I actually get the count of Goto
statements or atleast access these goto statements using some
iterator.
I have used -fdump-tree-all, -fdump-tree-cfg as flags.
Here is the pseudocode:
struct register_pass_info pass_info = {
&(pass_plugin.pass), /* Address of new pass,
here, the 'struct
opt_pass' field of
'gimple_opt_pass'
defined above */
"ssa", /* Name of the reference
pass for hooking up
the new pass. ??? */
0, /* Insert the pass at the
specified instance
number of the reference
pass. Do it for
every instance if it is 0. */
PASS_POS_INSERT_AFTER /* how to insert the new
pass: before,
after, or replace. Here
we are inserting
a pass names 'plug' after
the pass named
'pta' */
};
.............
static unsigned int dead_code_elimination (void)
{
FOR_EACH_BB_FN (bb, cfun)
{
// gimple_dump_bb(stdout,bb,0,0);
// printf("\nIn New BB");
gsi2= gsi_after_labels (bb);
print_gimple_stmt(stdout,gsi_stmt(gsi2),0,0);
/*Iterating over each gimple statement in a basic block*/
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
{
g = gsi_stmt(gsi);
print_gimple_stmt(stdout,g,0,0);
if (gimple_code(g)==GIMPLE_GOTO)
printf("\nFound GOTO stmt\n");
print_gimple_stmt(stdout,gsi_stmt(gsi),0,0);
// analyze_gimple_statement (gsi);
}
}
}