summaryrefslogtreecommitdiff
path: root/test/Analysis/TypeBasedAliasAnalysis
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-10-11 23:54:13 +0000
committerDan Gohman <gohman@apple.com>2010-10-11 23:54:13 +0000
commitc0157231313c96cdeebc16a4fe94d9b9d3f2a45e (patch)
treedd7602aec0c4884bbc2727bf1e416455fefd9e2f /test/Analysis/TypeBasedAliasAnalysis
parent08cec1ef27d4f27320f871cf17fd742196465232 (diff)
downloadllvm-c0157231313c96cdeebc16a4fe94d9b9d3f2a45e.tar.gz
llvm-c0157231313c96cdeebc16a4fe94d9b9d3f2a45e.tar.bz2
llvm-c0157231313c96cdeebc16a4fe94d9b9d3f2a45e.tar.xz
Add a simple testcase for tbaa.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116272 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis/TypeBasedAliasAnalysis')
-rw-r--r--test/Analysis/TypeBasedAliasAnalysis/aliastest.ll58
-rw-r--r--test/Analysis/TypeBasedAliasAnalysis/dg.exp3
2 files changed, 61 insertions, 0 deletions
diff --git a/test/Analysis/TypeBasedAliasAnalysis/aliastest.ll b/test/Analysis/TypeBasedAliasAnalysis/aliastest.ll
new file mode 100644
index 0000000000..5ea2e3fd4f
--- /dev/null
+++ b/test/Analysis/TypeBasedAliasAnalysis/aliastest.ll
@@ -0,0 +1,58 @@
+; RUN: opt < %s -tbaa -gvn -S | FileCheck %s
+
+; CHECK: @test0_yes
+; CHECK: add i8 %x, %x
+define i8 @test0_yes(i8* %a, i8* %b) nounwind {
+ %x = load i8* %a, !tbaa !1
+ store i8 0, i8* %b, !tbaa !2
+ %y = load i8* %a, !tbaa !1
+ %z = add i8 %x, %y
+ ret i8 %z
+}
+
+; CHECK: @test0_no
+; CHECK: add i8 %x, %y
+define i8 @test0_no(i8* %a, i8* %b) nounwind {
+ %x = load i8* %a, !tbaa !3
+ store i8 0, i8* %b, !tbaa !4
+ %y = load i8* %a, !tbaa !3
+ %z = add i8 %x, %y
+ ret i8 %z
+}
+
+; CHECK: @test1_yes
+; CHECK: add i8 %x, %x
+define i8 @test1_yes(i8* %a, i8* %b) nounwind {
+ %x = load i8* %a, !tbaa !5
+ store i8 0, i8* %b
+ %y = load i8* %a, !tbaa !5
+ %z = add i8 %x, %y
+ ret i8 %z
+}
+
+; CHECK: @test1_no
+; CHECK: add i8 %x, %y
+define i8 @test1_no(i8* %a, i8* %b) nounwind {
+ %x = load i8* %a, !tbaa !6
+ store i8 0, i8* %b
+ %y = load i8* %a, !tbaa !6
+ %z = add i8 %x, %y
+ ret i8 %z
+}
+
+; Root note.
+!0 = metadata !{ }
+; Some type.
+!1 = metadata !{ metadata !"foo", metadata !0 }
+; Some other non-aliasing type.
+!2 = metadata !{ metadata !"bar", metadata !0 }
+
+; Some type.
+!3 = metadata !{ metadata !"foo", metadata !0 }
+; Some type in a different type system.
+!4 = metadata !{ metadata !"bar", metadata !"different" }
+
+; Invariant memory.
+!5 = metadata !{ metadata !"qux", metadata !0, i1 1 }
+; Not invariant memory.
+!6 = metadata !{ metadata !"qux", metadata !0, i1 0 }
diff --git a/test/Analysis/TypeBasedAliasAnalysis/dg.exp b/test/Analysis/TypeBasedAliasAnalysis/dg.exp
new file mode 100644
index 0000000000..f2005891a5
--- /dev/null
+++ b/test/Analysis/TypeBasedAliasAnalysis/dg.exp
@@ -0,0 +1,3 @@
+load_lib llvm.exp
+
+RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]]