This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: GCC plugin not executing
- From: Deepak Aggrawal <deepakkansal1989 at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Sun, 14 Jul 2013 20:43:37 +0530
- Subject: Re: GCC plugin not executing
- References: <CAEO_aHJARN6R-m1LOvGw9Jn=550Wv2+pZp+dSSKT4n4rDTcT5A at mail dot gmail dot com>
Problem Resolved
On Sun, Jul 14, 2013 at 7:43 PM, Deepak Aggrawal
<deepakkansal1989@gmail.com> wrote:
> I am trying to add a gimple pass, after "pre"-partial redundancy
> elimination pass. But when I execute the code below, it does not
> create file "myfile" and so does not write anything in the file. It
> seems like the plugin is not executing.
>
> Please check where I am wrong in this. Thanks in advance.
>
>
>
> #include "gcc-plugin.h"
> #include "config.h"
> #include "system.h"
> #include "alloc-pool.h"
> #include "params.h"
> #include "ggc.h"
> #include "coretypes.h"
> #include "tm.h"
> #include "tree.h"
> #include "tree-flow.h"
> #include "diagnostic.h"
> #include "tree-pass.h"
> #include "timevar.h"
> #include "cgraph.h"
> #include "gimple.h"
>
> int plugin_is_GPL_compatible = 1;
>
> static unsigned int execute_TV_plugin(void)
> {
> FILE *fp;
> FILE *cg;
> cg = fopen("cgdump","a");
> fp = fopen("myfile","a");
> fprintf(fp,"The plugin is executing !!\n");
> }
>
> struct gimple_opt_pass pass_TV =
> {
> {
> GIMPLE_PASS,
> "TV", /* name */
> NULL, /* gate */
> execute_TV_plugin, /* execute */
> NULL, /* sub */
> NULL, /* next */
> 0, /* static_pass_number */
> TV_INTEGRATION, /*tv_id*/
> 0, /* properties_required */
> 0, /* properties_provided */
> 0, /* properties_destroyed */
> 0, /* todo_flags_start */
> 0 /* todo_flags_finish */
> }
> };
>
> struct register_pass_info pass_info =
> {
> &(pass_TV.pass),
> "pre",
> 0,
> PASS_POS_INSERT_AFTER
> };
>
> int plugin_init(struct plugin_name_args *plugin_info, struct
> plugin_gcc_version *version)
> {
> register_callback(
> plugin_info->base_name,
> PLUGIN_PASS_MANAGER_SETUP,
> NULL,
> &pass_info);
>
> return 0;
>
> }