xref: /llvm-project/polly/test/ScopDetectionDiagnostics/ReportVariantBasePtr-01.ll (revision e1f056f692d869708c1898d9d65a69ac5584a0ed)
1; RUN: opt %loadNPMPolly -pass-remarks-missed="polly-detect" -polly-detect-track-failures '-passes=print<polly-detect>' -disable-output < %s 2>&1| FileCheck %s
2
3; struct b {
4;   double **b;
5; };
6;
7; void a(struct b *A) {
8;   for (int i=0; i<32; i++)
9;     A[i].b[i] = 0;
10; }
11
12; The loads are currently just adds %7 to the list of required invariant loads
13; and only -polly-scops checks whether it is actionally possible the be load
14; hoisted. The SCoP is still rejected by -polly-detect because it may alias
15; with %A and is not considered to be eligible for runtime alias checking.
16
17; CHECK: remark: ReportVariantBasePtr01.c:6:8: The following errors keep this region from being a Scop.
18; CHECK: remark: ReportVariantBasePtr01.c:7:5: Accesses to the arrays "A", " <unknown> " may access the same memory.
19
20target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
21
22%struct.b = type { ptr }
23
24define void @a(ptr nocapture readonly %A) #0 !dbg !4 {
25entry:
26  br label %entry.split
27
28entry.split:                                      ; preds = %entry
29  tail call void @llvm.dbg.value(metadata ptr %A, i64 0, metadata !16, metadata !DIExpression()), !dbg !23
30  tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !17, metadata !DIExpression()), !dbg !25
31  br label %for.body, !dbg !27
32
33for.body:                                         ; preds = %for.body, %entry.split
34  %indvar4 = phi i64 [ %indvar.next, %for.body ], [ 0, %entry.split ]
35  %b = getelementptr inbounds %struct.b, ptr %A, i64 %indvar4, i32 0, !dbg !26
36  %0 = mul i64 %indvar4, 4, !dbg !26
37  %1 = add i64 %0, 3, !dbg !26
38  %2 = add i64 %0, 2, !dbg !26
39  %3 = add i64 %0, 1, !dbg !26
40  %4 = load ptr, ptr %b, align 8, !dbg !26, !tbaa !28
41  %arrayidx = getelementptr ptr, ptr %4, i64 %0, !dbg !26
42  store ptr null, ptr %arrayidx, align 8, !dbg !26, !tbaa !33
43  %5 = load ptr, ptr %b, align 8, !dbg !26, !tbaa !28
44  %arrayidx.1 = getelementptr ptr, ptr %5, i64 %3, !dbg !26
45  store ptr null, ptr %arrayidx.1, align 8, !dbg !26, !tbaa !33
46  %6 = load ptr, ptr %b, align 8, !dbg !26, !tbaa !28
47  %arrayidx.2 = getelementptr ptr, ptr %6, i64 %2, !dbg !26
48  store ptr null, ptr %arrayidx.2, align 8, !dbg !26, !tbaa !33
49  %7 = load ptr, ptr %b, align 8, !dbg !26, !tbaa !28
50  %arrayidx.3 = getelementptr ptr, ptr %7, i64 %1, !dbg !26
51  store ptr null, ptr %arrayidx.3, align 8, !dbg !26, !tbaa !33
52  %indvar.next = add i64 %indvar4, 1, !dbg !27
53  %exitcond = icmp eq i64 %indvar.next, 8, !dbg !27
54  br i1 %exitcond, label %for.end, label %for.body, !dbg !27
55
56for.end:                                          ; preds = %for.body
57  ret void, !dbg !34
58}
59
60declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1
61
62attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
63attributes #1 = { nounwind readnone }
64
65!llvm.dbg.cu = !{!0}
66!llvm.module.flags = !{!20, !21}
67!llvm.ident = !{!22}
68
69!0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.5.0 ", isOptimized: true, emissionKind: 1, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
70!1 = !DIFile(filename: "ReportVariantBasePtr01.c", directory: "test/ScopDetectionDiagnostics")
71!2 = !{}
72!4 = distinct !DISubprogram(name: "a", line: 5, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 5, file: !1, scope: !5, type: !6, retainedNodes: !15)
73!5 = !DIFile(filename: "ReportVariantBasePtr01.c", directory: "test/ScopDetectionDiagnostics")
74!6 = !DISubroutineType(types: !7)
75!7 = !{null, !8}
76!8 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !9)
77!9 = !DICompositeType(tag: DW_TAG_structure_type, name: "b", line: 1, size: 64, align: 64, file: !1, elements: !10)
78!10 = !{!11}
79!11 = !DIDerivedType(tag: DW_TAG_member, name: "b", line: 2, size: 64, align: 64, file: !1, scope: !9, baseType: !12)
80!12 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !13)
81!13 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !14)
82!14 = !DIBasicType(tag: DW_TAG_base_type, name: "double", size: 64, align: 64, encoding: DW_ATE_float)
83!15 = !{!16, !17}
84!16 = !DILocalVariable(name: "A", line: 5, arg: 1, scope: !4, file: !5, type: !8)
85!17 = !DILocalVariable(name: "i", line: 6, scope: !18, file: !5, type: !19)
86!18 = distinct !DILexicalBlock(line: 6, column: 3, file: !1, scope: !4)
87!19 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
88!20 = !{i32 2, !"Dwarf Version", i32 4}
89!21 = !{i32 2, !"Debug Info Version", i32 3}
90!22 = !{!"clang version 3.5.0 "}
91!23 = !DILocation(line: 5, column: 18, scope: !4)
92!24 = !{i32 0}
93!25 = !DILocation(line: 6, column: 12, scope: !18)
94!26 = !DILocation(line: 7, column: 5, scope: !18)
95!27 = !DILocation(line: 6, column: 8, scope: !18)
96!28 = !{!29, !30, i64 0}
97!29 = !{!"b", !30, i64 0}
98!30 = !{!"any pointer", !31, i64 0}
99!31 = !{!"omnipotent char", !32, i64 0}
100!32 = !{!"Simple C/C++ TBAA"}
101!33 = !{!30, !30, i64 0}
102!34 = !DILocation(line: 8, column: 1, scope: !4)
103