[LLVMdev] question about the 3th and 4th arguments in the registration function

John Criswell jtcriswel at gmail.com
Tue Feb 3 11:20:15 PST 2015


On 2/3/15 2:03 PM, Hui Zhang wrote:
> Is there anyone who can clear my confusion ?

First, the Hello pass may not be setting the third and fourth arguments 
as it could be.

Second, regarding their use, the third argument tells the LLVM 
PassManager that this pass never modifies a function's control-flow 
graph while the fourth argument indicates that the pass never modifies 
the LLVM IR at all.

An analysis pass can (and probably should) set the third and fourth 
arguments to true.

A transform (i.e., optimization) pass that never modifies the CFG, even 
though it may modify other parts of a function, can safely set the third 
argument to true and the fourth argument to false.

The third and fourth arguments help the PassManager optimize pass 
scheduling.  Many analysis passes rely on the CFG and must be rerun if 
it is altered.  This is why the third argument exists; it tells the 
PassManager that the CFG is unmodified and that analysis passes using 
the CFG do not need to be invalidated.

The fourth argument tells the PassManager that a pass never modifies the 
program at all and can be safely run with other analysis passes.

In short, the arguments work exactly as described; the Hello example 
pass may not be setting them optimally, though.

Regards,

John Criswell

>
> thanks !
>
> On Mon, Feb 2, 2015 at 11:32 AM, Hui Zhang <wayne.huizhang at gmail.com 
> <mailto:wayne.huizhang at gmail.com>> wrote:
>
>     Hello,
>
>     I'm a little confused about the 3th and 4th arguments in the
>     registration function, explained here:
>     http://llvm.org/releases/3.3/docs/WritingAnLLVMPass.html
>
>     e.g
>
>     static  RegisterPass<Hello>  X("hello",  "Hello World Pass",
>                                   false  /* Only looks at CFG */,
>                                   false  /* Analysis Pass */);
>
>
>     "Lastly, we /register our class/
>     <http://llvm.org/releases/3.3/docs/WritingAnLLVMPass.html#writing-an-llvm-pass-registration>
>     Hello, giving it a command line argument “hello”, and a name
>     “Hello World Pass”. The last two arguments describe its behavior:
>     if a pass walks CFG without modifying it then the third argument
>     is set to true; if a pass is an analysis pass, for example
>     dominator tree pass, then true is supplied as the fourth argument."
>
>     In this simple "Hello" pass, it only look at all the functions and
>     print out their name. So what's the difference between 3th and 4th
>     argument here ??
>
>     And since Hello pass didn't modify the module but analized it(as I
>     understand), shouldn't both of them be true instead of false in
>     the example ??
>
>     thanks
>
>     -- 
>     Best regards
>
>
>     Hui Zhang
>
>
>
>
> -- 
> Best regards
>
>
> Hui Zhang
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev


-- 
John Criswell
Assistant Professor
Department of Computer Science, University of Rochester
http://www.cs.rochester.edu/u/criswell

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150203/00716018/attachment.html>


More information about the llvm-dev mailing list