This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Basic Block Statistics
- From: Jeff Law <law at redhat dot com>
- To: Will Hawkins <whh8b at virginia dot edu>
- Cc: GCC Development <gcc at gcc dot gnu dot org>
- Date: Wed, 17 May 2017 11:02:08 -0600
- Subject: Re: Basic Block Statistics
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=law at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C718D7D4E6
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C718D7D4E6
- References: <CAE+MWFunCPEWzhmvOtuwo6L4C1vaS9r_L_eSHANx0fY8N2xgMw@mail.gmail.com> <60ef0242-a3ef-9d0c-5c9b-6cbe9c35305f@redhat.com> <CAE+MWFsUPwVY8V+edrEyS=1NWi_EZFQRE=QCUsjVwyGtDr=EHw@mail.gmail.com> <9c02d77c-246f-4584-7789-057563dd2aa4@redhat.com> <CAE+MWFvZ4nCadA5YFgBF-wOsPX=KXPrM8YC6O=nAGW-oxMxPKg@mail.gmail.com>
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