From 36e401b5d25c26152b62c7b57dc9c648b61a4faa Mon Sep 17 00:00:00 2001 From: AntonMilienkov Date: Wed, 20 Dec 2023 16:31:16 +0300 Subject: [PATCH 1/2] findlocaldata --- .../_src/Transformations/checkpoints.cpp | 57 ++++++++++++------- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/sapfor/experts/Sapfor_2017/_src/Transformations/checkpoints.cpp b/sapfor/experts/Sapfor_2017/_src/Transformations/checkpoints.cpp index 9da8cbc..a093fb0 100644 --- a/sapfor/experts/Sapfor_2017/_src/Transformations/checkpoints.cpp +++ b/sapfor/experts/Sapfor_2017/_src/Transformations/checkpoints.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include "../Utils/SgUtils.h" #include "../Utils/utils.h" @@ -38,7 +39,7 @@ static SgType* createArrayCharType(int len, int dim) } static void findDecls(SgExpression* ex, vector& local, const map& localParams, - set& added) + set& added, std::set& IntentInadded) { if (ex) { @@ -47,7 +48,8 @@ static void findDecls(SgExpression* ex, vector& local, const map< if (ex->symbol()->variant() == VARIABLE_NAME && localParams.find(ex->symbol()->identifier()) == localParams.end()) { - if (added.find(ex->symbol()->identifier()) == added.end()) + if (added.find(ex->symbol()->identifier()) == added.end() && + IntentInadded.find(ex->symbol()->identifier()) == IntentInadded.end()) { added.insert(ex->symbol()->identifier()); local.push_back(ex); @@ -58,21 +60,42 @@ static void findDecls(SgExpression* ex, vector& local, const map< if (ex->variant() == ARRAY_REF) { if (ex->symbol()->variant() == VARIABLE_NAME && - added.find(ex->symbol()->identifier()) == added.end()) + added.find(ex->symbol()->identifier()) == added.end() && + IntentInadded.find(ex->symbol()->identifier()) == IntentInadded.end()) { added.insert(ex->symbol()->identifier()); local.push_back(new SgArrayRefExp(*ex->symbol())); } } - findDecls(ex->lhs(), local, localParams, added); - findDecls(ex->rhs(), local, localParams, added); + findDecls(ex->lhs(), local, localParams, added, IntentInadded); + findDecls(ex->rhs(), local, localParams, added, IntentInadded); } } -static void findLocalData(SgStatement* start, SgStatement* end, vector& local, - map& localParams, set& added) + +static FuncInfo* findFileInfoByName(SgStatement* func, const vector& allFuncInfo) { + FuncInfo* funcI = NULL; + for (auto& funcs : allFuncInfo) + if (funcs->funcName == func->symbol()->identifier()) + funcI = funcs; + checkNull(funcI, convertFileName(__FILE__).c_str(), __LINE__); + + return funcI; +} + +static void findLocalData(SgStatement* func, SgStatement* end, vector& local, + map& localParams, set& added, const vector& allFuncInfo) +{ + SgStatement* start = func->lexNext(); + + FuncInfo* funcI = findFileInfoByName(func, allFuncInfo); + std::set IntentInadded; + for (int i = 0; i < funcI->funcParams.countOfPars; ++i) + if (funcI->funcParams.isArgIn(i) && !funcI->funcParams.isArgOut(i)) + IntentInadded.insert(funcI->funcParams.identificators[i]); + for (SgStatement* st = start; st != end; st = st->lexNext()) { if (st->variant() == PARAM_DECL) @@ -92,7 +115,7 @@ static void findLocalData(SgStatement* start, SgStatement* end, vectorlineNumber(), st->fileName(), tag[st->variant()]); if (st->variant() == VAR_DECL || st->variant() == VAR_DECL_90) - findDecls(st->expr(0), local, localParams, added); + findDecls(st->expr(0), local, localParams, added, IntentInadded); } } @@ -529,11 +552,7 @@ static void processFunctionCallChain(SgStatement* func, const vector& const int every, const vector& everyS) { //find function structure - FuncInfo* funcI = NULL; - for (auto& funcs : allFuncInfo) - if (funcs->funcName == func->symbol()->identifier()) - funcI = funcs; - checkNull(funcI, convertFileName(__FILE__).c_str(), __LINE__); + FuncInfo* funcI = findFileInfoByName(func, allFuncInfo); set> toProcess; fillToProcess(funcI, toProcess); @@ -555,7 +574,7 @@ static void processFunctionCallChain(SgStatement* func, const vector& vector local; map localParams; set addedToList; - findLocalData(hedrFrom->lexNext(), firstExec, local, localParams, addedToList); + findLocalData(hedrFrom, firstExec, local, localParams, addedToList, allFuncInfo); if (!processedFrom.count(funcFrom)) { @@ -720,7 +739,7 @@ static void processFunctionCallChain(SgStatement* func, const vector& } } -static void processModules(SgFile* file) +static void processModules(SgFile* file, const vector& allFuncInfo) { vector modules; findModulesInFile(file, modules); @@ -740,7 +759,7 @@ static void processModules(SgFile* file) vector local; map localParams; set addedToList; - findLocalData(mod->lexNext(), hasContains ? st : mod->lastNodeOfStmt(), local, localParams, addedToList); + findLocalData(mod, hasContains ? st : mod->lastNodeOfStmt(), local, localParams, addedToList, allFuncInfo); SgProcHedrStmt* newF = new SgProcHedrStmt((string("spf_cp_") + mod->symbol()->identifier()).c_str()); if (!hasContains) @@ -772,7 +791,7 @@ void createCheckpoints(SgFile* file, const map& commonBloc if (!inFile) { - processModules(file); + processModules(file, allFuncInfo); return; } @@ -832,7 +851,7 @@ void createCheckpoints(SgFile* file, const map& commonBloc vector local; map localParams; set addedToList; - findLocalData(func->lexNext(), firstExec, local, localParams, addedToList); + findLocalData(func, firstExec, local, localParams, addedToList, allFuncInfo); const vector useOfMods = findUseOfModules(func->lexNext(), firstExec); SgStatement* loadBlock = new SgStatement(IF_NODE); @@ -1165,7 +1184,7 @@ void createCheckpoints(SgFile* file, const map& commonBloc //processFunctionCallChain(func, allFuncInfo, moduleF, loadS, iostat, journal, frmt, unit, files, fileIdx, every, everyS); } - processModules(file); + processModules(file, allFuncInfo); } static string cuttingType(const string& all_decl_with_init) From e51f9643a48282631dadfdee4c81b9f1e3401353 Mon Sep 17 00:00:00 2001 From: AntonMilienkov Date: Fri, 22 Dec 2023 07:08:48 +0300 Subject: [PATCH 2/2] IntentInadded -> IntentInParams --- .../_src/Transformations/checkpoints.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/sapfor/experts/Sapfor_2017/_src/Transformations/checkpoints.cpp b/sapfor/experts/Sapfor_2017/_src/Transformations/checkpoints.cpp index a093fb0..9167653 100644 --- a/sapfor/experts/Sapfor_2017/_src/Transformations/checkpoints.cpp +++ b/sapfor/experts/Sapfor_2017/_src/Transformations/checkpoints.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include "../Utils/SgUtils.h" #include "../Utils/utils.h" @@ -39,7 +38,7 @@ static SgType* createArrayCharType(int len, int dim) } static void findDecls(SgExpression* ex, vector& local, const map& localParams, - set& added, std::set& IntentInadded) + set& added, set& IntentInParams) { if (ex) { @@ -68,8 +67,8 @@ static void findDecls(SgExpression* ex, vector& local, const map< } } - findDecls(ex->lhs(), local, localParams, added, IntentInadded); - findDecls(ex->rhs(), local, localParams, added, IntentInadded); + findDecls(ex->lhs(), local, localParams, added, IntentInParams); + findDecls(ex->rhs(), local, localParams, added, IntentInParams); } } @@ -91,10 +90,10 @@ static void findLocalData(SgStatement* func, SgStatement* end, vectorlexNext(); FuncInfo* funcI = findFileInfoByName(func, allFuncInfo); - std::set IntentInadded; + set IntentInParams; for (int i = 0; i < funcI->funcParams.countOfPars; ++i) if (funcI->funcParams.isArgIn(i) && !funcI->funcParams.isArgOut(i)) - IntentInadded.insert(funcI->funcParams.identificators[i]); + IntentInParams.insert(funcI->funcParams.identificators[i]); for (SgStatement* st = start; st != end; st = st->lexNext()) { @@ -115,7 +114,7 @@ static void findLocalData(SgStatement* func, SgStatement* end, vectorlineNumber(), st->fileName(), tag[st->variant()]); if (st->variant() == VAR_DECL || st->variant() == VAR_DECL_90) - findDecls(st->expr(0), local, localParams, added, IntentInadded); + findDecls(st->expr(0), local, localParams, added, IntentInParams); } }