aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-02-03 21:31:43 +0000
committerChris Lattner <sabre@nondot.org>2003-02-03 21:31:43 +0000
commit0eef9b31affb3a1a1c7026cf6a8f499f5b4157b3 (patch)
treec778adfbfb525f0ccee943f5b68ba43ad6fd9cb8
parentdc1ad196e1915e9dc6e3ba8271a0bdafd214e769 (diff)
downloadexternal_llvm-0eef9b31affb3a1a1c7026cf6a8f499f5b4157b3.zip
external_llvm-0eef9b31affb3a1a1c7026cf6a8f499f5b4157b3.tar.gz
external_llvm-0eef9b31affb3a1a1c7026cf6a8f499f5b4157b3.tar.bz2
Initial tests for DS alias analysis
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5481 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--test/Analysis/DSGraph/gcsetest.ll55
-rw-r--r--test/Transforms/DSGraphAA/Makefile10
2 files changed, 65 insertions, 0 deletions
diff --git a/test/Analysis/DSGraph/gcsetest.ll b/test/Analysis/DSGraph/gcsetest.ll
new file mode 100644
index 0000000..d451ed5
--- /dev/null
+++ b/test/Analysis/DSGraph/gcsetest.ll
@@ -0,0 +1,55 @@
+; Test that GCSE uses ds-aa to do alias analysis, which is capable of
+; disambiguating some cases.
+
+; RUN: if as < %s | opt -ds-aa -load-vn -gcse -instcombine -dce | dis | grep ELIM
+; RUN: then exit 1
+; RUN: else exit 0
+; RUN: fi
+
+%intpair = type {int*, int*}
+implementation
+
+%intpair *%alloc_pair() {
+ %Ap = malloc int
+ %Bp = malloc int
+ %C = malloc {int*, int*}
+ %C1p = getelementptr {int*, int*}* %C, long 0, ubyte 0
+ store int* %Ap, int** %C1p
+ %C2p = getelementptr {int*, int*}* %C, long 0, ubyte 1
+ store int* %Bp, int** %C2p
+ ret %intpair* %C
+}
+
+int %test() {
+ %C = call %intpair* %alloc_pair()
+ %C1p = getelementptr %intpair* %C, long 0, ubyte 0
+ %C2p = getelementptr %intpair* %C, long 0, ubyte 1
+ %A = load int** %C1p
+ %B = load int** %C2p
+ %A1 = load int* %A
+
+ store int 123, int* %B ; Store cannot alias %A
+
+ %A2 = load int* %A
+ %ELIM_x = sub int %A1, %A2
+ ret int %ELIM_x
+}
+
+int* %getp(%intpair* %P) {
+ %pp = getelementptr %intpair* %P, long 0, ubyte 0
+ %V = load int** %pp
+ ret int *%V
+}
+
+int %test2() { ; Test context sensitivity
+ %C1 = call %intpair* %alloc_pair()
+ %C2 = call %intpair* %alloc_pair()
+ %P1 = call int* %getp(%intpair* %C1)
+ %P2 = call int* %getp(%intpair* %C2)
+ %X = load int* %P1
+ store int 7, int* %P2
+ %Y = load int* %P1
+ %ELIM_x = sub int %X, %Y
+ ret int %ELIM_x
+}
+
diff --git a/test/Transforms/DSGraphAA/Makefile b/test/Transforms/DSGraphAA/Makefile
new file mode 100644
index 0000000..91acd4d
--- /dev/null
+++ b/test/Transforms/DSGraphAA/Makefile
@@ -0,0 +1,10 @@
+
+LEVEL = ../../../..
+include $(LEVEL)/test/Makefile.tests
+
+TESTS := $(wildcard *.ll)
+
+all:: $(addprefix Output/, $(TESTS:%.ll=%.ll.out))
+
+Output/%.ll.out: %.ll Output/.dir $(LOPT)
+ -$(TESTRUNR) $<