How to access both the source and target programs in gcc at the same time

Deepak Aggrawal
Sun Jul 14 15:41:00 GMT 2013

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 =
    "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 =

int plugin_init(struct plugin_name_args *plugin_info, struct
plugin_gcc_version *version)

        return 0;

On Tue, Jul 9, 2013 at 12:00 PM, Deepak Aggrawal
<> wrote:
> Hi,
> I need to access in-memory representation of both the source program(the
> program before compilation) and target program(the program after
> compilation) at the same time. If I add a plugin between two passes,say p1
> and p2, I will be able to access the program produced by only p1 but I would
> neither be able to access the program which was before executing p1 nor the
> program after p2. I want to compare the programs before and after
> compilation. How to do that?
> please help.

More information about the Gcc-help mailing list