OK, that's actually quite straightforward, I will just share it here:<div><br></div><div>1. In "my_pass", you need this:</div><div><div>    void getAnalysisUsage(AnalysisUsage &Info) const {</div><div>      Info.addRequired<AliasAnalysis>();</div>
<div>      Info.setPreservesAll();</div><div>    }</div><div><br></div><div>2. In the main() function, add this:</div><div><div>  PassRegistry &Registry = *PassRegistry::getPassRegistry();</div><div>  initializeBasicAliasAnalysisPass(Registry);</div>
</div><div><br></div><div>  You can replace "BasicAliasAnalysis" with other alias analysis classes, refer to llvm/InitializePasses.h for the list.</div><div><br></div><div>3. Finally, anywhere in your code, you can write this:</div>
<div><div>    AliasAnalysis &AA = getAnalysis<AliasAnalysis>();</div></div><div><br></div><div><br></div><div>Hope this helps,</div><div>Welson</div><br><div class="gmail_quote">On Wed, Sep 19, 2012 at 12:59 AM, Duncan Sands <span dir="ltr"><<a href="mailto:baldrick@free.fr" target="_blank">baldrick@free.fr</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Welson,<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
In case "my_pass" is compiled into a standalone executable, how can I run the<br>
specific alias analysis in the code?<br>
</blockquote>
<br></div>
I suggest you work out what passing -basic-aa to opt does, how it works, and do<br>
the same in your code.<br>
<br>
Ciao, Duncan.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
<br>
Thanks<br>
<br>
On Thu, Mar 8, 2012 at 8:55 AM, Duncan Sands <<a href="mailto:baldrick@free.fr" target="_blank">baldrick@free.fr</a><br></div><div class="im">
<mailto:<a href="mailto:baldrick@free.fr" target="_blank">baldrick@free.fr</a>>> wrote:<br>
<br>
    Hi,<br>
<br>
     > That's the reason I have defined getAnalysisUsage method. Isn't that the<br>
     > right way to do it?<br>
<br>
    no, that gives you access to whatever alias analysis has been computed, but<br>
    it doesn't specify what kind of alias analysis should be computed (there are<br>
    several).  Try something like this:<br>
        opt -load=my_pass.so -basic-aa -run_my_pass ...<br>
    Ciao, Duncan.<br>
    ______________________________<u></u>_________________<br>
    LLVM Developers mailing list<br></div>
    <a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a> <mailto:<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><div class="im">
<br>
    <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvmdev</a><br>
<br>
<br>
<br>
<br>
--<br>
Welson<br>
<br>
Phone: <a href="tel:%28408%29%20418-8385" value="+14084188385" target="_blank">(408) 418-8385</a><br></div>
Email: <a href="mailto:welson.sun@gmail.com" target="_blank">welson.sun@gmail.com</a> <mailto:<a href="mailto:welson.sun@gmail.com" target="_blank">welson.sun@gmail.com</a>><br>
<br>
<br>
</blockquote>
<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Welson<div><br></div><div>Phone: (408) 418-8385</div><div>Email:  <a href="mailto:welson.sun@gmail.com" target="_blank">welson.sun@gmail.com</a></div><div><br>
</div><br>
</div>