[LLVMdev] Basic Block API

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


Rotem Varon wrote:
> Hi,
>
> Thank you for your answer.
> But let me get it straight, when i compile code with the llvm compiler, and my basic block pass is being processed, other passes are concurrently being processed ?
>   
Currently, no.  The PassManager does not execute passes concurrently. 
However, it might in the future, which is why a BasicBlock pass must not
examine or modify anything outside of the BasicBlock that it is working
on (the doInitialization() and doFinalization() methods are exceptions
to the rule).

The purpose of the PassManager is to schedule the order of prerequisite
passes in order to minimize the number of times that they are executed.

For example, let's say I have three passes: A, B and C.  Each pass
requires analysis pass D.  Pass A preserves (does not invalidate) the
results of Pass D, but Pass B does invalidate the results of Pass D.

If I tell PassManager to run passes A, B, and C, it will examine all the
dependency and preservation information and run the following passes in
the following order:

D, A, B, D, C

-- John T.

> Thanks.
>
> On Sat, May 23, 2009 at 7:01 PM, John Criswell <criswell at cs.uiuc.edu<mailto:criswell at cs.uiuc.edu>> wrote:
> 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.
>>
>>     
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu<mailto:LLVMdev at cs.uiuc.edu>         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>   




More information about the llvm-dev mailing list