llvm.org GIT mirror llvm / 20813e0
First stab at updating the documentation for INITIALIZE_PASS(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109055 91177308-0d34-0410-b5e6-96231b3b80d8 Owen Anderson 9 years ago
1 changed file(s) with 7 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
289289 initialization value is not important.


292 RegisterPass<Hello> X("hello", "Hello World Pass",
292 INITIALIZE_PASS(Hello, "hello", "Hello World Pass",
293293 false /* Only looks at CFG */,
294294 false /* Analysis Pass */);
295295 } // end of anonymous namespace

Lastly, we register our class Hello,

299299 giving it a command line
300300 argument "hello", and a name "Hello World Pass".
301 Last two RegisterPass arguments are optional. Their default value is false.
301 Last two arguments describe its behavior.
302302 If a pass walks CFG without modifying it then third argument is set to true.
303303 If a pass is an analysis pass, for example dominator tree pass, then true
304304 is supplied as fourth argument.

325325 };
327327 char Hello::ID = 0;
328 RegisterPass<Hello> X("hello", "Hello World Pass");
328 INITIALIZE_PASS(Hello, "Hello", "Hello World Pass", false, false);
329329 }

Now that it's all together, compile the file with a simple "gmake"


Now that you have a brand new shiny shared object file, we can use the

349350 opt command to run an LLVM program through your pass. Because you
350 registered your pass with the RegisterPass template, you will be able to
351 registered your pass with the INITIALIZE_PASS macro, you will be able to
351352 use the opt tool to access it, once loaded.


To test it, follow the example at the end of the

965966 pass registration works, and discussed some of the reasons that it is used and
966967 what it does. Here we discuss how and why passes are registered.


As we saw above, passes are registered with the RegisterPass

969 template, which requires you to pass at least two
970 parameters. The first parameter is the name of the pass that is to be used on

As we saw above, passes are registered with the INITIALIZE_PASS

970 macro. The first parameter is the name of the pass that is to be used on
971971 the command line to specify that the pass should be added to a program (for
972972 example, with opt or bugpoint). The second argument is the
973973 name of the pass, which is to be used for the -help output of