xref: /llvm-project/llvm/test/Analysis/Lint/noalias-readonly.ll (revision ead84636a31cfa1f028743ed4e7ae3160a08c34d)
1; RUN: opt < %s -passes=lint -disable-output 2>&1 | FileCheck %s
2
3declare void @f1(ptr noalias readonly, ptr)
4
5define void @f2(ptr %a) {
6entry:
7  call void @f1(ptr %a, ptr %a)
8  ret void
9}
10
11; Lint should complain about us passing %a to both arguments, since the noalias
12; argument may depend on writes to the other.
13; CHECK: Unusual: noalias argument aliases another argument
14; CHECK-NEXT: call void @f1(ptr %a, ptr %a)
15
16declare void @f3(ptr noalias, ptr readonly)
17
18define void @f4(ptr %a) {
19entry:
20  call void @f3(ptr %a, ptr %a)
21  ret void
22}
23
24; Lint should complain about us passing %a to both arguments, since writes to
25; the noalias argument may cause a dependency for the other.
26; CHECK: Unusual: noalias argument aliases another argument
27; CHECK-NEXT: call void @f3(ptr %a, ptr %a)
28
29declare void @f5(ptr noalias readonly, ptr readonly)
30
31define void @f6(ptr %a) {
32entry:
33  call void @f5(ptr %a, ptr %a)
34  ret void
35}
36
37; Lint should not complain about passing %a to both arguments even if one is
38; noalias, since they are both readonly and thus have no dependence.
39; CHECK-NOT: Unusual: noalias argument aliases another argument
40; CHECK-NOT: call void @f5(ptr %a, ptr %a)
41