[llvm-dev] Queries Regarding Usage of PGOInstrumentation Passes instead of Deprecated ProfileInfo

Xinliang David Li via llvm-dev llvm-dev at lists.llvm.org
Wed Aug 15 12:08:40 PDT 2018


On Wed, Aug 15, 2018 at 7:36 AM Malhar Thakkar via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> Hey all,
>
> I have a piece of code (written in LLVM 2.8) which uses profiling results
> produced by ProfileInfo. It essentially computes the number of iterations
> performed by a loop from the profiling information available. The code
> snippet in my pass looks something like this.
>
>   BasicBlock *header = loop->getHeader();
>   ProfileInfo &pi = getAnalysis< ProfileInfo >();
>   for(pred_iterator i=pred_begin(header), e=pred_end(header); i!=e; ++i)
>   {
>     BasicBlock *pred = *i;
>
>     const double edgeCount = *pi.getEdgeWeight*( ProfileInfo::Edge(pred,header) );
>     */* Some code */*
>   }
>
> Now, since ProfileInfo has been deprecated and we have PGOInstrumentation
> passes along with BranchProbability and BlockFrequency, I wish to update
> the above snippet, in particular, obtaining the edge weights (highlighted
> in the code above) using the new tools.
>
> In order to do that, I'm first generating edge count profile by the
> PGOInstrumentationGen pass and then interpreting the edge count profile
> with PGOInstrumentationUse.
>
> In the original code, where I had
> au.addRequired< ProfileInfo >(), I now have
>
>
> *au.addRequired< BlockFrequencyInfoWrapperPass >();au.addRequired<
> BranchProbabilityInfoWrapperPass >();*
> Now, I have the following queries.
>
>    - How do I use the edge count and branch weights data obtained using
>    PGOInstrumentationUse in my pass and replace the *getEdgeWeight()*
>    from ProfileInfo?
>
>
You can do
 BPI.getEdgeProbability(Src, Dest).scale(BFI.getBlockProfileCount(Src));


>
>    - If I call *getBlockProfileCount() *from the BlockFrequency pass,
>    will that give me the data read during PGOInstrumentationUse or data based
>    on static analysis? In other words, does the data obtained during
>    PGOInstrumentationUse "propagate" to BlockFrequency and BranchProbability?
>
>
> Correct.

David



> Thank you.
>
>
> Regards,
> Malhar
>
>
>
>
>> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180815/507dc760/attachment.html>


More information about the llvm-dev mailing list