Update docs for bitcode changes. For object size checking we won't
[oota-llvm.git] / docs / AliasAnalysis.html
index d137ffe5f39927c23bf0f59e4265266bbd2cd1eb..ebf638689824b25d14329364439194cbf497e15f 100644 (file)
@@ -36,7 +36,7 @@
 
   <li><a href="#using">Using alias analysis results</a>
     <ul>
-    <li><a href="#loadvn">Using the <tt>-load-vn</tt> Pass</a></li>
+    <li><a href="#memdep">Using the <tt>MemoryDependenceAnalysis</tt> Pass</a></li>
     <li><a href="#ast">Using the <tt>AliasSetTracker</tt> class</a></li>
     <li><a href="#direct">Using the <tt>AliasAnalysis</tt> interface directly</a></li>
     </ul>
@@ -50,6 +50,7 @@
     implementations</a></li>
     </ul>
   </li>
+  <li><a href="#memdep">Memory Dependence Analysis</a></li>
 </ol>
 
 <div class="doc_author">
@@ -70,12 +71,12 @@ memory.  There are many different algorithms for alias analysis and many
 different ways of classifying them: flow-sensitive vs flow-insensitive,
 context-sensitive vs context-insensitive, field-sensitive vs field-insensitive,
 unification-based vs subset-based, etc.  Traditionally, alias analyses respond
-to a query with a <a href="#MustNoMay">Must, May, or No</a> alias response,
+to a query with a <a href="#MustMayNo">Must, May, or No</a> alias response,
 indicating that two pointers always point to the same object, might point to the
 same object, or are known to never point to the same object.</p>
 
 <p>The LLVM <a
-href="http://llvm.cs.uiuc.edu/doxygen/classllvm_1_1AliasAnalysis.html"><tt>AliasAnalysis</tt></a>
+href="http://llvm.org/doxygen/classllvm_1_1AliasAnalysis.html"><tt>AliasAnalysis</tt></a>
 class is the primary interface used by clients and implementations of alias
 analyses in the LLVM system.  This class is the common interface between clients
 of alias analysis information and the implementations providing it, and is
@@ -102,7 +103,7 @@ know</a>.</p>
 <div class="doc_text">
 
 <p>The <a
-href="http://llvm.cs.uiuc.edu/doxygen/classllvm_1_1AliasAnalysis.html"><tt>AliasAnalysis</tt></a>
+href="http://llvm.org/doxygen/classllvm_1_1AliasAnalysis.html"><tt>AliasAnalysis</tt></a>
 class defines the interface that the various alias analysis implementations
 should support.  This class exports two important enums: <tt>AliasResult</tt>
 and <tt>ModRefResult</tt> which represent the result of an alias query or a
@@ -190,16 +191,20 @@ and returns MustAlias, MayAlias, or NoAlias as appropriate.
 </div>
 
 <div class="doc_text">
+<p>The NoAlias response is used when the two pointers refer to distinct objects,
+regardless of whether the pointers compare equal.  For example, freed pointers
+don't alias any pointers that were allocated afterwards.  As a degenerate case,
+pointers returned by malloc(0) have no bytes for an object, and are considered
+NoAlias even when malloc returns the same pointer.  The same rule applies to
+NULL pointers.</p>
 
-<p>An Alias Analysis implementation can return one of three responses:
-MustAlias, MayAlias, and NoAlias.  The No and May alias results are obvious: if
-the two pointers can never equal each other, return NoAlias, if they might,
-return MayAlias.</p>
+<p>The MayAlias response is used whenever the two pointers might refer to the
+same object.  If the two memory objects overlap, but do not start at the same
+location, return MayAlias.</p>
 
-<p>The MustAlias response is trickier though.  In LLVM, the Must Alias response
-may only be returned if the two memory objects are guaranteed to always start at
-exactly the same location.  If two memory objects overlap, but do not start at
-the same location, return MayAlias.</p>
+<p>The MustAlias response may only be returned if the two memory objects are
+guaranteed to always start at exactly the same location. A MustAlias response
+implies that the pointers compare equal.</p>
 
 </div>
 
