diff --git a/sapfor/experts/Sapfor_2017/_src/Transformations/checkpoints.cpp b/sapfor/experts/Sapfor_2017/_src/Transformations/checkpoints.cpp index a9a155d..27b92fb 100644 --- a/sapfor/experts/Sapfor_2017/_src/Transformations/checkpoints.cpp +++ b/sapfor/experts/Sapfor_2017/_src/Transformations/checkpoints.cpp @@ -639,11 +639,8 @@ static void processCommonStmt(SgStatement* st, set& commonVariables) static void processVarStmt(SgStatement* st, map& moduleStmts, const char* funcName, const set& inFuncParam) { - SgExpression* lhs2; - SgExpression* ex2 = st->expr(2); - SgExpression* ex = st->expr(0); - SgExpression* lhs; + SgExpression* lhs = NULL; SgStatement* baseStmt = st->copyPtr(); baseStmt->expr(0)->setLhs(NULL); @@ -763,9 +760,7 @@ static void insertStmtToModule(const map& moduleStmts, con for (const auto& [varName, varStmt] : moduleStmts) { string varNameNoPref = varName; - - string::size_type pos{}; - varNameNoPref.erase(0, pos + prefixLen + 1); + varNameNoPref.erase(0, prefixLen + 1); if (commonVariables.count(varNameNoPref) == 0 && moduleParamStmts.count(varName) == 0 && externVars.count(varNameNoPref) == 0) @@ -904,7 +899,7 @@ static SgStatement* createLoadBlock(const vector& loadS, FuncInfo*& f //READ from modules for (auto& mod : moduleNames) { - SgCallStmt* call = new SgCallStmt(*new SgSymbol(FUNCTION_NAME, ("SPF_CP_" + mod).c_str())); + SgCallStmt* call = new SgCallStmt(*new SgSymbol(FUNCTION_NAME, ("spf_cp_" + mod).c_str())); call->addArg(*new SgValueExp(unitNum)); call->addArg(*new SgValueExp(0)); ifLoadOk1->insertStmtAfter(*call, *ifLoadOk1); @@ -993,7 +988,7 @@ static SgStatement* createSaveBlock(const vector& loadS, FuncInfo*& f //WRITE from modules for (auto& mod : moduleNames) { - SgCallStmt* call = new SgCallStmt(*new SgSymbol(FUNCTION_NAME, ("SPF_CP_" + mod).c_str())); + SgCallStmt* call = new SgCallStmt(*new SgSymbol(FUNCTION_NAME, ("spf_cp_" + mod).c_str())); call->addArg(*new SgValueExp(unitNum)); call->addArg(*new SgValueExp(1)); ifStoreOk->insertStmtAfter(*call, *ifStoreOk); @@ -1134,6 +1129,18 @@ static void processInFuncParam(FuncInfo* funcI, set& inFuncParam) inFuncParam.insert(funcI->funcParams.identificators[i]); } +static SgStatement* getFirstExecStat(SgStatement* func) +{ + SgStatement* firstExec = func->lexNext(); + SgStatement* last = func->lastNodeOfStmt(); + while (firstExec && firstExec != last && !isSgExecutableStatement(firstExec)) + { + firstExec = firstExec->lastNodeOfStmt(); + firstExec = firstExec->lexNext(); + } + return firstExec; +} + static void processFunctionCallChain(SgStatement* func, const vector& allFuncInfo, SgStatement* moduleF, const vector& loadS, SgExpression* iostat, SgArrayRefExp* journal, SgExpression& frmt, SgExpression& unit, @@ -1157,27 +1164,8 @@ static void processFunctionCallChain(SgStatement* func, const vector& SgFile::switchToFile(funcFrom->fileName); - int callNum = 1; - SgStatement* hedrTo = funcTo->funcPointer->GetOriginal(); SgStatement* hedrFrom = funcFrom->funcPointer->GetOriginal(); - SgStatement* lastDecl = hedrFrom->lexNext(); - SgStatement* firstExec; - if (isSgExecutableStatement(lastDecl)) - { - firstExec = lastDecl; - lastDecl = NULL; - } - else - { - while (lastDecl && !isSgExecutableStatement(lastDecl->lexNext())) - lastDecl = lastDecl->lexNext(); - - firstExec = lastDecl->lexNext(); - } - - vector local; - map localParams; - set addedToList; + SgStatement* firstExec = getFirstExecStat(hedrFrom); if (!processedFrom.count(funcFrom)) { @@ -1246,7 +1234,6 @@ static void processFunctionCallChain(SgStatement* func, const vector& makeDeclaration(hedrFrom, { timeF }); } - } SgFile::switchToFile(func->fileName()); @@ -1445,7 +1432,7 @@ void createCheckpoints(SgFile* file, const map& commonBloc SgStatement* loadBlock = createLoadBlock(loadS, funcI, iostat, journal, frmt, unit, files, fileIdx, numOfFiles, profS, frmtProf, unitNull, profCallS, profCallE, localVarNoParams, moduleStmts, commonVariables, createdModuleForIO, moduleNames, unitNum, funcName, chainLocalVarNoParamsa); - lastDecl->insertStmtAfter(*loadBlock, *lastDecl->controlParent()); + lastDecl->insertStmtAfter(*loadBlock, *func); if (funcI->isMain) insertInitNamesOfFiles(numOfFiles, additional, files, journal, lastDecl, false); @@ -1476,7 +1463,7 @@ void createCheckpoints(SgFile* file, const map& commonBloc if (ex && ex->variant() == ONLY_NODE) { modulesDone[modName] = true; - auto callName = new SgSymbol(VARIABLE_NAME, ("SPF_CP_" + modName).c_str()); + auto callName = new SgSymbol(VARIABLE_NAME, ("spf_cp_" + modName).c_str()); ex->setLhs(new SgExpression(EXPR_LIST, new SgVarRefExp(callName), ex->lhs())); } } @@ -1495,7 +1482,7 @@ void createCheckpoints(SgFile* file, const map& commonBloc { if (!elem.second) { - auto callName = new SgSymbol(VARIABLE_NAME, ("SPF_CP_" + elem.first).c_str()); + auto callName = new SgSymbol(VARIABLE_NAME, ("spf_cp_" + elem.first).c_str()); SgSymbol* modS = new SgSymbol(VARIABLE_NAME, elem.first.c_str()); vector onlyList; diff --git a/sapfor/experts/Sapfor_2017/_src/Transformations/function_purifying.cpp b/sapfor/experts/Sapfor_2017/_src/Transformations/function_purifying.cpp index c85d2e9..f78d726 100644 --- a/sapfor/experts/Sapfor_2017/_src/Transformations/function_purifying.cpp +++ b/sapfor/experts/Sapfor_2017/_src/Transformations/function_purifying.cpp @@ -2091,7 +2091,6 @@ static bool isIntrincis(const string& name) intrinsicF.insert(string("trailz")); intrinsicF.insert(string("trim")); intrinsicF.insert(string("xor")); - intrinsicF.insert(string("wtime")); intrinsicF.insert(string("zabs")); intrinsicF.insert(string("zcos")); intrinsicF.insert(string("zexp")); diff --git a/sapfor/experts/Sapfor_2017/_src/Utils/version.h b/sapfor/experts/Sapfor_2017/_src/Utils/version.h index 1f9f8a9..4a763c9 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 "2340" +#define VERSION_SPF "2341"