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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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;
}

On Tue, Jul 9, 2013 at 12:00 PM, Deepak Aggrawal
<deepakkansal1989@xxxxxxxxx> 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.




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux