<div dir="ltr">I'd like to write a pass that does both: implements a code transformation <i>and </i>saves information that can be accessed by subsequent passes.  If such a pass is not an Analysis pass and that therefore subsequent passes are not supposed to use getAnalysis() to extract the information from that pass... what is the right way to do this?<br>
<br>Right now I am using getAnalysis to get the information from the non-analysis (transformation)  pass.  It works, but now it sounds like that's not correct usage....<br><br>Marc<br><br><div class="gmail_quote">On Fri, Jul 25, 2008 at 2:01 PM, Devang Patel <span dir="ltr"><<a href="mailto:dpatel@apple.com">dpatel@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d"><br>
On Jul 25, 2008, at 10:56 AM, Marc de Kruijf wrote:<br>
<br>
> Could somebody please explain exactly what an "analysis pass" is?<br>
> I've spent some time trying to understand this and I just don't get<br>
> it.  Right now my understanding is the following:  if a pass is an<br>
> "analysis" pass, the "print" function is called when giving the "-<br>
> analyze" switch to opt.<br>
<br>
</div>Yes.<br>
<div class="Ih2E3d"><br>
> Is there more to it than that?<br>
<br>
</div>Analysis pass collects information that is used by other passes, for<br>
example alias info., loop info, dominator info etc..<br>
<div class="Ih2E3d"><br>
> If I've got it wrong, here are some potentially clarifying questions:<br>
><br>
> 1.  If a pass is an analysis pass, does it necessarily not alter the<br>
> CFG?<br>
<br>
</div>Yes, Analysis passes do not alter CFG.<br>
<div class="Ih2E3d"><br>
> 2.  Does a pass need to be an analysis pass if it is used by another<br>
> pass calling getAnalysisUsage?<br>
<br>
</div>The other passes uses getAnalysisUsage() to access information<br>
collected by an analysis information. getAnalysisUsage() interface<br>
should not be used to order transformation/code generation passes.<br>
There are couple of cases where code generator violates this and I'd<br>
like to eventually fix it.<br>
<div class="Ih2E3d"><br>
> 3.  How does whether or not a pass is an analysis pass or not affect<br>
> the pass's execution?<br>
<br>
</div>In general it does not. Analysis pass is executed just like any other<br>
pass.<br>
<br>
The distinction is important for the pass manager, who is responsible<br>
to automatically schedule an analysis pass if the analysis info is not<br>
available (or dirty) and is required by a transformation pass.<br>
<br>
One small distinction is - pass manager will not re-run an analysis<br>
pass if the information is up-to-date. However, the pass manager will<br>
re-run a transformation pass if requested to do so.<br>
<br>
For example,<br>
   $ opt -domtree -domtree a.bc -disable-output<br>
will run dominator tree analysis pass only once.<br>
   $ opt -instcombine -instcombine a.bc -disable-output<br>
will run instruction combiner pass twice.<br>
<br>
-<br>
Devang<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</blockquote></div><br></div>