1; RUN: opt %loadPolly -basic-aa -polly-stmt-granularity=bb -polly-scops -analyze -polly-allow-modref-calls \
2; RUN: < %s | FileCheck %s
3; RUN: opt %loadPolly -basic-aa -polly-codegen -disable-output \
4; RUN: -polly-allow-modref-calls < %s
5;
6; Verify that we model the read access of the gcread intrinsic
7; correctly, thus that A is read by it but B is not.
8;
9; CHECK:      Stmt_for_body
10; CHECK-NEXT:   Domain :=
11; CHECK-NEXT:       { Stmt_for_body[i0] : 0 <= i0 <= 1023 };
12; CHECK-NEXT:   Schedule :=
13; CHECK-NEXT:       { Stmt_for_body[i0] -> [i0] };
14; CHECK-NEXT:   ReadAccess := [Reduction Type: NONE]
15; CHECK-NEXT:       { Stmt_for_body[i0] -> MemRef_A[o0] };
16; CHECK-NEXT:   MustWriteAccess :=  [Reduction Type: NONE]
17; CHECK-NEXT:       { Stmt_for_body[i0] -> MemRef_dummyloc[0] };
18; CHECK-NEXT:   ReadAccess := [Reduction Type: NONE]
19; CHECK-NEXT:       { Stmt_for_body[i0] -> MemRef_B[i0] };
20; CHECK-NEXT:   MustWriteAccess :=  [Reduction Type: NONE]
21; CHECK-NEXT:       { Stmt_for_body[i0] -> MemRef_A[i0] };
22;
23;    void jd(int *restirct A, int *restrict B) {
24;      char **dummyloc;
25;      for (int i = 0; i < 1024; i++) {
26;        char *dummy = @llvm.gcread(A, nullptr);
27;        *dummyloc = dummy;
28;        A[i] = B[i];
29;      }
30;    }
31;
32target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
33
34define void @jd(i32* noalias %A, i32* noalias %B) gc "dummy" {
35entry:
36  %dummyloc = alloca i8*
37  br label %entry.split
38
39entry.split:					  ; preds = %entry
40  br label %for.body
41
42for.body:                                         ; preds = %entry.split, %for.inc
43  %i = phi i64 [ 0, %entry.split ], [ %i.next, %for.inc ]
44  %arrayidx = getelementptr inbounds i32, i32* %A, i64 %i
45  %arrayidx1 = getelementptr inbounds i32, i32* %B, i64 %i
46  %bc = bitcast i32* %arrayidx to i8*
47  %dummy = call i8* @f(i8* %bc, i8** null)
48  store i8* %dummy, i8** %dummyloc, align 4
49  %tmp = load i32, i32* %arrayidx1
50  store i32 %tmp, i32* %arrayidx, align 4
51  br label %for.inc
52
53for.inc:                                          ; preds = %for.body
54  %i.next = add nuw nsw i64 %i, 1
55  %exitcond = icmp ne i64 %i.next, 1024
56  br i1 %exitcond, label %for.body, label %for.end
57
58for.end:                                          ; preds = %for.inc
59  ret void
60}
61
62declare i8* @f(i8*, i8**) #0
63
64attributes #0 = { argmemonly readonly nounwind }
65