This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Can Some one please help me on this gcc plugin..
- From: David Malcolm <dmalcolm at redhat dot com>
- To: Mohsin Khan <mohsin1510 at gmail dot com>
- Cc: gcc <gcc at gcc dot gnu dot org>
- Date: Wed, 05 Mar 2014 11:45:02 -0500
- Subject: Re: Can Some one please help me on this gcc plugin..
- Authentication-results: sourceware.org; auth=none
- References: <CAHzm3F-F1Az33dNLOdmfqie2zAATjLEf5j56r3zKz9cwP+Lq_Q at mail dot gmail dot com>
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