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 <= -2 or M = -1) }
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(i32* %A, i32* %B, i32 %N, i32 %M, [100 x i32]* %C, i32 %Debug) #0 !dbg !4 {
46 call void @llvm.dbg.value(metadata i32* %A, i64 0, metadata !23, metadata !24), !dbg !25
47 call void @llvm.dbg.value(metadata i32* %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 [100 x i32]* %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 %arrayidx1 = getelementptr inbounds [100 x i32], [100 x i32]* %C, i64 0, i64 0, !dbg !40
61 store i32 0, i32* %arrayidx1, align 4, !dbg !41
62 br label %if.end, !dbg !40
64 if.end: ; preds = %if.then, %entry
65 call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !42, metadata !24), !dbg !44
66 %N64 = sext i32 %N to i64, !dbg !45
67 %M64 = sext i32 %M to i64, !dbg !45
68 br label %for.cond, !dbg !45
70 for.cond: ; preds = %for.inc.19, %if.end
71 %indvars.iv3 = phi i64 [ %indvars.iv.next4, %for.inc.19 ], [ 0, %if.end ]
72 %cmp2 = icmp slt i64 %indvars.iv3, %N64, !dbg !46
73 br i1 %cmp2, label %for.body, label %for.end.21, !dbg !49
75 for.body: ; preds = %for.cond
76 call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !50, metadata !24), !dbg !53
77 br label %for.cond.3, !dbg !54
79 for.cond.3: ; preds = %for.inc, %for.body
80 %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %for.body ]
81 %cmp4 = icmp eq i64 %indvars.iv, %M64, !dbg !55
82 br i1 %cmp4, label %for.end, label %for.body.5, !dbg !58
84 for.body.5: ; preds = %for.cond.3
85 %tmp8 = mul i64 %indvars.iv3, %M64, !dbg !59
86 %tmp9 = add i64 %tmp8, %indvars.iv, !dbg !61
87 %arrayidx7 = getelementptr inbounds i32, i32* %A, i64 %tmp9, !dbg !62
88 %tmp10 = load i32, i32* %arrayidx7, align 4, !dbg !62
89 %tmp11 = add i64 %indvars.iv3, %indvars.iv, !dbg !63
90 %arrayidx10 = getelementptr inbounds i32, i32* %B, i64 %tmp11, !dbg !64
91 %tmp12 = load i32, i32* %arrayidx10, align 4, !dbg !64
92 %add11 = add i32 %tmp10, %tmp12, !dbg !65
93 %arrayidx15 = getelementptr inbounds [100 x i32], [100 x i32]* %C, i64 %indvars.iv3, i64 %indvars.iv, !dbg !66
94 %tmp13 = load i32, i32* %arrayidx15, align 4, !dbg !67
95 %add16 = add i32 %tmp13, %add11, !dbg !67
96 store i32 %add16, i32* %arrayidx15, align 4, !dbg !67
97 br label %for.inc, !dbg !68
99 for.inc: ; preds = %for.body.5
100 %indvars.iv.next = add i64 %indvars.iv, 1, !dbg !69
101 call void @llvm.dbg.value(metadata !2, i64 0, metadata !50, metadata !24), !dbg !53
102 br label %for.cond.3, !dbg !69
104 for.end: ; preds = %for.cond.3
105 %tobool = icmp eq i32 %Debug, 0, !dbg !70
106 br i1 %tobool, label %if.end.18, label %if.then.17, !dbg !72
108 if.then.17: ; preds = %for.end
109 %call = call i32 (i8*, ...) @printf(i8* nonnull getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0)) #3, !dbg !73
110 br label %if.end.18, !dbg !73
112 if.end.18: ; preds = %for.end, %if.then.17
113 br label %for.inc.19, !dbg !74
115 for.inc.19: ; preds = %if.end.18
116 %indvars.iv.next4 = add nuw nsw i64 %indvars.iv3, 1, !dbg !75
117 call void @llvm.dbg.value(metadata !2, i64 0, metadata !42, metadata !24), !dbg !44
118 br label %for.cond, !dbg !75
120 for.end.21: ; preds = %for.cond
124 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
126 declare i32 @printf(i8*, ...) #2
128 define void @invalid0(i32* %A) #0 !dbg !13 {
130 call void @llvm.dbg.value(metadata i32* %A, i64 0, metadata !77, metadata !24), !dbg !78
131 call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !79, metadata !24), !dbg !81
132 br label %for.cond, !dbg !82
134 for.cond: ; preds = %for.inc.5, %entry
135 %i.0 = phi i32 [ 0, %entry ], [ %inc6, %for.inc.5 ]
136 %exitcond1 = icmp ne i32 %i.0, 10, !dbg !83
137 br i1 %exitcond1, label %for.body, label %for.end.7, !dbg !83
139 for.body: ; preds = %for.cond
140 call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !86, metadata !24), !dbg !88
141 br label %for.cond.1, !dbg !89
143 for.cond.1: ; preds = %for.inc, %for.body
144 %j.0 = phi i32 [ 0, %for.body ], [ %inc, %for.inc ]
145 %exitcond = icmp ne i32 %j.0, 10, !dbg !90
146 br i1 %exitcond, label %for.body.3, label %for.end, !dbg !90
148 for.body.3: ; preds = %for.cond.1
149 %tmp = load i32, i32* %A, align 4, !dbg !93
150 %tobool = icmp eq i32 %tmp, 0, !dbg !93
151 br i1 %tobool, label %if.end, label %if.then, !dbg !95
153 if.then: ; preds = %for.body.3
154 store i32 0, i32* %A, align 4, !dbg !96
155 br label %if.end, !dbg !97
157 if.end: ; preds = %for.body.3, %if.then
158 br label %for.inc, !dbg !98
160 for.inc: ; preds = %if.end
161 %inc = add nuw nsw i32 %j.0, 1, !dbg !100
162 call void @llvm.dbg.value(metadata i32 %inc, i64 0, metadata !86, metadata !24), !dbg !88
163 br label %for.cond.1, !dbg !101
165 for.end: ; preds = %for.cond.1
166 br label %for.inc.5, !dbg !102
168 for.inc.5: ; preds = %for.end
169 %inc6 = add nuw nsw i32 %i.0, 1, !dbg !103
170 call void @llvm.dbg.value(metadata i32 %inc6, i64 0, metadata !79, metadata !24), !dbg !81
171 br label %for.cond, !dbg !104
173 for.end.7: ; preds = %for.cond
177 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1
179 attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "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" }
180 attributes #1 = { nounwind readnone }
181 attributes #2 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "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" }
182 attributes #3 = { nounwind }
185 !llvm.module.flags = !{!20, !21}
188 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.8.0 (http://llvm.org/git/clang.git 65eeefc97d2eee4d075ec7d9ed56b5f0786b6421)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2)
189 !1 = !DIFile(filename: "test/ScopInfo/remarks.c", directory: "/home/johannes/repos/llvm-polly/tools/polly")
191 !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, variables: !2)
192 !5 = !DISubroutineType(types: !6)
193 !6 = !{null, !7, !7, !8, !8, !9, !8}
194 !7 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64, align: 64)
195 !8 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
196 !9 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64, align: 64)
197 !10 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 3200, align: 32, elements: !11)
199 !12 = !DISubrange(count: 100)
200 !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, variables: !2)
201 !14 = !DISubroutineType(types: !15)
203 !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, variables: !2)
204 !17 = !DISubroutineType(types: !18)
205 !18 = !{null, !19, !19}
206 !19 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64, align: 64)
207 !20 = !{i32 2, !"Dwarf Version", i32 4}
208 !21 = !{i32 2, !"Debug Info Version", i32 3}
209 !22 = !{!"clang version 3.8.0 (http://llvm.org/git/clang.git 65eeefc97d2eee4d075ec7d9ed56b5f0786b6421)"}
210 !23 = !DILocalVariable(name: "A", arg: 1, scope: !4, file: !1, line: 3, type: !7)
211 !24 = !DIExpression()
212 !25 = !DILocation(line: 3, column: 17, scope: !4)
213 !26 = !DILocalVariable(name: "B", arg: 2, scope: !4, file: !1, line: 3, type: !7)
214 !27 = !DILocation(line: 3, column: 25, scope: !4)
215 !28 = !DILocalVariable(name: "N", arg: 3, scope: !4, file: !1, line: 3, type: !8)
216 !29 = !DILocation(line: 3, column: 32, scope: !4)
217 !30 = !DILocalVariable(name: "M", arg: 4, scope: !4, file: !1, line: 3, type: !8)
218 !31 = !DILocation(line: 3, column: 39, scope: !4)
219 !32 = !DILocalVariable(name: "C", arg: 5, scope: !4, file: !1, line: 3, type: !9)
220 !33 = !DILocation(line: 3, column: 46, scope: !4)
221 !34 = !DILocalVariable(name: "Debug", arg: 6, scope: !4, file: !1, line: 3, type: !8)
222 !35 = !DILocation(line: 3, column: 63, scope: !4)
223 !36 = !DILocation(line: 4, column: 9, scope: !37)
224 !37 = distinct !DILexicalBlock(scope: !4, file: !1, line: 4, column: 7)
225 !38 = !DILocation(line: 4, column: 13, scope: !37)
226 !39 = !DILocation(line: 4, column: 7, scope: !4)
227 !40 = !DILocation(line: 5, column: 5, scope: !37)
228 !41 = !DILocation(line: 5, column: 13, scope: !37)
229 !42 = !DILocalVariable(name: "i", scope: !43, file: !1, line: 7, type: !8)
230 !43 = distinct !DILexicalBlock(scope: !4, file: !1, line: 7, column: 3)
231 !44 = !DILocation(line: 7, column: 12, scope: !43)
232 !45 = !DILocation(line: 7, column: 8, scope: !43)
233 !46 = !DILocation(line: 7, column: 21, scope: !47)
234 !47 = !DILexicalBlockFile(scope: !48, file: !1, discriminator: 1)
235 !48 = distinct !DILexicalBlock(scope: !43, file: !1, line: 7, column: 3)
236 !49 = !DILocation(line: 7, column: 3, scope: !47)
237 !50 = !DILocalVariable(name: "j", scope: !51, file: !1, line: 8, type: !8)
238 !51 = distinct !DILexicalBlock(scope: !52, file: !1, line: 8, column: 5)
239 !52 = distinct !DILexicalBlock(scope: !48, file: !1, line: 7, column: 31)
240 !53 = !DILocation(line: 8, column: 14, scope: !51)
241 !54 = !DILocation(line: 8, column: 10, scope: !51)
242 !55 = !DILocation(line: 8, column: 23, scope: !56)
243 !56 = !DILexicalBlockFile(scope: !57, file: !1, discriminator: 1)
244 !57 = distinct !DILexicalBlock(scope: !51, file: !1, line: 8, column: 5)
245 !58 = !DILocation(line: 8, column: 5, scope: !56)
246 !59 = !DILocation(line: 9, column: 22, scope: !60)
247 !60 = distinct !DILexicalBlock(scope: !57, file: !1, line: 8, column: 34)
248 !61 = !DILocation(line: 9, column: 26, scope: !60)
249 !62 = !DILocation(line: 9, column: 18, scope: !60)
250 !63 = !DILocation(line: 9, column: 37, scope: !60)
251 !64 = !DILocation(line: 9, column: 33, scope: !60)
252 !65 = !DILocation(line: 9, column: 31, scope: !60)
253 !66 = !DILocation(line: 9, column: 7, scope: !60)
254 !67 = !DILocation(line: 9, column: 15, scope: !60)
255 !68 = !DILocation(line: 10, column: 5, scope: !60)
256 !69 = !DILocation(line: 8, column: 5, scope: !57)
257 !70 = !DILocation(line: 12, column: 9, scope: !71)
258 !71 = distinct !DILexicalBlock(scope: !52, file: !1, line: 12, column: 9)
259 !72 = !DILocation(line: 12, column: 9, scope: !52)
260 !73 = !DILocation(line: 13, column: 7, scope: !71)
261 !74 = !DILocation(line: 14, column: 3, scope: !52)
262 !75 = !DILocation(line: 7, column: 3, scope: !48)
263 !76 = !DILocation(line: 16, column: 1, scope: !4)
264 !77 = !DILocalVariable(name: "A", arg: 1, scope: !13, file: !1, line: 18, type: !7)
265 !78 = !DILocation(line: 18, column: 20, scope: !13)
266 !79 = !DILocalVariable(name: "i", scope: !80, file: !1, line: 19, type: !8)
267 !80 = distinct !DILexicalBlock(scope: !13, file: !1, line: 19, column: 3)
268 !81 = !DILocation(line: 19, column: 12, scope: !80)
269 !82 = !DILocation(line: 19, column: 8, scope: !80)
270 !83 = !DILocation(line: 19, column: 3, scope: !84)
271 !84 = !DILexicalBlockFile(scope: !85, file: !1, discriminator: 1)
272 !85 = distinct !DILexicalBlock(scope: !80, file: !1, line: 19, column: 3)
273 !86 = !DILocalVariable(name: "j", scope: !87, file: !1, line: 20, type: !8)
274 !87 = distinct !DILexicalBlock(scope: !85, file: !1, line: 20, column: 5)
275 !88 = !DILocation(line: 20, column: 14, scope: !87)
276 !89 = !DILocation(line: 20, column: 10, scope: !87)
277 !90 = !DILocation(line: 20, column: 5, scope: !91)
278 !91 = !DILexicalBlockFile(scope: !92, file: !1, discriminator: 1)
279 !92 = distinct !DILexicalBlock(scope: !87, file: !1, line: 20, column: 5)
280 !93 = !DILocation(line: 21, column: 11, scope: !94)
281 !94 = distinct !DILexicalBlock(scope: !92, file: !1, line: 21, column: 11)
282 !95 = !DILocation(line: 21, column: 11, scope: !92)
283 !96 = !DILocation(line: 22, column: 14, scope: !94)
284 !97 = !DILocation(line: 22, column: 9, scope: !94)
285 !98 = !DILocation(line: 21, column: 14, scope: !99)
286 !99 = !DILexicalBlockFile(scope: !94, file: !1, discriminator: 1)
287 !100 = !DILocation(line: 20, column: 30, scope: !92)
288 !101 = !DILocation(line: 20, column: 5, scope: !92)
289 !102 = !DILocation(line: 22, column: 16, scope: !87)
290 !103 = !DILocation(line: 19, column: 28, scope: !85)
291 !104 = !DILocation(line: 19, column: 3, scope: !85)
292 !105 = !DILocation(line: 23, column: 1, scope: !13)
293 !106 = !DILocalVariable(name: "A", arg: 1, scope: !16, file: !1, line: 25, type: !19)
294 !107 = !DILocation(line: 25, column: 21, scope: !16)
295 !108 = !DILocalVariable(name: "B", arg: 2, scope: !16, file: !1, line: 25, type: !19)
296 !109 = !DILocation(line: 25, column: 30, scope: !16)
297 !110 = !DILocalVariable(name: "i", scope: !111, file: !1, line: 26, type: !8)
298 !111 = distinct !DILexicalBlock(scope: !16, file: !1, line: 26, column: 3)
299 !112 = !DILocation(line: 26, column: 12, scope: !111)
300 !113 = !DILocation(line: 26, column: 8, scope: !111)
301 !114 = !DILocation(line: 26, column: 3, scope: !115)
302 !115 = !DILexicalBlockFile(scope: !116, file: !1, discriminator: 1)
303 !116 = distinct !DILexicalBlock(scope: !111, file: !1, line: 26, column: 3)
304 !117 = !DILocalVariable(name: "j", scope: !118, file: !1, line: 27, type: !8)
305 !118 = distinct !DILexicalBlock(scope: !116, file: !1, line: 27, column: 5)
306 !119 = !DILocation(line: 27, column: 14, scope: !118)
307 !120 = !DILocation(line: 27, column: 10, scope: !118)
308 !121 = !DILocation(line: 27, column: 5, scope: !122)
309 !122 = !DILexicalBlockFile(scope: !123, file: !1, discriminator: 1)
310 !123 = distinct !DILexicalBlock(scope: !118, file: !1, line: 27, column: 5)
311 !124 = !DILocation(line: 28, column: 17, scope: !123)
312 !125 = !DILocation(line: 28, column: 7, scope: !123)
313 !126 = !DILocation(line: 28, column: 15, scope: !123)
314 !127 = !DILocation(line: 27, column: 5, scope: !123)
315 !128 = !DILocation(line: 28, column: 23, scope: !118)
316 !129 = !DILocation(line: 26, column: 3, scope: !116)
317 !130 = !DILocation(line: 29, column: 1, scope: !16)