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