[LLVMdev] Question about BlockFrequencyInfo

Vanderson Martins do Rosario vandersonmr2 at gmail.com
Sat Sep 6 20:43:48 PDT 2014


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140907/eabf8b17/attachment.html>


More information about the llvm-dev mailing list