[JSON] Make the failure to parse a jscop file a hard error

Summary:
Before, if we fail to parse a jscop file, this will be reported as an
error and importing is aborted. However, this isn't actually strong
enough, since although the import is aborted, the scop has already been
modified and is very likely broken. Instead, make this a hard failure
and throw an LLVM error. This new behaviour requires small changes to
the tests for the legacy pass, namely using `not` to verify the error.
Further, fixed the jscop file for the
base_pointer_load_is_inst_inside_invariant_1 testcase.

Reviewed By: Meinersbur

Split out of D36578.

llvm-svn: 310599
This commit is contained in:
Philip Pfaffe 2017-08-10 14:53:25 +00:00
parent 8dfe8e21e8
commit c3bcdc2f1a
25 changed files with 33 additions and 32 deletions

View File

@ -388,7 +388,8 @@ importAccesses(Scop &S, Json::Value &JScop, const DataLayout &DL,
return false;
}
// Check whether the number of indices equals the number of memory accesses
// Check whether the number of indices equals the number of memory
// accesses
if (Stmt.size() != statements[StatementIdx]["accesses"].size()) {
errs() << "The number of memory accesses in the JSop file and the number "
"of memory accesses differ for index "
@ -430,8 +431,8 @@ importAccesses(Scop &S, Json::Value &JScop, const DataLayout &DL,
// If the NewAccessMap has zero dimensions, it is the scalar access; it
// must be the same as before.
// If it has at least one dimension, it's an array access; search for its
// ScopArrayInfo.
// If it has at least one dimension, it's an array access; search for
// its ScopArrayInfo.
if (isl_map_dim(NewAccessMap, isl_dim_out) >= 1) {
NewOutId = isl_map_get_tuple_id(NewAccessMap, isl_dim_out);
auto *SAI = S.getArrayInfoByName(isl_id_get_name(NewOutId));
@ -781,7 +782,10 @@ bool JSONImporter::runOnScop(Scop &S) {
const Dependences &D =
getAnalysis<DependenceInfo>().getDependences(Dependences::AL_Statement);
const DataLayout &DL = S.getFunction().getParent()->getDataLayout();
importScop(S, D, DL, &NewAccessStrings);
if (!importScop(S, D, DL, &NewAccessStrings))
report_fatal_error("Tried to import a malformed jscop file.");
return false;
}
@ -800,7 +804,8 @@ PreservedAnalyses JSONImportPass::run(Scop &S, ScopAnalysisManager &SAM,
Dependences::AL_Statement);
const DataLayout &DL = S.getFunction().getParent()->getDataLayout();
importScop(S, D, DL);
if (!importScop(S, D, DL))
report_fatal_error("Tried to import a malformed jscop file.");
// This invalidates all analyses on Scop.
PreservedAnalyses PA;

View File

@ -1,4 +1,4 @@
; RUN: opt %loadPolly -polly-import-jscop -analyze 2>&1 < %s | FileCheck %s
; RUN: not opt %loadPolly -polly-import-jscop -analyze 2>&1 < %s | FileCheck %s
;
; Check that we do not allow to access elements not accessed before because the
; alignment information would become invalid.

View File

@ -1,4 +1,4 @@
; RUN: opt %loadPolly -polly-import-jscop -polly-ast -polly-ast-detect-parallel < %s 2>&1 >/dev/null | FileCheck %s
; RUN: not opt %loadPolly -polly-import-jscop -polly-ast -polly-ast-detect-parallel < %s 2>&1 >/dev/null | FileCheck %s
;
; CHECK: The access was not parsed successfully by ISL.
;

View File

@ -1,4 +1,4 @@
; RUN: opt %loadPolly -polly-import-jscop -polly-ast -polly-ast-detect-parallel < %s 2>&1 >/dev/null | FileCheck %s
; RUN: not opt %loadPolly -polly-import-jscop -polly-ast -polly-ast-detect-parallel < %s 2>&1 >/dev/null | FileCheck %s
;
; CHECK: Statement from JScop file has no key name 'accesses' for index 1.
;

View File

@ -1,4 +1,4 @@
; RUN: opt %loadPolly -polly-import-jscop -polly-ast -polly-ast-detect-parallel < %s 2>&1 >/dev/null | FileCheck %s
; RUN: not opt %loadPolly -polly-import-jscop -polly-ast -polly-ast-detect-parallel < %s 2>&1 >/dev/null | FileCheck %s
;
; CHECK: The number of memory accesses in the JSop file and the number of memory accesses differ for index 0.
;

View File

@ -1,4 +1,4 @@
; RUN: opt %loadPolly -polly-import-jscop -polly-ast -polly-ast-detect-parallel < %s 2>&1 >/dev/null | FileCheck %s
; RUN: not opt %loadPolly -polly-import-jscop -polly-ast -polly-ast-detect-parallel < %s 2>&1 >/dev/null | FileCheck %s
;
; CHECK: The number of indices and the number of statements differ.
;

View File

@ -1,4 +1,4 @@
; RUN: opt %loadPolly -polly-import-jscop -polly-ast -polly-ast-detect-parallel < %s 2>&1 >/dev/null | FileCheck %s
; RUN: not opt %loadPolly -polly-import-jscop -polly-ast -polly-ast-detect-parallel < %s 2>&1 >/dev/null | FileCheck %s
;
; CHECK: Memory access number 0 has no key name 'relation' for statement number 1.
;

View File

@ -1,4 +1,4 @@
; RUN: opt %loadPolly -polly-import-jscop -polly-ast -polly-ast-detect-parallel < %s 2>&1 >/dev/null | FileCheck %s
; RUN: not opt %loadPolly -polly-import-jscop -polly-ast -polly-ast-detect-parallel < %s 2>&1 >/dev/null | FileCheck %s
;
; CHECK: JScop file has no key name 'statements'.
;

View File

@ -1,4 +1,4 @@
; RUN: opt %loadPolly -polly-import-jscop -polly-ast -polly-ast-detect-parallel < %s 2>&1 >/dev/null | FileCheck %s
; RUN: not opt %loadPolly -polly-import-jscop -polly-ast -polly-ast-detect-parallel < %s 2>&1 >/dev/null | FileCheck %s
;
; CHECK: JScop file contains access function with undeclared ScopArrayInfo
;

View File

@ -1,4 +1,4 @@
; RUN: opt %loadPolly -polly-import-jscop -polly-ast -polly-ast-detect-parallel < %s 2>&1 >/dev/null | FileCheck %s
; RUN: not opt %loadPolly -polly-import-jscop -polly-ast -polly-ast-detect-parallel < %s 2>&1 >/dev/null | FileCheck %s
;
; CHECK: JScop file changes the number of parameter dimensions.
;

View File

@ -1,4 +1,4 @@
; RUN: opt %loadPolly -polly-scops -analyze -polly-import-jscop -polly-import-jscop-postfix=transformed < %s 2>&1 | FileCheck %s
; RUN: not opt %loadPolly -polly-scops -analyze -polly-import-jscop -polly-import-jscop-postfix=transformed < %s 2>&1 | FileCheck %s
;
; CHECK: Array has not a valid type.
;

View File

@ -1,4 +1,4 @@
; RUN: opt %loadPolly -polly-scops -analyze -polly-import-jscop -polly-import-jscop-postfix=transformed < %s 2>&1 | FileCheck %s
; RUN: not opt %loadPolly -polly-scops -analyze -polly-import-jscop -polly-import-jscop-postfix=transformed < %s 2>&1 | FileCheck %s
;
; #define Ni 1056
; #define Nj 1056

View File

@ -1,4 +1,4 @@
; RUN: opt %loadPolly -polly-scops -analyze -polly-import-jscop -polly-import-jscop-postfix=transformed < %s 2>&1 | FileCheck %s
; RUN: not opt %loadPolly -polly-scops -analyze -polly-import-jscop -polly-import-jscop-postfix=transformed < %s 2>&1 | FileCheck %s
;
; CHECK: Array has no key 'name'.
;

View File

@ -1,4 +1,4 @@
; RUN: opt %loadPolly -polly-scops -analyze -polly-import-jscop -polly-import-jscop-postfix=transformed < %s 2>&1 | FileCheck %s
; RUN: not opt %loadPolly -polly-scops -analyze -polly-import-jscop -polly-import-jscop-postfix=transformed < %s 2>&1 | FileCheck %s
;
; CHECK: Array has no key 'sizes'.
;

View File

@ -1,4 +1,4 @@
; RUN: opt %loadPolly -polly-scops -analyze -polly-import-jscop -polly-import-jscop-postfix=transformed < %s 2>&1 | FileCheck %s
; RUN: not opt %loadPolly -polly-scops -analyze -polly-import-jscop -polly-import-jscop-postfix=transformed < %s 2>&1 | FileCheck %s
;
; CHECK: Array has no key 'type'.
;

View File

@ -1,4 +1,4 @@
; RUN: opt %loadPolly -polly-import-jscop -polly-ast -polly-ast-detect-parallel < %s 2>&1 >/dev/null | FileCheck %s
; RUN: not opt %loadPolly -polly-import-jscop -polly-ast -polly-ast-detect-parallel < %s 2>&1 >/dev/null | FileCheck %s
;
; CHECK: JScop file has no key named 'context'.
;

View File

@ -1,4 +1,4 @@
; RUN: opt %loadPolly -polly-import-jscop -polly-ast -polly-ast-detect-parallel -analyze < %s 2>&1 >/dev/null | FileCheck %s
; RUN: not opt %loadPolly -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.
;

View File

@ -1,4 +1,4 @@
; RUN: opt %loadPolly -polly-import-jscop -polly-ast -polly-ast-detect-parallel < %s 2>&1 >/dev/null | FileCheck %s
; RUN: not opt %loadPolly -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.
;

View File

@ -1,4 +1,4 @@
; RUN: opt %loadPolly -polly-import-jscop -polly-ast -polly-ast-detect-parallel < %s 2>&1 >/dev/null | FileCheck %s
; RUN: not opt %loadPolly -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
;

View File

@ -1,4 +1,4 @@
; RUN: opt %loadPolly -polly-import-jscop -polly-ast -polly-ast-detect-parallel < %s 2>&1 >/dev/null | FileCheck %s
; RUN: not opt %loadPolly -polly-import-jscop -polly-ast -polly-ast-detect-parallel < %s 2>&1 >/dev/null | FileCheck %s
;
; CHECK: Statement 0 has no 'schedule' key.
;

View File

@ -1,4 +1,4 @@
; RUN: opt %loadPolly -polly-import-jscop -polly-ast -polly-ast-detect-parallel < %s 2>&1 >/dev/null | FileCheck %s
; RUN: not opt %loadPolly -polly-import-jscop -polly-ast -polly-ast-detect-parallel < %s 2>&1 >/dev/null | FileCheck %s
;
; CHECK: The schedule was not parsed successfully (index = 1).
;

View File

@ -1,4 +1,4 @@
; RUN: opt %loadPolly -polly-import-jscop -polly-ast -polly-ast-detect-parallel < %s 2>&1 >/dev/null | FileCheck %s
; RUN: not opt %loadPolly -polly-import-jscop -polly-ast -polly-ast-detect-parallel < %s 2>&1 >/dev/null | FileCheck %s
;
; CHECK: JScop file has no key name 'statements'.
;

View File

@ -1,4 +1,4 @@
; RUN: opt %loadPolly -polly-import-jscop -polly-ast -polly-ast-detect-parallel < %s 2>&1 >/dev/null | FileCheck %s
; RUN: not opt %loadPolly -polly-import-jscop -polly-ast -polly-ast-detect-parallel < %s 2>&1 >/dev/null | FileCheck %s
;
; CHECK: The number of indices and the number of statements differ.
;

View File

@ -16,10 +16,6 @@
"statements" : [
{
"accesses" : [
{
"kind" : "read",
"relation" : "[n] -> { Stmt_S1[i0] -> MemRef_A[0] }"
},
{
"kind" : "write",
"relation" : "[n] -> { Stmt_S1[i0] -> MemRef_ptr[i0+1] }"

View File

@ -1,4 +1,4 @@
; RUN: opt %loadPolly -polly-import-jscop -polly-import-jscop-postfix=transformed -polly-simplify -analyze < %s | FileCheck %s -match-full-lines
; RUN: opt %loadPolly -polly-simplify -analyze < %s | FileCheck %s -match-full-lines
;
; Do not remove redundant stores in the middle of region statements.
; The store in region_true could be removed, but in practice we do try to