311 lines · plain
1; RUN: opt %loadNPMPolly -pass-remarks-analysis=polly-scops '-passes=polly-custom<scops>' -polly-print-scops -polly-invariant-load-hoisting=true -disable-output < %s 2>&1 | FileCheck %s2;3; CHECK: remark: test/ScopInfo/remarks.c:4:7: SCoP begins here.4; CHECK: remark: test/ScopInfo/remarks.c:9:15: Inbounds assumption: [N, M, Debug] -> { : M <= 100 }5; 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) }6; CHECK: remark: test/ScopInfo/remarks.c:8:5: Finite loop restriction: [N, M, Debug] -> { : N > 0 and M < 0 }7; CHECK: remark: test/ScopInfo/remarks.c:4:7: No-overflows restriction: [N, M, Debug] -> { : M <= -2147483649 - N or M >= 2147483648 - N }8; CHECK: remark: test/ScopInfo/remarks.c:9:18: Possibly aliasing pointer, use restrict keyword.9; CHECK: remark: test/ScopInfo/remarks.c:9:33: Possibly aliasing pointer, use restrict keyword.10; CHECK: remark: test/ScopInfo/remarks.c:9:15: Possibly aliasing pointer, use restrict keyword.11; CHECK: remark: test/ScopInfo/remarks.c:14:3: SCoP ends here.12; CHECK: remark: test/ScopInfo/remarks.c:19:3: SCoP begins here.13; CHECK: remark: test/ScopInfo/remarks.c:21:11: Invariant load restriction: [tmp] -> { : tmp < 0 or tmp > 0 }14; CHECK: remark: test/ScopInfo/remarks.c:22:16: SCoP ends here but was dismissed.15;16; #include <stdio.h>17;18; void valid(int *A, int *B, int N, int M, int C[100][100], int Debug) {19; if (N + M == -1)20; C[0][0] = 0;21;22; for (int i = 0; i < N; i++) {23; for (int j = 0; j != M; j++) {24; C[i][j] += A[i * M + j] + B[i + j];25; }26;27; if (Debug)28; printf("Printf!");29; }30; }31;32; void invalid0(int *A) {33; for (int i = 0; i < 10; i++)34; for (int j = 0; j < 10; j++)35; if (A[0])36; A[0] = 0;37; }38;39target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"40 41@.str = private unnamed_addr constant [8 x i8] c"Printf!\00", align 142 43define void @valid(ptr %A, ptr %B, i32 %N, i32 %M, ptr %C, i32 %Debug) !dbg !4 {44entry:45 call void @llvm.dbg.value(metadata ptr %A, i64 0, metadata !23, metadata !24), !dbg !2546 call void @llvm.dbg.value(metadata ptr %B, i64 0, metadata !26, metadata !24), !dbg !2747 call void @llvm.dbg.value(metadata i32 %N, i64 0, metadata !28, metadata !24), !dbg !2948 call void @llvm.dbg.value(metadata i32 %M, i64 0, metadata !30, metadata !24), !dbg !3149 call void @llvm.dbg.value(metadata ptr %C, i64 0, metadata !32, metadata !24), !dbg !3350 call void @llvm.dbg.value(metadata i32 %Debug, i64 0, metadata !34, metadata !24), !dbg !3551 br label %entry.split52 53entry.split:54 %add = add i32 %N, %M, !dbg !3655 %cmp = icmp eq i32 %add, -1, !dbg !3856 br i1 %cmp, label %if.then, label %if.end, !dbg !3957 58if.then: ; preds = %entry59 store i32 0, ptr %C, align 4, !dbg !4160 br label %if.end, !dbg !4061 62if.end: ; preds = %if.then, %entry63 call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !42, metadata !24), !dbg !4464 %N64 = sext i32 %N to i64, !dbg !4565 %M64 = sext i32 %M to i64, !dbg !4566 br label %for.cond, !dbg !4567 68for.cond: ; preds = %for.inc.19, %if.end69 %indvars.iv3 = phi i64 [ %indvars.iv.next4, %for.inc.19 ], [ 0, %if.end ]70 %cmp2 = icmp slt i64 %indvars.iv3, %N64, !dbg !4671 br i1 %cmp2, label %for.body, label %for.end.21, !dbg !4972 73for.body: ; preds = %for.cond74 call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !50, metadata !24), !dbg !5375 br label %for.cond.3, !dbg !5476 77for.cond.3: ; preds = %for.inc, %for.body78 %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %for.body ]79 %cmp4 = icmp eq i64 %indvars.iv, %M64, !dbg !5580 br i1 %cmp4, label %for.end, label %for.body.5, !dbg !5881 82for.body.5: ; preds = %for.cond.383 %tmp8 = mul i64 %indvars.iv3, %M64, !dbg !5984 %tmp9 = add i64 %tmp8, %indvars.iv, !dbg !6185 %arrayidx7 = getelementptr inbounds i32, ptr %A, i64 %tmp9, !dbg !6286 %tmp10 = load i32, ptr %arrayidx7, align 4, !dbg !6287 %tmp11 = add i64 %indvars.iv3, %indvars.iv, !dbg !6388 %arrayidx10 = getelementptr inbounds i32, ptr %B, i64 %tmp11, !dbg !6489 %tmp12 = load i32, ptr %arrayidx10, align 4, !dbg !6490 %add11 = add i32 %tmp10, %tmp12, !dbg !6591 %arrayidx15 = getelementptr inbounds [100 x i32], ptr %C, i64 %indvars.iv3, i64 %indvars.iv, !dbg !6692 %tmp13 = load i32, ptr %arrayidx15, align 4, !dbg !6793 %add16 = add i32 %tmp13, %add11, !dbg !6794 store i32 %add16, ptr %arrayidx15, align 4, !dbg !6795 br label %for.inc, !dbg !6896 97for.inc: ; preds = %for.body.598 %indvars.iv.next = add i64 %indvars.iv, 1, !dbg !6999 call void @llvm.dbg.value(metadata !2, i64 0, metadata !50, metadata !24), !dbg !53100 br label %for.cond.3, !dbg !69101 102for.end: ; preds = %for.cond.3103 %tobool = icmp eq i32 %Debug, 0, !dbg !70104 br i1 %tobool, label %if.end.18, label %if.then.17, !dbg !72105 106if.then.17: ; preds = %for.end107 %call = call i32 (ptr, ...) @printf(ptr nonnull @.str), !dbg !73108 br label %if.end.18, !dbg !73109 110if.end.18: ; preds = %for.end, %if.then.17111 br label %for.inc.19, !dbg !74112 113for.inc.19: ; preds = %if.end.18114 %indvars.iv.next4 = add nuw nsw i64 %indvars.iv3, 1, !dbg !75115 call void @llvm.dbg.value(metadata !2, i64 0, metadata !42, metadata !24), !dbg !44116 br label %for.cond, !dbg !75117 118for.end.21: ; preds = %for.cond119 ret void, !dbg !76120}121 122declare void @llvm.dbg.declare(metadata, metadata, metadata)123 124declare i32 @printf(ptr, ...)125 126define void @invalid0(ptr %A) !dbg !13 {127entry:128 call void @llvm.dbg.value(metadata ptr %A, i64 0, metadata !77, metadata !24), !dbg !78129 call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !79, metadata !24), !dbg !81130 br label %for.cond, !dbg !82131 132for.cond: ; preds = %for.inc.5, %entry133 %i.0 = phi i32 [ 0, %entry ], [ %inc6, %for.inc.5 ]134 %exitcond1 = icmp ne i32 %i.0, 10, !dbg !83135 br i1 %exitcond1, label %for.body, label %for.end.7, !dbg !83136 137for.body: ; preds = %for.cond138 call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !86, metadata !24), !dbg !88139 br label %for.cond.1, !dbg !89140 141for.cond.1: ; preds = %for.inc, %for.body142 %j.0 = phi i32 [ 0, %for.body ], [ %inc, %for.inc ]143 %exitcond = icmp ne i32 %j.0, 10, !dbg !90144 br i1 %exitcond, label %for.body.3, label %for.end, !dbg !90145 146for.body.3: ; preds = %for.cond.1147 %tmp = load i32, ptr %A, align 4, !dbg !93148 %tobool = icmp eq i32 %tmp, 0, !dbg !93149 br i1 %tobool, label %if.end, label %if.then, !dbg !95150 151if.then: ; preds = %for.body.3152 store i32 0, ptr %A, align 4, !dbg !96153 br label %if.end, !dbg !97154 155if.end: ; preds = %for.body.3, %if.then156 br label %for.inc, !dbg !98157 158for.inc: ; preds = %if.end159 %inc = add nuw nsw i32 %j.0, 1, !dbg !100160 call void @llvm.dbg.value(metadata i32 %inc, i64 0, metadata !86, metadata !24), !dbg !88161 br label %for.cond.1, !dbg !101162 163for.end: ; preds = %for.cond.1164 br label %for.inc.5, !dbg !102165 166for.inc.5: ; preds = %for.end167 %inc6 = add nuw nsw i32 %i.0, 1, !dbg !103168 call void @llvm.dbg.value(metadata i32 %inc6, i64 0, metadata !79, metadata !24), !dbg !81169 br label %for.cond, !dbg !104170 171for.end.7: ; preds = %for.cond172 ret void, !dbg !105173}174 175declare void @llvm.dbg.value(metadata, i64, metadata, metadata)176 177!llvm.dbg.cu = !{!0}178!llvm.module.flags = !{!20, !21}179!llvm.ident = !{!22}180 181!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.8.0", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2)182!1 = !DIFile(filename: "test/ScopInfo/remarks.c", directory: "/home/johannes/repos/llvm-polly/tools/polly")183!2 = !{}184!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)185!5 = !DISubroutineType(types: !6)186!6 = !{null, !7, !7, !8, !8, !9, !8}187!7 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64, align: 64)188!8 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)189!9 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64, align: 64)190!10 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 3200, align: 32, elements: !11)191!11 = !{!12}192!12 = !DISubrange(count: 100)193!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)194!14 = !DISubroutineType(types: !15)195!15 = !{null, !7}196!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)197!17 = !DISubroutineType(types: !18)198!18 = !{null, !19, !19}199!19 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64, align: 64)200!20 = !{i32 2, !"Dwarf Version", i32 4}201!21 = !{i32 2, !"Debug Info Version", i32 3}202!22 = !{!"clang version 3.8.0"}203!23 = !DILocalVariable(name: "A", arg: 1, scope: !4, file: !1, line: 3, type: !7)204!24 = !DIExpression()205!25 = !DILocation(line: 3, column: 17, scope: !4)206!26 = !DILocalVariable(name: "B", arg: 2, scope: !4, file: !1, line: 3, type: !7)207!27 = !DILocation(line: 3, column: 25, scope: !4)208!28 = !DILocalVariable(name: "N", arg: 3, scope: !4, file: !1, line: 3, type: !8)209!29 = !DILocation(line: 3, column: 32, scope: !4)210!30 = !DILocalVariable(name: "M", arg: 4, scope: !4, file: !1, line: 3, type: !8)211!31 = !DILocation(line: 3, column: 39, scope: !4)212!32 = !DILocalVariable(name: "C", arg: 5, scope: !4, file: !1, line: 3, type: !9)213!33 = !DILocation(line: 3, column: 46, scope: !4)214!34 = !DILocalVariable(name: "Debug", arg: 6, scope: !4, file: !1, line: 3, type: !8)215!35 = !DILocation(line: 3, column: 63, scope: !4)216!36 = !DILocation(line: 4, column: 9, scope: !37)217!37 = distinct !DILexicalBlock(scope: !4, file: !1, line: 4, column: 7)218!38 = !DILocation(line: 4, column: 13, scope: !37)219!39 = !DILocation(line: 4, column: 7, scope: !4)220!40 = !DILocation(line: 5, column: 5, scope: !37)221!41 = !DILocation(line: 5, column: 13, scope: !37)222!42 = !DILocalVariable(name: "i", scope: !43, file: !1, line: 7, type: !8)223!43 = distinct !DILexicalBlock(scope: !4, file: !1, line: 7, column: 3)224!44 = !DILocation(line: 7, column: 12, scope: !43)225!45 = !DILocation(line: 7, column: 8, scope: !43)226!46 = !DILocation(line: 7, column: 21, scope: !47)227!47 = !DILexicalBlockFile(scope: !48, file: !1, discriminator: 1)228!48 = distinct !DILexicalBlock(scope: !43, file: !1, line: 7, column: 3)229!49 = !DILocation(line: 7, column: 3, scope: !47)230!50 = !DILocalVariable(name: "j", scope: !51, file: !1, line: 8, type: !8)231!51 = distinct !DILexicalBlock(scope: !52, file: !1, line: 8, column: 5)232!52 = distinct !DILexicalBlock(scope: !48, file: !1, line: 7, column: 31)233!53 = !DILocation(line: 8, column: 14, scope: !51)234!54 = !DILocation(line: 8, column: 10, scope: !51)235!55 = !DILocation(line: 8, column: 23, scope: !56)236!56 = !DILexicalBlockFile(scope: !57, file: !1, discriminator: 1)237!57 = distinct !DILexicalBlock(scope: !51, file: !1, line: 8, column: 5)238!58 = !DILocation(line: 8, column: 5, scope: !56)239!59 = !DILocation(line: 9, column: 22, scope: !60)240!60 = distinct !DILexicalBlock(scope: !57, file: !1, line: 8, column: 34)241!61 = !DILocation(line: 9, column: 26, scope: !60)242!62 = !DILocation(line: 9, column: 18, scope: !60)243!63 = !DILocation(line: 9, column: 37, scope: !60)244!64 = !DILocation(line: 9, column: 33, scope: !60)245!65 = !DILocation(line: 9, column: 31, scope: !60)246!66 = !DILocation(line: 9, column: 7, scope: !60)247!67 = !DILocation(line: 9, column: 15, scope: !60)248!68 = !DILocation(line: 10, column: 5, scope: !60)249!69 = !DILocation(line: 8, column: 5, scope: !57)250!70 = !DILocation(line: 12, column: 9, scope: !71)251!71 = distinct !DILexicalBlock(scope: !52, file: !1, line: 12, column: 9)252!72 = !DILocation(line: 12, column: 9, scope: !52)253!73 = !DILocation(line: 13, column: 7, scope: !71)254!74 = !DILocation(line: 14, column: 3, scope: !52)255!75 = !DILocation(line: 7, column: 3, scope: !48)256!76 = !DILocation(line: 16, column: 1, scope: !4)257!77 = !DILocalVariable(name: "A", arg: 1, scope: !13, file: !1, line: 18, type: !7)258!78 = !DILocation(line: 18, column: 20, scope: !13)259!79 = !DILocalVariable(name: "i", scope: !80, file: !1, line: 19, type: !8)260!80 = distinct !DILexicalBlock(scope: !13, file: !1, line: 19, column: 3)261!81 = !DILocation(line: 19, column: 12, scope: !80)262!82 = !DILocation(line: 19, column: 8, scope: !80)263!83 = !DILocation(line: 19, column: 3, scope: !84)264!84 = !DILexicalBlockFile(scope: !85, file: !1, discriminator: 1)265!85 = distinct !DILexicalBlock(scope: !80, file: !1, line: 19, column: 3)266!86 = !DILocalVariable(name: "j", scope: !87, file: !1, line: 20, type: !8)267!87 = distinct !DILexicalBlock(scope: !85, file: !1, line: 20, column: 5)268!88 = !DILocation(line: 20, column: 14, scope: !87)269!89 = !DILocation(line: 20, column: 10, scope: !87)270!90 = !DILocation(line: 20, column: 5, scope: !91)271!91 = !DILexicalBlockFile(scope: !92, file: !1, discriminator: 1)272!92 = distinct !DILexicalBlock(scope: !87, file: !1, line: 20, column: 5)273!93 = !DILocation(line: 21, column: 11, scope: !94)274!94 = distinct !DILexicalBlock(scope: !92, file: !1, line: 21, column: 11)275!95 = !DILocation(line: 21, column: 11, scope: !92)276!96 = !DILocation(line: 22, column: 14, scope: !94)277!97 = !DILocation(line: 22, column: 9, scope: !94)278!98 = !DILocation(line: 21, column: 14, scope: !99)279!99 = !DILexicalBlockFile(scope: !94, file: !1, discriminator: 1)280!100 = !DILocation(line: 20, column: 30, scope: !92)281!101 = !DILocation(line: 20, column: 5, scope: !92)282!102 = !DILocation(line: 22, column: 16, scope: !87)283!103 = !DILocation(line: 19, column: 28, scope: !85)284!104 = !DILocation(line: 19, column: 3, scope: !85)285!105 = !DILocation(line: 23, column: 1, scope: !13)286!106 = !DILocalVariable(name: "A", arg: 1, scope: !16, file: !1, line: 25, type: !19)287!107 = !DILocation(line: 25, column: 21, scope: !16)288!108 = !DILocalVariable(name: "B", arg: 2, scope: !16, file: !1, line: 25, type: !19)289!109 = !DILocation(line: 25, column: 30, scope: !16)290!110 = !DILocalVariable(name: "i", scope: !111, file: !1, line: 26, type: !8)291!111 = distinct !DILexicalBlock(scope: !16, file: !1, line: 26, column: 3)292!112 = !DILocation(line: 26, column: 12, scope: !111)293!113 = !DILocation(line: 26, column: 8, scope: !111)294!114 = !DILocation(line: 26, column: 3, scope: !115)295!115 = !DILexicalBlockFile(scope: !116, file: !1, discriminator: 1)296!116 = distinct !DILexicalBlock(scope: !111, file: !1, line: 26, column: 3)297!117 = !DILocalVariable(name: "j", scope: !118, file: !1, line: 27, type: !8)298!118 = distinct !DILexicalBlock(scope: !116, file: !1, line: 27, column: 5)299!119 = !DILocation(line: 27, column: 14, scope: !118)300!120 = !DILocation(line: 27, column: 10, scope: !118)301!121 = !DILocation(line: 27, column: 5, scope: !122)302!122 = !DILexicalBlockFile(scope: !123, file: !1, discriminator: 1)303!123 = distinct !DILexicalBlock(scope: !118, file: !1, line: 27, column: 5)304!124 = !DILocation(line: 28, column: 17, scope: !123)305!125 = !DILocation(line: 28, column: 7, scope: !123)306!126 = !DILocation(line: 28, column: 15, scope: !123)307!127 = !DILocation(line: 27, column: 5, scope: !123)308!128 = !DILocation(line: 28, column: 23, scope: !118)309!129 = !DILocation(line: 26, column: 3, scope: !116)310!130 = !DILocation(line: 29, column: 1, scope: !16)311