xref: /llvm-project/llvm/test/Analysis/GlobalsModRef/func-memattributes.ll (revision 47f0b6630c78ab52c2197ec5e1c2d13a6acffed1)
1; RUN: opt < %s -aa-pipeline=globals-aa -passes='require<globals-aa>,dse' -S | FileCheck %s
2
3@X = internal global i32 4
4
5define i32 @test0() {
6; CHECK-LABEL: @test0
7; CHECK: store i32 0, ptr @X
8; CHECK-NEXT: call i32 @func_readonly() #0
9; CHECK-NEXT: store i32 1, ptr @X
10  store i32 0, ptr @X
11  %x = call i32 @func_readonly() #0
12  store i32 1, ptr @X
13  ret i32 %x
14}
15
16define i32 @test1() {
17; CHECK-LABEL: @test1
18; CHECK-NOT: store
19; CHECK: call i32 @func_read_argmem_only() #1
20; CHECK-NEXT: store i32 3, ptr @X
21  store i32 2, ptr @X
22  %x = call i32 @func_read_argmem_only() #1
23  store i32 3, ptr @X
24  ret i32 %x
25}
26
27declare i32 @func_readonly() #0
28declare i32 @func_read_argmem_only() #1
29
30attributes #0 = { readonly nounwind }
31attributes #1 = { readonly argmemonly nounwind }
32