aboutsummaryrefslogtreecommitdiffstats
path: root/test/Transforms/FunctionAttrs
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2008-12-31 16:14:43 +0000
committerDuncan Sands <baldrick@free.fr>2008-12-31 16:14:43 +0000
commit9e89ba31f16a960239a750a26a982b4c9dfe8949 (patch)
tree4b985f2525e7c6470e7a9d345b5c7eb7ffa889fe /test/Transforms/FunctionAttrs
parent0c913735c7f66d6bcf0807fac4018a867c3a77e0 (diff)
downloadexternal_llvm-9e89ba31f16a960239a750a26a982b4c9dfe8949.zip
external_llvm-9e89ba31f16a960239a750a26a982b4c9dfe8949.tar.gz
external_llvm-9e89ba31f16a960239a750a26a982b4c9dfe8949.tar.bz2
Rename AddReadAttrs to FunctionAttrs, and teach it how
to work out (in a very simplistic way) which function arguments (pointer arguments only) are only dereferenced and so do not escape. Mark such arguments 'nocapture'. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61525 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/FunctionAttrs')
-rw-r--r--test/Transforms/FunctionAttrs/2008-09-03-Mutual.ll11
-rw-r--r--test/Transforms/FunctionAttrs/2008-09-03-ReadNone.ll18
-rw-r--r--test/Transforms/FunctionAttrs/2008-09-03-ReadOnly.ll9
-rw-r--r--test/Transforms/FunctionAttrs/2008-09-13-VolatileRead.ll9
-rw-r--r--test/Transforms/FunctionAttrs/2008-10-04-LocalMemory.ll10
-rw-r--r--test/Transforms/FunctionAttrs/2008-12-29-Constant.ll8
-rw-r--r--test/Transforms/FunctionAttrs/2008-12-31-NoCapture.ll34
-rw-r--r--test/Transforms/FunctionAttrs/dg.exp3
8 files changed, 102 insertions, 0 deletions
diff --git a/test/Transforms/FunctionAttrs/2008-09-03-Mutual.ll b/test/Transforms/FunctionAttrs/2008-09-03-Mutual.ll
new file mode 100644
index 0000000..5261ac4
--- /dev/null
+++ b/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/test/Transforms/FunctionAttrs/2008-09-03-ReadNone.ll b/test/Transforms/FunctionAttrs/2008-09-03-ReadNone.ll
new file mode 100644
index 0000000..a17d381
--- /dev/null
+++ b/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/test/Transforms/FunctionAttrs/2008-09-03-ReadOnly.ll b/test/Transforms/FunctionAttrs/2008-09-03-ReadOnly.ll
new file mode 100644
index 0000000..cebfdac
--- /dev/null
+++ b/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/test/Transforms/FunctionAttrs/2008-09-13-VolatileRead.ll b/test/Transforms/FunctionAttrs/2008-09-13-VolatileRead.ll
new file mode 100644
index 0000000..b6077fd
--- /dev/null
+++ b/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/test/Transforms/FunctionAttrs/2008-10-04-LocalMemory.ll b/test/Transforms/FunctionAttrs/2008-10-04-LocalMemory.ll
new file mode 100644
index 0000000..50ca641
--- /dev/null
+++ b/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/test/Transforms/FunctionAttrs/2008-12-29-Constant.ll b/test/Transforms/FunctionAttrs/2008-12-29-Constant.ll
new file mode 100644
index 0000000..d9c0117
--- /dev/null
+++ b/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/test/Transforms/FunctionAttrs/2008-12-31-NoCapture.ll b/test/Transforms/FunctionAttrs/2008-12-31-NoCapture.ll
new file mode 100644
index 0000000..6d2ca1e
--- /dev/null
+++ b/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/test/Transforms/FunctionAttrs/dg.exp b/test/Transforms/FunctionAttrs/dg.exp
new file mode 100644
index 0000000..f200589
--- /dev/null
+++ b/test/Transforms/FunctionAttrs/dg.exp
@@ -0,0 +1,3 @@
+load_lib llvm.exp
+
+RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]]