• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -lint -disable-output 2>&1 | FileCheck %s
2
3%s = type { i8 }
4
5; Function Attrs: argmemonly nounwind
6declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture writeonly, i8* nocapture readonly, i32, i1) #0
7
8; Function Attrs: argmemonly nounwind
9declare void @llvm.memset.p0i8.i32(i8* nocapture writeonly, i8, i32, i1) #0
10
11declare void @f1(%s* noalias nocapture sret(%s), %s* nocapture readnone)
12
13define void @f2() {
14entry:
15  %c = alloca %s
16  %tmp = alloca %s
17  %0 = bitcast %s* %c to i8*
18  %1 = bitcast %s* %tmp to i8*
19  call void @llvm.memset.p0i8.i32(i8* %0, i8 0, i32 1, i1 false)
20  call void @f1(%s* sret(%s) %c, %s* %c)
21  ret void
22}
23
24; Lint should complain about us passing %c to both arguments since one of them
25; is noalias.
26; CHECK: Unusual: noalias argument aliases another argument
27; CHECK-NEXT: call void @f1(%s* sret(%s) %c, %s* %c)
28
29declare void @f3(%s* noalias nocapture sret(%s), %s* byval(%s) nocapture readnone)
30
31define void @f4() {
32entry:
33  %c = alloca %s
34  %tmp = alloca %s
35  %0 = bitcast %s* %c to i8*
36  %1 = bitcast %s* %tmp to i8*
37  call void @llvm.memset.p0i8.i32(i8* %0, i8 0, i32 1, i1 false)
38  call void @f3(%s* sret(%s) %c, %s* byval(%s) %c)
39  ret void
40}
41
42; Lint should not complain about passing %c to both arguments even if one is
43; noalias, since the other one is byval, effectively copying the data to the
44; stack instead of passing the pointer itself.
45; CHECK-NOT: Unusual: noalias argument aliases another argument
46; CHECK-NOT: call void @f3(%s* sret(%s) %c, %s* byval(%s) %c)
47
48attributes #0 = { argmemonly nounwind }
49