A question about alias analysis

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

A question about alias analysis

ymxia
Hello,

I got a strange result when I used alias analysis DSAA, can you tell what is
wrong?

1. The following is the primary body of my pass "fps.cpp":

  AliasAnalysis *AA = &getAnalysis<AliasAnalysis>();
  AliasSetTracker AST(*AA);
       
  for (Module::iterator fi = M.begin(), fe = M.end(); fi != fe; ++fi )
    for (Function::iterator bi = fi->begin(), be = fi->end(); bi != be; ++bi)
        AST.add(*bi);

  for (AliasSetTracker::iterator I = AST.begin(), E = AST.end(); I != E; ++I) {
        AliasSet &AS = *I;
        AS.print (std::cerr);
  }

2. The follwoing is the test program "hello.cpp":

   int *a, *b;
   int main() {
      int t;
      a = &t;
      b = &t;
      printf ("%d, %d", a, b);
   }

3. I compiled the test program with "llvm-gcc hello.cpp -o hello", and made alias
   analysis with:
          opt -ds-aa -load ../Debug/lib/fps.so -FPS < hello.bc > /dev/null

   opt printed that:
    AliasSet[XXXX,1] must alis, Mod Pointers: (sbyte** %a, 4)
    AliasSet[YYYY,1] must alis, Mod Pointers: (sbyte** %b, 4)
 
   I donot know why "a" and "b" are not alias? They donot point to a same memory
object? But, when I donot use DSAA, that is, "opt -load ../Debug/lib/fps.so -FPS <
hello.bc > /dev/null", "a" and "b" are alias!

Thanks.

-Xia



_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: A question about alias analysis

ymxia

Oh, your meaning is pointers in a aliasset have equal address logically?
But I think that two pointers are alias means they point to a same 
memory object, so if pointers "p" and "q" are alias, it seem as p = q, 
not &p = &q.

Another question is about "forwarding". 
"AliasSet[XXXX, 0] may alias, Mod/Ref forwarding to YYYY" (XXXX != YYYY) 
means the address XXXX can be regarded as YYYY in interprocedural analysis, 
and XXXX should be ignored? 

Thank you.

>On Sat, 14 Jan 2006, ymxia wrote:
>> 1. The following is the primary body of my pass "fps.cpp":
>>
>>  AliasAnalysis *AA = &getAnalysis<AliasAnalysis>();
>>  AliasSetTracker AST(*AA);
>>
>>  for (Module::iterator fi = M.begin(), fe = M.end(); fi != fe; ++fi )
>>    for (Function::iterator bi = fi->begin(), be = fi->end(); bi != be; ++bi)
>>  AST.add(*bi);
>>
>>  for (AliasSetTracker::iterator I = AST.begin(), E = AST.end(); I != E; ++I) {
>>  AliasSet &AS = *I;
>>  AS.print (std::cerr);
>>  }
>>
>> 2. The follwoing is the test program "hello.cpp":
>>
>>   int *a, *b;
>>   int main() {
>>      int t;
>>      a = &t;
>>      b = &t;
>>      printf ("%d, %d", a, b);
>>   }
>>
>> 3. I compiled the test program with "llvm-gcc hello.cpp -o hello", and made alias
>>   analysis with:
>>          opt -ds-aa -load ../Debug/lib/fps.so -FPS < hello.bc > /dev/null
>>
>>   opt printed that:
>>     AliasSet[XXXX,1] must alis, Mod Pointers: (sbyte** %a, 4)
>>     AliasSet[YYYY,1] must alis, Mod Pointers: (sbyte** %b, 4)
>>
>>   I donot know why "a" and "b" are not alias? They donot point to a same memory
>> object? But, when I donot use DSAA, that is, "opt -load ../Debug/lib/fps.so -FPS <
>> hello.bc > /dev/null", "a" and "b" are alias!
>
>This is telling you that &a != &b.
>
>-Chris
>
>-- 
>http://nondot.org/sabre/
>http://llvm.org


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

¾°Îï3 (6K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: A question about alias analysis

ymxia
In reply to this post by ymxia
Thank you, Chris. The following is my comprehension about the AliasSetTracker,
please correct me.

1. A aliasset "as" represents a memory object, and all pointer "p" in "as"
represent values with the type of pointer that may/must point to the memory
object "as".

2. If a aliasset is "forwarding", it has been merged to another aliasset and
I should ignore it.

-Xia







_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev