1 ; RUN: opt -S -passes=inferattrs,function-attrs < %s | FileCheck %s
3 declare void @f_readonly() readonly
4 declare void @f_readnone() readnone
5 declare void @f_writeonly() writeonly
7 define void @test_0(ptr %x) {
8 ; FunctionAttrs must not infer readonly / readnone for %x
10 ; CHECK-LABEL: define void @test_0(ptr %x) #3 {
12 ; CHECK: call void @f_readonly() [ "foo"(ptr %x) ]
13 call void @f_readonly() [ "foo"(ptr %x) ]
17 define void @test_1(ptr %x) {
18 ; FunctionAttrs must not infer readonly / readnone for %x
20 ; CHECK-LABEL: define void @test_1(ptr %x) #4 {
22 ; CHECK: call void @f_readnone() [ "foo"(ptr %x) ]
23 call void @f_readnone() [ "foo"(ptr %x) ]
27 define void @test_2(ptr %x) {
28 ; FunctionAttrs must not infer writeonly
30 ; CHECK-LABEL: define void @test_2(ptr %x) {
32 ; CHECK: call void @f_writeonly() [ "foo"(ptr %x) ]
33 call void @f_writeonly() [ "foo"(ptr %x) ]
37 define void @test_3(ptr %x) {
38 ; The "deopt" operand bundle does not capture or write to %x.
40 ; CHECK-LABEL: define void @test_3(ptr nocapture readonly %x)
42 call void @f_readonly() [ "deopt"(ptr %x) ]
46 ; CHECK: attributes #0 = { nofree memory(read) }
47 ; CHECK: attributes #1 = { nofree nosync memory(none) }
48 ; CHECK: attributes #2 = { memory(write) }
49 ; CHECK: attributes #3 = { nofree }
50 ; CHECK: attributes #4 = { nofree nosync }