<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jul 25, 2008, at 12:58 PM, Marc de Kruijf wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><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. </div></blockquote><div><br></div><div>Ideally, we want to use two separate pass. However, it is quiet possible that your requirement is unique. Would it be possible to provide more info. on what your pass does ?</div><br><blockquote type="cite"><div dir="ltr"> 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?</div></blockquote><br><div><br></div></div><div><blockquote type="cite"><div dir="ltr">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....</div></blockquote><div><br></div><div>One alternative approach is to use getAnalysisToUpdate() to access this info. This interface does not require you to register requirement using getAnalysisUsage(). getAnalysisToUpdate() will return null if the requested info is not available and users are expected to handle this.</div><div><br></div><div>The reason why it is not a good idea to request transformation pass through getAnalysisUsage() is: when requested transformation pass does not preserve some info that is required by the original pass then pass manager may not able to handle this properly. </div><div><br></div><div>However, if there is a good requirement, I'm ready to let getAnalysis() access transformation pass.</div><div>-</div><div>Devang</div><div><br></div><div><div><br><blockquote type="cite"></blockquote></div></div><blockquote type="cite"><div dir="ltr"><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> _______________________________________________<br>LLVM Developers mailing list<br>LLVMdev@cs.uiuc.edu         <a href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br></blockquote></div><br></body></html>