1 ; RUN: opt -inferattrs -function-attrs -S %s | FileCheck %s
3 declare void @decl_readonly() readonly
4 declare void @decl_readnone() readnone
5 declare void @decl_argmemonly(i32*) argmemonly
6 declare void @decl_unknown()
8 define void @test_fn_mustprogress(i32* %ptr) mustprogress {
9 ; CHECK: Function Attrs: mustprogress
10 ; CHECK-LABEL: @test_fn_mustprogress(
11 ; CHECK-NOT: call void @decl_readonly() #
12 ; CHECK-NOT: call void @decl_readnone() #
13 ; CHECK-NOT: call void @decl_unknown() #
14 ; CHECK-NOT: call void @decl_argmemonly(i32* [[PTR:%.*]]) #
17 call void @decl_readonly()
18 call void @decl_readnone()
19 call void @decl_unknown()
20 call void @decl_argmemonly(i32* %ptr)
24 define void @test_fn_willreturn(i32* %ptr) willreturn {
25 ; CHECK: Function Attrs: mustprogress willreturn
26 ; CHECK-LABEL: @test_fn_willreturn(
27 ; CHECK-NOT: call void @decl_readonly() #
28 ; CHECK-NOT : call void @decl_readnone() #
29 ; CHECK-NOT: call void @decl_unknown() #
30 ; CHECK-NOT: call void @decl_argmemonly(i32* [[PTR:%.*]]) #
33 call void @decl_readonly()
34 call void @decl_readnone()
35 call void @decl_unknown()
36 call void @decl_argmemonly(i32* %ptr)
40 define void @test_fn_mustprogress_readonly_calls(i32* %ptr) mustprogress {
41 ; CHECK: Function Attrs: mustprogress nofree readonly willreturn
42 ; CHECK-LABEL: @test_fn_mustprogress_readonly_calls(
43 ; CHECK-NOT: call void @decl_readonly() #
44 ; CHECK-NOT: call void @decl_readnone() #
47 call void @decl_readonly()
48 call void @decl_readnone()
52 define void @test_fn_mustprogress_readonly_calls_but_stores(i32* %ptr) mustprogress {
53 ; CHECK: Function Attrs: mustprogress nofree
54 ; CHECK-LABEL: @test_fn_mustprogress_readonly_calls_but_stores(
55 ; CHECK-NOT: call void @decl_readonly() #
56 ; CHECK-NOT: call void @decl_readnone() #
57 ; CHECK: store i32 0, i32* [[PTR:%.*]], align 4
58 ; CHECK-NEXT: ret void
60 call void @decl_readonly()
61 call void @decl_readnone()
62 store i32 0, i32* %ptr