blob: 7f22e6f2a2c5454460ab3ea8c09fa067ca4d08d0 [file] [log] [blame]
Nick Lewyckyc2ec0722013-07-06 00:29:58 +00001; RUN: opt < %s -functionattrs -S | FileCheck %s
2@x = global i32 0
3
4declare void @test1_1(i8* %x1_1, i8* readonly %y1_1, ...)
5
6; CHECK: define void @test1_2(i8* %x1_2, i8* readonly %y1_2, i8* %z1_2)
7define void @test1_2(i8* %x1_2, i8* %y1_2, i8* %z1_2) {
David Blaikie23af6482015-04-16 23:24:18 +00008 call void (i8*, i8*, ...) @test1_1(i8* %x1_2, i8* %y1_2, i8* %z1_2)
Nick Lewyckyc2ec0722013-07-06 00:29:58 +00009 store i32 0, i32* @x
10 ret void
11}
12
13; CHECK: define i8* @test2(i8* readnone %p)
14define i8* @test2(i8* %p) {
15 store i32 0, i32* @x
16 ret i8* %p
17}
18
19; CHECK: define i1 @test3(i8* readnone %p, i8* readnone %q)
20define i1 @test3(i8* %p, i8* %q) {
21 %A = icmp ult i8* %p, %q
22 ret i1 %A
23}
24
25declare void @test4_1(i8* nocapture) readonly
26
27; CHECK: define void @test4_2(i8* nocapture readonly %p)
28define void @test4_2(i8* %p) {
29 call void @test4_1(i8* %p)
30 ret void
31}
32
33; CHECK: define void @test5(i8** nocapture %p, i8* %q)
34; Missed optz'n: we could make %q readnone, but don't break test6!
35define void @test5(i8** %p, i8* %q) {
36 store i8* %q, i8** %p
37 ret void
38}
39
40declare void @test6_1()
41; CHECK: define void @test6_2(i8** nocapture %p, i8* %q)
42; This is not a missed optz'n.
43define void @test6_2(i8** %p, i8* %q) {
44 store i8* %q, i8** %p
45 call void @test6_1()
46 ret void
47}
Reid Kleckner26af2ca2014-01-28 02:38:36 +000048
49; CHECK: define void @test7_1(i32* inalloca nocapture %a)
50; inalloca parameters are always considered written
51define void @test7_1(i32* inalloca %a) {
52 ret void
53}
Nick Lewycky59633cb2014-05-30 02:31:27 +000054
55; CHECK: define i32* @test8_1(i32* readnone %p)
56define i32* @test8_1(i32* %p) {
57entry:
58 ret i32* %p
59}
60
61; CHECK: define void @test8_2(i32* %p)
62define void @test8_2(i32* %p) {
63entry:
64 %call = call i32* @test8_1(i32* %p)
65 store i32 10, i32* %call, align 4
66 ret void
67}