It's not necessary to do rounding for alloca operations when the requested
alignment is equal to the stack alignment.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40004 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Analysis/GlobalsModRef/aliastest.ll b/test/Analysis/GlobalsModRef/aliastest.ll
new file mode 100644
index 0000000..4363d3b
--- /dev/null
+++ b/test/Analysis/GlobalsModRef/aliastest.ll
@@ -0,0 +1,9 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -globalsmodref-aa -load-vn -gcse | llvm-dis | not grep load
+%X = internal global int 4
+
+int %test(int *%P) {
+  store int 7, int* %P
+  store int 12,  int* %X   ;; cannot alias P, X's addr isn't taken
+  %V = load int* %P
+  ret int %V
+}
diff --git a/test/Analysis/GlobalsModRef/chaining-analysis.ll b/test/Analysis/GlobalsModRef/chaining-analysis.ll
new file mode 100644
index 0000000..4924456
--- /dev/null
+++ b/test/Analysis/GlobalsModRef/chaining-analysis.ll
@@ -0,0 +1,20 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -globalsmodref-aa -load-vn -gcse | llvm-dis | not grep load
+
+; This test requires the use of previous analyses to determine that 
+; doesnotmodX does not modify X (because 'sin' doesn't).
+
+%X = internal global int 4
+
+declare double %sin(double)
+
+int %test(int *%P) {
+  store int 12,  int* %X
+  call double %doesnotmodX(double 1.0)
+  %V = load int* %X
+  ret int %V
+}
+
+double %doesnotmodX(double %V) {
+  %V2 = call double %sin(double %V)
+  ret double %V2
+}
diff --git a/test/Analysis/GlobalsModRef/dg.exp b/test/Analysis/GlobalsModRef/dg.exp
new file mode 100644
index 0000000..879685c
--- /dev/null
+++ b/test/Analysis/GlobalsModRef/dg.exp
@@ -0,0 +1,3 @@
+load_lib llvm.exp
+
+RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,llx,c,cpp,tr}]]
diff --git a/test/Analysis/GlobalsModRef/indirect-global.ll b/test/Analysis/GlobalsModRef/indirect-global.ll
new file mode 100644
index 0000000..0ab82ae
--- /dev/null
+++ b/test/Analysis/GlobalsModRef/indirect-global.ll
@@ -0,0 +1,26 @@
+; RUN: llvm-upgrade < %s | llvm-as | \
+; RUN:   opt -globalsmodref-aa -load-vn -gcse -instcombine | llvm-dis | \
+; RUN:   grep {ret i32 0}
+; END.
+%G = internal global int* null
+
+implementation
+
+void %test() {
+	%A = malloc int
+	store int* %A, int** %G
+	ret void
+}
+
+int %test1(int *%P) {
+	%g1 = load int** %G
+	%h1 = load int* %g1
+
+	; This store cannot alias either G or g1.
+	store int 123, int* %P
+
+	%g2 = load int** %G
+	%h2 = load int* %g1
+	%X = sub int %h1, %h2   ;; -> 0
+	ret int %X
+}
diff --git a/test/Analysis/GlobalsModRef/modreftest.ll b/test/Analysis/GlobalsModRef/modreftest.ll
new file mode 100644
index 0000000..fadc747
--- /dev/null
+++ b/test/Analysis/GlobalsModRef/modreftest.ll
@@ -0,0 +1,13 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -globalsmodref-aa -load-vn -gcse | llvm-dis | not grep load
+%X = internal global int 4
+
+int %test(int *%P) {
+  store int 12,  int* %X
+  call void %doesnotmodX()
+  %V = load int* %X
+  ret int %V
+}
+
+void %doesnotmodX() {
+  ret void
+}
diff --git a/test/Analysis/GlobalsModRef/purecse.ll b/test/Analysis/GlobalsModRef/purecse.ll
new file mode 100644
index 0000000..0c95182
--- /dev/null
+++ b/test/Analysis/GlobalsModRef/purecse.ll
@@ -0,0 +1,23 @@
+; Test that pure functions are cse'd away
+
+; RUN: llvm-upgrade < %s | llvm-as | opt -globalsmodref-aa -load-vn -gcse -instcombine | llvm-dis | not grep sub
+
+int %pure(int %X) {
+	%Y = add int %X, 1
+	ret int %Y
+}
+
+int %test1(int %X) {
+	%A = call int %pure(int %X)
+	%B = call int %pure(int %X)
+	%C = sub int %A, %B
+	ret int %C
+}
+
+int %test2(int %X, int* %P) {
+	%A = call int %pure(int %X)
+	store int %X, int* %P          ;; Does not invalidate 'pure' call.
+	%B = call int %pure(int %X)
+	%C = sub int %A, %B
+	ret int %C
+}