[LLVMdev] Question about BlockFrequencyInfo

Bob Wilson bob.wilson at apple.com
Mon Sep 8 09:38:44 PDT 2014


> On 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.

Unless you are using profile-guided optimization (http://clang.llvm.org/docs/UsersManual.html#profile-guided-optimization <http://clang.llvm.org/docs/UsersManual.html#profile-guided-optimization>), the block frequency info is derived from heuristics, e.g., loop back edges are usually taken. You won’t get entry frequency data from those heuristics.

> 
> 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/20140908/8f0df68c/attachment.html>


More information about the llvm-dev mailing list