summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/FunctionAttrs/readattrs.ll
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/test/Transforms/FunctionAttrs/readattrs.ll')
-rw-r--r--llvm/test/Transforms/FunctionAttrs/readattrs.ll41
1 files changed, 27 insertions, 14 deletions
diff --git a/llvm/test/Transforms/FunctionAttrs/readattrs.ll b/llvm/test/Transforms/FunctionAttrs/readattrs.ll
index 0521986bd1b..a97f49901b2 100644
--- a/llvm/test/Transforms/FunctionAttrs/readattrs.ll
+++ b/llvm/test/Transforms/FunctionAttrs/readattrs.ll
@@ -1,19 +1,24 @@
-; RUN: opt < %s -functionattrs -S | FileCheck %s
-; RUN: opt < %s -aa-pipeline=basic-aa -passes='cgscc(function-attrs)' -S | FileCheck %s
+; RUN: opt < %s -functionattrs -S | FileCheck %s --check-prefixes=CHECK,FNATTR
+; RUN: opt < %s -aa-pipeline=basic-aa -passes='cgscc(function-attrs)' -S | FileCheck %s --check-prefixes=CHECK,FNATTR
+; RUN: opt < %s -attributor -attributor-disable=false -S | FileCheck %s --check-prefixes=CHECK,ATTRIBUTOR
+; RUN: opt < %s -aa-pipeline=basic-aa -passes='attributor' -attributor-disable=false -S | FileCheck %s --check-prefixes=CHECK,ATTRIBUTOR
+
@x = global i32 0
declare void @test1_1(i8* %x1_1, i8* readonly %y1_1, ...)
; NOTE: readonly for %y1_2 would be OK here but not for the similar situation in test13.
;
-; CHECK: define void @test1_2(i8* %x1_2, i8* readonly %y1_2, i8* %z1_2)
+; FNATTR: define void @test1_2(i8* %x1_2, i8* readonly %y1_2, i8* %z1_2)
+; ATTRIBUTOR: define void @test1_2(i8* %x1_2, i8* %y1_2, i8* %z1_2)
define void @test1_2(i8* %x1_2, i8* %y1_2, i8* %z1_2) {
call void (i8*, i8*, ...) @test1_1(i8* %x1_2, i8* %y1_2, i8* %z1_2)
store i32 0, i32* @x
ret void
}
-; CHECK: define i8* @test2(i8* readnone returned %p)
+; FNATTR: define i8* @test2(i8* readnone returned %p)
+; ATTRIBUTOR: define i8* @test2(i8* readnone returned %p)
define i8* @test2(i8* %p) {
store i32 0, i32* @x
ret i8* %p
@@ -33,7 +38,8 @@ define void @test4_2(i8* %p) {
ret void
}
-; CHECK: define void @test5(i8** nocapture %p, i8* %q)
+; FNATTR: define void @test5(i8** nocapture %p, i8* %q)
+; ATTRIBUTOR: define void @test5(i8** nocapture writeonly %p, i8* %q)
; Missed optz'n: we could make %q readnone, but don't break test6!
define void @test5(i8** %p, i8* %q) {
store i8* %q, i8** %p
@@ -41,7 +47,8 @@ define void @test5(i8** %p, i8* %q) {
}
declare void @test6_1()
-; CHECK: define void @test6_2(i8** nocapture %p, i8* %q)
+; FNATTR: define void @test6_2(i8** nocapture %p, i8* %q)
+; ATTRIBUTOR: define void @test6_2(i8** nocapture writeonly %p, i8* %q)
; This is not a missed optz'n.
define void @test6_2(i8** %p, i8* %q) {
store i8* %q, i8** %p
@@ -49,19 +56,22 @@ define void @test6_2(i8** %p, i8* %q) {
ret void
}
-; CHECK: define void @test7_1(i32* inalloca nocapture %a)
+; FNATTR: define void @test7_1(i32* inalloca nocapture %a)
+; ATTRIBUTOR: define void @test7_1(i32* inalloca nocapture writeonly %a)
; inalloca parameters are always considered written
define void @test7_1(i32* inalloca %a) {
ret void
}
-; CHECK: define i32* @test8_1(i32* readnone returned %p)
+; FNATTR: define i32* @test8_1(i32* readnone returned %p)
+; ATTRIBUTOR: define i32* @test8_1(i32* readnone returned %p)
define i32* @test8_1(i32* %p) {
entry:
ret i32* %p
}
-; CHECK: define void @test8_2(i32* %p)
+; FNATTR: define void @test8_2(i32* %p)
+; ATTRIBUTOR: define void @test8_2(i32* nocapture writeonly %p)
define void @test8_2(i32* %p) {
entry:
%call = call i32* @test8_1(i32* %p)
@@ -115,18 +125,21 @@ define i32 @volatile_load(i32* %p) {
ret i32 %load
}
-declare void @escape_readonly_ptr(i8** %addr, i8* readnone %ptr)
-declare void @escape_readnone_ptr(i8** %addr, i8* readonly %ptr)
+declare void @escape_readnone_ptr(i8** %addr, i8* readnone %ptr)
+declare void @escape_readonly_ptr(i8** %addr, i8* readonly %ptr)
; The argument pointer %escaped_then_written cannot be marked readnone/only even
; though the only direct use, in @escape_readnone_ptr/@escape_readonly_ptr,
; is marked as readnone/only. However, the functions can write the pointer into
; %addr, causing the store to write to %escaped_then_written.
;
-; FIXME: This test currently exposes a bug!
+; FIXME: This test currently exposes a bug in functionattrs!
+;
+; FNATTR: define void @unsound_readnone(i8* nocapture readnone %ignored, i8* readnone %escaped_then_written)
+; FNATTR: define void @unsound_readonly(i8* nocapture readnone %ignored, i8* readonly %escaped_then_written)
;
-; BUG: define void @unsound_readnone(i8* %ignored, i8* readnone %escaped_then_written)
-; BUG: define void @unsound_readonly(i8* %ignored, i8* readonly %escaped_then_written)
+; ATTRIBUTOR: define void @unsound_readnone(i8* nocapture readnone %ignored, i8* %escaped_then_written)
+; ATTRIBUTOR: define void @unsound_readonly(i8* nocapture readnone %ignored, i8* %escaped_then_written)
define void @unsound_readnone(i8* %ignored, i8* %escaped_then_written) {
%addr = alloca i8*
call void @escape_readnone_ptr(i8** %addr, i8* %escaped_then_written)
OpenPOWER on IntegriCloud