[LLVMdev] Limitations of Alias Analysis?

Wenzhi Tao linus_wind at zju.edu.cn
Mon Jun 29 19:32:33 PDT 2009


Hi Duncan,
  I tried to perform alias analysis after optimization(O1, since O2 and
O3 implement inlining).

  opt -O1 test.bc -o o1.bc

  The content of main() is listed as follow:
define i32 @main() nounwind {
entry:
	%0 = tail call %struct.Location* @getNewLocation(i32 0, i32 0)
nounwind		; <%struct.Location*> [#uses=2]
	%1 = tail call %struct.Location* @getNewLocation(i32 1, i32 2)
nounwind		; <%struct.Location*> [#uses=2]
	%2 = tail call %struct.Location* @sub(%struct.Location* %0, %
struct.Location* %1) nounwind		; <%struct.Location*> [#uses=1]
	%3 = bitcast %struct.Location* %0 to i8*		; <i8*> [#uses=1]
	tail call void @free(i8* %3) nounwind
	%4 = bitcast %struct.Location* %1 to i8*		; <i8*> [#uses=1]
	tail call void @free(i8* %4) nounwind
	%5 = bitcast %struct.Location* %2 to i8*		; <i8*> [#uses=1]
	tail call void @free(i8* %5) nounwind
	ret i32 0
}

  Then, the AA result with option "-basicaa -ds-aa -anders-aa" is:

  MayAlias:	%struct.Location* %0, %struct.Location* %1
  MayAlias:	%struct.Location* %0, %struct.Location* %2
  MayAlias:	%struct.Location* %1, %struct.Location* %2

  %0 and %1 are still considered as 'may alias'.

在 2009-06-29一的 10:36 +0200,Duncan Sands写道:
> Hi,
> 
> > llvm-gcc -emit-llvm -O0 -c test.c -o test.bc
> 
> try compiling with optimization.
> 
> Ciao,
> 
> Duncan.
> 




More information about the llvm-dev mailing list