[LLVMdev] A question about alias analysis

Chris Lattner sabre at nondot.org
Sat Jan 14 12:44:12 PST 2006


On Sat, 14 Jan 2006, [gb2312] ÏÄÒ»Ãñ 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/


More information about the llvm-dev mailing list