<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Sep 6, 2014, at 8:43 PM, Vanderson Martins do Rosario <<a href="mailto:vandersonmr2@gmail.com" class="">vandersonmr2@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi everyone,<br class=""><br class="">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.<br class=""><br class="">I managed to do a toy compiler with bison and llvm, but now I need to do some others things:<br class=""><br class="">1) I need discover the amount of times that each basic block is executed.<br class="">I tried to use the BlockFrequencyInfo but I think I'm doing some thing wrong:<br class=""> ....<br class="">  BlockFrequencyInfo* BFI = new BlockFrequencyInfo();<br class="">  FunctionPassManager FPM(module);<br class="">  FPM.add(BFI);<br class="">  FPM.doInitialization();<br class=""><br class="">  for(auto& func : *module) {<br class="">    FPM.run(func);<br class="">    for(auto& bb : func) <br class="">      std::cout << BFI->getEntryFreq() << std::endl;<br class="">  }<br class=""><br class="">This code just prints 0.<br class=""></div></div></blockquote><div><br class=""></div>Unless you are using profile-guided optimization (<a href="http://clang.llvm.org/docs/UsersManual.html#profile-guided-optimization" class="">http://clang.llvm.org/docs/UsersManual.html#profile-guided-optimization</a>), 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.</div><div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><br class="">And for example, if I want to do it (get the BasicBlock frequency) dynamically how could I proceed?<br class=""><br class="">2) I saw that there is a MachineBasicBlock, what do I need to study to be able to get this blocks from BasicBlock?<br class=""><br class="">Thank you,<br class=""><br clear="all" class=""><div class=""><div class=""><div class=""><div dir="ltr" class=""><span style="color:rgb(102,102,102)" class="">Vanderson M. Rosario</span><br class=""></div></div>
</div></div></div>
_______________________________________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:LLVMdev@cs.uiuc.edu" class="">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" class="">http://llvm.cs.uiuc.edu</a><br class=""><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" class="">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br class=""></div></blockquote></div><br class=""></body></html>