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: Basic Block Statistics


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.

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.

jeff


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