diff options
Diffstat (limited to 'test/Transforms/FunctionAttrs/readattrs.ll')
-rw-r--r-- | test/Transforms/FunctionAttrs/readattrs.ll | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/test/Transforms/FunctionAttrs/readattrs.ll b/test/Transforms/FunctionAttrs/readattrs.ll new file mode 100644 index 0000000..0842f56 --- /dev/null +++ b/test/Transforms/FunctionAttrs/readattrs.ll @@ -0,0 +1,47 @@ +; RUN: opt < %s -functionattrs -S | FileCheck %s +@x = global i32 0 + +declare void @test1_1(i8* %x1_1, i8* readonly %y1_1, ...) + +; CHECK: define void @test1_2(i8* %x1_2, i8* readonly %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 %p) +define i8* @test2(i8* %p) { + store i32 0, i32* @x + ret i8* %p +} + +; CHECK: define i1 @test3(i8* readnone %p, i8* readnone %q) +define i1 @test3(i8* %p, i8* %q) { + %A = icmp ult i8* %p, %q + ret i1 %A +} + +declare void @test4_1(i8* nocapture) readonly + +; CHECK: define void @test4_2(i8* nocapture readonly %p) +define void @test4_2(i8* %p) { + call void @test4_1(i8* %p) + ret void +} + +; CHECK: define void @test5(i8** nocapture %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 + ret void +} + +declare void @test6_1() +; CHECK: define void @test6_2(i8** nocapture %p, i8* %q) +; This is not a missed optz'n. +define void @test6_2(i8** %p, i8* %q) { + store i8* %q, i8** %p + call void @test6_1() + ret void +} |