From c8603c24442e643971585b53688aa88ec4ddc4ad Mon Sep 17 00:00:00 2001
From: Chris Lattner This makefile specifies that all of the .cpp files in the current
directory are to be compiled and linked together into a
Debug/lib/Hello.so shared object that can be dynamically loaded by
-the opt or analyze tools via their -load options.
+the opt or bugpoint tools via their -load options.
If your operating system uses a suffix other than .so (such as windows or
Mac OS/X), the appropriate extension will be used.
@@ -194,7 +193,7 @@ include $(LEVEL)/Makefile.common
- RegisterOpt<Hello> X("hello", "Hello World Pass"); + RegisterPass<Hello> X("hello", "Hello World Pass"); } // end of anonymous namespace
Lastly, we register our class Hello, giving it a command line -argument "hello", and a name "Hello World Pass". There are -several different ways of registering your pass, -depending on what it is to be used for. For "optimizations" we use the -RegisterOpt template.
+Lastly, we register our class Hello, +giving it a command line +argument "hello", and a name "Hello World Pass".
As a whole, the .cpp file looks like:
@@ -297,7 +294,7 @@ depending on what it is to be used for. For "optimizations" we use the } }; - RegisterOpt<Hello> X("hello", "Hello World Pass"); + RegisterPass<Hello> X("hello", "Hello World Pass"); } @@ -312,14 +309,14 @@ them) to be useful.Now that you have a brand new shiny shared object file, we can use the opt command to run an LLVM program through your pass. Because you -registered your pass with the RegisterOpt template, you will be able to +registered your pass with the RegisterPass template, you will be able to use the opt tool to access it, once loaded.
To test it, follow the example at the end of the Function or its contents from a pass registration works, and discussed some of the reasons that it is used and what it does. Here we discuss how and why passes are registered.
-Passes can be registered in several different ways. Depending on the general -classification of the pass, you should use one of the following templates to -register the pass:
- -Regardless of how you register your pass, you must specify at least two +
As we saw above, passes are registered with the RegisterPass +template, which requires you to pass at least two parameters. The first parameter is the name of the pass that is to be used on the command line to specify that the pass should be added to a program (for -example opt or analyze). The second argument is the name of -the pass, which is to be used for the --help output of programs, as +example, with opt or bugpoint). The second argument is the +name of the pass, which is to be used for the --help output of +programs, as well as for debug output generated by the --debug-pass option.
-If a pass is registered to be used by the analyze utility, you -should implement the virtual print method:
+If you want your pass to be easily dumpable, you should +implement the virtual print method:
The print method must be implemented by "analyses" in order to print a human readable version of the analysis results. This is useful for debugging an analysis itself, as well as for other people to figure out how an analysis -works. The analyze tool uses this method to generate its output.
+works. Use the opt -analyze argument to invoke this method.The ostream parameter specifies the stream to write the results on, and the Module parameter gives a pointer to the top level module of the @@ -1181,7 +1158,7 @@ implementations of the interface by using the following code:
namespace { // Analysis Group implementations must be registered normally... - RegisterOpt<FancyAA> + RegisterPass<FancyAA> B("somefancyaa", "A more complex alias analysis implementation"); // Declare that we implement the AliasAnalysis interface @@ -1199,7 +1176,7 @@ no problem.namespace { // Analysis Group implementations must be registered normally... - RegisterOpt<BasicAliasAnalysis> + RegisterPass<BasicAliasAnalysis> D("basicaa", "Basic Alias Analysis (default AA impl)"); // Declare that we implement the AliasAnalysis interface