I am creating a pass using GCC plugins, this is my pass :
static const struct pass_data calls_printer_pass_data = {
.type = GIMPLE_PASS,
.name = "calls_printer",
.optinfo_flags = OPTGROUP_NONE,
.has_gate = false,
.has_execute = true,
.tv_id = TV_NONE,
.properties_required = 0,
.properties_provided = 0,
.properties_destroyed = 0,
.todo_flags_start = 0,
.todo_flags_finish = 0
};
class calls_printer_pass : public gimple_opt_pass {
public:
calls_printer_pass() : gimple_opt_pass(calls_printer_pass_data, g) {}
unsigned int execute() { return toto(); }
};
int plugin_init (plugin_name_args* plugin_info,
plugin_gcc_version* ver)
{
cerr << "starting " << plugin_info->base_name << endl;
const char * const plugin_name = plugin_info->base_name;
const int argc = plugin_info->argc;
const struct plugin_argument * const argv = plugin_info->argv;
struct register_pass_info calls_printer_info;
calls_printer_info.pass = new calls_printer_pass();
calls_printer_info.reference_pass_name = "ssa" ;
calls_printer_info.ref_pass_instance_number = 1;
calls_printer_info.pos_op = PASS_POS_INSERT_AFTER;
register_callback (plugin_name,
PLUGIN_PASS_MANAGER_SETUP,
NULL,
&calls_printer_info);
return 0;
}
so toto() is executed for each function defined, is it possible to get the number of all functions when executing toto()
if not, how can I execute the pass only one time for the whole file, and loop trough all the functions using FOR_EACH_FUNCTION() ?