@@ -220,12 +225,7 @@ method for testing dependencies between function calls.  This method takes two
 call sites (CS1 &amp; CS2), returns NoModRef if the two calls refer to disjoint
 memory locations, Ref if CS1 reads memory written by CS2, Mod if CS1 writes to
 memory read or written by CS2, or ModRef if CS1 might read or write memory
-accessed by CS2.  Note that this relation is not commutative.  Clients that use
-this method should be predicated on the <tt>hasNoModRefInfoForCalls()</tt>
-method, which indicates whether or not an analysis can provide mod/ref
-information for function call pairs (most can not).  If this predicate is false,
-the client shouldn't waste analysis time querying the <tt>getModRefInfo</tt>
-method many times.</p>
+accessed by CS2.  Note that this relation is not commutative.</p>
 
 </div>
 
@@ -244,21 +244,6 @@ analysis implementations and can be put to good use by various clients.
 
 </div>
 
-<!-- _______________________________________________________________________ -->
-<div class="doc_subsubsection">
-  The <tt>getMustAliases</tt> method
-</div>
-
-<div class="doc_text">
-
-<p>The <tt>getMustAliases</tt> method returns all values that are known to
-always must alias a pointer.  This information can be provided in some cases for
-important objects like the null pointer and global values.  Knowing that a
-pointer always points to a particular function allows indirect calls to be
-turned into direct calls, for example.</p>
-
-</div>
-
 <!-- _______________________________________________________________________ -->
 <div class="doc_subsubsection">
   The <tt>pointsToConstantMemory</tt> method
@@ -274,7 +259,6 @@ memory location to be modified.</p>
 
 </div>
 
-
 <!-- _______________________________________________________________________ -->
 <div class="doc_subsubsection">
   <a name="simplemodref">The <tt>doesNotAccessMemory</tt> and
@@ -304,8 +288,6 @@ functions that satisfy the <tt>doesNotAccessMemory</tt> method also satisfies
 
 </div>
 
-
-
 <!-- *********************************************************************** -->
 <div class="doc_section">
   <a name="writingnew">Writing a new <tt>AliasAnalysis</tt> Implementation</a>
@@ -535,16 +517,16 @@ preference, these are...</p>
 
 <!-- ======================================================================= -->
 <div class="doc_subsection">
-  <a name="loadvn">Using the <tt>-load-vn</tt> Pass</a>
+  <a name="memdep">Using the <tt>MemoryDependenceAnalysis</tt> Pass</a>
 </div>
 
 <div class="doc_text">
 
-<p>The <tt>load-vn</tt> pass uses alias analysis to provide value numbering
-information for <tt>load</tt> instructions and pointer values.  If your analysis
-or transformation can be modeled in a form that uses value numbering
-information, you don't have to do anything special to handle load instructions:
-just use the <tt>load-vn</tt> pass, which uses alias analysis.</p>
+<p>The <tt>memdep</tt> pass uses alias analysis to provide high-level dependence
+information about memory-using instructions.  This will tell you which store
+feeds into a load, for example.  It uses caching and other techniques to be
+efficient, and is used by Dead Store Elimination, GVN, and memcpy optimizations.
+</p>
 
 </div>
 
@@ -708,7 +690,7 @@ aggressive local analysis that "knows" many important facts:</p>
 for internal global variables that don't "have their address taken".  If a
 global does not have its address taken, the pass knows that no pointers alias
 the global.  This pass also keeps track of functions that it knows never access
-memory or never read memory.  This allows certain optimizations (e.g. GCSE) to
+memory or never read memory.  This allows certain optimizations (e.g. GVN) to
 eliminate call instructions entirely.
 </p>
 
@@ -758,6 +740,9 @@ field-<b>sensitive</b>" version of Steensgaard's algorithm using the Data
 Structure Analysis framework.  This gives it substantially more precision than
 the standard algorithm while maintaining excellent analysis scalability.</p>
 
