1 ; RUN: opt %loadPolly -pass-remarks-analysis="polly-scops" -polly-scops \
2 ; RUN: -polly-invariant-load-hoisting=true -disable-output < %s 2>&1 | FileCheck %s
4 ; CHECK: remark: test/ScopInfo/remarks.c:4:7: SCoP begins here.
5 ; CHECK: remark: test/ScopInfo/remarks.c:9:15: Inbounds assumption: [N, M, Debug] -> { : M <= 100 }
6 ; CHECK: remark: test/ScopInfo/remarks.c:13:7: No-error restriction: [N, M, Debug] -> { : N > 0 and M >= 0 and (Debug < 0 or Debug > 0) }
7 ; CHECK: remark: test/ScopInfo/remarks.c:8:5: Finite loop restriction: [N, M, Debug] -> { : N > 0 and M < 0 }
8 ; CHECK: remark: test/ScopInfo/remarks.c:4:7: No-overflows restriction: [N, M, Debug] -> { : M <= -2147483649 - N or M >= 2147483648 - N }
9 ; CHECK: remark: test/ScopInfo/remarks.c:9:18: Possibly aliasing pointer, use restrict keyword.
10 ; CHECK: remark: test/ScopInfo/remarks.c:9:33: Possibly aliasing pointer, use restrict keyword.
11 ; CHECK: remark: test/ScopInfo/remarks.c:9:15: Possibly aliasing pointer, use restrict keyword.
12 ; CHECK: remark: test/ScopInfo/remarks.c:14:3: SCoP ends here.
13 ; CHECK: remark: test/ScopInfo/remarks.c:19:3: SCoP begins here.
14 ; CHECK: remark: test/ScopInfo/remarks.c:21:11: Invariant load restriction: [tmp] -> { : tmp < 0 or tmp > 0 }
15 ; CHECK: remark: test/ScopInfo/remarks.c:22:16: SCoP ends here but was dismissed.
19 ; void valid(int *A, int *B, int N, int M, int C[100][100], int Debug) {
23 ; for (int i = 0; i < N; i++) {
24 ; for (int j = 0; j != M; j++) {
25 ; C[i][j] += A[i * M + j] + B[i + j];
33 ; void invalid0(int *A) {
34 ; for (int i = 0; i < 10; i++)
35 ; for (int j = 0; j < 10; j++)
40 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
42 @.str = private unnamed_addr constant [8 x i8] c"Printf!\00", align 1
44 define void @valid(ptr %A, ptr %B, i32 %N, i32 %M, ptr %C, i32 %Debug) #0 !dbg !4 {
46 call void @llvm.dbg.value(metadata ptr %A, i64 0, metadata !23, metadata !24), !dbg !25
47 call void @llvm.dbg.value(metadata ptr %B, i64 0, metadata !26, metadata !24), !dbg !27
48 call void @llvm.dbg.value(metadata i32 %N, i64 0, metadata !28, metadata !24), !dbg !29
49 call void @llvm.dbg.value(metadata i32 %M, i64 0, metadata !30, metadata !24), !dbg !31
50 call void @llvm.dbg.value(metadata ptr %C, i64 0, metadata !32, metadata !24), !dbg !33
51 call void @llvm.dbg.value(metadata i32 %Debug, i64 0, metadata !34, metadata !24), !dbg !35
55 %add = add i32 %N, %M, !dbg !36
56 %cmp = icmp eq i32 %add, -1, !dbg !38
57 br i1 %cmp, label %if.then, label %if.end, !dbg !39
59 if.then: ; preds = %entry
60 store i32 0, ptr %C, align 4, !dbg !41
61 br label %if.end, !dbg !40
63 if.end: ; preds = %if.then, %entry
64 call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !42, metadata !24), !dbg !44
65 %N64 = sext i32 %N to i64, !dbg !45
66 %M64 = sext i32 %M to i64, !dbg !45
67 br label %for.cond, !dbg !45
69 for.cond: ; preds = %for.inc.19, %if.end
70 %indvars.iv3 = phi i64 [ %indvars.iv.next4, %for.inc.19 ], [ 0, %if.end ]
71 %cmp2 = icmp slt i64 %indvars.iv3, %N64, !dbg !46
72 br i1 %cmp2, label %for.body, label %for.end.21, !dbg !49
74 for.body: ; preds = %for.cond
75 call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !50, metadata !24), !dbg !53
76 br label %for.cond.3, !dbg !54
78 for.cond.3: ; preds = %for.inc, %for.body
79 %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %for.body ]
80 %cmp4 = icmp eq i64 %indvars.iv, %M64, !dbg !55
81 br i1 %cmp4, label %for.end, label %for.body.5, !dbg !58
83 for.body.5: ; preds = %for.cond.3
84 %tmp8 = mul i64 %indvars.iv3, %M64, !dbg !59
85 %tmp9 = add i64 %tmp8, %indvars.iv, !dbg !61
86 %arrayidx7 = getelementptr inbounds i32, ptr %A, i64 %tmp9, !dbg !62
87 %tmp10 = load i32, ptr %arrayidx7, align 4, !dbg !62
88 %tmp11 = add i64 %indvars.iv3, %indvars.iv, !dbg !63
89 %arrayidx10 = getelementptr inbounds i32, ptr %B, i64 %tmp11, !dbg !64
90 %tmp12 = load i32, ptr %arrayidx10, align 4, !dbg !64
91 %add11 = add i32 %tmp10, %tmp12, !dbg !65
92 %arrayidx15 = getelementptr inbounds [100 x i32], ptr %C, i64 %indvars.iv3, i64 %indvars.iv, !dbg !66
93 %tmp13 = load i32, ptr %arrayidx15, align 4, !dbg !67
94 %add16 = add i32 %tmp13, %add11, !dbg !67
95 store i32 %add16, ptr %arrayidx15, align 4, !dbg !67
96 br label %for.inc, !dbg !68
98 for.inc: ; preds = %for.body.5
99 %indvars.iv.next = add i64 %indvars.iv, 1, !dbg !69
100 call void @llvm.dbg.value(metadata !2, i64 0, metadata !50, metadata !24), !dbg !53
101 br label %for.cond.3, !dbg !69
103 for.end: ; preds = %for.cond.3
104 %tobool = icmp eq i32 %Debug, 0, !dbg !70
105 br i1 %tobool, label %if.end.18, label %if.then.17, !dbg !72
107 if.then.17: ; preds = %for.end
108 %call = call i32 (ptr, ...) @printf(ptr nonnull @.str) #3, !dbg !73
109 br label %if.end.18, !dbg !73
111 if.end.18: ; preds = %for.end, %if.then.17
112 br label %for.inc.19, !dbg !74
114 for.inc.19: ; preds = %if.end.18
115 %indvars.iv.next4 = add nuw nsw i64 %indvars.iv3, 1, !dbg !75
116 call void @llvm.dbg.value(metadata !2, i64 0, metadata !42, metadata !24), !dbg !44
117 br label %for.cond, !dbg !75
119 for.end.21: ; preds = %for.cond
123 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
125 declare i32 @printf(ptr, ...) #2
127 define void @invalid0(ptr %A) #0 !dbg !13 {
129 call void @llvm.dbg.value(metadata ptr %A, i64 0, metadata !77, metadata !24), !dbg !78
130 call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !79, metadata !24), !dbg !81
131 br label %for.cond, !dbg !82
133 for.cond: ; preds = %for.inc.5, %entry
134 %i.0 = phi i32 [ 0, %entry ], [ %inc6, %for.inc.5 ]
135 %exitcond1 = icmp ne i32 %i.0, 10, !dbg !83
136 br i1 %exitcond1, label %for.body, label %for.end.7, !dbg !83
138 for.body: ; preds = %for.cond
139 call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !86, metadata !24), !dbg !88
140 br label %for.cond.1, !dbg !89
142 for.cond.1: ; preds = %for.inc, %for.body
143 %j.0 = phi i32 [ 0, %for.body ], [ %inc, %for.inc ]
144 %exitcond = icmp ne i32 %j.0, 10, !dbg !90
145 br i1 %exitcond, label %for.body.3, label %for.end, !dbg !90
147 for.body.3: ; preds = %for.cond.1
148 %tmp = load i32, ptr %A, align 4, !dbg !93
149 %tobool = icmp eq i32 %tmp, 0, !dbg !93
150 br i1 %tobool, label %if.end, label %if.then, !dbg !95
152 if.then: ; preds = %for.body.3
153 store i32 0, ptr %A, align 4, !dbg !96
154 br label %if.end, !dbg !97
156 if.end: ; preds = %for.body.3, %if.then
157 br label %for.inc, !dbg !98
159 for.inc: ; preds = %if.end
160 %inc = add nuw nsw i32 %j.0, 1, !dbg !100
161 call void @llvm.dbg.value(metadata i32 %inc, i64 0, metadata !86, metadata !24), !dbg !88
162 br label %for.cond.1, !dbg !101
164 for.end: ; preds = %for.cond.1
165 br label %for.inc.5, !dbg !102
167 for.inc.5: ; preds = %for.end
168 %inc6 = add nuw nsw i32 %i.0, 1, !dbg !103
169 call void @llvm.dbg.value(metadata i32 %inc6, i64 0, metadata !79, metadata !24), !dbg !81
170 br label %for.cond, !dbg !104
172 for.end.7: ; preds = %for.cond
176 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1
178 attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
179 attributes #1 = { nounwind readnone }
180 attributes #2 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
181 attributes #3 = { nounwind }
184 !llvm.module.flags = !{!20, !21}
187 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.8.0", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2)
188 !1 = !DIFile(filename: "test/ScopInfo/remarks.c", directory: "/home/johannes/repos/llvm-polly/tools/polly")
190 !4 = distinct !DISubprogram(name: "valid", scope: !1, file: !1, line: 3, type: !5, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
191 !5 = !DISubroutineType(types: !6)
192 !6 = !{null, !7, !7, !8, !8, !9, !8}
193 !7 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64, align: 64)
194 !8 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
195 !9 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64, align: 64)
196 !10 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 3200, align: 32, elements: !11)
198 !12 = !DISubrange(count: 100)
199 !13 = distinct !DISubprogram(name: "invalid0", scope: !1, file: !1, line: 18, type: !14, isLocal: false, isDefinition: true, scopeLine: 18, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
200 !14 = !DISubroutineType(types: !15)
202 !16 = distinct !DISubprogram(name: "invalid1", scope: !1, file: !1, line: 25, type: !17, isLocal: false, isDefinition: true, scopeLine: 25, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
203 !17 = !DISubroutineType(types: !18)
204 !18 = !{null, !19, !19}
205 !19 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64, align: 64)
206 !20 = !{i32 2, !"Dwarf Version", i32 4}
207 !21 = !{i32 2, !"Debug Info Version", i32 3}
208 !22 = !{!"clang version 3.8.0"}
209 !23 = !DILocalVariable(name: "A", arg: 1, scope: !4, file: !1, line: 3, type: !7)
210 !24 = !DIExpression()
211 !25 = !DILocation(line: 3, column: 17, scope: !4)
212 !26 = !DILocalVariable(name: "B", arg: 2, scope: !4, file: !1, line: 3, type: !7)
213 !27 = !DILocation(line: 3, column: 25, scope: !4)
214 !28 = !DILocalVariable(name: "N", arg: 3, scope: !4, file: !1, line: 3, type: !8)
215 !29 = !DILocation(line: 3, column: 32, scope: !4)
216 !30 = !DILocalVariable(name: "M", arg: 4, scope: !4, file: !1, line: 3, type: !8)
217 !31 = !DILocation(line: 3, column: 39, scope: !4)
218 !32 = !DILocalVariable(name: "C", arg: 5, scope: !4, file: !1, line: 3, type: !9)
219 !33 = !DILocation(line: 3, column: 46, scope: !4)
220 !34 = !DILocalVariable(name: "Debug", arg: 6, scope: !4, file: !1, line: 3, type: !8)
221 !35 = !DILocation(line: 3, column: 63, scope: !4)
222 !36 = !DILocation(line: 4, column: 9, scope: !37)
223 !37 = distinct !DILexicalBlock(scope: !4, file: !1, line: 4, column: 7)
224 !38 = !DILocation(line: 4, column: 13, scope: !37)
225 !39 = !DILocation(line: 4, column: 7, scope: !4)
226 !40 = !DILocation(line: 5, column: 5, scope: !37)
227 !41 = !DILocation(line: 5, column: 13, scope: !37)
228 !42 = !DILocalVariable(name: "i", scope: !43, file: !1, line: 7, type: !8)
229 !43 = distinct !DILexicalBlock(scope: !4, file: !1, line: 7, column: 3)
230 !44 = !DILocation(line: 7, column: 12, scope: !43)
231 !45 = !DILocation(line: 7, column: 8, scope: !43)
232 !46 = !DILocation(line: 7, column: 21, scope: !47)
233 !47 = !DILexicalBlockFile(scope: !48, file: !1, discriminator: 1)
234 !48 = distinct !DILexicalBlock(scope: !43, file: !1, line: 7, column: 3)
235 !49 = !DILocation(line: 7, column: 3, scope: !47)
236 !50 = !DILocalVariable(name: "j", scope: !51, file: !1, line: 8, type: !8)
237 !51 = distinct !DILexicalBlock(scope: !52, file: !1, line: 8, column: 5)
238 !52 = distinct !DILexicalBlock(scope: !48, file: !1, line: 7, column: 31)
239 !53 = !DILocation(line: 8, column: 14, scope: !51)
240 !54 = !DILocation(line: 8, column: 10, scope: !51)
241 !55 = !DILocation(line: 8, column: 23, scope: !56)
242 !56 = !DILexicalBlockFile(scope: !57, file: !1, discriminator: 1)
243 !57 = distinct !DILexicalBlock(scope: !51, file: !1, line: 8, column: 5)
244 !58 = !DILocation(line: 8, column: 5, scope: !56)
245 !59 = !DILocation(line: 9, column: 22, scope: !60)
246 !60 = distinct !DILexicalBlock(scope: !57, file: !1, line: 8, column: 34)
247 !61 = !DILocation(line: 9, column: 26, scope: !60)
248 !62 = !DILocation(line: 9, column: 18, scope: !60)
249 !63 = !DILocation(line: 9, column: 37, scope: !60)
250 !64 = !DILocation(line: 9, column: 33, scope: !60)
251 !65 = !DILocation(line: 9, column: 31, scope: !60)
252 !66 = !DILocation(line: 9, column: 7, scope: !60)
253 !67 = !DILocation(line: 9, column: 15, scope: !60)
254 !68 = !DILocation(line: 10, column: 5, scope: !60)
255 !69 = !DILocation(line: 8, column: 5, scope: !57)
256 !70 = !DILocation(line: 12, column: 9, scope: !71)
257 !71 = distinct !DILexicalBlock(scope: !52, file: !1, line: 12, column: 9)
258 !72 = !DILocation(line: 12, column: 9, scope: !52)
259 !73 = !DILocation(line: 13, column: 7, scope: !71)
260 !74 = !DILocation(line: 14, column: 3, scope: !52)
261 !75 = !DILocation(line: 7, column: 3, scope: !48)
262 !76 = !DILocation(line: 16, column: 1, scope: !4)
263 !77 = !DILocalVariable(name: "A", arg: 1, scope: !13, file: !1, line: 18, type: !7)
264 !78 = !DILocation(line: 18, column: 20, scope: !13)
265 !79 = !DILocalVariable(name: "i", scope: !80, file: !1, line: 19, type: !8)
266 !80 = distinct !DILexicalBlock(scope: !13, file: !1, line: 19, column: 3)
267 !81 = !DILocation(line: 19, column: 12, scope: !80)
268 !82 = !DILocation(line: 19, column: 8, scope: !80)
269 !83 = !DILocation(line: 19, column: 3, scope: !84)
270 !84 = !DILexicalBlockFile(scope: !85, file: !1, discriminator: 1)
271 !85 = distinct !DILexicalBlock(scope: !80, file: !1, line: 19, column: 3)
272 !86 = !DILocalVariable(name: "j", scope: !87, file: !1, line: 20, type: !8)
273 !87 = distinct !DILexicalBlock(scope: !85, file: !1, line: 20, column: 5)
274 !88 = !DILocation(line: 20, column: 14, scope: !87)
275 !89 = !DILocation(line: 20, column: 10, scope: !87)
276 !90 = !DILocation(line: 20, column: 5, scope: !91)
277 !91 = !DILexicalBlockFile(scope: !92, file: !1, discriminator: 1)
278 !92 = distinct !DILexicalBlock(scope: !87, file: !1, line: 20, column: 5)
279 !93 = !DILocation(line: 21, column: 11, scope: !94)
280 !94 = distinct !DILexicalBlock(scope: !92, file: !1, line: 21, column: 11)
281 !95 = !DILocation(line: 21, column: 11, scope: !92)
282 !96 = !DILocation(line: 22, column: 14, scope: !94)
283 !97 = !DILocation(line: 22, column: 9, scope: !94)
284 !98 = !DILocation(line: 21, column: 14, scope: !99)
285 !99 = !DILexicalBlockFile(scope: !94, file: !1, discriminator: 1)
286 !100 = !DILocation(line: 20, column: 30, scope: !92)
287 !101 = !DILocation(line: 20, column: 5, scope: !92)
288 !102 = !DILocation(line: 22, column: 16, scope: !87)
289 !103 = !DILocation(line: 19, column: 28, scope: !85)
290 !104 = !DILocation(line: 19, column: 3, scope: !85)
291 !105 = !DILocation(line: 23, column: 1, scope: !13)
292 !106 = !DILocalVariable(name: "A", arg: 1, scope: !16, file: !1, line: 25, type: !19)
293 !107 = !DILocation(line: 25, column: 21, scope: !16)
294 !108 = !DILocalVariable(name: "B", arg: 2, scope: !16, file: !1, line: 25, type: !19)
295 !109 = !DILocation(line: 25, column: 30, scope: !16)
296 !110 = !DILocalVariable(name: "i", scope: !111, file: !1, line: 26, type: !8)
297 !111 = distinct !DILexicalBlock(scope: !16, file: !1, line: 26, column: 3)
298 !112 = !DILocation(line: 26, column: 12, scope: !111)
299 !113 = !DILocation(line: 26, column: 8, scope: !111)
300 !114 = !DILocation(line: 26, column: 3, scope: !115)
301 !115 = !DILexicalBlockFile(scope: !116, file: !1, discriminator: 1)
302 !116 = distinct !DILexicalBlock(scope: !111, file: !1, line: 26, column: 3)
303 !117 = !DILocalVariable(name: "j", scope: !118, file: !1, line: 27, type: !8)
304 !118 = distinct !DILexicalBlock(scope: !116, file: !1, line: 27, column: 5)
305 !119 = !DILocation(line: 27, column: 14, scope: !118)
306 !120 = !DILocation(line: 27, column: 10, scope: !118)
307 !121 = !DILocation(line: 27, column: 5, scope: !122)
308 !122 = !DILexicalBlockFile(scope: !123, file: !1, discriminator: 1)
309 !123 = distinct !DILexicalBlock(scope: !118, file: !1, line: 27, column: 5)
310 !124 = !DILocation(line: 28, column: 17, scope: !123)
311 !125 = !DILocation(line: 28, column: 7, scope: !123)
312 !126 = !DILocation(line: 28, column: 15, scope: !123)
313 !127 = !DILocation(line: 27, column: 5, scope: !123)
314 !128 = !DILocation(line: 28, column: 23, scope: !118)
315 !129 = !DILocation(line: 26, column: 3, scope: !116)
316 !130 = !DILocation(line: 29, column: 1, scope: !16)