<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>LLVM Alias Analysis Infrastructure</title>
<link rel="stylesheet" href="llvm.css" type="text/css">
</head>
<body>
<h1>
LLVM Alias Analysis Infrastructure
</h1>
<ol>
<li><a href="#introduction">Introduction</a></li>
<li><a href="#overview"><tt>AliasAnalysis</tt> Class Overview</a>
<ul>
<li><a href="#pointers">Representation of Pointers</a></li>
<li><a href="#alias">The <tt>alias</tt> method</a></li>
<li><a href="#ModRefInfo">The <tt>getModRefInfo</tt> methods</a></li>
<li><a href="#OtherItfs">Other useful <tt>AliasAnalysis</tt> methods</a></li>
</ul>
</li>
<li><a href="#writingnew">Writing a new <tt>AliasAnalysis</tt> Implementation</a>
<ul>
<li><a href="#passsubclasses">Different Pass styles</a></li>
<li><a href="#requiredcalls">Required initialization calls</a></li>
<li><a href="#interfaces">Interfaces which may be specified</a></li>
<li><a href="#chaining"><tt>AliasAnalysis</tt> chaining behavior</a></li>
<li><a href="#updating">Updating analysis results for transformations</a></li>
<li><a href="#implefficiency">Efficiency Issues</a></li>
<li><a href="#limitations">Limitations</a></li>
</ul>
</li>
<li><a href="#using">Using alias analysis results</a>
<ul>
<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>
</li>
<li><a href="#exist">Existing alias analysis implementations and clients</a>
<ul>
<li><a href="#impls">Available <tt>AliasAnalysis</tt> implementations</a></li>
<li><a href="#aliasanalysis-xforms">Alias analysis driven transformations</a></li>
<li><a href="#aliasanalysis-debug">Clients for debugging and evaluation of
implementations</a></li>
</ul>
</li>
<li><a href="#memdep">Memory Dependence Analysis</a></li>
</ol>
<div class="doc_author">
<p>Written by <a href="mailto:sabre@nondot.org">Chris Lattner</a></p>
</div>
<!-- *********************************************************************** -->
<h2>
<a name="introduction">Introduction</a>
</h2>
<!-- *********************************************************************** -->
<div>
<p>Alias Analysis (aka Pointer Analysis) is a class of techniques which attempt
to determine whether or not two pointers ever can point to the same object in
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="#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.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
designed to support a wide range of implementations and clients (but currently
all clients are assumed to be flow-insensitive). In addition to simple alias
analysis information, this class exposes Mod/Ref information from those
implementations which can provide it, allowing for powerful analyses and
transformations to work well together.</p>
<p>This document contains information necessary to successfully implement this
interface, use it, and to test both sides. It also explains some of the finer
points about what exactly results mean. If you feel that something is unclear
or should be added, please <a href="mailto:sabre@nondot.org">let me
know</a>.</p>
</div>
<!-- *********************************************************************** -->
<h2>
<a name="overview"><tt>AliasAnalysis</tt> Class Overview</a>
</h2>
<!-- *********************************************************************** -->
<div>
<p>The <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
mod/ref query, respectively.</p>
<p>The <tt>AliasAnalysis</tt> interface exposes information about memory,
represented in several different ways. In particular, memory objects are
represented as a starting address and size, and function calls are represented
as the actual <tt>call</tt> or <tt>invoke</tt> instructions that perf