Basic Block Statistics

Will Hawkins
Wed May 17 17:04:00 GMT 2017

On Wed, May 17, 2017 at 1:02 PM, Jeff Law <> wrote:
> On 05/17/2017 10:36 AM, Will Hawkins wrote:
>> As I started looking into this, it seems like PLUGIN_FINISH is where
>> my plugin will go. Everything is great so far. However, when plugins
>> at that event are invoked, they get no data. That means I will have to
>> look into global structures for information regarding the compilation.
>> Are there pointers to the documentation that describe the relevant
>> global data structures that are accessible at this point?
>> I am looking through the source code and documentation and can't find
>> what I am looking for. I am happy to continue working, but thought I'd
>> ask just in case I was missing something silly.
>> Thanks again for all your help getting me started on this!
> FOR_EACH_BB (bb) is what you're looking for.  That will iterate over the
> basic blocks.

Thank you so much for your response!

I just found this as soon as you sent it. Sorry for wasting your time!

> Assuming you're running late, you'll then want to walk each insn within
> the bb.  So something like this
> basic_block bb
> FOR_EACH_BB (bb)
>   {
>     rtx_insn *insn;
>     FOR_BB_INSNS (bb, insn)
>       {
>         /* Do something with INSN.  */
>       }
>   }
> Note that if you're running too late the CFG may have been released, in
> which case this code wouldn't do anything.

I will just have to experiment to see exactly when the right time to
invoke this plugin to get the best data.

Thanks again!

> jeff

More information about the Gcc mailing list