[LLVMdev] A very basic doubt about LLVM Alias Analysis

ambika ambika at cse.iitb.ac.in
Mon Feb 15 01:33:23 PST 2010


I tried the program u mentioned but still did not get the result you are 
getting. I think there must be some mistake in compiling.
The commands which I am using are :

To create bc file:

llvm-gcc -emit-llvm -c -o s.bc s.c -O1

and to get alias result :

opt -anders-aa -aa-eval -print-all-alias-modref-info  s.bc


Török Edwin wrote:
> On 02/14/2010 06:39 PM, ambika wrote:
>   
>> Oh m sorry for that mistake as I had points to in mind.
>> But still what about the following prog:
>>
>> int main()
>> {
>>         int *i,*j,k;
>>         i=&k;
>>         j=&k;
>>         k=4;
>>         printf("%d,%d,%d",*i,*j,k);
>>         return 0;
>> }
>>   
>>     
>
> Your example is too simple, i,j,k don't exist after running mem2reg.
> And well, without running mem2reg i and j will be stack variables, so
> you need to look for the value that is loaded from them.
> That is the real pointer:
>   AliasSet[0x0x1631400,3] may alias, Mod/Ref   Pointers: (i32* %k, 4),
> (i32* %tmp, 4), (i32* %tmp2, 4)
>
> Here %tmp is i (  %tmp = load i32** %i ), %tmp2 is j ( %tmp2 = load
> i32** %j).
>
> If you make it a bit more complicated:
> int main(int argc, char **argv)
> {
>         int *i=0,*j=0,k;
>         if (argc > 1) {
>           i=&k;
>         } else {
>           j=&k;
>         }
>         k=4;
>         printf("%d,%d,%d,%p,%p",*i,*j,k,i,j);
>         return 0;
> }
>
> Then you get this:
>   AliasSet[0x0xb8e6a0,3] may alias, Mod/Ref   Pointers: (i32* %k, 4),
> (i32* %i.0, 4), (i32* %j.0, 4)
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>   




More information about the llvm-dev mailing list