This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Can Some one please help me on this gcc plugin..


On Wed, 2014-03-05 at 21:58 +0530, Mohsin Khan wrote:
> Hi,
> 
>  I am developing plugins for the GCC-4.8.2. I am a newbie in plugins.
> I wrote a plugin and tried to count and see the Goto Statements using
> the gimple_stmt_iterator. I get gimple statements printed on my
> stdout, but I am not able to find the line which has goto statements.
> I only get other lines such as variable declaration and logic
> statements, but no goto statements.
>   When I open the Gimple/SSA/CFG file seperately using the vim editor
> I find the goto statements are actually present.
>   So, can anyone help me. How can I actually get the count of Goto
> statements or atleast access these goto statements using some
> iterator.
>   I have used -fdump-tree-all, -fdump-tree-cfg as flags.
> 
> Here is the pseudocode:
> 
> struct register_pass_info pass_info = {
> &(pass_plugin.pass),                         /* Address of new pass,
> here, the 'struct
>                                              opt_pass' field of
> 'gimple_opt_pass'
>                                              defined above */
>         "ssa",                               /* Name of the reference
> pass for hooking up
>                                              the new pass.   ??? */
>         0,                                   /* Insert the pass at the
> specified instance
>                                              number of the reference
> pass. Do it for
>                                              every instance if it is 0. */
>         PASS_POS_INSERT_AFTER                /* how to insert the new
> pass: before,

You're inserting your pass after the "ssa" pass, which converts the CFG
to SSA form.  This is run *after* the function has been converted from a
flat list of gimple statements into a CFG of basic blocks, and that CFG
conversion eliminates the goto statements in favor of edges within the
CFG.  If you see "goto" in the dump, that's presumably just a textual
way of expressing an edge in the CFG.

To see gimple goto statements, you need to run your pass *before* the
convertion to CFG, which happens fairly early on, in the "cfg" pass

FWIW there's a diagram showing the passes here:
http://gcc-python-plugin.readthedocs.org/en/latest/tables-of-passes.html


Hope this is helpful
Dave


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]