<div class="doc_code"><pre>
static char ID;
- Hello() : FunctionPass(&ID) {}
+ Hello() : FunctionPass(ID) {}
</pre></div><p>
<p> This declares pass identifier used by LLVM to identify pass. This allows LLVM to
initialization value is not important.</p>
<div class="doc_code"><pre>
- INITIALIZE_PASS(Hello, "<i>hello</i>", "<i>Hello World Pass</i>",
+ static RegisterPass<Hello> X("<i>hello</i>", "<i>Hello World Pass</i>",
false /* Only looks at CFG */,
false /* Analysis Pass */);
} <i>// end of anonymous namespace</i>
<b>struct Hello</b> : <b>public</b> <a href="#FunctionPass">FunctionPass</a> {
static char ID;
- Hello() : FunctionPass(&ID) {}
+ Hello() : FunctionPass(ID) {}
<b>virtual bool</b> <a href="#runOnFunction">runOnFunction</a>(Function &F) {
errs() << "<i>Hello: </i>" << F.getName() << "\n";
};
char Hello::ID = 0;
- INITIALIZE_PASS(Hello, "<i>Hello</i>", "<i>Hello World Pass</i>", false, false);
+ static RegisterPass<Hello> X("hello", "Hello World Pass", false, false);
}
</pre></div>
<p>Now that you have a brand new shiny shared object file, we can use the
<tt>opt</tt> command to run an LLVM program through your pass. Because you
-registered your pass with the <tt>INITIALIZE_PASS</tt> macro, you will be able to
+registered your pass with <tt>RegisterPass</tt>, you will be able to
use the <tt>opt</tt> tool to access it, once loaded.</p>
<p>To test it, follow the example at the end of the <a
<ol>
-<li>... <em>not allowed</em> to modify any <tt>Function</tt>s that are not in
-the current SCC.</li>
-
-<li>... <em>not allowed</em> to inspect any Function's other than those in the
-current SCC and the direct callees of the SCC.</li>
+<li>... <em>not allowed</em> to inspect or modify any <tt>Function</tt>s other
+than those in the current SCC and the direct callers and direct callees of the
+SCC.</li>
<li>... <em>required</em> to preserve the current CallGraph object, updating it
to reflect any changes made to the program.</li>
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.</p>
-<p>As we saw above, passes are registered with the <b><tt>INITIALIZE_PASS</tt></b>
-macro. The first parameter is the name of the pass that is to be used on
+<p>As we saw above, passes are registered with the <b><tt>RegisterPass</tt></b>
+template. The template 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, with <tt>opt</tt> or <tt>bugpoint</tt>). The second argument is the
+example, with <tt>opt</tt> or <tt>bugpoint</tt>). The first argument is the
name of the pass, which is to be used for the <tt>-help</tt> output of
programs, as
well as for debug output generated by the <tt>--debug-pass</tt> option.</p>
<div class="doc_text">
-<div class="doc_code"><pre>
- <i>// This is an example implementation from an analysis, which does not modify
- // the program at all, yet has a prerequisite.</i>
- <b>void</b> <a href="http://llvm.org/doxygen/classllvm_1_1PostDominanceFrontier.html">PostDominanceFrontier</a>::getAnalysisUsage(AnalysisUsage &AU) <b>const</b> {
- AU.setPreservesAll();
- AU.addRequired<<a href="http://llvm.org/doxygen/classllvm_1_1PostDominatorTree.html">PostDominatorTree</a>>();
- }
-</pre></div>
-
-<p>and:</p>
-
<div class="doc_code"><pre>
<i>// This example modifies the program, but does not modify the CFG</i>
<b>void</b> <a href="http://llvm.org/doxygen/structLICM.html">LICM</a>::getAnalysisUsage(AnalysisUsage &AU) <b>const</b> {
<li><b>Pipeline the execution of passes on the program</b> - The
<tt>PassManager</tt> attempts to get better cache and memory usage behavior out
of a series of passes by pipelining the passes together. This means that, given
-a series of consequtive <a href="#FunctionPass"><tt>FunctionPass</tt></a>'s, it
+a series of consecutive <a href="#FunctionPass"><tt>FunctionPass</tt></a>'s, it
will execute all of the <a href="#FunctionPass"><tt>FunctionPass</tt></a>'s on
the first function, then all of the <a
href="#FunctionPass"><tt>FunctionPass</tt></a>es on the second function,