diff --git a/dvm/fdvm/trunk/Sage/lib/include/libSage++.h b/dvm/fdvm/trunk/Sage/lib/include/libSage++.h index 3c6104a..9142d22 100644 --- a/dvm/fdvm/trunk/Sage/lib/include/libSage++.h +++ b/dvm/fdvm/trunk/Sage/lib/include/libSage++.h @@ -338,7 +338,7 @@ public: }; class SgExpression -{ +{ public: PTR_LLND thellnd; // generic expression class. diff --git a/dvm/fdvm/trunk/fdvm/acc_f2c.cpp b/dvm/fdvm/trunk/fdvm/acc_f2c.cpp index 53267c1..0f1e19c 100644 --- a/dvm/fdvm/trunk/fdvm/acc_f2c.cpp +++ b/dvm/fdvm/trunk/fdvm/acc_f2c.cpp @@ -1465,7 +1465,7 @@ void convertExpr(SgExpression *expr, SgExpression* &retExp) { printf(" [EXPR ERROR: %s, line %d, user line %d] unsupported variant of func call with name \"%s\"\n", __FILE__, __LINE__, first_do_par->lineNumber(), name); if (unSupportedVars.size() != 0) - Error("Internal inconsistency in F->C onvertation", "", 654, first_do_par); + Error("Internal inconsistency in F->C convertation", "", 654, first_do_par); } } } @@ -1706,7 +1706,7 @@ static SgExpression* splitReductionForAtomic(SgExpression* lhs, SgExpression* rh SgExpression* args = NULL; if (!lhs || !rhs) { - Error("Internal inconsistency in F->C onvertation", "", 654, first_do_par); + Error("Internal inconsistency in F->C convertation", "", 654, first_do_par); return NULL; } @@ -2814,7 +2814,7 @@ static bool convertStmt(SgStatement* &st, pair &retS { printf(" [STMT ERROR: %s, line %d, user line %d] unsupported variant of node: %s\n", __FILE__, __LINE__, first_do_par->lineNumber(), tag[st->variant()]); if (unSupportedVars.size() != 0) - Error("Internal inconsistency in F->C onvertation", "", 654, first_do_par); + Error("Internal inconsistency in F->C convertation", "", 654, first_do_par); } } @@ -3224,7 +3224,7 @@ void Translate_Fortran_To_C(SgStatement *Stmt) for (set::iterator i = unSupportedVars.begin(); i != unSupportedVars.end(); i++) printf(" [EXPR ERROR: %s, line %d, %d] unsupported variant of node: %s\n", __FILE__, __LINE__, first_do_par->lineNumber(), tag[*i]); if (unSupportedVars.size() != 0) - Error("Internal inconsistency in F->C onvertation", "", 654, first_do_par); + Error("Internal inconsistency in F->C convertation", "", 654, first_do_par); correctLabelsUse(Stmt, Stmt->lastExecutable()); @@ -3305,7 +3305,7 @@ void Translate_Fortran_To_C(SgStatement *firstStmt, SgStatement *lastStmt, vecto for (set::iterator i = unSupportedVars.begin(); i != unSupportedVars.end(); i++) printf(" [EXPR ERROR: %s, line %d, %d] unsupported variant of node: %s\n", __FILE__, __LINE__, first_do_par->lineNumber(), tag[*i]); if (unSupportedVars.size() != 0) - Error("Internal inconsistency in F->C onvertation", "", 654, first_do_par); + Error("Internal inconsistency in F->C convertation", "", 654, first_do_par); correctLabelsUse(firstStmt->lexNext(), lastStmt); diff --git a/sapfor/experts/Sapfor_2017/_src/Inliner/inliner.cpp b/sapfor/experts/Sapfor_2017/_src/Inliner/inliner.cpp index 811ee90..c8ea081 100644 --- a/sapfor/experts/Sapfor_2017/_src/Inliner/inliner.cpp +++ b/sapfor/experts/Sapfor_2017/_src/Inliner/inliner.cpp @@ -101,7 +101,7 @@ static void checkSymbols(const int currFileId, const set& symbs) { if (symb->getFileId() != currFileId) { - __spf_print(1, "check failed - given %d, correct %d\n", symb->getFileId(), currFileId); // DEBUG + __spf_print(1, "check failed - given %d, correct %d\n", symb->getFileId(), currFileId); printInternalError(convertFileName(__FILE__).c_str(), __LINE__); } } @@ -109,14 +109,21 @@ static void checkSymbols(const int currFileId, const set& symbs) static map createMapOfArgs(SgStatement* tempHedr, SgExpression* actualArgs) { - __spf_print(DEB, "------create map of vars------\n"); // DEBUG - map vars; + __spf_print(DEB, "------create map of vars------\n"); + SgProgHedrStmt* hedr = isSgProgHedrStmt(tempHedr); + checkNull(hedr, convertFileName(__FILE__).c_str(), __LINE__); + + int numPars = hedr->numberOfParameters(); + map vars; int i = 0; while (actualArgs) { + if (i >= numPars) + printInternalError(convertFileName(__FILE__).c_str(), __LINE__); + auto actualArg = actualArgs->lhs(); - auto formalArg = ((SgFunctionSymb*)tempHedr->symbol())->parameter(i++); + auto formalArg = hedr->parameter(i++); auto it = vars.find(formalArg->identifier()); if (it == vars.end()) @@ -1062,7 +1069,7 @@ static inline bool insert(SgStatement* callSt, SgStatement* funcStat, SgExpressi SgStatement* tempHedr = NULL; SgSymbol* tempSymb = NULL; - __spf_print(DEB, "------creating template------\n"); // DEBUG + __spf_print(DEB, "------creating template------\n"); // 2.a create function template auto funcSt = funcSymb->body(); if (funcSt->variant() == ENTRY_STAT) @@ -1297,7 +1304,8 @@ static void renameArgsIfGlobalNameIntersection(FuncInfo* func, const set for (int z = 0; z < 3; ++z) renameArgs(st->expr(z), remapArgs); - auto prog = isSgProgHedrStmt(header); + auto prog = isSgProcHedrStmt(header); + PTR_SYMB listP = SYMB_FUNC_PARAM(BIF_SYMB(prog->thebif)); vector newElems; for (int p = 0; p < prog->numberOfParameters(); ++p) @@ -1307,11 +1315,12 @@ static void renameArgsIfGlobalNameIntersection(FuncInfo* func, const set if (it != remapArgs.end()) { - SgSymbol* replace = findSymbolOrCreate(current_file, it->second, par->type()); + SgSymbol* replace = par->copyPtr(); + replace->changeName(it->second.c_str()); newElems.push_back(replace->thesymb); } else - newElems.push_back(listP); + newElems.push_back(duplicateSymbol(listP)); listP = SYMB_NEXT_DECL(listP); } @@ -1419,7 +1428,6 @@ static bool run_inliner(const map& funcMap, set } set newSymbols; - bool foundCall = false; if (!callSt || !isSgExecutableStatement(callSt)) @@ -1433,9 +1441,8 @@ static bool run_inliner(const map& funcMap, set printInternalError(convertFileName(__FILE__).c_str(), __LINE__); } - __spf_print(DEB, "------start inliner-----\n"); // DEBUG - __spf_print(DEB, "---statement preprocessing---\n"); // DEBUG - + __spf_print(DEB, "------start inliner-----\n"); + __spf_print(DEB, "---statement preprocessing---\n"); //simple convertation if (callSt->controlParent()->variant() == LOGIF_NODE) LogIftoIfThen(callSt->controlParent()); @@ -1448,10 +1455,9 @@ static bool run_inliner(const map& funcMap, set for (int i = 0; i < 3; ++i) recFindFuncCall(currentFuncI, callSt->expr(i), NULL, i, false, funcName, foundCall, callSt, newSymbols, insertPlace); - __spf_print(DEB, "---argument preprocessing---\n"); // DEBUG + __spf_print(DEB, "---argument preprocessing---\n"); // 1.b: make argument preprocessing checkNull(begin, convertFileName(__FILE__).c_str(), __LINE__); - // if call statement has any expression as its artument, split this expression for separate statement // if call statement has any function as its argument, split this call for (auto st = begin->lexNext(); st != end; st = st->lexNext()) @@ -1480,7 +1486,7 @@ static bool run_inliner(const map& funcMap, set } set useStats; - __spf_print(DEB, "---start inlining---\n"); // DEBUG + __spf_print(DEB, "---start inlining---\n"); // 2. create function template to modify and insert it if (foundCall) { @@ -1638,7 +1644,7 @@ static bool inliner(const string& fileName_in, const string& funcName, const int const map>& allFuncInfo, map>& SPF_messages, map>& newSymbsToDeclare, const map& commonBlocks, int deepLvl = 0) -{ +{ map funcMap; createMapOfFunc(allFuncInfo, funcMap); @@ -2355,6 +2361,7 @@ static void createDeclarations(const map>& newSymbs static void convertLinesToAbsolute(const map>& allFuncInfo, vector>& inDataProc) { + set> added; for (int z = 0; z < inDataProc.size(); ++z) { if (std::get<2>(inDataProc[z]) > 0) @@ -2364,7 +2371,7 @@ static void convertLinesToAbsolute(const map>& allFunc auto file = std::get<1>(inDataProc[z]); int absoluteLine = 0; int shilftLine = -std::get<2>(inDataProc[z]); - + for (auto& funcByFile : allFuncInfo) { if (funcByFile.first != file) @@ -2373,12 +2380,14 @@ static void convertLinesToAbsolute(const map>& allFunc for (auto& func : funcByFile.second) { int targetLine = func->linesNum.first + shilftLine; - __spf_print(1, "%s target %d + %d = %d\n", func->funcName.c_str(), func->linesNum.first, shilftLine, targetLine); + //__spf_print(1, "%s target %d + %d = %d\n", func->funcName.c_str(), func->linesNum.first, shilftLine, targetLine); for (auto& detCall : func->callsFromDetailed) { - __spf_print(1, "%s %d\n", detCall.detailCallsFrom.first.c_str(), detCall.detailCallsFrom.second); - if (detCall.detailCallsFrom == make_pair(funcToInl, targetLine)) + if (detCall.detailCallsFrom == make_pair(funcToInl, targetLine) && + added.find(make_tuple(file, funcToInl, targetLine)) == added.end()) { + __spf_print(1, "%s %d (was %d) %s\n", funcToInl, targetLine, std::get<2>(inDataProc[z]), funcByFile.first.c_str()); + added.insert(make_tuple(file, funcToInl, targetLine)); absoluteLine = targetLine; break; } @@ -2386,6 +2395,8 @@ static void convertLinesToAbsolute(const map>& allFunc if (absoluteLine) break; } + if (absoluteLine) + break; } if (absoluteLine == 0) @@ -2417,6 +2428,7 @@ void callInliner(const map>& allFuncInfo, if (inDataProc.size()) { + __spf_print(1, "count of inline data %ld\n", inDataProc.size()); convertLinesToAbsolute(allFuncInfo, inDataProc); map> sortByLvl; diff --git a/sapfor/experts/Sapfor_2017/_src/ParallelizationRegions/ParRegions.cpp b/sapfor/experts/Sapfor_2017/_src/ParallelizationRegions/ParRegions.cpp index 7a611ef..5f6c522 100644 --- a/sapfor/experts/Sapfor_2017/_src/ParallelizationRegions/ParRegions.cpp +++ b/sapfor/experts/Sapfor_2017/_src/ParallelizationRegions/ParRegions.cpp @@ -98,7 +98,7 @@ static void updateRegionInfo(SgStatement *st, mapsymbol()->identifier(); // DEBUG + if (st_ps->variant() == PROC_HEDR || st_ps->variant() == PROG_HEDR || st_ps->variant() == FUNC_HEDR) containsPrefix = st_ps->symbol()->identifier() + string("."); diff --git a/sapfor/experts/Sapfor_2017/_src/ParallelizationRegions/resolve_par_reg_conflicts.cpp b/sapfor/experts/Sapfor_2017/_src/ParallelizationRegions/resolve_par_reg_conflicts.cpp index 91c3458..d848895 100644 --- a/sapfor/experts/Sapfor_2017/_src/ParallelizationRegions/resolve_par_reg_conflicts.cpp +++ b/sapfor/experts/Sapfor_2017/_src/ParallelizationRegions/resolve_par_reg_conflicts.cpp @@ -1625,7 +1625,7 @@ int resolveParRegions(vector ®ions, const mapGetName().c_str()); // DEBUG + __spf_print(1, "[%s]: create local arrays\n", region->GetName().c_str()); // creating new local arrays for (auto& funcArrays : region->GetUsedLocalArrays()) @@ -1661,7 +1661,7 @@ int resolveParRegions(vector ®ions, const mapGetName().c_str()); // DEBUG + __spf_print(1, "[%s]: create common arrays\n", region->GetName().c_str()); // creating new common-blocks for files with explicit lines for (auto& fileLines : region->GetAllLines()) @@ -1793,7 +1793,7 @@ int resolveParRegions(vector ®ions, const map ®ions, const mapfirstStatement(); st; st = st->lexNext()) removeOmpDir(st); } + else if (curr_regime == REMOVE_COMMENTS) + { + for (SgStatement* st = file->firstStatement(); st; st = st->lexNext()) + if (st->comments()) + st->delComments(); + } else if (curr_regime == GET_MIN_MAX_BLOCK_DIST) getMaxMinBlockDistribution(file, min_max_block); else if (curr_regime == TEST_PASS) @@ -2469,6 +2475,7 @@ void runPass(const int curr_regime, const char *proj_name, const char *folderNam case CREATE_CHECKPOINTS: case PURE_INTENT_INSERT: case REMOVE_OMP_DIRS_TRANSFORM: + case REMOVE_COMMENTS: runAnalysis(*project, curr_regime, true, "", folderName); break; case PRIVATE_REMOVING: @@ -2705,7 +2712,8 @@ int main(int argc, char **argv) parallizeFreeLoops = 1; else if (string(curr_arg) == "-parse") { - auto result = splitCommandLineForParse(argv + (i + 1), argc - (i + 1)); + bool isInline = false; + auto result = splitCommandLineForParse(argv + (i + 1), argc - (i + 1), isInline); if (result.second.size() == 0) { printf("Nothing to parse\n"); @@ -2727,7 +2735,7 @@ int main(int argc, char **argv) listOfProject.push_back(FileInfo(file, toAddOpt + "-o " + file + ".dep", "", "", "", fileText, 0)); } - int rethrow = parseFiles(errors, listOfProject, filesCompilationOrder, 1, true); + int rethrow = parseFiles(errors, listOfProject, filesCompilationOrder, isInline, true); if (rethrow == 0) { for (auto& err : errors) diff --git a/sapfor/experts/Sapfor_2017/_src/Sapfor.h b/sapfor/experts/Sapfor_2017/_src/Sapfor.h index abe30d8..ceea0b2 100644 --- a/sapfor/experts/Sapfor_2017/_src/Sapfor.h +++ b/sapfor/experts/Sapfor_2017/_src/Sapfor.h @@ -169,6 +169,7 @@ enum passes { FIX_COMMON_BLOCKS, REMOVE_OMP_DIRS, REMOVE_OMP_DIRS_TRANSFORM, + REMOVE_COMMENTS, GET_MIN_MAX_BLOCK_DIST, TEST_PASS, @@ -344,6 +345,7 @@ static void setPassValues() passNames[FIX_COMMON_BLOCKS] = "FIX_COMMON_BLOCKS"; passNames[REMOVE_OMP_DIRS] = "REMOVE_OMP_DIRS"; passNames[REMOVE_OMP_DIRS_TRANSFORM] = "REMOVE_OMP_DIRS_TRANSFORM"; + passNames[REMOVE_COMMENTS] = "REMOVE_COMMENTS"; passNames[GET_MIN_MAX_BLOCK_DIST] = "GET_MIN_MAX_BLOCK_DIST"; passNames[TEST_PASS] = "TEST_PASS"; diff --git a/sapfor/experts/Sapfor_2017/_src/Utils/SgUtils.cpp b/sapfor/experts/Sapfor_2017/_src/Utils/SgUtils.cpp index a770c83..72974de 100644 --- a/sapfor/experts/Sapfor_2017/_src/Utils/SgUtils.cpp +++ b/sapfor/experts/Sapfor_2017/_src/Utils/SgUtils.cpp @@ -4010,6 +4010,7 @@ SgProject* createProject(const char* proj_name, for (int z = 0; z < project->numberOfFiles(); ++z) { SgFile* file = &(project->file(z)); + //file->unparsestdout(); const string fileN = file->filename(); auto first = file->firstStatement(); diff --git a/sapfor/experts/Sapfor_2017/_src/Utils/utils.cpp b/sapfor/experts/Sapfor_2017/_src/Utils/utils.cpp index 8eefae6..acc6ab5 100644 --- a/sapfor/experts/Sapfor_2017/_src/Utils/utils.cpp +++ b/sapfor/experts/Sapfor_2017/_src/Utils/utils.cpp @@ -1372,7 +1372,7 @@ set getAllRegionsByLine(const vector& regions, return regFound; } -pair, vector> splitCommandLineForParse(char** argv, int argc) +pair, vector> splitCommandLineForParse(char** argv, int argc, bool& isInline) { #if __cplusplus >= 201703L vector filesInDir; @@ -1410,7 +1410,12 @@ pair, vector> splitCommandLineForParse(char** argv, int a } } else - options.push_back(isFile); + { + if (isFile == "-inl") + isInline = true; + else + options.push_back(isFile); + } } vector filesV; diff --git a/sapfor/experts/Sapfor_2017/_src/Utils/utils.h b/sapfor/experts/Sapfor_2017/_src/Utils/utils.h index 1f42dbc..d3643d9 100644 --- a/sapfor/experts/Sapfor_2017/_src/Utils/utils.h +++ b/sapfor/experts/Sapfor_2017/_src/Utils/utils.h @@ -82,7 +82,7 @@ std::map createMapOfArrayAccess(const std: std::string readFileToStr(const std::string& name); void writeFileFromStr(const std::string& name, const std::string& data); -std::pair, std::vector> splitCommandLineForParse(char** argv, int argc); +std::pair, std::vector> splitCommandLineForParse(char** argv, int argc, bool& isInline); std::string getClearName(const std::string& in); std::wstring fixedLongFormat(const wchar_t* old); diff --git a/sapfor/experts/Sapfor_2017/_src/Utils/version.h b/sapfor/experts/Sapfor_2017/_src/Utils/version.h index 14638ce..a080b07 100644 --- a/sapfor/experts/Sapfor_2017/_src/Utils/version.h +++ b/sapfor/experts/Sapfor_2017/_src/Utils/version.h @@ -1,3 +1,3 @@ #pragma once -#define VERSION_SPF "2247" +#define VERSION_SPF "2250" diff --git a/sapfor/experts/Sapfor_2017/_src/VisualizerCalls/get_information.cpp b/sapfor/experts/Sapfor_2017/_src/VisualizerCalls/get_information.cpp index 08ef4da..15575dd 100644 --- a/sapfor/experts/Sapfor_2017/_src/VisualizerCalls/get_information.cpp +++ b/sapfor/experts/Sapfor_2017/_src/VisualizerCalls/get_information.cpp @@ -1802,6 +1802,14 @@ int SPF_RemoveDvmDirectivesToComments(void*& context, int winHandler, short *opt return simpleTransformPass(REMOVE_DVM_DIRS_TO_COMMENTS, options, projName, folderName, output, outputSize, outputMessage, outputMessageSize); } +int SPF_RemoveComments(void*& context, int winHandler, short* options, short* projName, short* folderName, short*& output, + int*& outputSize, short*& outputMessage, int*& outputMessageSize) +{ + MessageManager::clearCache(); + MessageManager::setWinHandler(winHandler); + return simpleTransformPass(REMOVE_COMMENTS, options, projName, folderName, output, outputSize, outputMessage, outputMessageSize); +} + int SPF_RemoveDvmIntervals(void*& context, int winHandler, short *options, short *projName, short *folderName, short *&output, int *&outputSize, short *&outputMessage, int *&outputMessageSize) { @@ -2528,6 +2536,8 @@ const wstring Sapfor_RunTransformation(const char* transformName_c, const char* retCode = SPF_RemoveDvmDirectives(context, winHandler, optSh, projSh, fold, output, outputSize, outputMessage, outputMessageSize); else if (whichRun == "SPF_RemoveDvmDirectivesToComments") retCode = SPF_RemoveDvmDirectivesToComments(context, winHandler, optSh, projSh, fold, output, outputSize, outputMessage, outputMessageSize); + else if (whichRun == "SPF_RemoveComments") + retCode = SPF_RemoveComments(context, winHandler, optSh, projSh, fold, output, outputSize, outputMessage, outputMessageSize); else if (whichRun == "SPF_InsertIncludesPass") retCode = SPF_InsertIncludesPass(context, winHandler, optSh, projSh, fold, (char*)addOpt_c, output, outputSize, outputMessage, outputMessageSize); else if (whichRun == "SPF_ResolveParallelRegionConflicts")