fixed module symbols analysis
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
@@ -361,7 +361,7 @@ static void fillIterationVars(SgStatement* stmt, SgStatement* outerLoopStmt, vec
|
|||||||
|
|
||||||
static void addMessageVarNotAlignedWithLoop(vector<Messages>& messages, string varName, int loopLineNum)
|
static void addMessageVarNotAlignedWithLoop(vector<Messages>& messages, string varName, int loopLineNum)
|
||||||
{
|
{
|
||||||
__spf_print(1, "WARR: cannot remove private var '%s' - its references have different alignment with the loop %d\n",
|
__spf_print(1, " WARR: cannot remove private var '%s' - its references have different alignment with the loop %d\n",
|
||||||
varName.c_str(), loopLineNum);
|
varName.c_str(), loopLineNum);
|
||||||
|
|
||||||
wstring messageE, messageR;
|
wstring messageE, messageR;
|
||||||
@@ -374,7 +374,7 @@ static void addMessageVarNotAlignedWithLoop(vector<Messages>& messages, string v
|
|||||||
|
|
||||||
static void addMessageRemovePrivateVar(vector<Messages>& messages, string varName, int loopLineNum)
|
static void addMessageRemovePrivateVar(vector<Messages>& messages, string varName, int loopLineNum)
|
||||||
{
|
{
|
||||||
__spf_print(1, "NOTE: private variable '%s' was removed in loop %d\n", varName.c_str(), loopLineNum);
|
__spf_print(1, " NOTE: private variable '%s' was removed in loop %d\n", varName.c_str(), loopLineNum);
|
||||||
|
|
||||||
wstring messageE, messageR;
|
wstring messageE, messageR;
|
||||||
__spf_printToLongBuf(messageE, L"Private variable '%s' was removed", to_wstring(varName).c_str());
|
__spf_printToLongBuf(messageE, L"Private variable '%s' was removed", to_wstring(varName).c_str());
|
||||||
@@ -385,7 +385,7 @@ static void addMessageRemovePrivateVar(vector<Messages>& messages, string varNam
|
|||||||
|
|
||||||
static void addMessageRemovePrivateVarPart(vector<Messages>& messages, string varName, int loopLineNum)
|
static void addMessageRemovePrivateVarPart(vector<Messages>& messages, string varName, int loopLineNum)
|
||||||
{
|
{
|
||||||
__spf_print(1, "NOTE: private variable '%s' was partially removed in loop %d\n",
|
__spf_print(1, " NOTE: private variable '%s' was partially removed in loop %d\n",
|
||||||
varName.c_str(), loopLineNum);
|
varName.c_str(), loopLineNum);
|
||||||
|
|
||||||
wstring messageE, messageR;
|
wstring messageE, messageR;
|
||||||
@@ -398,7 +398,7 @@ static void addMessageRemovePrivateVarPart(vector<Messages>& messages, string va
|
|||||||
|
|
||||||
static void addMessageCannotFindRD(vector<Messages>& messages, string varName, int loopLineNum)
|
static void addMessageCannotFindRD(vector<Messages>& messages, string varName, int loopLineNum)
|
||||||
{
|
{
|
||||||
__spf_print(1, "WARR: cannot remove private var '%s' - cannot find reaching definition for the statement in line %d\n",
|
__spf_print(1, " WARR: cannot remove private var '%s' - cannot find reaching definition for the statement in line %d\n",
|
||||||
varName.c_str(), loopLineNum);
|
varName.c_str(), loopLineNum);
|
||||||
|
|
||||||
wstring messageE, messageR;
|
wstring messageE, messageR;
|
||||||
@@ -412,7 +412,7 @@ static void addMessageCannotFindRD(vector<Messages>& messages, string varName, i
|
|||||||
static void addMessagePossibleDifferentAssumption(vector<Messages>& messages, string varName,
|
static void addMessagePossibleDifferentAssumption(vector<Messages>& messages, string varName,
|
||||||
string ref1, string ref2, int loopLineNum)
|
string ref1, string ref2, int loopLineNum)
|
||||||
{
|
{
|
||||||
__spf_print(1, "WARR: removing of private var '%s' was made with assumption that references '%s' and '%s' are different in line %d\n",
|
__spf_print(1, " WARR: removing of private var '%s' was made with assumption that references '%s' and '%s' are different in line %d\n",
|
||||||
varName.c_str(), ref1.c_str(), ref2.c_str(), loopLineNum);
|
varName.c_str(), ref1.c_str(), ref2.c_str(), loopLineNum);
|
||||||
|
|
||||||
wstring messageE, messageR;
|
wstring messageE, messageR;
|
||||||
@@ -425,7 +425,7 @@ static void addMessagePossibleDifferentAssumption(vector<Messages>& messages, st
|
|||||||
|
|
||||||
static void addMessageRecursiveDependency(vector<Messages>& messages, string varName, int lineNum)
|
static void addMessageRecursiveDependency(vector<Messages>& messages, string varName, int lineNum)
|
||||||
{
|
{
|
||||||
__spf_print(1, "WARR: cannot remove private var '%s' in line %d - it has recursive dependency\n",
|
__spf_print(1, " WARR: cannot remove private var '%s' in line %d - it has recursive dependency\n",
|
||||||
varName.c_str(), lineNum);
|
varName.c_str(), lineNum);
|
||||||
|
|
||||||
wstring messageE, messageR;
|
wstring messageE, messageR;
|
||||||
@@ -438,7 +438,7 @@ static void addMessageRecursiveDependency(vector<Messages>& messages, string var
|
|||||||
|
|
||||||
static void addMessageDependOnNonInvariant(vector<Messages>& messages, string varName, string dependOn, int lineNum)
|
static void addMessageDependOnNonInvariant(vector<Messages>& messages, string varName, string dependOn, int lineNum)
|
||||||
{
|
{
|
||||||
__spf_print(1, "WARR: cannot remove private var '%s' in line %d - it depends on non-invariant var '%s'\n",
|
__spf_print(1, " WARR: cannot remove private var '%s' in line %d - it depends on non-invariant var '%s'\n",
|
||||||
varName.c_str(), lineNum, dependOn.c_str());
|
varName.c_str(), lineNum, dependOn.c_str());
|
||||||
|
|
||||||
wstring messageE, messageR;
|
wstring messageE, messageR;
|
||||||
@@ -451,7 +451,7 @@ static void addMessageDependOnNonInvariant(vector<Messages>& messages, string va
|
|||||||
|
|
||||||
static void addMessageDoesNotMatchMask(vector<Messages>& messages, string varName, int loopLineNum)
|
static void addMessageDoesNotMatchMask(vector<Messages>& messages, string varName, int loopLineNum)
|
||||||
{
|
{
|
||||||
__spf_print(1, "WARR: cannot remove private var '%s' in loop %d - it doesn't match any fixed dimensions mask\n",
|
__spf_print(1, " WARR: cannot remove private var '%s' in loop %d - it doesn't match any fixed dimensions mask\n",
|
||||||
varName.c_str(), loopLineNum);
|
varName.c_str(), loopLineNum);
|
||||||
|
|
||||||
wstring messageE, messageR;
|
wstring messageE, messageR;
|
||||||
@@ -465,7 +465,7 @@ static void addMessageDoesNotMatchMask(vector<Messages>& messages, string varNam
|
|||||||
static void addMessageUsageInFunctionCall(vector<Messages>& messages, string varName,
|
static void addMessageUsageInFunctionCall(vector<Messages>& messages, string varName,
|
||||||
string funcName, int loopLineNum, int stmtLineNum)
|
string funcName, int loopLineNum, int stmtLineNum)
|
||||||
{
|
{
|
||||||
__spf_print(1, "WARR: cannot remove private var '%s' in loop %d - it is used in the call of function '%s' in line %d\n",
|
__spf_print(1, " WARR: cannot remove private var '%s' in loop %d - it is used in the call of function '%s' in line %d\n",
|
||||||
varName.c_str(), loopLineNum, funcName.c_str(), stmtLineNum);
|
varName.c_str(), loopLineNum, funcName.c_str(), stmtLineNum);
|
||||||
|
|
||||||
wstring messageE, messageR;
|
wstring messageE, messageR;
|
||||||
@@ -1251,7 +1251,7 @@ static vector<bool> getFixedDimensionsMask(Context* ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
string unparsedFixedDimensions = sunparseFixedDimensionsVector(resultMask);
|
string unparsedFixedDimensions = sunparseFixedDimensionsVector(resultMask);
|
||||||
__spf_print(1, "NOTE: found fixed subsripts mask %s for array '%s' in loop %d\n",
|
__spf_print(1, " NOTE: found fixed subsripts mask %s for array '%s' in loop %d\n",
|
||||||
unparsedFixedDimensions.c_str(), ctx->arraySymbol->identifier(), ctx->loop->lineNum);
|
unparsedFixedDimensions.c_str(), ctx->arraySymbol->identifier(), ctx->loop->lineNum);
|
||||||
|
|
||||||
return resultMask;
|
return resultMask;
|
||||||
@@ -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);
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define VERSION_SPF "2398"
|
#define VERSION_SPF "2399"
|
||||||
|
|||||||
Reference in New Issue
Block a user