[LLVMdev] Alias analysis result
Welson Sun
welson.sun at gmail.com
Wed Sep 19 17:05:26 PDT 2012
OK, that's actually quite straightforward, I will just share it here:
1. In "my_pass", you need this:
void getAnalysisUsage(AnalysisUsage &Info) const {
Info.addRequired<AliasAnalysis>();
Info.setPreservesAll();
}
2. In the main() function, add this:
PassRegistry &Registry = *PassRegistry::getPassRegistry();
initializeBasicAliasAnalysisPass(Registry);
You can replace "BasicAliasAnalysis" with other alias analysis classes,
refer to llvm/InitializePasses.h for the list.
3. Finally, anywhere in your code, you can write this:
AliasAnalysis &AA = getAnalysis<AliasAnalysis>();
Hope this helps,
Welson
On Wed, Sep 19, 2012 at 12:59 AM, Duncan Sands <baldrick at free.fr> wrote:
> Hi Welson,
>
>
> In case "my_pass" is compiled into a standalone executable, how can I run
>> the
>> specific alias analysis in the code?
>>
>
> I suggest you work out what passing -basic-aa to opt does, how it works,
> and do
> the same in your code.
>
> Ciao, Duncan.
>
>
>> Thanks
>>
>> On Thu, Mar 8, 2012 at 8:55 AM, Duncan Sands <baldrick at free.fr
>> <mailto:baldrick at free.fr>> wrote:
>>
>> Hi,
>>
>> > That's the reason I have defined getAnalysisUsage method. Isn't
>> that the
>> > right way to do it?
>>
>> no, that gives you access to whatever alias analysis has been
>> computed, but
>> it doesn't specify what kind of alias analysis should be computed
>> (there are
>> several). Try something like this:
>> opt -load=my_pass.so -basic-aa -run_my_pass ...
>> Ciao, Duncan.
>> ______________________________**_________________
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu <mailto:LLVMdev at cs.uiuc.edu>
>> http://llvm.cs.uiuc.edu
>>
>> http://lists.cs.uiuc.edu/**mailman/listinfo/llvmdev<http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev>
>>
>>
>>
>>
>> --
>> Welson
>>
>> Phone: (408) 418-8385
>> Email: welson.sun at gmail.com <mailto:welson.sun at gmail.com>
>>
>>
>>
>
--
Welson
Phone: (408) 418-8385
Email: welson.sun at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120919/31e21d8a/attachment.html>
More information about the llvm-dev
mailing list