diff options
| author | Michael Kruse <llvm@meinersbur.de> | 2017-05-24 15:09:35 +0000 |
|---|---|---|
| committer | Michael Kruse <llvm@meinersbur.de> | 2017-05-24 15:09:35 +0000 |
| commit | cb58bd6ccdf9d2bbbf021599c92a74f776feee40 (patch) | |
| tree | 2d95a1b76ec1890dd9a8e71ea20971a95037c6d9 /polly/test/JSONExporter/ImportArrays | |
| parent | b07351f4f87ff31373bd5d8321569736117a7c90 (diff) | |
| download | bcm5719-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/ImportArrays')
8 files changed, 437 insertions, 0 deletions
diff --git a/polly/test/JSONExporter/ImportArrays/ImportArrays-Mispelled-type.ll b/polly/test/JSONExporter/ImportArrays/ImportArrays-Mispelled-type.ll new file mode 100644 index 00000000000..9fbac2e5279 --- /dev/null +++ b/polly/test/JSONExporter/ImportArrays/ImportArrays-Mispelled-type.ll @@ -0,0 +1,58 @@ +; RUN: opt %loadPolly -polly-scops -analyze -polly-import-jscop-dir=%S -polly-import-jscop -polly-import-jscop-postfix=transformed < %s 2>&1 | FileCheck %s +; +; CHECK: Array has not a valid type. +; +; Verify if the JSONImporter checks if the parsed type is valid. +; +; for (i = 0; i < _PB_NI; i++) +; for (j = 0; j < _PB_NJ; j++) +; for (k = 0; k < _PB_NK; ++k) +; B[i][j] = beta * A[i][k]; +; +; + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-unknown" + +; Function Attrs: nounwind uwtable +define internal void @ia4(i32 %arg, i32 %arg1, i32 %arg2, double %arg3, double %beta, [1056 x double]* %A, [1024 x double]* %B, [1056 x double]* %arg7) #0 { +bb: + br label %bb8 + +bb8: ; preds = %bb + br label %bb9 + +bb9: ; preds = %bb23, %bb8 + %tmp = phi i64 [ 0, %bb8 ], [ %tmp24, %bb23 ] + br label %bb10 + +bb10: ; preds = %bb20, %bb9 + %tmp11 = phi i64 [ 0, %bb9 ], [ %tmp21, %bb20 ] + br label %bb12 + +bb12: ; preds = %bb12, %bb10 + %tmp13 = phi i64 [ 0, %bb10 ], [ %tmp18, %bb12 ] + %tmp14 = getelementptr inbounds [1024 x double], [1024 x double]* %B, i64 %tmp, i64 %tmp13 + %tmp15 = load double, double* %tmp14, align 8 + %tmp16 = fmul double %tmp15, %beta + %tmp17 = getelementptr inbounds [1056 x double], [1056 x double]* %A, i64 %tmp, i64 %tmp11 + store double %tmp16, double* %tmp17, align 8 + %tmp18 = add nuw nsw i64 %tmp13, 1 + %tmp19 = icmp ne i64 %tmp18, 1024 + br i1 %tmp19, label %bb12, label %bb20 + +bb20: ; preds = %bb12 + %tmp21 = add nuw nsw i64 %tmp11, 1 + %tmp22 = icmp ne i64 %tmp21, 1056 + br i1 %tmp22, label %bb10, label %bb23 + +bb23: ; preds = %bb20 + %tmp24 = add nuw nsw i64 %tmp, 1 + %tmp25 = icmp ne i64 %tmp24, 1056 + br i1 %tmp25, label %bb9, label %bb26 + +bb26: ; preds = %bb23 + ret void +} + +attributes #0 = { nounwind uwtable "target-cpu"="x86-64" "target-features"="+aes,+avx,+cmov,+cx16,+fxsr,+mmx,+pclmul,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt" } diff --git a/polly/test/JSONExporter/ImportArrays/ImportArrays-No-name.ll b/polly/test/JSONExporter/ImportArrays/ImportArrays-No-name.ll new file mode 100644 index 00000000000..2065e5c399b --- /dev/null +++ b/polly/test/JSONExporter/ImportArrays/ImportArrays-No-name.ll @@ -0,0 +1,58 @@ +; RUN: opt %loadPolly -polly-scops -analyze -polly-import-jscop-dir=%S -polly-import-jscop -polly-import-jscop-postfix=transformed < %s 2>&1 | FileCheck %s +; +; CHECK: Array has no key 'name'. +; +; Verify if the JSONImporter checks if the arrays have a key name 'name'. +; +; for (i = 0; i < _PB_NI; i++) +; for (j = 0; j < _PB_NJ; j++) +; for (k = 0; k < _PB_NK; ++k) +; B[i][j] = beta * A[i][k]; +; +; + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-unknown" + +; Function Attrs: nounwind uwtable +define internal void @ia3(i32 %arg, i32 %arg1, i32 %arg2, double %arg3, double %beta, [1056 x double]* %A, [1024 x double]* %B, [1056 x double]* %arg7) #0 { +bb: + br label %bb8 + +bb8: ; preds = %bb + br label %bb9 + +bb9: ; preds = %bb23, %bb8 + %tmp = phi i64 [ 0, %bb8 ], [ %tmp24, %bb23 ] + br label %bb10 + +bb10: ; preds = %bb20, %bb9 + %tmp11 = phi i64 [ 0, %bb9 ], [ %tmp21, %bb20 ] + br label %bb12 + +bb12: ; preds = %bb12, %bb10 + %tmp13 = phi i64 [ 0, %bb10 ], [ %tmp18, %bb12 ] + %tmp14 = getelementptr inbounds [1024 x double], [1024 x double]* %B, i64 %tmp, i64 %tmp13 + %tmp15 = load double, double* %tmp14, align 8 + %tmp16 = fmul double %tmp15, %beta + %tmp17 = getelementptr inbounds [1056 x double], [1056 x double]* %A, i64 %tmp, i64 %tmp11 + store double %tmp16, double* %tmp17, align 8 + %tmp18 = add nuw nsw i64 %tmp13, 1 + %tmp19 = icmp ne i64 %tmp18, 1024 + br i1 %tmp19, label %bb12, label %bb20 + +bb20: ; preds = %bb12 + %tmp21 = add nuw nsw i64 %tmp11, 1 + %tmp22 = icmp ne i64 %tmp21, 1056 + br i1 %tmp22, label %bb10, label %bb23 + +bb23: ; preds = %bb20 + %tmp24 = add nuw nsw i64 %tmp, 1 + %tmp25 = icmp ne i64 %tmp24, 1056 + br i1 %tmp25, label %bb9, label %bb26 + +bb26: ; preds = %bb23 + ret void +} + +attributes #0 = { nounwind uwtable "target-cpu"="x86-64" "target-features"="+aes,+avx,+cmov,+cx16,+fxsr,+mmx,+pclmul,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt" } diff --git a/polly/test/JSONExporter/ImportArrays/ImportArrays-No-sizes-key.ll b/polly/test/JSONExporter/ImportArrays/ImportArrays-No-sizes-key.ll new file mode 100644 index 00000000000..e0d2a84cd8b --- /dev/null +++ b/polly/test/JSONExporter/ImportArrays/ImportArrays-No-sizes-key.ll @@ -0,0 +1,58 @@ +; RUN: opt %loadPolly -polly-scops -analyze -polly-import-jscop-dir=%S -polly-import-jscop -polly-import-jscop-postfix=transformed < %s 2>&1 | FileCheck %s +; +; CHECK: Array has no key 'sizes'. +; +; Verify if the JSONImporter checks if the arrays have a key name 'sizes'. +; +; for (i = 0; i < _PB_NI; i++) +; for (j = 0; j < _PB_NJ; j++) +; for (k = 0; k < _PB_NK; ++k) +; B[i][j] = beta * A[i][k]; +; +; + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-unknown" + +; Function Attrs: nounwind uwtable +define internal void @ia2(i32 %arg, i32 %arg1, i32 %arg2, double %arg3, double %beta, [1056 x double]* %A, [1024 x double]* %B, [1056 x double]* %arg7) #0 { +bb: + br label %bb8 + +bb8: ; preds = %bb + br label %bb9 + +bb9: ; preds = %bb23, %bb8 + %tmp = phi i64 [ 0, %bb8 ], [ %tmp24, %bb23 ] + br label %bb10 + +bb10: ; preds = %bb20, %bb9 + %tmp11 = phi i64 [ 0, %bb9 ], [ %tmp21, %bb20 ] + br label %bb12 + +bb12: ; preds = %bb12, %bb10 + %tmp13 = phi i64 [ 0, %bb10 ], [ %tmp18, %bb12 ] + %tmp14 = getelementptr inbounds [1024 x double], [1024 x double]* %B, i64 %tmp, i64 %tmp13 + %tmp15 = load double, double* %tmp14, align 8 + %tmp16 = fmul double %tmp15, %beta + %tmp17 = getelementptr inbounds [1056 x double], [1056 x double]* %A, i64 %tmp, i64 %tmp11 + store double %tmp16, double* %tmp17, align 8 + %tmp18 = add nuw nsw i64 %tmp13, 1 + %tmp19 = icmp ne i64 %tmp18, 1024 + br i1 %tmp19, label %bb12, label %bb20 + +bb20: ; preds = %bb12 + %tmp21 = add nuw nsw i64 %tmp11, 1 + %tmp22 = icmp ne i64 %tmp21, 1056 + br i1 %tmp22, label %bb10, label %bb23 + +bb23: ; preds = %bb20 + %tmp24 = add nuw nsw i64 %tmp, 1 + %tmp25 = icmp ne i64 %tmp24, 1056 + br i1 %tmp25, label %bb9, label %bb26 + +bb26: ; preds = %bb23 + ret void +} + +attributes #0 = { nounwind uwtable "target-cpu"="x86-64" "target-features"="+aes,+avx,+cmov,+cx16,+fxsr,+mmx,+pclmul,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt" } diff --git a/polly/test/JSONExporter/ImportArrays/ImportArrays-No-type-key.ll b/polly/test/JSONExporter/ImportArrays/ImportArrays-No-type-key.ll new file mode 100644 index 00000000000..fd67e2d43e9 --- /dev/null +++ b/polly/test/JSONExporter/ImportArrays/ImportArrays-No-type-key.ll @@ -0,0 +1,58 @@ +; RUN: opt %loadPolly -polly-scops -analyze -polly-import-jscop-dir=%S -polly-import-jscop -polly-import-jscop-postfix=transformed < %s 2>&1 | FileCheck %s +; +; CHECK: Array has no key 'type'. +; +; Verify if the JSONImporter checks if the arrays have a key name 'type'. +; +; for (i = 0; i < _PB_NI; i++) +; for (j = 0; j < _PB_NJ; j++) +; for (k = 0; k < _PB_NK; ++k) +; B[i][j] = beta * A[i][k]; +; +; + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-unknown" + +; Function Attrs: nounwind uwtable +define internal void @ia(i32 %arg, i32 %arg1, i32 %arg2, double %arg3, double %beta, [1056 x double]* %A, [1024 x double]* %B, [1056 x double]* %arg7) #0 { +bb: + br label %bb8 + +bb8: ; preds = %bb + br label %bb9 + +bb9: ; preds = %bb23, %bb8 + %tmp = phi i64 [ 0, %bb8 ], [ %tmp24, %bb23 ] + br label %bb10 + +bb10: ; preds = %bb20, %bb9 + %tmp11 = phi i64 [ 0, %bb9 ], [ %tmp21, %bb20 ] + br label %bb12 + +bb12: ; preds = %bb12, %bb10 + %tmp13 = phi i64 [ 0, %bb10 ], [ %tmp18, %bb12 ] + %tmp14 = getelementptr inbounds [1024 x double], [1024 x double]* %B, i64 %tmp, i64 %tmp13 + %tmp15 = load double, double* %tmp14, align 8 + %tmp16 = fmul double %tmp15, %beta + %tmp17 = getelementptr inbounds [1056 x double], [1056 x double]* %A, i64 %tmp, i64 %tmp11 + store double %tmp16, double* %tmp17, align 8 + %tmp18 = add nuw nsw i64 %tmp13, 1 + %tmp19 = icmp ne i64 %tmp18, 1024 + br i1 %tmp19, label %bb12, label %bb20 + +bb20: ; preds = %bb12 + %tmp21 = add nuw nsw i64 %tmp11, 1 + %tmp22 = icmp ne i64 %tmp21, 1056 + br i1 %tmp22, label %bb10, label %bb23 + +bb23: ; preds = %bb20 + %tmp24 = add nuw nsw i64 %tmp, 1 + %tmp25 = icmp ne i64 %tmp24, 1056 + br i1 %tmp25, label %bb9, label %bb26 + +bb26: ; preds = %bb23 + ret void +} + +attributes #0 = { nounwind uwtable "target-cpu"="x86-64" "target-features"="+aes,+avx,+cmov,+cx16,+fxsr,+mmx,+pclmul,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt" } diff --git a/polly/test/JSONExporter/ImportArrays/ia2___%bb9---%bb26.jscop.transformed b/polly/test/JSONExporter/ImportArrays/ia2___%bb9---%bb26.jscop.transformed new file mode 100644 index 00000000000..e7029197616 --- /dev/null +++ b/polly/test/JSONExporter/ImportArrays/ia2___%bb9---%bb26.jscop.transformed @@ -0,0 +1,51 @@ +{ + "arrays" : [ + { + "name" : "MemRef_B", + "type" : "double" + }, + { + "name" : "MemRef_A", + "sizes" : [ "*", "1056" ], + "type" : "double" + }, + { + "name" : "D", + "sizes" : [ "270336" ], + "type" : "double" + }, + { + "name" : "E", + "sizes" : [ "270336", "200000" ], + "type" : "double" + }, + { + "name" : "F", + "sizes" : [ "270336" ], + "type" : "i64" + } + ], + "context" : "{ : }", + "name" : "%bb9---%bb26", + "statements" : [ + { + "accesses" : [ + { + "kind" : "read", + "relation" : "{ Stmt_bb12[i0, i1, i2] -> E[i2, i0] }" + }, + { + "kind" : "read", + "relation" : "{ Stmt_bb12[i0, i1, i2] -> MemRef_beta[] }" + }, + { + "kind" : "write", + "relation" : "{ Stmt_bb12[i0, i1, i2] -> MemRef_A[i0, i1] }" + } + ], + "domain" : "{ Stmt_bb12[i0, i1, i2] : 0 <= i0 <= 1055 and 0 <= i1 <= 1055 and 0 <= i2 <= 1023 }", + "name" : "Stmt_bb12", + "schedule" : "{ Stmt_bb12[i0, i1, i2] -> [i0, i1, i2] }" + } + ] +} diff --git a/polly/test/JSONExporter/ImportArrays/ia3___%bb9---%bb26.jscop.transformed b/polly/test/JSONExporter/ImportArrays/ia3___%bb9---%bb26.jscop.transformed new file mode 100644 index 00000000000..b3e968f44c4 --- /dev/null +++ b/polly/test/JSONExporter/ImportArrays/ia3___%bb9---%bb26.jscop.transformed @@ -0,0 +1,51 @@ +{ + "arrays" : [ + { + "sizes" : [ "*", "1024" ], + "type" : "double" + }, + { + "name" : "MemRef_A", + "sizes" : [ "*", "1056" ], + "type" : "double" + }, + { + "name" : "D", + "sizes" : [ "270336" ], + "type" : "double" + }, + { + "name" : "E", + "sizes" : [ "270336", "200000" ], + "type" : "double" + }, + { + "name" : "F", + "sizes" : [ "270336" ], + "type" : "i64" + } + ], + "context" : "{ : }", + "name" : "%bb9---%bb26", + "statements" : [ + { + "accesses" : [ + { + "kind" : "read", + "relation" : "{ Stmt_bb12[i0, i1, i2] -> E[i2, i0] }" + }, + { + "kind" : "read", + "relation" : "{ Stmt_bb12[i0, i1, i2] -> MemRef_beta[] }" + }, + { + "kind" : "write", + "relation" : "{ Stmt_bb12[i0, i1, i2] -> MemRef_A[i0, i1] }" + } + ], + "domain" : "{ Stmt_bb12[i0, i1, i2] : 0 <= i0 <= 1055 and 0 <= i1 <= 1055 and 0 <= i2 <= 1023 }", + "name" : "Stmt_bb12", + "schedule" : "{ Stmt_bb12[i0, i1, i2] -> [i0, i1, i2] }" + } + ] +} diff --git a/polly/test/JSONExporter/ImportArrays/ia4___%bb9---%bb26.jscop.transformed b/polly/test/JSONExporter/ImportArrays/ia4___%bb9---%bb26.jscop.transformed new file mode 100644 index 00000000000..066294b3d13 --- /dev/null +++ b/polly/test/JSONExporter/ImportArrays/ia4___%bb9---%bb26.jscop.transformed @@ -0,0 +1,52 @@ +{ + "arrays" : [ + { + "name" : "MemRef_B", + "sizes" : [ "*", "1024" ], + "type" : "doble" + }, + { + "name" : "MemRef_A", + "sizes" : [ "*", "1056" ], + "type" : "double" + }, + { + "name" : "D", + "sizes" : [ "270336" ], + "type" : "double" + }, + { + "name" : "E", + "sizes" : [ "270336", "200000" ], + "type" : "double" + }, + { + "name" : "F", + "sizes" : [ "270336" ], + "type" : "i64" + } + ], + "context" : "{ : }", + "name" : "%bb9---%bb26", + "statements" : [ + { + "accesses" : [ + { + "kind" : "read", + "relation" : "{ Stmt_bb12[i0, i1, i2] -> E[i2, i0] }" + }, + { + "kind" : "read", + "relation" : "{ Stmt_bb12[i0, i1, i2] -> MemRef_beta[] }" + }, + { + "kind" : "write", + "relation" : "{ Stmt_bb12[i0, i1, i2] -> MemRef_A[i0, i1] }" + } + ], + "domain" : "{ Stmt_bb12[i0, i1, i2] : 0 <= i0 <= 1055 and 0 <= i1 <= 1055 and 0 <= i2 <= 1023 }", + "name" : "Stmt_bb12", + "schedule" : "{ Stmt_bb12[i0, i1, i2] -> [i0, i1, i2] }" + } + ] +} diff --git a/polly/test/JSONExporter/ImportArrays/ia___%bb9---%bb26.jscop.transformed b/polly/test/JSONExporter/ImportArrays/ia___%bb9---%bb26.jscop.transformed new file mode 100644 index 00000000000..5015e4eeb22 --- /dev/null +++ b/polly/test/JSONExporter/ImportArrays/ia___%bb9---%bb26.jscop.transformed @@ -0,0 +1,51 @@ +{ + "arrays" : [ + { + "name" : "MemRef_B", + "sizes" : [ "*", "1024" ] + }, + { + "name" : "MemRef_A", + "sizes" : [ "*", "1056" ], + "type" : "double" + }, + { + "name" : "D", + "sizes" : [ "270336" ], + "type" : "double" + }, + { + "name" : "E", + "sizes" : [ "270336", "200000" ], + "type" : "double" + }, + { + "name" : "F", + "sizes" : [ "270336" ], + "type" : "i64" + } + ], + "context" : "{ : }", + "name" : "%bb9---%bb26", + "statements" : [ + { + "accesses" : [ + { + "kind" : "read", + "relation" : "{ Stmt_bb12[i0, i1, i2] -> E[i2, i0] }" + }, + { + "kind" : "read", + "relation" : "{ Stmt_bb12[i0, i1, i2] -> MemRef_beta[] }" + }, + { + "kind" : "write", + "relation" : "{ Stmt_bb12[i0, i1, i2] -> MemRef_A[i0, i1] }" + } + ], + "domain" : "{ Stmt_bb12[i0, i1, i2] : 0 <= i0 <= 1055 and 0 <= i1 <= 1055 and 0 <= i2 <= 1023 }", + "name" : "Stmt_bb12", + "schedule" : "{ Stmt_bb12[i0, i1, i2] -> [i0, i1, i2] }" + } + ] +} |

