[LLVMdev] Basic Block API

John Criswell criswell at cs.uiuc.edu
Sat May 23 09:01:03 PDT 2009


Rotem Varon wrote:
> Hi,
>
> Is there an API for getting (within a basic block pass) the number of basic block in the program ?
>   
Not of which I am aware.  You will probably need to write code that does
this for you.

One place to put the code would be in the doInitialization() method of
the BasicBlockPass that you're writing.  However, I'm not sure if the
count would be accurate; other passes could invalidate the information
before the runOnBasicBlock() method is called by the PassManager.

Another method is to write a separate ModulePass that counts the number
of basic blocks.  Your pass could list it as a prerequisite, and the
PassManager would automatically run this separate ModulePass for you.

-- John T.

> Thanks.
>   




More information about the llvm-dev mailing list