[LLVMdev] Question on parameters in RegisterPass

John Criswell jtcriswel at gmail.com
Mon Aug 11 05:46:53 PDT 2014


Dear Byungchang,

The OnlyCFG parameter tells the LLVM PassManager whether your pass 
modifies a function's control-flow graph (CFG) (i.e., does your pass 
change the branches between basic blocks or add or remove basic 
blocks).  The PassManager can avoid re-running analysis passes in some 
cases if the CFG is left unmodified.  If you're unsure of what to put in 
this field, put false.

Setting the AnalysisPass option to true tells the PassManager that your 
pass never modifies the program.  If it is set to false, a pass *may* 
modify the program (but it is not required to do so). If in doubt, set 
this to false.

Regards,

John Criswell


On 8/10/14, 9:39 PM, Byungchan An wrote:
> Hello. This is Byungchan An.
> I have a question on meaning of parameters in RegisterPass.
>
> In the LLVM Pass examples, I see the followings.
> static  RegisterPass<Hello>  X("hello",  "Hello World Pass",
>                               false  /* Only looks at CFG */,
>                               false  /* Analysis Pass */);
> Here I have one question, what means by only looking at CFG?
> If I set it third parameters as "true" what limitations I have?
>
> Second, the last parameter, Analysis Pass means it doesn't change IR 
> given as input. Am I right? Then, why the following example I got from 
> the llvm website set the last parameter as false?
>
> Thanks.
> #include "llvm/Pass.h"
> #include "llvm/IR/Function.h"
> #include "llvm/Support/raw_ostream.h"
>
> using  namespace  llvm;
>
> namespace  {
>    struct  Hello  :  public  FunctionPass  {
>      static  char  ID;
>      Hello()  :  FunctionPass(ID)  {}
>
>      virtual  bool  runOnFunction(Function  &F)  {
>        errs()  <<  "Hello:";
>        errs().write_escaped(F.getName())  <<  '\n';
>        return  false;
>      }
>    };
> }
>
> char  Hello::ID  =  0;
> static  RegisterPass<Hello>  X("hello",  "Hello World Pass",  false,  false);
>
>
> _______________________________________________
> 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/20140811/51333bb3/attachment.html>


More information about the llvm-dev mailing list