brintos

brintos / llvm-project-archived public Read only

0
0
Text · 24.4 KiB · e392066 Raw
739 lines · cpp
1//===-- JSONExporter.cpp  - Export Scops as JSON  -------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8//9// Export the Scops build by ScopInfo pass as a JSON file.10//11//===----------------------------------------------------------------------===//12 13#include "polly/JSONExporter.h"14#include "polly/DependenceInfo.h"15#include "polly/Options.h"16#include "polly/ScopInfo.h"17#include "polly/Support/ISLTools.h"18#include "polly/Support/ScopLocation.h"19#include "llvm/ADT/Statistic.h"20#include "llvm/IR/Module.h"21#include "llvm/Support/FileSystem.h"22#include "llvm/Support/JSON.h"23#include "llvm/Support/MemoryBuffer.h"24#include "llvm/Support/ToolOutputFile.h"25#include "llvm/Support/raw_ostream.h"26#include "isl/map.h"27#include "isl/set.h"28#include <memory>29#include <string>30#include <system_error>31 32using namespace llvm;33using namespace polly;34 35#define DEBUG_TYPE "polly-import-jscop"36 37static cl::opt<bool>38    PollyPrintImportJscop("polly-print-import-jscop",39                          cl::desc("Polly - Print Scop import result"),40                          cl::cat(PollyCategory));41 42STATISTIC(NewAccessMapFound, "Number of updated access functions");43 44namespace {45static cl::opt<std::string>46    ImportDir("polly-import-jscop-dir",47              cl::desc("The directory to import the .jscop files from."),48              cl::Hidden, cl::value_desc("Directory path"), cl::ValueRequired,49              cl::init("."), cl::cat(PollyCategory));50 51static cl::opt<std::string>52    ImportPostfix("polly-import-jscop-postfix",53                  cl::desc("Postfix to append to the import .jsop files."),54                  cl::Hidden, cl::value_desc("File postfix"), cl::ValueRequired,55                  cl::init(""), cl::cat(PollyCategory));56} // namespace57 58static std::string getFileName(Scop &S, StringRef Suffix = "") {59  std::string FunctionName = S.getFunction().getName().str();60  std::string FileName = FunctionName + "___" + S.getNameStr() + ".jscop";61 62  if (Suffix != "")63    FileName += "." + Suffix.str();64 65  return FileName;66}67 68/// Export all arrays from the Scop.69///70/// @param S The Scop containing the arrays.71///72/// @returns Json::Value containing the arrays.73static json::Array exportArrays(const Scop &S) {74  json::Array Arrays;75  std::string Buffer;76  llvm::raw_string_ostream RawStringOstream(Buffer);77 78  for (auto &SAI : S.arrays()) {79    if (!SAI->isArrayKind())80      continue;81 82    json::Object Array;83    json::Array Sizes;84    Array["name"] = SAI->getName();85    unsigned i = 0;86    if (!SAI->getDimensionSize(i)) {87      Sizes.push_back("*");88      i++;89    }90    for (; i < SAI->getNumberOfDimensions(); i++) {91      SAI->getDimensionSize(i)->print(RawStringOstream);92      Sizes.push_back(Buffer);93      Buffer.clear();94    }95    Array["sizes"] = std::move(Sizes);96    SAI->getElementType()->print(RawStringOstream);97    Array["type"] = Buffer;98    Buffer.clear();99    Arrays.push_back(std::move(Array));100  }101  return Arrays;102}103 104static json::Value getJSON(Scop &S) {105  json::Object root;106  unsigned LineBegin, LineEnd;107  std::string FileName;108 109  getDebugLocation(&S.getRegion(), LineBegin, LineEnd, FileName);110  std::string Location;111  if (LineBegin != (unsigned)-1)112    Location = FileName + ":" + std::to_string(LineBegin) + "-" +113               std::to_string(LineEnd);114 115  root["name"] = S.getNameStr();116  root["context"] = S.getContextStr();117  if (LineBegin != (unsigned)-1)118    root["location"] = Location;119 120  root["arrays"] = exportArrays(S);121 122  root["statements"];123 124  json::Array Statements;125  for (ScopStmt &Stmt : S) {126    json::Object statement;127 128    statement["name"] = Stmt.getBaseName();129    statement["domain"] = Stmt.getDomainStr();130    statement["schedule"] = Stmt.getScheduleStr();131 132    json::Array Accesses;133    for (MemoryAccess *MA : Stmt) {134      json::Object access;135 136      access["kind"] = MA->isRead() ? "read" : "write";137      access["relation"] = MA->getAccessRelationStr();138 139      Accesses.push_back(std::move(access));140    }141    statement["accesses"] = std::move(Accesses);142 143    Statements.push_back(std::move(statement));144  }145 146  root["statements"] = std::move(Statements);147  return json::Value(std::move(root));148}149 150static void exportScop(Scop &S) {151  std::string FileName = ImportDir + "/" + getFileName(S);152 153  json::Value jscop = getJSON(S);154 155  // Write to file.156  std::error_code EC;157  ToolOutputFile F(FileName, EC, llvm::sys::fs::OF_TextWithCRLF);158 159  std::string FunctionName = S.getFunction().getName().str();160  errs() << "Writing JScop '" << S.getNameStr() << "' in function '"161         << FunctionName << "' to '" << FileName << "'.\n";162 163  if (!EC) {164    F.os() << formatv("{0:3}", jscop);165    F.os().close();166    if (!F.os().has_error()) {167      errs() << "\n";168      F.keep();169      return;170    }171  }172 173  errs() << "  error opening file for writing!\n";174  F.os().clear_error();175}176 177typedef Dependences::StatementToIslMapTy StatementToIslMapTy;178 179/// Import a new context from JScop.180///181/// @param S The scop to update.182/// @param JScop The JScop file describing the new schedule.183///184/// @returns True if the import succeeded, otherwise False.185static bool importContext(Scop &S, const json::Object &JScop) {186  isl::set OldContext = S.getContext();187 188  // Check if key 'context' is present.189  if (!JScop.get("context")) {190    errs() << "JScop file has no key named 'context'.\n";191    return false;192  }193 194  isl::set NewContext =195      isl::set{S.getIslCtx().get(), JScop.getString("context").value().str()};196 197  // Check whether the context was parsed successfully.198  if (NewContext.is_null()) {199    errs() << "The context was not parsed successfully by ISL.\n";200    return false;201  }202 203  // Check if the isl_set is a parameter set.204  if (!NewContext.is_params()) {205    errs() << "The isl_set is not a parameter set.\n";206    return false;207  }208 209  unsigned OldContextDim = unsignedFromIslSize(OldContext.dim(isl::dim::param));210  unsigned NewContextDim = unsignedFromIslSize(NewContext.dim(isl::dim::param));211 212  // Check if the imported context has the right number of parameters.213  if (OldContextDim != NewContextDim) {214    errs() << "Imported context has the wrong number of parameters : "215           << "Found " << NewContextDim << " Expected " << OldContextDim216           << "\n";217    return false;218  }219 220  for (unsigned i = 0; i < OldContextDim; i++) {221    isl::id Id = OldContext.get_dim_id(isl::dim::param, i);222    NewContext = NewContext.set_dim_id(isl::dim::param, i, Id);223  }224 225  S.setContext(NewContext);226  return true;227}228 229/// Import a new schedule from JScop.230///231/// ... and verify that the new schedule does preserve existing data232/// dependences.233///234/// @param S The scop to update.235/// @param JScop The JScop file describing the new schedule.236/// @param D The data dependences of the @p S.237///238/// @returns True if the import succeeded, otherwise False.239static bool importSchedule(Scop &S, const json::Object &JScop,240                           const Dependences &D) {241  StatementToIslMapTy NewSchedule;242 243  // Check if key 'statements' is present.244  if (!JScop.get("statements")) {245    errs() << "JScop file has no key name 'statements'.\n";246    return false;247  }248 249  const json::Array &statements = *JScop.getArray("statements");250 251  // Check whether the number of indices equals the number of statements252  if (statements.size() != S.getSize()) {253    errs() << "The number of indices and the number of statements differ.\n";254    return false;255  }256 257  int Index = 0;258  for (ScopStmt &Stmt : S) {259    // Check if key 'schedule' is present.260    if (!statements[Index].getAsObject()->get("schedule")) {261      errs() << "Statement " << Index << " has no 'schedule' key.\n";262      return false;263    }264    std::optional<StringRef> Schedule =265        statements[Index].getAsObject()->getString("schedule");266    assert(Schedule.has_value() &&267           "Schedules that contain extension nodes require special handling.");268    isl_map *Map = isl_map_read_from_str(S.getIslCtx().get(),269                                         Schedule.value().str().c_str());270 271    // Check whether the schedule was parsed successfully272    if (!Map) {273      errs() << "The schedule was not parsed successfully (index = " << Index274             << ").\n";275      return false;276    }277 278    isl_space *Space = Stmt.getDomainSpace().release();279 280    // Copy the old tuple id. This is necessary to retain the user pointer,281    // that stores the reference to the ScopStmt this schedule belongs to.282    Map = isl_map_set_tuple_id(Map, isl_dim_in,283                               isl_space_get_tuple_id(Space, isl_dim_set));284    for (isl_size i = 0; i < isl_space_dim(Space, isl_dim_param); i++) {285      isl_id *Id = isl_space_get_dim_id(Space, isl_dim_param, i);286      Map = isl_map_set_dim_id(Map, isl_dim_param, i, Id);287    }288    isl_space_free(Space);289    NewSchedule[&Stmt] = isl::manage(Map);290    Index++;291  }292 293  // Check whether the new schedule is valid or not.294  if (!D.isValidSchedule(S, NewSchedule)) {295    errs() << "JScop file contains a schedule that changes the "296           << "dependences. Use -disable-polly-legality to continue anyways\n";297    return false;298  }299 300  auto ScheduleMap = isl::union_map::empty(S.getIslCtx());301  for (ScopStmt &Stmt : S) {302    if (NewSchedule.contains(&Stmt))303      ScheduleMap = ScheduleMap.unite(NewSchedule[&Stmt]);304    else305      ScheduleMap = ScheduleMap.unite(Stmt.getSchedule());306  }307 308  S.setSchedule(ScheduleMap);309 310  return true;311}312 313/// Import new memory accesses from JScop.314///315/// @param S The scop to update.316/// @param JScop The JScop file describing the new schedule.317/// @param DL The data layout to assume.318/// @param NewAccessStrings optionally record the imported access strings319///320/// @returns True if the import succeeded, otherwise False.321static bool322importAccesses(Scop &S, const json::Object &JScop, const DataLayout &DL,323               std::vector<std::string> *NewAccessStrings = nullptr) {324  int StatementIdx = 0;325 326  // Check if key 'statements' is present.327  if (!JScop.get("statements")) {328    errs() << "JScop file has no key name 'statements'.\n";329    return false;330  }331  const json::Array &statements = *JScop.getArray("statements");332 333  // Check whether the number of indices equals the number of statements334  if (statements.size() != S.getSize()) {335    errs() << "The number of indices and the number of statements differ.\n";336    return false;337  }338 339  for (ScopStmt &Stmt : S) {340    int MemoryAccessIdx = 0;341    const json::Object *Statement = statements[StatementIdx].getAsObject();342    assert(Statement);343 344    // Check if key 'accesses' is present.345    if (!Statement->get("accesses")) {346      errs()347          << "Statement from JScop file has no key name 'accesses' for index "348          << StatementIdx << ".\n";349      return false;350    }351    const json::Array &JsonAccesses = *Statement->getArray("accesses");352 353    // Check whether the number of indices equals the number of memory354    // accesses355    if (Stmt.size() != JsonAccesses.size()) {356      errs() << "The number of memory accesses in the JSop file and the number "357                "of memory accesses differ for index "358             << StatementIdx << ".\n";359      return false;360    }361 362    for (MemoryAccess *MA : Stmt) {363      // Check if key 'relation' is present.364      const json::Object *JsonMemoryAccess =365          JsonAccesses[MemoryAccessIdx].getAsObject();366      assert(JsonMemoryAccess);367      if (!JsonMemoryAccess->get("relation")) {368        errs() << "Memory access number " << MemoryAccessIdx369               << " has no key name 'relation' for statement number "370               << StatementIdx << ".\n";371        return false;372      }373      StringRef Accesses = *JsonMemoryAccess->getString("relation");374      isl_map *NewAccessMap =375          isl_map_read_from_str(S.getIslCtx().get(), Accesses.str().c_str());376 377      // Check whether the access was parsed successfully378      if (!NewAccessMap) {379        errs() << "The access was not parsed successfully by ISL.\n";380        return false;381      }382      isl_map *CurrentAccessMap = MA->getAccessRelation().release();383 384      // Check if the number of parameter change385      if (isl_map_dim(NewAccessMap, isl_dim_param) !=386          isl_map_dim(CurrentAccessMap, isl_dim_param)) {387        errs() << "JScop file changes the number of parameter dimensions.\n";388        isl_map_free(CurrentAccessMap);389        isl_map_free(NewAccessMap);390        return false;391      }392 393      isl_id *NewOutId;394 395      // If the NewAccessMap has zero dimensions, it is the scalar access; it396      // must be the same as before.397      // If it has at least one dimension, it's an array access; search for398      // its ScopArrayInfo.399      if (isl_map_dim(NewAccessMap, isl_dim_out) >= 1) {400        NewOutId = isl_map_get_tuple_id(NewAccessMap, isl_dim_out);401        auto *SAI = S.getArrayInfoByName(isl_id_get_name(NewOutId));402        isl_id *OutId = isl_map_get_tuple_id(CurrentAccessMap, isl_dim_out);403        auto *OutSAI = ScopArrayInfo::getFromId(isl::manage(OutId));404        if (!SAI || SAI->getElementType() != OutSAI->getElementType()) {405          errs() << "JScop file contains access function with undeclared "406                    "ScopArrayInfo\n";407          isl_map_free(CurrentAccessMap);408          isl_map_free(NewAccessMap);409          isl_id_free(NewOutId);410          return false;411        }412        isl_id_free(NewOutId);413        NewOutId = SAI->getBasePtrId().release();414      } else {415        NewOutId = isl_map_get_tuple_id(CurrentAccessMap, isl_dim_out);416      }417 418      NewAccessMap = isl_map_set_tuple_id(NewAccessMap, isl_dim_out, NewOutId);419 420      if (MA->isArrayKind()) {421        // We keep the old alignment, thus we cannot allow accesses to memory422        // locations that were not accessed before if the alignment of the423        // access is not the default alignment.424        bool SpecialAlignment = true;425        if (LoadInst *LoadI = dyn_cast<LoadInst>(MA->getAccessInstruction())) {426          SpecialAlignment =427              DL.getABITypeAlign(LoadI->getType()) != LoadI->getAlign();428        } else if (StoreInst *StoreI =429                       dyn_cast<StoreInst>(MA->getAccessInstruction())) {430          SpecialAlignment =431              DL.getABITypeAlign(StoreI->getValueOperand()->getType()) !=432              StoreI->getAlign();433        }434 435        if (SpecialAlignment) {436          isl_set *NewAccessSet = isl_map_range(isl_map_copy(NewAccessMap));437          isl_set *CurrentAccessSet =438              isl_map_range(isl_map_copy(CurrentAccessMap));439          bool IsSubset = isl_set_is_subset(NewAccessSet, CurrentAccessSet);440          isl_set_free(NewAccessSet);441          isl_set_free(CurrentAccessSet);442 443          // Check if the JScop file changes the accessed memory.444          if (!IsSubset) {445            errs() << "JScop file changes the accessed memory\n";446            isl_map_free(CurrentAccessMap);447            isl_map_free(NewAccessMap);448            return false;449          }450        }451      }452 453      // We need to copy the isl_ids for the parameter dimensions to the new454      // map. Without doing this the current map would have different455      // ids then the new one, even though both are named identically.456      for (isl_size i = 0; i < isl_map_dim(CurrentAccessMap, isl_dim_param);457           i++) {458        isl_id *Id = isl_map_get_dim_id(CurrentAccessMap, isl_dim_param, i);459        NewAccessMap = isl_map_set_dim_id(NewAccessMap, isl_dim_param, i, Id);460      }461 462      // Copy the old tuple id. This is necessary to retain the user pointer,463      // that stores the reference to the ScopStmt this access belongs to.464      isl_id *Id = isl_map_get_tuple_id(CurrentAccessMap, isl_dim_in);465      NewAccessMap = isl_map_set_tuple_id(NewAccessMap, isl_dim_in, Id);466 467      auto NewAccessDomain = isl_map_domain(isl_map_copy(NewAccessMap));468      auto CurrentAccessDomain = isl_map_domain(isl_map_copy(CurrentAccessMap));469 470      if (!isl_set_has_equal_space(NewAccessDomain, CurrentAccessDomain)) {471        errs() << "JScop file contains access function with incompatible "472               << "dimensions\n";473        isl_map_free(CurrentAccessMap);474        isl_map_free(NewAccessMap);475        isl_set_free(NewAccessDomain);476        isl_set_free(CurrentAccessDomain);477        return false;478      }479 480      NewAccessDomain =481          isl_set_intersect_params(NewAccessDomain, S.getContext().release());482      CurrentAccessDomain = isl_set_intersect_params(CurrentAccessDomain,483                                                     S.getContext().release());484      CurrentAccessDomain =485          isl_set_intersect(CurrentAccessDomain, Stmt.getDomain().release());486 487      if (MA->isRead() &&488          isl_set_is_subset(CurrentAccessDomain, NewAccessDomain) ==489              isl_bool_false) {490        errs() << "Mapping not defined for all iteration domain elements\n";491        isl_set_free(CurrentAccessDomain);492        isl_set_free(NewAccessDomain);493        isl_map_free(CurrentAccessMap);494        isl_map_free(NewAccessMap);495        return false;496      }497 498      isl_set_free(CurrentAccessDomain);499      isl_set_free(NewAccessDomain);500 501      if (!isl_map_is_equal(NewAccessMap, CurrentAccessMap)) {502        // Statistics.503        ++NewAccessMapFound;504        if (NewAccessStrings)505          NewAccessStrings->push_back(Accesses.str());506        MA->setNewAccessRelation(isl::manage(NewAccessMap));507      } else {508        isl_map_free(NewAccessMap);509      }510      isl_map_free(CurrentAccessMap);511      MemoryAccessIdx++;512    }513    StatementIdx++;514  }515 516  return true;517}518 519/// Check whether @p SAI and @p Array represent the same array.520static bool areArraysEqual(ScopArrayInfo *SAI, const json::Object &Array) {521  std::string Buffer;522  llvm::raw_string_ostream RawStringOstream(Buffer);523 524  // Check if key 'type' is present.525  if (!Array.get("type")) {526    errs() << "Array has no key 'type'.\n";527    return false;528  }529 530  // Check if key 'sizes' is present.531  if (!Array.get("sizes")) {532    errs() << "Array has no key 'sizes'.\n";533    return false;534  }535 536  // Check if key 'name' is present.537  if (!Array.get("name")) {538    errs() << "Array has no key 'name'.\n";539    return false;540  }541 542  if (SAI->getName() != *Array.getString("name"))543    return false;544 545  if (SAI->getNumberOfDimensions() != Array.getArray("sizes")->size())546    return false;547 548  for (unsigned i = 1; i < Array.getArray("sizes")->size(); i++) {549    SAI->getDimensionSize(i)->print(RawStringOstream);550    const json::Array &SizesArray = *Array.getArray("sizes");551    if (Buffer != SizesArray[i].getAsString().value())552      return false;553    Buffer.clear();554  }555 556  // Check if key 'type' differs from the current one or is not valid.557  SAI->getElementType()->print(RawStringOstream);558  if (Buffer != Array.getString("type").value()) {559    errs() << "Array has not a valid type.\n";560    return false;561  }562 563  return true;564}565 566/// Get the accepted primitive type from its textual representation567///        @p TypeTextRepresentation.568///569/// @param TypeTextRepresentation The textual representation of the type.570/// @return The pointer to the primitive type, if this type is accepted571///         or nullptr otherwise.572static Type *parseTextType(const std::string &TypeTextRepresentation,573                           LLVMContext &LLVMContext) {574  std::map<std::string, Type *> MapStrToType = {575      {"void", Type::getVoidTy(LLVMContext)},576      {"half", Type::getHalfTy(LLVMContext)},577      {"float", Type::getFloatTy(LLVMContext)},578      {"double", Type::getDoubleTy(LLVMContext)},579      {"x86_fp80", Type::getX86_FP80Ty(LLVMContext)},580      {"fp128", Type::getFP128Ty(LLVMContext)},581      {"ppc_fp128", Type::getPPC_FP128Ty(LLVMContext)},582      {"i1", Type::getInt1Ty(LLVMContext)},583      {"i8", Type::getInt8Ty(LLVMContext)},584      {"i16", Type::getInt16Ty(LLVMContext)},585      {"i32", Type::getInt32Ty(LLVMContext)},586      {"i64", Type::getInt64Ty(LLVMContext)},587      {"i128", Type::getInt128Ty(LLVMContext)}};588 589  auto It = MapStrToType.find(TypeTextRepresentation);590  if (It != MapStrToType.end())591    return It->second;592 593  errs() << "Textual representation can not be parsed: "594         << TypeTextRepresentation << "\n";595  return nullptr;596}597 598/// Import new arrays from JScop.599///600/// @param S The scop to update.601/// @param JScop The JScop file describing new arrays.602///603/// @returns True if the import succeeded, otherwise False.604static bool importArrays(Scop &S, const json::Object &JScop) {605  if (!JScop.get("arrays"))606    return true;607  const json::Array &Arrays = *JScop.getArray("arrays");608  if (Arrays.size() == 0)609    return true;610 611  unsigned ArrayIdx = 0;612  for (auto &SAI : S.arrays()) {613    if (!SAI->isArrayKind())614      continue;615    if (ArrayIdx + 1 > Arrays.size()) {616      errs() << "Not enough array entries in JScop file.\n";617      return false;618    }619    if (!areArraysEqual(SAI, *Arrays[ArrayIdx].getAsObject())) {620      errs() << "No match for array '" << SAI->getName() << "' in JScop.\n";621      return false;622    }623    ArrayIdx++;624  }625 626  for (; ArrayIdx < Arrays.size(); ArrayIdx++) {627    const json::Object &Array = *Arrays[ArrayIdx].getAsObject();628    auto *ElementType =629        parseTextType(Array.get("type")->getAsString().value().str(),630                      S.getSE()->getContext());631    if (!ElementType) {632      errs() << "Error while parsing element type for new array.\n";633      return false;634    }635    const json::Array &SizesArray = *Array.getArray("sizes");636    std::vector<unsigned> DimSizes;637    for (unsigned i = 0; i < SizesArray.size(); i++) {638      auto Size = std::stoi(SizesArray[i].getAsString()->str());639 640      // Check if the size if positive.641      if (Size <= 0) {642        errs() << "The size at index " << i << " is =< 0.\n";643        return false;644      }645 646      DimSizes.push_back(Size);647    }648 649    auto NewSAI = S.createScopArrayInfo(650        ElementType, Array.getString("name").value().str(), DimSizes);651 652    if (Array.get("allocation")) {653      NewSAI->setIsOnHeap(Array.getString("allocation").value() == "heap");654    }655  }656 657  return true;658}659 660/// Import a Scop from a JSCOP file661/// @param S The scop to be modified662/// @param D Dependence Info663/// @param DL The DataLayout of the function664/// @param NewAccessStrings Optionally record the imported access strings665///666/// @returns true on success, false otherwise. Beware that if this returns667/// false, the Scop may still have been modified. In this case the Scop contains668/// invalid information.669static bool importScop(Scop &S, const Dependences &D, const DataLayout &DL,670                       std::vector<std::string> *NewAccessStrings = nullptr) {671  std::string FileName = ImportDir + "/" + getFileName(S, ImportPostfix);672 673  std::string FunctionName = S.getFunction().getName().str();674  errs() << "Reading JScop '" << S.getNameStr() << "' in function '"675         << FunctionName << "' from '" << FileName << "'.\n";676  ErrorOr<std::unique_ptr<MemoryBuffer>> result =677      MemoryBuffer::getFile(FileName);678  std::error_code ec = result.getError();679 680  if (ec) {681    errs() << "File could not be read: " << ec.message() << "\n";682    return false;683  }684 685  Expected<json::Value> ParseResult =686      json::parse(result.get().get()->getBuffer());687 688  if (Error E = ParseResult.takeError()) {689    errs() << "JSCoP file could not be parsed\n";690    errs() << E << "\n";691    consumeError(std::move(E));692    return false;693  }694  json::Object &jscop = *ParseResult.get().getAsObject();695 696  bool Success = importContext(S, jscop);697 698  if (!Success)699    return false;700 701  Success = importSchedule(S, jscop, D);702 703  if (!Success)704    return false;705 706  Success = importArrays(S, jscop);707 708  if (!Success)709    return false;710 711  Success = importAccesses(S, jscop, DL, NewAccessStrings);712 713  if (!Success)714    return false;715  return true;716}717 718void polly::runImportJSON(Scop &S, DependenceAnalysis::Result &DA) {719  const Dependences &D = DA.getDependences(Dependences::AL_Statement);720  const DataLayout &DL = S.getFunction().getParent()->getDataLayout();721  std::vector<std::string> NewAccessStrings;722  if (!importScop(S, D, DL, &NewAccessStrings))723    report_fatal_error("Tried to import a malformed jscop file.");724 725  if (PollyPrintImportJscop) {726    outs()727        << "Printing analysis 'Polly - Print Scop import result' for region: '"728        << S.getRegion().getNameStr() << "' in function '"729        << S.getFunction().getName() << "':\n";730    outs() << S;731    for (std::vector<std::string>::const_iterator I = NewAccessStrings.begin(),732                                                  E = NewAccessStrings.end();733         I != E; I++)734      outs() << "New access function '" << *I << "' detected in JSCOP file\n";735  }736}737 738void polly::runExportJSON(Scop &S) { exportScop(S); }739