fixed module symbols analysis

This commit is contained in:
ALEXks
2025-03-19 20:31:19 +03:00
committed by Dudarenko
parent 7460cf6e59
commit 5231eeacd8
4 changed files with 35 additions and 29 deletions

View File

@@ -943,14 +943,10 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
{ {
auto itFound = loopGraph.find(file->filename()); auto itFound = loopGraph.find(file->filename());
if (itFound != loopGraph.end()) if (itFound != loopGraph.end())
removePrivatesAnalysis(file_name, itFound->second, getObjectForFileFromMap(file_name, SPF_messages), removePrivatesAnalysis(file_name, itFound->second, getObjectForFileFromMap(file_name, SPF_messages), usersDirectives, commonBlocks, allFuncInfo);
usersDirectives, commonBlocks, allFuncInfo);
} }
else if (curr_regime == PRIVATE_REMOVING) else if (curr_regime == PRIVATE_REMOVING)
{ removePrivates(file_name, getObjectForFileFromMap(file_name, SPF_messages), commonBlocks, allFuncInfo, countOfTransform);
removePrivates(file_name, getObjectForFileFromMap(file_name, SPF_messages),
commonBlocks, allFuncInfo, countOfTransform);
}
else if (curr_regime == CREATE_INTER_TREE) else if (curr_regime == CREATE_INTER_TREE)
{ {
vector<string> include_functions; vector<string> include_functions;

View File

@@ -2190,7 +2190,7 @@ static set<SgSymbol*> getPrivateArraysForLoop(LoopGraph* loop, const UsersDirect
return privateArrays; return privateArrays;
} }
void removePrivateAnalyze(Context *ctx) static void removePrivateAnalyze(Context *ctx)
{ {
// inserting assignment to reduced array variables for getting reaching definitions analysis: // inserting assignment to reduced array variables for getting reaching definitions analysis:
auto reducedArrayVars = getReducedArrayVars(ctx); auto reducedArrayVars = getReducedArrayVars(ctx);

View File

@@ -293,35 +293,45 @@ static SgStatement* findModWithName(const vector<SgStatement*>& modules, const s
return NULL; return NULL;
} }
static map<SgStatement*, set<SgSymbol*>> symbolsForFunc; static map<string, set<SgSymbol*>> symbolsForFunc;
static set<string> allFiles; static set<string> allFiles;
static void getModuleSymbols(SgStatement* func, set<SgSymbol*>& symbs) static void getModuleSymbols(SgStatement* func, set<SgSymbol*>& symbs)
{ {
string currScope = func->symbol()->identifier();
auto it = symbolsForFunc.find(currScope);
if (it != symbolsForFunc.end()) {
for (const auto& s : it->second)
symbs.insert(s);
return;
}
SgSymbol* s = func->symbol()->next(); SgSymbol* s = func->symbol()->next();
while (s) while (s)
{ {
if (s->scope() == func && IS_BY_USE(s)) if (IS_BY_USE(s) && s->scope()->symbol()->identifier() == currScope)
symbs.insert(s); symbs.insert(s);
s = s->next(); s = s->next();
} }
} }
const set<SgSymbol*>& getModuleSymbols(SgStatement *func) const const set<SgSymbol*>& getModuleSymbols(SgStatement *func)
{ {
if (symbolsForFunc.find(func) != symbolsForFunc.end()) auto it = symbolsForFunc.find(func->symbol()->identifier());
return symbolsForFunc[func]; if (it != symbolsForFunc.end())
return it->second;
set<SgSymbol*> symbs; set<SgSymbol*> symbs;
getModuleSymbols(func, symbs); getModuleSymbols(func, symbs);
//if function in contains //if function in contains
func = func->controlParent(); auto cp = func->controlParent();
if (isSgProgHedrStmt(func)) if (isSgProgHedrStmt(cp))
getModuleSymbols(func, symbs); getModuleSymbols(cp, symbs);
symbolsForFunc[func] = symbs; symbolsForFunc[func->symbol()->identifier()] = symbs;
return symbolsForFunc[func]; return symbs;
} }
SgSymbol* getNameInLocation(SgStatement* func, const string& varName, const string& locName) SgSymbol* getNameInLocation(SgStatement* func, const string& varName, const string& locName)

View File

@@ -1,3 +1,3 @@
#pragma once #pragma once
#define VERSION_SPF "2398" #define VERSION_SPF "2399"