xref: /llvm-project/polly/test/ScopDetectionDiagnostics/ReportUnprofitable.ll (revision e1f056f692d869708c1898d9d65a69ac5584a0ed)
1; RUN: opt %loadNPMPolly -pass-remarks-missed="polly-detect" \
2; RUN:     -polly-detect-track-failures '-passes=print<polly-detect>' -disable-output \
3; RUN:     -polly-process-unprofitable=false < %s 2>&1| FileCheck %s
4
5; RUN: opt %loadNPMPolly -pass-remarks-missed="polly-detect" \
6; RUN:     -polly-detect-track-failures '-passes=print<polly-detect>' -disable-output \
7; RUN:     -polly-process-unprofitable=false < %s 2>&1 -pass-remarks-output=%t.yaml
8; RUN: cat %t.yaml | FileCheck -check-prefix=YAML %s
9target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
10
11; void onlyWrite(float *A) {
12;   for (long i = 0; i < 100; i++)
13;     A[i] = 0;
14; }
15;
16; void onlyRead(float *A) {
17;   for (long i = 0; i < 100; i++)
18;     A[i];
19; }
20
21; CHECK: remark: /tmp/test.c:2:3: The following errors keep this region from being a Scop.
22; CHECK: remark: /tmp/test.c:2:3: No profitable polyhedral optimization found
23; CHECK: remark: /tmp/test.c:3:10: Invalid Scop candidate ends here.
24
25; CHECK: remark: /tmp/test.c:7:3: The following errors keep this region from being a Scop.
26; CHECK: remark: /tmp/test.c:7:3: No profitable polyhedral optimization found
27; CHECK: remark: /tmp/test.c:8:10: Invalid Scop candidate ends here.
28
29; YAML: --- !Missed
30; YAML: Pass:            polly-detect
31; YAML: Name:            RejectionErrors
32; YAML: DebugLoc:        { File: '/tmp/test.c', Line: 2, Column: 3 }
33; YAML: Function:        onlyWrite
34; YAML: Args:
35; YAML:   - String:          The following errors keep this region from being a Scop.
36; YAML: ...
37; YAML: --- !Missed
38; YAML: Pass:            polly-detect
39; YAML: Name:            Unprofitable
40; YAML: DebugLoc:        { File: '/tmp/test.c', Line: 2, Column: 3 }
41; YAML: Function:        onlyWrite
42; YAML: Args:
43; YAML:   - String:          No profitable polyhedral optimization found
44; YAML: ...
45; YAML: --- !Missed
46; YAML: Pass:            polly-detect
47; YAML: Name:            InvalidScopEnd
48; YAML: DebugLoc:        { File: '/tmp/test.c', Line: 3, Column: 10 }
49; YAML: Function:        onlyWrite
50; YAML: Args:
51; YAML:   - String:          Invalid Scop candidate ends here.
52; YAML: ...
53; YAML: --- !Missed
54; YAML: Pass:            polly-detect
55; YAML: Name:            RejectionErrors
56; YAML: DebugLoc:        { File: '/tmp/test.c', Line: 7, Column: 3 }
57; YAML: Function:        onlyRead
58; YAML: Args:
59; YAML:   - String:          The following errors keep this region from being a Scop.
60; YAML: ...
61; YAML: --- !Missed
62; YAML: Pass:            polly-detect
63; YAML: Name:            Unprofitable
64; YAML: DebugLoc:        { File: '/tmp/test.c', Line: 7, Column: 3 }
65; YAML: Function:        onlyRead
66; YAML: Args:
67; YAML:   - String:          No profitable polyhedral optimization found
68; YAML: ...
69; YAML: --- !Missed
70; YAML: Pass:            polly-detect
71; YAML: Name:            InvalidScopEnd
72; YAML: DebugLoc:        { File: '/tmp/test.c', Line: 8, Column: 10 }
73; YAML: Function:        onlyRead
74; YAML: Args:
75; YAML:   - String:          Invalid Scop candidate ends here.
76
77
78; Function Attrs: nounwind uwtable
79define void @onlyWrite(ptr %A) #0 !dbg !4 {
80entry:
81  call void @llvm.dbg.value(metadata ptr %A, i64 0, metadata !14, metadata !15), !dbg !16
82  call void @llvm.dbg.value(metadata i64 0, i64 0, metadata !17, metadata !15), !dbg !20
83  br label %for.cond, !dbg !21
84
85for.cond:                                         ; preds = %for.inc, %entry
86  %i.0 = phi i64 [ 0, %entry ], [ %inc, %for.inc ]
87  %exitcond = icmp ne i64 %i.0, 100, !dbg !22
88  br i1 %exitcond, label %for.body, label %for.end, !dbg !22
89
90for.body:                                         ; preds = %for.cond
91  %arrayidx = getelementptr inbounds float, ptr %A, i64 %i.0, !dbg !23
92  store float 0.000000e+00, ptr %arrayidx, align 4, !dbg !25
93  br label %for.inc, !dbg !23
94
95for.inc:                                          ; preds = %for.body
96  %inc = add nuw nsw i64 %i.0, 1, !dbg !26
97  call void @llvm.dbg.value(metadata i64 %inc, i64 0, metadata !17, metadata !15), !dbg !20
98  br label %for.cond, !dbg !27
99
100for.end:                                          ; preds = %for.cond
101  ret void, !dbg !28
102}
103
104; Function Attrs: nounwind readnone
105declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
106
107; Function Attrs: nounwind uwtable
108define void @onlyRead(ptr %A) #0 !dbg !10 {
109entry:
110  call void @llvm.dbg.value(metadata ptr %A, i64 0, metadata !29, metadata !15), !dbg !30
111  call void @llvm.dbg.value(metadata i64 0, i64 0, metadata !31, metadata !15), !dbg !33
112  br label %for.cond, !dbg !34
113
114for.cond:                                         ; preds = %for.inc, %entry
115  %i.0 = phi i64 [ 0, %entry ], [ %inc, %for.inc ]
116  %exitcond = icmp ne i64 %i.0, 100, !dbg !35
117  br i1 %exitcond, label %for.body, label %for.end, !dbg !35
118
119for.body:                                         ; preds = %for.cond
120  %arrayidx = getelementptr inbounds float, ptr %A, i64 %i.0, !dbg !36
121  %val = load float, ptr %arrayidx, align 4, !dbg !38
122  br label %for.inc, !dbg !36
123
124for.inc:                                          ; preds = %for.body
125  %inc = add nuw nsw i64 %i.0, 1, !dbg !39
126  call void @llvm.dbg.value(metadata i64 %inc, i64 0, metadata !31, metadata !15), !dbg !33
127  br label %for.cond, !dbg !40
128
129for.end:                                          ; preds = %for.cond
130  ret void, !dbg !41
131}
132
133; Function Attrs: nounwind readnone
134declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1
135
136attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
137attributes #1 = { nounwind readnone }
138
139!llvm.dbg.cu = !{!0}
140!llvm.module.flags = !{!11, !12}
141!llvm.ident = !{!13}
142
143!0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.7.0  (llvm/trunk 229257)", isOptimized: false, emissionKind: 1, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
144!1 = !DIFile(filename: "/tmp/test.c", directory: "/home/grosser/Projects/polly/git/tools/polly")
145!2 = !{}
146!4 = distinct !DISubprogram(name: "onlyWrite", line: 1, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 1, file: !1, scope: !5, type: !6, retainedNodes: !2)
147!5 = !DIFile(filename: "/tmp/test.c", directory: "/home/grosser/Projects/polly/git/tools/polly")
148!6 = !DISubroutineType(types: !7)
149!7 = !{null, !8}
150!8 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !9)
151!9 = !DIBasicType(tag: DW_TAG_base_type, name: "float", size: 32, align: 32, encoding: DW_ATE_float)
152!10 = distinct !DISubprogram(name: "onlyRead", line: 6, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 6, file: !1, scope: !5, type: !6, retainedNodes: !2)
153!11 = !{i32 2, !"Dwarf Version", i32 4}
154!12 = !{i32 2, !"Debug Info Version", i32 3}
155!13 = !{!"clang version 3.7.0  (llvm/trunk 229257)"}
156!14 = !DILocalVariable(name: "A", line: 1, arg: 1, scope: !4, file: !5, type: !8)
157!15 = !DIExpression()
158!16 = !DILocation(line: 1, column: 23, scope: !4)
159!17 = !DILocalVariable(name: "i", line: 2, scope: !18, file: !5, type: !19)
160!18 = distinct !DILexicalBlock(line: 2, column: 3, file: !1, scope: !4)
161!19 = !DIBasicType(tag: DW_TAG_base_type, name: "long int", size: 64, align: 64, encoding: DW_ATE_signed)
162!20 = !DILocation(line: 2, column: 13, scope: !18)
163!21 = !DILocation(line: 2, column: 8, scope: !18)
164!22 = !DILocation(line: 2, column: 3, scope: !18)
165!23 = !DILocation(line: 3, column: 5, scope: !24)
166!24 = distinct !DILexicalBlock(line: 2, column: 3, file: !1, scope: !18)
167!25 = !DILocation(line: 3, column: 10, scope: !24)
168!26 = !DILocation(line: 2, column: 30, scope: !24)
169!27 = !DILocation(line: 2, column: 3, scope: !24)
170!28 = !DILocation(line: 4, column: 1, scope: !4)
171!29 = !DILocalVariable(name: "A", line: 6, arg: 1, scope: !10, file: !5, type: !8)
172!30 = !DILocation(line: 6, column: 22, scope: !10)
173!31 = !DILocalVariable(name: "i", line: 7, scope: !32, file: !5, type: !19)
174!32 = distinct !DILexicalBlock(line: 7, column: 3, file: !1, scope: !10)
175!33 = !DILocation(line: 7, column: 13, scope: !32)
176!34 = !DILocation(line: 7, column: 8, scope: !32)
177!35 = !DILocation(line: 7, column: 3, scope: !32)
178!36 = !DILocation(line: 8, column: 5, scope: !37)
179!37 = distinct !DILexicalBlock(line: 7, column: 3, file: !1, scope: !32)
180!38 = !DILocation(line: 8, column: 10, scope: !37)
181!39 = !DILocation(line: 7, column: 30, scope: !37)
182!40 = !DILocation(line: 7, column: 3, scope: !37)
183!41 = !DILocation(line: 9, column: 1, scope: !10)
184