summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/FunctionAttrs
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/test/Transforms/FunctionAttrs')
-rw-r--r--llvm/test/Transforms/FunctionAttrs/2008-09-03-Mutual.ll11
-rw-r--r--llvm/test/Transforms/FunctionAttrs/2008-09-03-ReadNone.ll18
-rw-r--r--llvm/test/Transforms/FunctionAttrs/2008-09-03-ReadOnly.ll9
-rw-r--r--llvm/test/Transforms/FunctionAttrs/2008-09-13-VolatileRead.ll9
-rw-r--r--llvm/test/Transforms/FunctionAttrs/2008-10-04-LocalMemory.ll10
-rw-r--r--llvm/test/Transforms/FunctionAttrs/2008-12-29-Constant.ll8
-rw-r--r--llvm/test/Transforms/FunctionAttrs/2008-12-31-NoCapture.ll34
-rw-r--r--llvm/test/Transforms/FunctionAttrs/dg.exp3
8 files changed, 102 insertions, 0 deletions
diff --git a/llvm/test/Transforms/FunctionAttrs/2008-09-03-Mutual.ll b/llvm/test/Transforms/FunctionAttrs/2008-09-03-Mutual.ll
new file mode 100644
index 00000000000..5261ac46588
--- /dev/null
+++ b/llvm/test/Transforms/FunctionAttrs/2008-09-03-Mutual.ll
@@ -0,0 +1,11 @@
+; RUN: llvm-as < %s | opt -functionattrs | llvm-dis | grep readnone
+
+define i32 @a() {
+ %tmp = call i32 @b( ) ; <i32> [#uses=1]
+ ret i32 %tmp
+}
+
+define i32 @b() {
+ %tmp = call i32 @a( ) ; <i32> [#uses=1]
+ ret i32 %tmp
+}
diff --git a/llvm/test/Transforms/FunctionAttrs/2008-09-03-ReadNone.ll b/llvm/test/Transforms/FunctionAttrs/2008-09-03-ReadNone.ll
new file mode 100644
index 00000000000..a17d381eec8
--- /dev/null
+++ b/llvm/test/Transforms/FunctionAttrs/2008-09-03-ReadNone.ll
@@ -0,0 +1,18 @@
+; RUN: llvm-as < %s | opt -functionattrs | llvm-dis | grep readnone | count 4
+@x = global i32 0
+
+declare i32 @e() readnone
+
+define i32 @f() {
+ %tmp = call i32 @e( ) ; <i32> [#uses=1]
+ ret i32 %tmp
+}
+
+define i32 @g() readonly {
+ ret i32 0
+}
+
+define i32 @h() readnone {
+ %tmp = load i32* @x ; <i32> [#uses=1]
+ ret i32 %tmp
+}
diff --git a/llvm/test/Transforms/FunctionAttrs/2008-09-03-ReadOnly.ll b/llvm/test/Transforms/FunctionAttrs/2008-09-03-ReadOnly.ll
new file mode 100644
index 00000000000..cebfdacb4c0
--- /dev/null
+++ b/llvm/test/Transforms/FunctionAttrs/2008-09-03-ReadOnly.ll
@@ -0,0 +1,9 @@
+; RUN: llvm-as < %s | opt -functionattrs | llvm-dis | grep readonly | count 2
+
+define i32 @f() {
+entry:
+ %tmp = call i32 @e( ) ; <i32> [#uses=1]
+ ret i32 %tmp
+}
+
+declare i32 @e() readonly
diff --git a/llvm/test/Transforms/FunctionAttrs/2008-09-13-VolatileRead.ll b/llvm/test/Transforms/FunctionAttrs/2008-09-13-VolatileRead.ll
new file mode 100644
index 00000000000..b6077fd8ee3
--- /dev/null
+++ b/llvm/test/Transforms/FunctionAttrs/2008-09-13-VolatileRead.ll
@@ -0,0 +1,9 @@
+; RUN: llvm-as < %s | opt -functionattrs | llvm-dis | not grep read
+; PR2792
+
+@g = global i32 0 ; <i32*> [#uses=1]
+
+define i32 @f() {
+ %t = volatile load i32* @g ; <i32> [#uses=1]
+ ret i32 %t
+}
diff --git a/llvm/test/Transforms/FunctionAttrs/2008-10-04-LocalMemory.ll b/llvm/test/Transforms/FunctionAttrs/2008-10-04-LocalMemory.ll
new file mode 100644
index 00000000000..50ca6412000
--- /dev/null
+++ b/llvm/test/Transforms/FunctionAttrs/2008-10-04-LocalMemory.ll
@@ -0,0 +1,10 @@
+; RUN: llvm-as < %s | opt -functionattrs | llvm-dis | grep readnone | count 2
+
+declare i32 @g(i32*) readnone
+
+define i32 @f() {
+ %x = alloca i32 ; <i32*> [#uses=2]
+ store i32 0, i32* %x
+ %y = call i32 @g(i32* %x) ; <i32> [#uses=1]
+ ret i32 %y
+}
diff --git a/llvm/test/Transforms/FunctionAttrs/2008-12-29-Constant.ll b/llvm/test/Transforms/FunctionAttrs/2008-12-29-Constant.ll
new file mode 100644
index 00000000000..d9c01171ac4
--- /dev/null
+++ b/llvm/test/Transforms/FunctionAttrs/2008-12-29-Constant.ll
@@ -0,0 +1,8 @@
+; RUN: llvm-as < %s | opt -functionattrs | llvm-dis | grep readnone
+
+@s = external constant i8 ; <i8*> [#uses=1]
+
+define i8 @f() {
+ %tmp = load i8* @s ; <i8> [#uses=1]
+ ret i8 %tmp
+}
diff --git a/llvm/test/Transforms/FunctionAttrs/2008-12-31-NoCapture.ll b/llvm/test/Transforms/FunctionAttrs/2008-12-31-NoCapture.ll
new file mode 100644
index 00000000000..6d2ca1e446f
--- /dev/null
+++ b/llvm/test/Transforms/FunctionAttrs/2008-12-31-NoCapture.ll
@@ -0,0 +1,34 @@
+; RUN: llvm-as < %s | opt -functionattrs | llvm-dis | not grep {@c.*nocapture}
+; RUN: llvm-as < %s | opt -functionattrs | llvm-dis | grep nocapture | count 3
+@g = global i32* null ; <i32**> [#uses=1]
+
+define i32* @c1(i32* %p) {
+ ret i32* %p
+}
+
+define void @c2(i32* %p) {
+ store i32* %p, i32** @g
+ ret void
+}
+
+define void @c3(i32* %p) {
+ call void @c2(i32* %p)
+ ret void
+}
+
+define i32 @nc1(i32* %p) {
+ %tmp = bitcast i32* %p to i32* ; <i32*> [#uses=2]
+ %val = load i32* %tmp ; <i32> [#uses=1]
+ store i32 0, i32* %tmp
+ ret i32 %val
+}
+
+define void @nc2(i32* %p) {
+ %1 = call i32 @nc1(i32* %p) ; <i32> [#uses=0]
+ ret void
+}
+
+define void @nc3(void ()* %f) {
+ call void %f()
+ ret void
+}
diff --git a/llvm/test/Transforms/FunctionAttrs/dg.exp b/llvm/test/Transforms/FunctionAttrs/dg.exp
new file mode 100644
index 00000000000..f2005891a59
--- /dev/null
+++ b/llvm/test/Transforms/FunctionAttrs/dg.exp
@@ -0,0 +1,3 @@
+load_lib llvm.exp
+
+RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]]
OpenPOWER on IntegriCloud