[LLVMdev] Question about BlockFrequencyInfo

Manish Gupta mgupta.iitr at gmail.com
Sat Sep 6 21:30:23 PDT 2014


I am using llvm-prof. It prints very nice BB freq summaries.
Ex:  Top 20 most frequently executed basic blocks:

 ##      %% Frequency
  1. 32.3232%    32/99 _Z12func_sin_cosdd() - entry
  2. 32.3232%    32/99 main() - for.body
  3. 32.3232%    32/99 main() - for.body14
  4. 1.0101%     1/99 main() - entry
  5. 1.0101%     1/99 main() - for.cond12.preheader
  6. 1.0101%     1/99 main() - for.end20

http://llvm.org/releases/2.1/docs/CommandGuide/html/llvm-prof.html [I am
using llvm 3.3].


On Sat, Sep 6, 2014 at 8:43 PM, Vanderson Martins do Rosario <
vandersonmr2 at gmail.com> wrote:

> Hi everyone,
>
> I have been studying llvm for the last two weeks and I got stuck in some
> topics. I'm a little lost about where to look for information, for this
> reason I'm asking here. Sorry if it's not the right place to do that.
>
> I managed to do a toy compiler with bison and llvm, but now I need to do
> some others things:
>
> 1) I need discover the amount of times that each basic block is executed.
> I tried to use the BlockFrequencyInfo but I think I'm doing some thing
> wrong:
>  ....
>   BlockFrequencyInfo* BFI = new BlockFrequencyInfo();
>   FunctionPassManager FPM(module);
>   FPM.add(BFI);
>   FPM.doInitialization();
>
>   for(auto& func : *module) {
>     FPM.run(func);
>     for(auto& bb : func)
>       std::cout << BFI->getEntryFreq() << std::endl;
>   }
>
> This code just prints 0.
>
> And for example, if I want to do it (get the BasicBlock frequency)
> dynamically how could I proceed?
>
> 2) I saw that there is a MachineBasicBlock, what do I need to study to be
> able to get this blocks from BasicBlock?
>
> Thank you,
>
> Vanderson M. Rosario
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140906/4da654d3/attachment.html>


More information about the llvm-dev mailing list