How to register a gimple pass in a gcc-5.1.0 plugin?

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

 



Hi, I had no problem doing it for gcc 4.8.x and gcc 4.9.2, but it's
not the same for gcc 5.1.0 to me.

The syntax about how to register a pass it is almost the same than in 4.9.2.

Here is the the example what I'm trying to make work:

///////////////////////////// plug.cpp /////////////////////////////////////////

//some includes

int plugin_is_GPL_compatible;

static bool gateCheck(void)
{
    printf("AAAAA\n");
    return true;
}

static unsigned int executeCheck(void)
{
    printf("BBBBBB\n");
    return 0;
}

const pass_data gimplePass =
{
    GIMPLE_PASS,    // opt type name
    "exampleChecker",  // name
    OPTGROUP_NONE,  // optinfo_flags
    TV_NONE,        // tv_id
    PROP_ssa,       // properties_required
    0,              // properties_provided
    0,              // properties_destroyed
    0,              // todo_flags_start
    0,              // todo_flags_finish
};

class passAttrChecker : public gimple_opt_pass
{
public:
    passAttrChecker(gcc::context* ctxt)
        : gimple_opt_pass(gimplePass, ctxt)
    {}

    bool gate (){return gateCheck();}
    unsigned int execute(){return executeCheck();}
};

extern int plugin_init(struct plugin_name_args* plugin_info,
                struct plugin_gcc_version* version)
{
    const char * name = "example";
    struct register_pass_info pass_info;
    pass_info.pass = new passAttrChecker(g);
    pass_info.reference_pass_name = "ssa";
    pass_info.ref_pass_instance_number = 1;
    pass_info.pos_op = PASS_POS_INSERT_AFTER;
    register_callback(name, PLUGIN_PASS_MANAGER_SETUP, NULL, &pass_info);
    return 0;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////

When compiling some file with this example plugin, it should be
printed some A's and B's but nothing is happening. I don't know if I'm
forgettiing something or what, but for some reason this is not
working.

If you know why this is happening I will apreciate your help.

Regards,
Andres




[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