+<p>Note that <tt>-steens-aa</tt> is available in the optional "poolalloc"
+module, it is not part of the LLVM core.</p>
+
 </div>
 
 <!-- _______________________________________________________________________ -->
@@ -778,6 +763,9 @@ queries, and can provide context-sensitive mod/ref information as well.  The
 only major facility not implemented so far is support for must-alias
 information.</p>
 
+<p>Note that <tt>-ds-aa</tt> is available in the optional "poolalloc"
+module, it is not part of the LLVM core.</p>
+
 </div>
 
 
@@ -847,26 +835,14 @@ pointer.</p>
 
 <!-- _______________________________________________________________________ -->
 <div class="doc_subsubsection">
-  <a name="gcseloadvn">The <tt>-load-vn</tt> &amp; <tt>-gcse</tt> passes</a>
+  <a name="gvn">The <tt>-gvn</tt>, <tt>-memcpyopt</tt>, and <tt>-dse</tt>
+     passes</a>
 </div>
 
 <div class="doc_text">
 
-<p>The <tt>-load-vn</tt> pass uses alias analysis to "<a href="#loadvn">value
-number</a>" loads and pointers values, which is used by the GCSE pass to
-eliminate instructions.  The <tt>-load-vn</tt> pass relies on alias information
-and must-alias information.  This combination of passes can make the following
-transformations:</p>
-
-<ul>
-<li>Redundant load instructions are eliminated.</li>
-<li>Load instructions that follow a store to the same location are replaced with
-the stored value ("store forwarding").</li>
-<li>Pointers values (e.g. formal arguments) that must-alias simpler expressions
-(e.g. global variables or the null pointer) are replaced.  Note that this
-implements transformations like "virtual method resolution", turning indirect
-calls into direct calls.</li>
-</ul>
+<p>These passes use AliasAnalysis information to reason about loads and stores.
+</p>
 
 </div>
 
@@ -892,9 +868,15 @@ implementations.  You can use them with commands like '<tt>opt -anders-aa -ds-aa
 <div class="doc_text">
 
 <p>The <tt>-print-alias-sets</tt> pass is exposed as part of the
-<tt>analyze</tt> tool to print out the Alias Sets formed by the <a
+<tt>opt</tt> tool to print out the Alias Sets formed by the <a
 href="#ast"><tt>AliasSetTracker</tt></a> class.  This is useful if you're using
-the <tt>AliasSetTracker</tt> class.</p>
+the <tt>AliasSetTracker</tt> class.  To use it, use something like:</p>
+
+<div class="doc_code">
+<pre>
+% opt -ds-aa -print-alias-sets -disable-output
+</pre>
+</div>
 
 </div>
 
@@ -938,17 +920,35 @@ algorithm will have a lower number of may aliases).</p>
 
 </div>
 
+<!-- *********************************************************************** -->
+<div class="doc_section">
+  <a name="memdep">Memory Dependence Analysis</a>
+</div>
+<!-- *********************************************************************** -->
+
+<div class="doc_text">
+
+<p>If you're just looking to be a client of alias analysis information, consider
+using the Memory Dependence Analysis interface instead.  MemDep is a lazy, 
+caching layer on top of alias analysis that is able to answer the question of
+what preceding memory operations a given instruction depends on, either at an
+intra- or inter-block level.  Because of its laziness and caching 
+policy, using MemDep can be a significant performance win over accessing alias
+analysis directly.</p>
+
+</div>
+
 <!-- *********************************************************************** -->
 
 <hr>
 <address>
   <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
-  src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
+  src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS"></a>
   <a href="http://validator.w3.org/check/referer"><img
-  src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"></a>
+  src="http://www.w3.org/Icons/valid-html401-blue" alt="Valid HTML 4.01"></a>
 
   <a href="mailto:sabre@nondot.org">Chris Lattner</a><br>
-  <a href="http://llvm.cs.uiuc.edu">LLVM Compiler Infrastructure</a><br>
+  <a href="http://llvm.org">LLVM Compiler Infrastructure</a><br>
   Last modified: $Date$
 </address>