[llvm-commits] CVS: llvm/test/Regression/Analysis/Andersens/arg-must-alias.ll basictest.ll external.ll

Chris Lattner lattner at cs.uiuc.edu
Sun May 23 16:33:01 PDT 2004


Changes in directory llvm/test/Regression/Analysis/Andersens:

arg-must-alias.ll added (r1.1)
basictest.ll added (r1.1)
external.ll added (r1.1)

---
Log message:

Testcases for andersen's alias analysis.

I think this is all of the stuff I had pending in my tree..


---
Diffs of the changes:  (+68 -0)

Index: llvm/test/Regression/Analysis/Andersens/arg-must-alias.ll
diff -c /dev/null llvm/test/Regression/Analysis/Andersens/arg-must-alias.ll:1.1
*** /dev/null	Sun May 23 16:31:10 2004
--- llvm/test/Regression/Analysis/Andersens/arg-must-alias.ll	Sun May 23 16:31:00 2004
***************
*** 0 ****
--- 1,17 ----
+ ; RUN: llvm-as < %s | opt -anders-aa -load-vn -gcse -deadargelim | llvm-dis | not grep ARG
+ 
+ %G = internal constant int* null
+ 
+ implementation
+ 
+ internal int %internal(int* %ARG) {
+ 	;; The 'Arg' argument must-aliases the null pointer, so it can be subsituted
+ 	;; directly here, making it dead.
+ 	store int* %ARG, int** %G
+ 	ret int 0
+ }
+ 
+ int %foo() {
+ 	%V = call int %internal(int* null)
+ 	ret int %V
+ }


Index: llvm/test/Regression/Analysis/Andersens/basictest.ll
diff -c /dev/null llvm/test/Regression/Analysis/Andersens/basictest.ll:1.1
*** /dev/null	Sun May 23 16:31:10 2004
--- llvm/test/Regression/Analysis/Andersens/basictest.ll	Sun May 23 16:31:00 2004
***************
*** 0 ****
--- 1,29 ----
+ 
+ implementation
+ 
+ void %test1() {
+ 	%X = malloc int*
+ 	%Y = malloc int
+ 	%Z = cast int* %Y to int
+ 	%W = cast int %Z to int*
+ 	store int* %W, int** %X
+ 	ret void
+ }
+ 
+ void %test2(int* %P) {
+ 	%X = malloc int*
+ 	%Y = malloc int
+ 	store int* %P, int** %X
+ 	ret void
+ }
+ 
+ internal int *%test3(int* %P) {
+ 	ret int* %P
+ }
+ 
+ void %test4() {
+ 	%X = malloc int
+ 	%Y = call int* %test3(int* %X)
+ 	%ZZ = getelementptr int* null, int 17
+ 	ret void
+ }


Index: llvm/test/Regression/Analysis/Andersens/external.ll
diff -c /dev/null llvm/test/Regression/Analysis/Andersens/external.ll:1.1
*** /dev/null	Sun May 23 16:31:10 2004
--- llvm/test/Regression/Analysis/Andersens/external.ll	Sun May 23 16:31:00 2004
***************
*** 0 ****
--- 1,22 ----
+ ; RUN: llvm-as < %s | opt -anders-aa -load-vn -gcse -deadargelim | llvm-dis | grep store | not grep null
+ 
+ ; Because the 'internal' function is passed to an external function, we don't
+ ; know what the incoming values will alias.  As such, we cannot do the 
+ ; optimization checked by the 'arg-must-alias.llx' test.
+ 
+ declare void %external(int(int*)*)
+ %G = internal constant int* null
+ 
+ implementation
+ 
+ internal int %internal(int* %ARG) {
+ 	;;; We *DON'T* know that ARG always points to null!
+ 	store int* %ARG, int** %G
+ 	ret int 0
+ }
+ 
+ int %foo() {
+ 	call void %external(int(int*)* %internal)
+ 	%V = call int %internal(int* null)
+ 	ret int %V
+ }





More information about the llvm-commits mailing list