[llvm-dev] Profiling with LLVM.

Duncan P. N. Exon Smith via llvm-dev llvm-dev at lists.llvm.org
Thu Feb 4 09:13:49 PST 2016


It's up to the frontend (or whatever is generating the branch weights metadata) to scale the branch weights down appropriately.  You can have a look at how clang does it for an example (IIRC, it's in clang's lib/CodeGen/CodeGenPGO.cpp, but possibly just the caller is there and the scaling logic is somewhere in LLVM).

When are your counters overflowing?  If they overflow during an optimization pass, that sounds like a bug.

> On 2016-Feb-04, at 05:51, Giorgio Zacharo <giorgiozacharo at gmail.com> wrote:
> 
> Dear Duncan,
> 
> Thank you a lot for your feedback. I have a problem though. The branch weights counters overflow in some files and thus I get incorrect numbers. 
> Is there any way to find a workaround for that? Is is supposed to be a known bug or is it something that needs configuration on my part?
> 
> Again, thank you a lot for your reply.
> 
> Best Regards,
> Georgios Zacharopoulos
> 
> 2016-02-03 18:23 GMT+01:00 Duncan P. N. Exon Smith <dexonsmith at apple.com>:
> (Ideally you would have sent this to llvm-dev at lists.llvm.org (and
> CC'ed me) so that the answer is there for others to find in the
> archive.  If you have any follow-up questions, please add llvm-dev
> to the CC list.)
> 
> Assuming you already have branch weights, you should use the
> BlockFrequencyInfo analysis to calculate the block frequencies.  At
> the Machine level, there's a MachineBlockFrequencyInfo analysis.
> 
> The frequencies shouldn't be used in isolation, but with reference
> to each other.
> 
> Cheers,
> Duncan
> 
> > On 2016-Feb-03, at 00:43, Giorgio Zacharo <giorgiozacharo at gmail.com> wrote:
> >
> > Dear Duncan,
> >
> > My name is Georgios Zacharopoulos and I am a PhD student at University of Lugano, in Switzerland. I am currently working on a research project and for a part of it I need to use some profiling information generated by existing LLVM tools from the latest version of LLVM. In more detail, I am trying to map profiling information generated from LLVM (Profiling with instrumentation) to IR.
> > (http://clang.llvm.org/docs/UsersManual.html#profiling-with-instrumentation)
> >
> > Specifically, I want to annotate each Basic Block with its respective execution frequency. In order to accomplish that I am using the branch weight metadata annotated to conditional branches in the terminator instructions of Basic Blocks. These branch weight information as well as the entry counter of each function are generated by the already existing profiling tools of LLVM.
> >
> > Are you aware of such frequency annotation for each BB already existing? Do you know whether this is feasible using the information of the branch weights and the entry counters of functions? I want to verify that I am doing it in the correct way, but unfortunately I have not come up with a clean way to do this. If you could give me any tips regarding that, it would be extremely helpful to me.
> >
> > Thank you a lot in advance.
> >
> > --
> > Best Regards,
> > Georgios Zacharopoulos
> >
> > PhD student
> > Faculty of Informatics
> > Università della Svizzera italiana
> > Lugano, Switzerland
> 
> 
> 
> 
> -- 
> Best Regards,
> Georgios Zacharopoulos
> 
> PhD student
> Faculty of Informatics 
> Università della Svizzera italiana
> Lugano, Switzerland



More information about the llvm-dev mailing list