[LLVMdev] A question about alias analysis

夏一民 ymxia at nudt.edu.cn
Fri Jan 13 19:43:21 PST 2006


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






More information about the llvm-dev mailing list