51 lines · plain
1; RUN: opt -S -passes=inferattrs,function-attrs < %s | FileCheck %s2 3declare void @f_readonly() readonly4declare void @f_readnone() readnone5declare void @f_writeonly() writeonly6 7define void @test_0(ptr %x) {8; FunctionAttrs must not infer readonly / readnone for %x9 10; CHECK-LABEL: define void @test_0(ptr %x) #3 {11 entry:12 ; CHECK: call void @f_readonly() [ "foo"(ptr %x) ]13 call void @f_readonly() [ "foo"(ptr %x) ]14 ret void15}16 17define void @test_1(ptr %x) {18; FunctionAttrs must not infer readonly / readnone for %x19 20; CHECK-LABEL: define void @test_1(ptr %x) #4 {21 entry:22 ; CHECK: call void @f_readnone() [ "foo"(ptr %x) ]23 call void @f_readnone() [ "foo"(ptr %x) ]24 ret void25}26 27define void @test_2(ptr %x) {28; FunctionAttrs must not infer writeonly29 30; CHECK-LABEL: define void @test_2(ptr %x) {31 entry:32 ; CHECK: call void @f_writeonly() [ "foo"(ptr %x) ]33 call void @f_writeonly() [ "foo"(ptr %x) ]34 ret void35}36 37define void @test_3(ptr %x) {38; The "deopt" operand bundle does not capture or write to %x.39 40; CHECK-LABEL: define void @test_3(ptr readonly captures(none) %x)41 entry:42 call void @f_readonly() [ "deopt"(ptr %x) ]43 ret void44}45 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 }51