summaryrefslogtreecommitdiffstats
path: root/polly/test/JSONExporter/ImportContext
diff options
context:
space:
mode:
authorMichael Kruse <llvm@meinersbur.de>2017-05-24 15:09:35 +0000
committerMichael Kruse <llvm@meinersbur.de>2017-05-24 15:09:35 +0000
commitcb58bd6ccdf9d2bbbf021599c92a74f776feee40 (patch)
tree2d95a1b76ec1890dd9a8e71ea20971a95037c6d9 /polly/test/JSONExporter/ImportContext
parentb07351f4f87ff31373bd5d8321569736117a7c90 (diff)
downloadbcm5719-llvm-cb58bd6ccdf9d2bbbf021599c92a74f776feee40.tar.gz
bcm5719-llvm-cb58bd6ccdf9d2bbbf021599c92a74f776feee40.zip
[JSONImporter] misses checks whether the data it imports makes sense.
Without this patch, the JSONImporter did not verify if the data it loads were correct or not (Bug llvm.org/PR32543). I add some checks in the JSONImporter class and some test cases. Here are the checks (and test cases) I added : JSONImporter::importContext - The "context" key does not exist. - The context was not parsed successfully by ISL. - The isl_set has the wrong number of parameters. - The isl_set is not a parameter set. JSONImporter::importSchedule - The "statements" key does not exist. - There is not the right number of statement in the file. - The "schedule" key does not exist. - The schedule was not parsed successfully by ISL. JSONImporter::importAccesses - The "statements" key does not exist. - There is not the right number of statement in the file. - The "accesses" key does not exist. - There is not the right number of memory accesses in the file. - The "relation" key does not exist. - The memory access was not parsed successfully by ISL. JSONImporter::areArraysEqual - The "type" key does not exist. - The "sizes" key does not exist. - The "name" key does not exist. JSONImporter::importArrays /!\ Do not check if there is an key name "arrays" because it is not considered as an error. All checks are already in place or implemented in JSONImporter::areArraysEqual. Contributed-by: Nicolas Bonfante <nicolas.bonfante@insa-lyon.fr> Differential Revision: https://reviews.llvm.org/D32739 llvm-svn: 303759
Diffstat (limited to 'polly/test/JSONExporter/ImportContext')
-rw-r--r--polly/test/JSONExporter/ImportContext/ImportContext-Context-mispelled.ll64
-rw-r--r--polly/test/JSONExporter/ImportContext/ImportContext-Not-parameter-set.ll64
-rw-r--r--polly/test/JSONExporter/ImportContext/ImportContext-Unvalid-Context.ll64
-rw-r--r--polly/test/JSONExporter/ImportContext/ImportContext-Wrong-dimension.ll64
-rw-r--r--polly/test/JSONExporter/ImportContext/ic2___%for.cond---%for.end10.jscop32
-rw-r--r--polly/test/JSONExporter/ImportContext/ic3___%for.cond---%for.end10.jscop32
-rw-r--r--polly/test/JSONExporter/ImportContext/ic4___%for.cond---%for.end10.jscop32
-rw-r--r--polly/test/JSONExporter/ImportContext/ic___%for.cond---%for.end10.jscop32
8 files changed, 384 insertions, 0 deletions
diff --git a/polly/test/JSONExporter/ImportContext/ImportContext-Context-mispelled.ll b/polly/test/JSONExporter/ImportContext/ImportContext-Context-mispelled.ll
new file mode 100644
index 00000000000..bbe7224633b
--- /dev/null
+++ b/polly/test/JSONExporter/ImportContext/ImportContext-Context-mispelled.ll
@@ -0,0 +1,64 @@
+; RUN: opt %loadPolly -polly-import-jscop-dir=%S -polly-import-jscop -polly-ast -polly-ast-detect-parallel < %s 2>&1 >/dev/null | FileCheck %s
+;
+; CHECK: JScop file has no key named 'context'.
+;
+; Verify if the JSONImporter check if there is a key name 'context'.
+;
+; void ic(int *A, long n) {
+; for (long i = 0; i < 2 * n; i++)
+; S0: A[0] += i;
+; for (long i = 0; i < 2 * n; i++)
+; S1: A[i + 1] = 1;
+; }
+;
+target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-n32-S64"
+
+define void @ic(i32* %A, i32 %n) {
+entry:
+ br label %for.cond
+
+for.cond: ; preds = %for.inc, %entry
+ %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
+ %mul = shl nsw i32 %n, 1
+ %cmp = icmp slt i32 %i.0, %mul
+ br i1 %cmp, label %for.body, label %for.end
+
+for.body: ; preds = %for.cond
+ br label %S0
+
+S0: ; preds = %for.body
+ %tmp = load i32, i32* %A, align 4
+ %add = add nsw i32 %tmp, %i.0
+ store i32 %add, i32* %A, align 4
+ br label %for.inc
+
+for.inc: ; preds = %S0
+ %inc = add nsw i32 %i.0, 1
+ br label %for.cond
+
+for.end: ; preds = %for.cond
+ br label %for.cond2
+
+for.cond2: ; preds = %for.inc8, %for.end
+ %i1.0 = phi i32 [ 0, %for.end ], [ %inc9, %for.inc8 ]
+ %mul3 = shl nsw i32 %n, 1
+ %cmp4 = icmp slt i32 %i1.0, %mul3
+ br i1 %cmp4, label %for.body5, label %for.end10
+
+for.body5: ; preds = %for.cond2
+ br label %S1
+
+S1: ; preds = %for.body5
+ %add6 = add nsw i32 %i1.0, 1
+ %arrayidx7 = getelementptr inbounds i32, i32* %A, i32 %add6
+ store i32 1, i32* %arrayidx7, align 4
+ br label %for.inc8
+
+for.inc8: ; preds = %S1
+ %inc9 = add nsw i32 %i1.0, 1
+ br label %for.cond2
+
+for.end10: ; preds = %for.cond2
+ ret void
+}
+
diff --git a/polly/test/JSONExporter/ImportContext/ImportContext-Not-parameter-set.ll b/polly/test/JSONExporter/ImportContext/ImportContext-Not-parameter-set.ll
new file mode 100644
index 00000000000..f20abc637ef
--- /dev/null
+++ b/polly/test/JSONExporter/ImportContext/ImportContext-Not-parameter-set.ll
@@ -0,0 +1,64 @@
+; RUN: opt %loadPolly -polly-import-jscop-dir=%S -polly-import-jscop -polly-ast -polly-ast-detect-parallel -analyze < %s 2>&1 >/dev/null | FileCheck %s
+;
+; CHECK: The isl_set is not a parameter set.
+;
+; Verify if the JSONImporter check if the imported set is a parameter one.
+;
+; void ic3(int *A, long n) {
+; for (long i = 0; i < 2 * n; i++)
+; S0: A[0] += i;
+; for (long i = 0; i < 2 * n; i++)
+; S1: A[i + 1] = 1;
+; }
+;
+target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-n32-S64"
+
+define void @ic3(i32* %A, i32 %n) {
+entry:
+ br label %for.cond
+
+for.cond: ; preds = %for.inc, %entry
+ %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
+ %mul = shl nsw i32 %n, 1
+ %cmp = icmp slt i32 %i.0, %mul
+ br i1 %cmp, label %for.body, label %for.end
+
+for.body: ; preds = %for.cond
+ br label %S0
+
+S0: ; preds = %for.body
+ %tmp = load i32, i32* %A, align 4
+ %add = add nsw i32 %tmp, %i.0
+ store i32 %add, i32* %A, align 4
+ br label %for.inc
+
+for.inc: ; preds = %S0
+ %inc = add nsw i32 %i.0, 1
+ br label %for.cond
+
+for.end: ; preds = %for.cond
+ br label %for.cond2
+
+for.cond2: ; preds = %for.inc8, %for.end
+ %i1.0 = phi i32 [ 0, %for.end ], [ %inc9, %for.inc8 ]
+ %mul3 = shl nsw i32 %n, 1
+ %cmp4 = icmp slt i32 %i1.0, %mul3
+ br i1 %cmp4, label %for.body5, label %for.end10
+
+for.body5: ; preds = %for.cond2
+ br label %S1
+
+S1: ; preds = %for.body5
+ %add6 = add nsw i32 %i1.0, 1
+ %arrayidx7 = getelementptr inbounds i32, i32* %A, i32 %add6
+ store i32 1, i32* %arrayidx7, align 4
+ br label %for.inc8
+
+for.inc8: ; preds = %S1
+ %inc9 = add nsw i32 %i1.0, 1
+ br label %for.cond2
+
+for.end10: ; preds = %for.cond2
+ ret void
+}
+
diff --git a/polly/test/JSONExporter/ImportContext/ImportContext-Unvalid-Context.ll b/polly/test/JSONExporter/ImportContext/ImportContext-Unvalid-Context.ll
new file mode 100644
index 00000000000..de0a0810da0
--- /dev/null
+++ b/polly/test/JSONExporter/ImportContext/ImportContext-Unvalid-Context.ll
@@ -0,0 +1,64 @@
+; RUN: opt %loadPolly -polly-import-jscop-dir=%S -polly-import-jscop -polly-ast -polly-ast-detect-parallel < %s 2>&1 >/dev/null | FileCheck %s
+;
+; CHECK: The context was not parsed successfully by ISL.
+;
+; Verify if the JSONImporter check if the context is parsed successfully.
+;
+; void ic2(int *A, long n) {
+; for (long i = 0; i < 2 * n; i++)
+; S0: A[0] += i;
+; for (long i = 0; i < 2 * n; i++)
+; S1: A[i + 1] = 1;
+; }
+;
+target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-n32-S64"
+
+define void @ic2(i32* %A, i32 %n) {
+entry:
+ br label %for.cond
+
+for.cond: ; preds = %for.inc, %entry
+ %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
+ %mul = shl nsw i32 %n, 1
+ %cmp = icmp slt i32 %i.0, %mul
+ br i1 %cmp, label %for.body, label %for.end
+
+for.body: ; preds = %for.cond
+ br label %S0
+
+S0: ; preds = %for.body
+ %tmp = load i32, i32* %A, align 4
+ %add = add nsw i32 %tmp, %i.0
+ store i32 %add, i32* %A, align 4
+ br label %for.inc
+
+for.inc: ; preds = %S0
+ %inc = add nsw i32 %i.0, 1
+ br label %for.cond
+
+for.end: ; preds = %for.cond
+ br label %for.cond2
+
+for.cond2: ; preds = %for.inc8, %for.end
+ %i1.0 = phi i32 [ 0, %for.end ], [ %inc9, %for.inc8 ]
+ %mul3 = shl nsw i32 %n, 1
+ %cmp4 = icmp slt i32 %i1.0, %mul3
+ br i1 %cmp4, label %for.body5, label %for.end10
+
+for.body5: ; preds = %for.cond2
+ br label %S1
+
+S1: ; preds = %for.body5
+ %add6 = add nsw i32 %i1.0, 1
+ %arrayidx7 = getelementptr inbounds i32, i32* %A, i32 %add6
+ store i32 1, i32* %arrayidx7, align 4
+ br label %for.inc8
+
+for.inc8: ; preds = %S1
+ %inc9 = add nsw i32 %i1.0, 1
+ br label %for.cond2
+
+for.end10: ; preds = %for.cond2
+ ret void
+}
+
diff --git a/polly/test/JSONExporter/ImportContext/ImportContext-Wrong-dimension.ll b/polly/test/JSONExporter/ImportContext/ImportContext-Wrong-dimension.ll
new file mode 100644
index 00000000000..4c4b6c39d84
--- /dev/null
+++ b/polly/test/JSONExporter/ImportContext/ImportContext-Wrong-dimension.ll
@@ -0,0 +1,64 @@
+; RUN: opt %loadPolly -polly-import-jscop-dir=%S -polly-import-jscop -polly-ast -polly-ast-detect-parallel < %s 2>&1 >/dev/null | FileCheck %s
+;
+; CHECK: Imported context has the wrong number of parameters : Found 2 Expected 1
+;
+; Verify if the JSONImporter check if there is the right number of parameters.
+;
+; void ic4(int *A, long n) {
+; for (long i = 0; i < 2 * n; i++)
+; S0: A[0] += i;
+; for (long i = 0; i < 2 * n; i++)
+; S1: A[i + 1] = 1;
+; }
+;
+target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-n32-S64"
+
+define void @ic4(i32* %A, i32 %n) {
+entry:
+ br label %for.cond
+
+for.cond: ; preds = %for.inc, %entry
+ %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
+ %mul = shl nsw i32 %n, 1
+ %cmp = icmp slt i32 %i.0, %mul
+ br i1 %cmp, label %for.body, label %for.end
+
+for.body: ; preds = %for.cond
+ br label %S0
+
+S0: ; preds = %for.body
+ %tmp = load i32, i32* %A, align 4
+ %add = add nsw i32 %tmp, %i.0
+ store i32 %add, i32* %A, align 4
+ br label %for.inc
+
+for.inc: ; preds = %S0
+ %inc = add nsw i32 %i.0, 1
+ br label %for.cond
+
+for.end: ; preds = %for.cond
+ br label %for.cond2
+
+for.cond2: ; preds = %for.inc8, %for.end
+ %i1.0 = phi i32 [ 0, %for.end ], [ %inc9, %for.inc8 ]
+ %mul3 = shl nsw i32 %n, 1
+ %cmp4 = icmp slt i32 %i1.0, %mul3
+ br i1 %cmp4, label %for.body5, label %for.end10
+
+for.body5: ; preds = %for.cond2
+ br label %S1
+
+S1: ; preds = %for.body5
+ %add6 = add nsw i32 %i1.0, 1
+ %arrayidx7 = getelementptr inbounds i32, i32* %A, i32 %add6
+ store i32 1, i32* %arrayidx7, align 4
+ br label %for.inc8
+
+for.inc8: ; preds = %S1
+ %inc9 = add nsw i32 %i1.0, 1
+ br label %for.cond2
+
+for.end10: ; preds = %for.cond2
+ ret void
+}
+
diff --git a/polly/test/JSONExporter/ImportContext/ic2___%for.cond---%for.end10.jscop b/polly/test/JSONExporter/ImportContext/ic2___%for.cond---%for.end10.jscop
new file mode 100644
index 00000000000..14619582bcb
--- /dev/null
+++ b/polly/test/JSONExporter/ImportContext/ic2___%for.cond---%for.end10.jscop
@@ -0,0 +1,32 @@
+{
+ "context" : "[n] -> { : >= -2147483648 and n <= 2147483647 }",
+ "name" : "for.cond => for.end10",
+ "statements" : [
+ {
+ "accesses" : [
+ {
+ "kind" : "read",
+ "relation" : "[n] -> { Stmt_S0[i0] -> MemRef_A[0] }"
+ },
+ {
+ "kind" : "write",
+ "relation" : "[n] -> { Stmt_S0[i0] -> MemRef_A[0] }"
+ }
+ ],
+ "domain" : "[n] -> { Stmt_S0[i0] : i0 >= 0 and i0 <= -1 + 2n and n >= 1 }",
+ "name" : "Stmt_S0",
+ "schedule" : "[n] -> { Stmt_S0[i0] -> [0, n - i0, 0] }"
+ },
+ {
+ "accesses" : [
+ {
+ "kind" : "write",
+ "relation" : "[n] -> { Stmt_S1[i0] -> MemRef_A[1 + i0] }"
+ }
+ ],
+ "domain" : "[n] -> { Stmt_S1[i0] : i0 >= 0 and i0 <= -1 + 2n and n >= 1 }",
+ "name" : "Stmt_S1",
+ "schedule" : "[n] -> { Stmt_S1[i0] -> [1, n - i0, 0] }"
+ }
+ ]
+}
diff --git a/polly/test/JSONExporter/ImportContext/ic3___%for.cond---%for.end10.jscop b/polly/test/JSONExporter/ImportContext/ic3___%for.cond---%for.end10.jscop
new file mode 100644
index 00000000000..0046db8df65
--- /dev/null
+++ b/polly/test/JSONExporter/ImportContext/ic3___%for.cond---%for.end10.jscop
@@ -0,0 +1,32 @@
+{
+ "context" : "{ S[n] : n >= -2147483648 and n <= 2147483647 }",
+ "name" : "for.cond => for.end10",
+ "statements" : [
+ {
+ "accesses" : [
+ {
+ "kind" : "read",
+ "relation" : "[n] -> { Stmt_S0[i0] -> MemRef_A[0] }"
+ },
+ {
+ "kind" : "write",
+ "relation" : "[n] -> { Stmt_S0[i0] -> MemRef_A[0] }"
+ }
+ ],
+ "domain" : "[n] -> { Stmt_S0[i0] : i0 >= 0 and i0 <= -1 + 2n and n >= 1 }",
+ "name" : "Stmt_S0",
+ "schedule" : "[n] -> { Stmt_S0[i0] -> [0, n - i0, 0] }"
+ },
+ {
+ "accesses" : [
+ {
+ "kind" : "write",
+ "relation" : "[n] -> { Stmt_S1[i0] -> MemRef_A[1 + i0] }"
+ }
+ ],
+ "domain" : "[n] -> { Stmt_S1[i0] : i0 >= 0 and i0 <= -1 + 2n and n >= 1 }",
+ "name" : "Stmt_S1",
+ "schedule" : "[n] -> { Stmt_S1[i0] -> [1, n - i0, 0] }"
+ }
+ ]
+}
diff --git a/polly/test/JSONExporter/ImportContext/ic4___%for.cond---%for.end10.jscop b/polly/test/JSONExporter/ImportContext/ic4___%for.cond---%for.end10.jscop
new file mode 100644
index 00000000000..536b23e236b
--- /dev/null
+++ b/polly/test/JSONExporter/ImportContext/ic4___%for.cond---%for.end10.jscop
@@ -0,0 +1,32 @@
+{
+ "context" : "[n, m] -> { : n >= -2147483648 and n <= 2147483647 }",
+ "name" : "for.cond => for.end10",
+ "statements" : [
+ {
+ "accesses" : [
+ {
+ "kind" : "read",
+ "relation" : "[n] -> { Stmt_S0[i0] -> MemRef_A[0] }"
+ },
+ {
+ "kind" : "write",
+ "relation" : "[n] -> { Stmt_S0[i0] -> MemRef_A[0] }"
+ }
+ ],
+ "domain" : "[n] -> { Stmt_S0[i0] : i0 >= 0 and i0 <= -1 + 2n and n >= 1 }",
+ "name" : "Stmt_S0",
+ "schedule" : "[n] -> { Stmt_S0[i0] -> [0, n - i0, 0] }"
+ },
+ {
+ "accesses" : [
+ {
+ "kind" : "write",
+ "relation" : "[n] -> { Stmt_S1[i0] -> MemRef_A[1 + i0] }"
+ }
+ ],
+ "domain" : "[n] -> { Stmt_S1[i0] : i0 >= 0 and i0 <= -1 + 2n and n >= 1 }",
+ "name" : "Stmt_S1",
+ "schedule" : "[n] -> { Stmt_S1[i0] -> [1, n - i0, 0] }"
+ }
+ ]
+}
diff --git a/polly/test/JSONExporter/ImportContext/ic___%for.cond---%for.end10.jscop b/polly/test/JSONExporter/ImportContext/ic___%for.cond---%for.end10.jscop
new file mode 100644
index 00000000000..d0838098417
--- /dev/null
+++ b/polly/test/JSONExporter/ImportContext/ic___%for.cond---%for.end10.jscop
@@ -0,0 +1,32 @@
+{
+ "cntext" : "[n] -> { : n >= -2147483648 and n <= 2147483647 }",
+ "name" : "for.cond => for.end10",
+ "statements" : [
+ {
+ "accesses" : [
+ {
+ "kind" : "read",
+ "relation" : "[n] -> { Stmt_S0[i0] -> MemRef_A[0] }"
+ },
+ {
+ "kind" : "write",
+ "relation" : "[n] -> { Stmt_S0[i0] -> MemRef_A[0] }"
+ }
+ ],
+ "domain" : "[n] -> { Stmt_S0[i0] : i0 >= 0 and i0 <= -1 + 2n and n >= 1 }",
+ "name" : "Stmt_S0",
+ "schedule" : "[n] -> { Stmt_S0[i0] -> [0, n - i0, 0] }"
+ },
+ {
+ "accesses" : [
+ {
+ "kind" : "write",
+ "relation" : "[n] -> { Stmt_S1[i0] -> MemRef_A[1 + i0] }"
+ }
+ ],
+ "domain" : "[n] -> { Stmt_S1[i0] : i0 >= 0 and i0 <= -1 + 2n and n >= 1 }",
+ "name" : "Stmt_S1",
+ "schedule" : "[n] -> { Stmt_S1[i0] -> [1, n - i0, 0] }"
+ }
+ ]
+}
OpenPOWER on IntegriCloud