blob: 9f21196b2c77e3c16a2d80ef7de8b1e66802d938 [file] [log] [blame]
Chris Lattnerb512e9f2003-03-04 19:37:49 +00001<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
Misha Brukman283ff692003-10-22 23:27:16 +00002<html>
3<head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
5 <link rel="stylesheet" href="llvm.css" type="text/css" media="screen" />
6 <title>Alias Analysis Infrastructure in LLVM</title>
7</head>
Chris Lattnerb512e9f2003-03-04 19:37:49 +00008
Misha Brukman283ff692003-10-22 23:27:16 +00009<body>
Chris Lattnerb512e9f2003-03-04 19:37:49 +000010
Misha Brukman283ff692003-10-22 23:27:16 +000011<div class="doc_title">
12 Alias Analysis Infrastructure in LLVM
13</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +000014
15<ol>
16 <li><a href="#introduction">Introduction</a>
17
18 <li><a href="#overview">AliasAnalysis Overview</a>
19 <ul>
20 <li><a href="#pointers">Representation of Pointers</a>
21 <li><a href="#MustMayNo">Must, May, and No Alias Responses</a>
22 <li><a href="#ModRefInfo">The <tt>getModRefInfo</tt> methods</a>
23 </ul>
24
25 <li><a href="#writingnew">Writing a new AliasAnalysis Implementation</a>
26 <ul>
27 <li><a href="#passsubclasses">Different Pass styles</a>
28 <li><a href="#requiredcalls">Required initialization calls</a>
29 <li><a href="#interfaces">Interfaces which may be specified</a>
30 <li><a href="#chaining">The AliasAnalysis chaining behavior</a>
31 <li><a href="#implefficiency">Efficiency Issues</a>
32 </ul>
33
34 <li><a href="#using">Using AliasAnalysis results</a>
35 <ul>
36 <li><a href="#loadvn">Using the <tt>-load-vn</tt> Pass</a>
37 <li><a href="#ast">Using the <tt>AliasSetTracker</tt> class</a>
38 <li><a href="#direct">Using the AliasAnalysis interface directly</a>
39 </ul>
40 <li><a href="#tools">Helpful alias analysis related tools</a>
41 <ul>
42 <li><a href="#no-aa">The <tt>-no-aa</tt> pass</a>
43 <li><a href="#print-alias-sets">The <tt>-print-alias-sets</tt> pass</a>
44 <li><a href="#count-aa">The <tt>-count-aa</tt> pass</a>
45 <li><a href="#aa-eval">The <tt>-aa-eval</tt> pass</a>
46 </ul>
47 </ul>
48
49 <p><b>Written by <a href="mailto:sabre@nondot.org">Chris Lattner</a></b><p>
50</ol><p>
51
52
Chris Lattnerb512e9f2003-03-04 19:37:49 +000053<!-- *********************************************************************** -->
Misha Brukman283ff692003-10-22 23:27:16 +000054<div class="doc_section">
55 <a name="introduction">Introduction</a>
56</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +000057<!-- *********************************************************************** -->
58
Misha Brukman283ff692003-10-22 23:27:16 +000059<div class="doc_text">
60<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +000061Alias Analysis (or Pointer Analysis) is a technique which attempts to determine
62whether or not two pointers ever can point to the same object in memory.
63Traditionally, Alias Analyses respond to a query with either a <a
64href="#MustNoMay">Must, May, or No</a> alias response, indicating that two
65pointers do point to the same object, might point to the same object, or are
Misha Brukman283ff692003-10-22 23:27:16 +000066known not to point to the same object.
67</p>
68<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +000069The <a href="/doxygen/classAliasAnalysis.html">AliasAnalysis</a> class is the
70centerpiece of the LLVM Alias Analysis related infrastructure. This class is
71the common interface between clients of alias analysis information and the
72implementations providing it. In addition to simple alias analysis information,
73this class exposes Mod/Ref information from those implementations which can
74provide it, allowing for powerful analyses and transformations to work well
Misha Brukman283ff692003-10-22 23:27:16 +000075together.
76</p>
77<p>
Misha Brukman7eb05a12003-08-18 14:43:39 +000078This document contains information necessary to successfully implement this
Chris Lattnerb512e9f2003-03-04 19:37:49 +000079interface, use it, and to test both sides. It also explains some of the finer
80points about what exactly results mean. If you feel that something is unclear
Misha Brukman283ff692003-10-22 23:27:16 +000081or should be added, please <a href="mailto:sabre@nondot.org">let me
82know</a>.
83</p>
84</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +000085
86<!-- *********************************************************************** -->
Misha Brukman283ff692003-10-22 23:27:16 +000087<div class="doc_section">
88 <a name="overview">AliasAnalysis Overview</a>
89</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +000090<!-- *********************************************************************** -->
91
Misha Brukman283ff692003-10-22 23:27:16 +000092<div class="doc_text">
93<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +000094The <a href="/doxygen/classAliasAnalysis.html">AliasAnalysis</a> class defines
95the interface that Alias Analysis implementations should support. This class
96exports two important enums: <tt>AliasResult</tt> and <tt>ModRefResult</tt>
97which represent the result of an alias query or a mod/ref query,
Misha Brukman283ff692003-10-22 23:27:16 +000098respectively.
99</p>
100<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000101The AliasAnalysis interface exposes information about memory, represented in
102several different ways. In particular, memory objects are represented as a
103starting address and size, and function calls are represented as the actual
104<tt>call</tt> or <tt>invoke</tt> instructions that performs the call. The
105AliasAnalysis interface also exposes some helper methods which allow you to get
Misha Brukman283ff692003-10-22 23:27:16 +0000106mod/ref information for arbitrary instructions.
107</p>
108</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000109
110<!-- ======================================================================= -->
Misha Brukman283ff692003-10-22 23:27:16 +0000111<div class="doc_subsection">
112 <a name="pointers">Representation of Pointers</a>
113</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000114
Misha Brukman283ff692003-10-22 23:27:16 +0000115<div class="doc_text">
116<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000117Most importantly, the AliasAnalysis class provides several methods which are
118used to query whether or not pointers alias, whether function calls can modify
Misha Brukman283ff692003-10-22 23:27:16 +0000119or read memory, etc.
120</p>
121<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000122Representing memory objects as a starting address and a size is critically
123important for precise Alias Analyses. For example, consider this (silly) C
Misha Brukman283ff692003-10-22 23:27:16 +0000124code:
125</p>
126<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000127<pre>
128 int i;
129 char C[2];
130 char A[10];
131 /* ... */
132 for (i = 0; i != 10; ++i) {
133 C[0] = A[i]; /* One byte store */
134 C[1] = A[9-i]; /* One byte store */
135 }
136</pre>
Misha Brukman283ff692003-10-22 23:27:16 +0000137</p>
138<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000139In this case, the <tt>basicaa</tt> pass will disambiguate the stores to
140<tt>C[0]</tt> and <tt>C[1]</tt> because they are accesses to two distinct
141locations one byte apart, and the accesses are each one byte. In this case, the
142LICM pass can use store motion to remove the stores from the loop. In
Misha Brukman283ff692003-10-22 23:27:16 +0000143constrast, the following code:
144</p>
145<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000146<pre>
147 int i;
148 char C[2];
149 char A[10];
150 /* ... */
151 for (i = 0; i != 10; ++i) {
152 ((short*)C)[0] = A[i]; /* Two byte store! */
153 C[1] = A[9-i]; /* One byte store */
154 }
155</pre>
Misha Brukman283ff692003-10-22 23:27:16 +0000156</p>
157<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000158In this case, the two stores to C do alias each other, because the access to the
159<tt>&amp;C[0]</tt> element is a two byte access. If size information wasn't
160available in the query, even the first case would have to conservatively assume
Misha Brukman283ff692003-10-22 23:27:16 +0000161that the accesses alias.
162</p>
163</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000164
165<!-- ======================================================================= -->
Misha Brukman283ff692003-10-22 23:27:16 +0000166<div class="doc_subsection">
167 <a name="MustMayNo">Must, May, and No Alias Responses</a>
168</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000169
Misha Brukman283ff692003-10-22 23:27:16 +0000170<div class="doc_text">
171<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000172An Alias Analysis implementation can return one of three responses: MustAlias,
173MayAlias, and NoAlias. The No and May alias results are obvious: if the two
174pointers may never equal each other, return NoAlias, if they might, return
Misha Brukman283ff692003-10-22 23:27:16 +0000175MayAlias.
176</p>
177<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000178The Must Alias response is trickier though. In LLVM, the Must Alias response
179may only be returned if the two memory objects are guaranteed to always start at
180exactly the same location. If two memory objects overlap, but do not start at
Misha Brukman283ff692003-10-22 23:27:16 +0000181the same location, MayAlias must be returned.
182</p>
183</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000184
185<!-- ======================================================================= -->
Misha Brukman283ff692003-10-22 23:27:16 +0000186<div class="doc_subsection">
187 <a name="ModRefInfo">The <tt>getModRefInfo</tt> methods</a>
188</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000189
Misha Brukman283ff692003-10-22 23:27:16 +0000190<div class="doc_text">
191<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000192The <tt>getModRefInfo</tt> methods return information about whether the
193execution of an instruction can read or modify a memory location. Mod/Ref
194information is always conservative: if an action <b>may</b> read a location, Ref
Misha Brukman283ff692003-10-22 23:27:16 +0000195is returned.
196</p>
197</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000198
199<!-- *********************************************************************** -->
Misha Brukman283ff692003-10-22 23:27:16 +0000200<div class="doc_section">
201 <a name="writingnew">Writing a new AliasAnalysis Implementation</a>
202</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000203<!-- *********************************************************************** -->
204
Misha Brukman283ff692003-10-22 23:27:16 +0000205<div class="doc_text">
206<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000207Writing a new alias analysis implementation for LLVM is quite straight-forward.
208There are already several implementations that you can use for examples, and the
209following information should help fill in any details. For a minimal example,
210take a look at the <a href="/doxygen/structNoAA.html"><tt>no-aa</tt></a>
Misha Brukman283ff692003-10-22 23:27:16 +0000211implementation.
212</p>
213</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000214
215<!-- ======================================================================= -->
Misha Brukman283ff692003-10-22 23:27:16 +0000216<div class="doc_subsection">
217 <a name="passsubclasses">Different Pass styles</a>
218</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000219
Misha Brukman283ff692003-10-22 23:27:16 +0000220<div class="doc_text">
221<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000222The first step to determining what type of <a href="WritingAnLLVMPass.html">LLVM
223pass</a> you need to use for your Alias Analysis. As is the case with most
224other analyses and transformations, the answer should be fairly obvious from
Misha Brukman283ff692003-10-22 23:27:16 +0000225what type of problem you are trying to solve:
226</p>
227<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000228<ol>
Misha Brukman283ff692003-10-22 23:27:16 +0000229 <li>If you require interprocedural analysis, it should be a
230 <tt>Pass</tt>.</li>
231 <li>If you are a global analysis, subclass <tt>FunctionPass</tt>.</li>
232 <li>If you are a local pass, subclass <tt>BasicBlockPass</tt>.</li>
233 <li>If you don't need to look at the program at all, subclass
234 <tt>ImmutablePass</tt>.</li>
235</ol>
236</p>
237<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000238In addition to the pass that you subclass, you should also inherit from the
Misha Brukmanb4dd5392003-05-07 21:47:16 +0000239<tt>AliasAnalysis</tt> interface, of course, and use the
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000240<tt>RegisterAnalysisGroup</tt> template to register as an implementation of
Misha Brukman283ff692003-10-22 23:27:16 +0000241<tt>AliasAnalysis</tt>.
242</p>
243</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000244
245<!-- ======================================================================= -->
Misha Brukman283ff692003-10-22 23:27:16 +0000246<div class="doc_subsection">
247 <a name="requiredcalls">Required initialization calls</a>
248</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000249
Misha Brukman283ff692003-10-22 23:27:16 +0000250<div class="doc_text">
251<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000252Your subclass of AliasAnalysis is required to invoke two methods on the
253AliasAnalysis base class: <tt>getAnalysisUsage</tt> and
254<tt>InitializeAliasAnalysis</tt>. In particular, your implementation of
255<tt>getAnalysisUsage</tt> should explicitly call into the
256<tt>AliasAnalysis::getAnalysisUsage</tt> method in addition to doing any
257declaring any pass dependencies your pass has. Thus you should have something
Misha Brukman283ff692003-10-22 23:27:16 +0000258like this:
259</p>
260<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000261<pre>
262 void getAnalysisUsage(AnalysisUsage &amp;AU) const {
263 AliasAnalysis::getAnalysisUsage(AU);
264 <i>// declare your dependencies here.</i>
265 }
266</pre>
Misha Brukman283ff692003-10-22 23:27:16 +0000267</p>
268<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000269Additionally, your must invoke the <tt>InitializeAliasAnalysis</tt> method from
270your analysis run method (<tt>run</tt> for a <tt>Pass</tt>,
271<tt>runOnFunction</tt> for a <tt>FunctionPass</tt>, <tt>runOnBasicBlock</tt> for
272a <tt>BasicBlockPass</tt>, or <tt>InitializeAliasAnalysis</tt> for an
Misha Brukman283ff692003-10-22 23:27:16 +0000273<tt>ImmutablePass</tt>). For example (as part of a <tt>Pass</tt>):
274</p>
275<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000276<pre>
277 bool run(Module &amp;M) {
278 InitializeAliasAnalysis(this);
279 <i>// Perform analysis here...</i>
280 return false;
281 }
282</pre>
Misha Brukman283ff692003-10-22 23:27:16 +0000283</p>
284</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000285
286<!-- ======================================================================= -->
Misha Brukman283ff692003-10-22 23:27:16 +0000287<div class="doc_subsection">
288 <a name="interfaces">Interfaces which may be specified</a>
289</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000290
Misha Brukman283ff692003-10-22 23:27:16 +0000291<div class="doc_text">
292<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000293All of the <a href="/doxygen/classAliasAnalysis.html">AliasAnalysis</a> virtual
294methods default to providing conservatively correct information (returning "May"
295Alias and "Mod/Ref" for alias and mod/ref queries respectively). Depending on
296the capabilities of the analysis you are implementing, you just override the
297interfaces you can improve.
Misha Brukman283ff692003-10-22 23:27:16 +0000298</p>
299</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000300
301<!-- ======================================================================= -->
Misha Brukman283ff692003-10-22 23:27:16 +0000302<div class="doc_subsection">
303 <a name="chaining">The AliasAnalysis chaining behavior</a>
304</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000305
Misha Brukman283ff692003-10-22 23:27:16 +0000306<div class="doc_text">
307<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000308With only two special exceptions (the <tt>basicaa</tt> and <a
309href="#no-aa"><tt>no-aa</tt></a> passes) every alias analysis pass should chain
310to another alias analysis implementation (for example, you could specify
311"<tt>-basic-aa -ds-aa -andersens-aa -licm</tt>" to get the maximum benefit from
312the three alias analyses). To do this, simply "Require" AliasAnalysis in your
313<tt>getAnalysisUsage</tt> method, and if you need to return a conservative
Misha Brukman283ff692003-10-22 23:27:16 +0000314MayAlias or Mod/Ref result, simply chain to a lower analysis.
315</p>
316</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000317
318<!-- ======================================================================= -->
Misha Brukman283ff692003-10-22 23:27:16 +0000319<div class="doc_subsection">
320 <a name="implefficiency">Efficiency Issues</a>
321</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000322
Misha Brukman283ff692003-10-22 23:27:16 +0000323<div class="doc_text">
324<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000325From the LLVM perspective, the only thing you need to do to provide an efficient
326alias analysis is to make sure that alias analysis <b>queries</b> are serviced
327quickly. The actual calculation of the alias analysis results (the "run"
328method) is only performed once, but many (perhaps duplicate) queries may be
329performed. Because of this, try to move as much computation to the run method
Misha Brukman283ff692003-10-22 23:27:16 +0000330as possible (within reason).
331</p>
332</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000333
334<!-- *********************************************************************** -->
Misha Brukman283ff692003-10-22 23:27:16 +0000335<div class="doc_section">
336 <a name="using">Using AliasAnalysis results</a>
337</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000338<!-- *********************************************************************** -->
339
Misha Brukman283ff692003-10-22 23:27:16 +0000340<div class="doc_text">
341<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000342There are several different ways to use alias analysis results. In order of
Misha Brukman283ff692003-10-22 23:27:16 +0000343preference, these are...
344</p>
345</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000346
347<!-- ======================================================================= -->
Misha Brukman283ff692003-10-22 23:27:16 +0000348<div class="doc_subsection">
349 <a name="loadvn">Using the <tt>-load-vn</tt> Pass</a>
350</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000351
Misha Brukman283ff692003-10-22 23:27:16 +0000352<div class="doc_text">
353<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000354The <tt>load-vn</tt> pass uses alias analysis to provide value numbering
355information for <tt>load</tt> instructions. If your analysis or transformation
356can be modelled in a form that uses value numbering information, you don't have
357to do anything special to handle load instructions: just use the
Misha Brukman283ff692003-10-22 23:27:16 +0000358<tt>load-vn</tt> pass, which uses alias analysis.
359</p>
360</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000361
362<!-- ======================================================================= -->
Misha Brukman283ff692003-10-22 23:27:16 +0000363<div class="doc_subsection">
364 <a name="ast">Using the <tt>AliasSetTracker</tt> class</a>
365</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000366
Misha Brukman283ff692003-10-22 23:27:16 +0000367<div class="doc_text">
368<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000369Many transformations need information about alias <b>sets</b> that are active in
370some scope, rather than information about pairwise aliasing. The <tt><a
371href="/doxygen/classAliasSetTracker.html">AliasSetTracker</a></tt> class is used
372to efficiently build these Alias Sets from the pairwise alias analysis
Misha Brukman283ff692003-10-22 23:27:16 +0000373information provided by the AliasAnalysis interface.
374</p>
375<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000376First you initialize the AliasSetTracker by use the "<tt>add</tt>" methods to
377add information about various potentially aliasing instructions in the scope you
378are interested in. Once all of the alias sets are completed, your pass should
379simply iterate through the constructed alias sets, using the AliasSetTracker
Misha Brukman283ff692003-10-22 23:27:16 +0000380<tt>begin()</tt>/<tt>end()</tt> methods.
381</p>
382<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000383The <tt>AliasSet</tt>s formed by the <tt>AliasSetTracker</tt> are guaranteed to
384be disjoint, calculate mod/ref information for the set, and keep track of
385whether or not all of the pointers in the set are Must aliases. The
386AliasSetTracker also makes sure that sets are properly folded due to call
Misha Brukman283ff692003-10-22 23:27:16 +0000387instructions, and can provide a list of pointers in each set.
388</p>
389<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000390As an example user of this, the <a href="/doxygen/structLICM.html">Loop
391Invariant Code Motion</a> pass uses AliasSetTrackers to build alias information
392about each loop nest. If an AliasSet in a loop is not modified, then all load
393instructions from that set may be hoisted out of the loop. If any alias sets
394are stored <b>and</b> are must alias sets, then the stores may be sunk to
395outside of the loop. Both of these transformations obviously only apply if the
Misha Brukman283ff692003-10-22 23:27:16 +0000396pointer argument is loop-invariant.
397</p>
398</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000399
400<!-- ======================================================================= -->
Misha Brukman283ff692003-10-22 23:27:16 +0000401<div class="doc_subsection">
402 <a name="direct">Using the AliasAnalysis interface directly</a>
403</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000404
Misha Brukman283ff692003-10-22 23:27:16 +0000405<div class="doc_text">
406<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000407As a last resort, your pass could use the AliasAnalysis interface directly to
408service your pass. If you find the need to do this, please <a
409href="mailto:sabre@nondot.org">let me know</a> so I can see if something new
Misha Brukman283ff692003-10-22 23:27:16 +0000410needs to be added to LLVM.
411</p>
412</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000413
414<!-- *********************************************************************** -->
Misha Brukman283ff692003-10-22 23:27:16 +0000415<div class="doc_section">
416 <a name="tools">Helpful alias-analysis-related tools</a>
417</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000418<!-- *********************************************************************** -->
419
Misha Brukman283ff692003-10-22 23:27:16 +0000420<div class="doc_text">
421<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000422If you're going to be working with the AliasAnalysis infrastructure, there are
Misha Brukman283ff692003-10-22 23:27:16 +0000423several nice tools that may be useful for you and are worth knowing about...
424</p>
425</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000426
427<!-- ======================================================================= -->
Misha Brukman283ff692003-10-22 23:27:16 +0000428<div class="doc_subsection">
429 <a name="no-aa">The <tt>-no-aa</tt> pass</a>
430</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000431
Misha Brukman283ff692003-10-22 23:27:16 +0000432<div class="doc_text">
433<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000434The <tt>-no-aa</tt> analysis is just like what it sounds: an alias analysis that
435never returns any useful information. This pass can be useful if you think that
436alias analysis is doing something wrong and are trying to narrow down a problem.
437If you don't specify an alias analysis, the default will be to use the
Misha Brukman283ff692003-10-22 23:27:16 +0000438<tt>basicaa</tt> pass which does quite a bit of disambiguation on its own.
439</p>
440</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000441
442
443<!-- ======================================================================= -->
Misha Brukman283ff692003-10-22 23:27:16 +0000444<div class="doc_subsection">
445 <a name="print-alias-sets">The <tt>-print-alias-sets</tt> pass</a>
446</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000447
Misha Brukman283ff692003-10-22 23:27:16 +0000448<div class="doc_text">
449<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000450The <tt>-print-alias-sets</tt> pass is exposed as part of the <tt>analyze</tt>
451tool to print out the Alias Sets formed by the <a
452href="#ast"><tt>AliasSetTracker</tt></a> class. This is useful if you're using
Misha Brukman283ff692003-10-22 23:27:16 +0000453the <tt>AliasSetTracker</tt>.
454</p>
455</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000456
457<!-- ======================================================================= -->
Misha Brukman283ff692003-10-22 23:27:16 +0000458<div class="doc_subsection">
459 <a name="count-aa">The <tt>-count-aa</tt> pass</a>
460</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000461
Misha Brukman283ff692003-10-22 23:27:16 +0000462<div class="doc_text">
463<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000464The <tt>-count-aa</tt> pass is useful to see how many queries a particular pass
465is making and what kinds of responses are returned by the alias analysis. An
Misha Brukman283ff692003-10-22 23:27:16 +0000466example usage is:
467</p>
468<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000469<pre>
470 $ opt -basicaa -count-aa -ds-aa -count-aa -licm
471</pre>
Misha Brukman283ff692003-10-22 23:27:16 +0000472</p>
473<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000474Which will print out how many queries (and what responses are returned) by the
475<tt>-licm</tt> pass (of the <tt>-ds-aa</tt> pass) and how many queries are made
476of the <tt>-basicaa</tt> pass by the <tt>-ds-aa</tt> pass. This can be useful
Misha Brukman283ff692003-10-22 23:27:16 +0000477when evaluating an alias analysis for precision.
478</p>
479</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000480
481<!-- ======================================================================= -->
Misha Brukman283ff692003-10-22 23:27:16 +0000482<div class="doc_subsection">
483 <a name="aa-eval">The <tt>-aa-eval</tt> pass</a>
484</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000485
Misha Brukman283ff692003-10-22 23:27:16 +0000486<div class="doc_text">
487<p>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000488The <tt>-aa-eval</tt> pass simply iterates through all pairs of pointers in a
489function and asks an alias analysis whether or not the pointers alias. This
490gives an indication of the precision of the alias analysis. Statistics are
Misha Brukman283ff692003-10-22 23:27:16 +0000491printed.
492</p>
493</div>
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000494
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000495<!-- *********************************************************************** -->
496
Misha Brukmanf1e6b152003-10-23 01:49:47 +0000497<hr><font size="-1">
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000498<address><a href="mailto:sabre@nondot.org">Chris Lattner</a></address>
499<!-- Created: Wed Feb 26 10:40:50 CST 2003 -->
500<!-- hhmts start -->
Misha Brukmanf1e6b152003-10-23 01:49:47 +0000501Last modified: $Date$
Chris Lattnerb512e9f2003-03-04 19:37:49 +0000502<!-- hhmts end -->
Misha Brukman283ff692003-10-22 23:27:16 +0000503</font>
504
505</body>
506</html>