question about the 3th and 4th arguments in the registration function

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 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

Is there anyone who can clear my confusion ?

thanks !

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