Add ptr annotation intrinsic.
[oota-llvm.git] / docs / WritingAnLLVMPass.html
index 61bbba51361939e4b0652b12b17577cb8bbfa83e..486de6f631c7c6bcd6c929983ceea9059a0e92c6 100644 (file)
@@ -292,13 +292,19 @@ function.</p>
 initialization value is not important.</p>
 
 <div class="doc_code"><pre>
-  RegisterPass&lt;Hello&gt; X("<i>hello</i>", "<i>Hello World Pass</i>");
+  RegisterPass&lt;Hello&gt; X("<i>hello</i>", "<i>Hello World Pass</i>",
+                        false /* Only looks at CFG */,
+                        false /* Analysis Pass */);
 }  <i>// end of anonymous namespace</i>
 </pre></div>
 
 <p>Lastly, we <a href="#registration">register our class</a> <tt>Hello</tt>, 
 giving it a command line
-argument "<tt>hello</tt>", and a name "<tt>Hello World Pass</tt>".</p>
+argument "<tt>hello</tt>", and a name "<tt>Hello World Pass</tt>".
+Last two RegisterPass arguments are optional. Their default value is false.
+If a pass walks CFG without modifying it then third argument is set to true. 
+If  a pass is an analysis pass, for example dominator tree pass, then true 
+is supplied as fourth argument. </p>
 
 <p>As a whole, the <tt>.cpp</tt> file looks like:</p>
 
@@ -486,7 +492,8 @@ refering to function bodies in no predictable order, or adding and removing
 functions.  Because nothing is known about the behavior of <tt>ModulePass</tt>
 subclasses, no optimization can be done for their execution. A module pass
 can use function level passes (e.g. dominators) using getAnalysis interface
-<tt> getAnalysis&lt;DominatorTree&gt;(Function)</tt>. </p> 
+<tt> getAnalysis&lt;DominatorTree&gt;(Function)</tt>, if the function pass
+does not require any module passes. </p> 
 
 <p>To write a correct <tt>ModulePass</tt> subclass, derive from
 <tt>ModulePass</tt> and overload the <tt>runOnModule</tt> method with the
@@ -971,7 +978,7 @@ implement the virtual <tt>print</tt> method:</p>
 <div class="doc_text">
 
 <div class="doc_code"><pre>
-  <b>virtual void</b> print(llvm::OStream &amp;O, <b>const</b> Module *M) <b>const</b>;
+  <b>virtual void</b> print(std::ostream &amp;O, <b>const</b> Module *M) <b>const</b>;
 </pre></div>
 
 <p>The <tt>print</tt> method must be implemented by "analyses" in order to print
@@ -996,7 +1003,7 @@ depended on.</p>
 
 <div class="doc_text">
 
-<p>One of the main responsibilities of the <tt>PassManager</tt> is the make sure
+<p>One of the main responsibilities of the <tt>PassManager</tt> is to make sure
 that passes interact with each other correctly.  Because <tt>PassManager</tt>
 tries to <a href="#passmanager">optimize the execution of passes</a> it must
 know how the passes interact with each other and what dependencies exist between
@@ -1376,7 +1383,8 @@ the LLVM program representation for a single function at a time, instead of
 traversing the entire program.  It reduces the memory consumption of compiler,
 because, for example, only one <a
 href="http://llvm.org/doxygen/classllvm_1_1DominatorSet.html"><tt>DominatorSet</tt></a>
-needs to be calculated at a time.  This also makes it possible some <a
+needs to be calculated at a time.  This also makes it possible to implement
+some <a
 href="#SMP">interesting enhancements</a> in the future.</p></li>
 
 </ol>
@@ -1655,7 +1663,7 @@ MachinePassRegistry RegisterMyPasses::Registry;
 
 <div class="doc_code"><pre>
   cl::opt&lt;RegisterMyPasses::FunctionPassCtor, false,
-          RegisterPassParser&lt;RegisterMyPasses&gt &gt
+          RegisterPassParser&lt;RegisterMyPasses&gt; &gt;
   MyPassOpt("mypass",
             cl::init(&amp;createDefaultMyPass),
             cl::desc("my pass option help"));