fixed dead flag for functions

This commit is contained in:
ALEXks
2025-02-09 20:48:06 +03:00
parent c5d063b0da
commit d8aa5606ef
19 changed files with 897 additions and 241 deletions

View File

@@ -1561,12 +1561,25 @@ static set<DIST::Array*>
for (auto& decl : decls)
{
declStat = SgStatement::getStatementByFileAndLine(decl.first, decl.second);
checkNull(declStat, convertFileName(__FILE__).c_str(), __LINE__);
if (declStat == NULL) // check in inlcudes
{
for (auto st = main; st != main->lastNodeOfStmt() && !declStat; st = st->lexNext())
{
if (st->fileName() == decl.first && st->lineNumber() == decl.second)
declStat = st;
}
if (declStat != main)
if (declStat)
break;
}
else
{
declStat = NULL;
continue;
declStat = getFuncStat(declStat);
if (declStat != main)
{
declStat = NULL;
continue;
}
}
}
}

View File

@@ -2235,10 +2235,10 @@ static bool hasRecursionChain(vector<FuncInfo*> currentChainCalls, const FuncInf
currentChainCalls.push_back(itF->second);
const string &chain = printChainRec(currentChainCalls);
__spf_print(1, "For function on line %d found recursive chain calls: %s\n", currentChainCalls[0]->linesNum.first, chain.c_str());
__spf_print(1, " For function on line %d found recursive chain calls: %s\n", currentChainCalls[0]->linesNum.first, chain.c_str());
wstring bufE, bufR;
__spf_printToLongBuf(bufE, L"Found recursive chain calls: %s, this function will be ignored", to_wstring(chain).c_str());
__spf_printToLongBuf(bufE, L" Found recursive chain calls: %s, this function will be ignored", to_wstring(chain).c_str());
__spf_printToLongBuf(bufR, R46, to_wstring(chain).c_str());
messagesForFile.push_back(Messages(NOTE, currentChainCalls[0]->linesNum.first, bufR, bufE, 1014));
@@ -2273,7 +2273,7 @@ void checkForRecursion(SgFile *file, map<string, vector<FuncInfo*>> &allFuncInfo
for (int i = 0; i < itCurrFuncs->second.size(); ++i)
{
__spf_print(1, "run for func %s\n", itCurrFuncs->second[i]->funcName.c_str());
__spf_print(1, " run for func %s\n", itCurrFuncs->second[i]->funcName.c_str());
if (hasRecursionChain( { itCurrFuncs->second[i] }, itCurrFuncs->second[i], mapFuncInfo, messagesForFile))
itCurrFuncs->second[i]->doNotAnalyze = true;
}

View File

@@ -404,6 +404,7 @@ void findDeadFunctionsAndFillCalls(map<string, vector<FuncInfo*>> &allFuncInfo,
set<string> allExternalCalls;
set<string> allChildCalls;
for (auto &it : mapFuncInfo)
{
FuncInfo *currInfo = it.second;
@@ -448,9 +449,37 @@ void findDeadFunctionsAndFillCalls(map<string, vector<FuncInfo*>> &allFuncInfo,
}
}
}
FuncInfo* main = NULL;
for (auto& it : mapFuncInfo)
if (it.second->isMain)
main = it.second;
checkNull(main, convertFileName(__FILE__).c_str(), __LINE__);
set<FuncInfo*> liveFunctions;
liveFunctions.insert(main);
for (auto& callFrom : main->callsFromV)
liveFunctions.insert(callFrom);
//find live functions
bool changes = true;
while (changes)
{
changes = false;
for (auto& currInfo : liveFunctions)
{
for (auto& callFrom : currInfo->callsFromV) {
if (liveFunctions.find(callFrom) == liveFunctions.end()) {
changes = true;
liveFunctions.insert(callFrom);
}
}
}
}
// propagate 'deadFunction' status for all 'CallsFrom' from dead functions
bool changes = true;
changes = true;
while (changes)
{
changes = false;
@@ -466,10 +495,11 @@ void findDeadFunctionsAndFillCalls(map<string, vector<FuncInfo*>> &allFuncInfo,
auto itFrom = mapFuncInfo.find(callFrom);
if (itFrom != mapFuncInfo.end())
{
if (!itFrom->second->deadFunction)
auto func = itFrom->second;
if (!func->deadFunction && liveFunctions.find(func) == liveFunctions.end())
{
changes = true;
itFrom->second->deadFunction = itFrom->second->doNotAnalyze = true;
func->deadFunction = func->doNotAnalyze = true;
}
}
}

View File

@@ -778,7 +778,7 @@ static void isAllOk(const vector<LoopGraph*> &loops, vector<Messages> &currMessa
if (loops[i]->countOfIters == 0 && loops[i]->region && loops[i]->isFor)
{
wstring bufE, bufR;
__spf_printToLongBuf(bufE, L"Can not calculate count of iterations for this loop, information about iterations in all loops in parallel regions '%s' will be ignored",
__spf_printToLongBuf(bufE, L" Can not calculate count of iterations for this loop, information about iterations in all loops in parallel regions '%s' will be ignored",
to_wstring(loops[i]->region->GetName()).c_str());
auto itM = uniqMessages.find(bufE);
@@ -789,7 +789,7 @@ static void isAllOk(const vector<LoopGraph*> &loops, vector<Messages> &currMessa
__spf_printToLongBuf(bufR, R48, to_wstring(loops[i]->region->GetName()).c_str());
currMessages.push_back(Messages(NOTE, loops[i]->lineNum, bufR, bufE, 1016));
__spf_print(1, "Can not calculate count of iterations for loop on line %d, information about iterations in all loops in parallel regions '%s' will be ignored\n", loops[i]->lineNum, loops[i]->region->GetName().c_str());
__spf_print(1, " Can not calculate count of iterations for loop on line %d, information about iterations in all loops in parallel regions '%s' will be ignored\n", loops[i]->lineNum, loops[i]->region->GetName().c_str());
}
isNotOkey.insert(loops[i]->region);
}
@@ -1085,7 +1085,7 @@ static void checkArraysMapping(vector<LoopGraph*> &loopList, map<DIST::Array*, v
if (!elem.first->IsDimDepracated(z))
{
std::wstring bufw, bufR;
__spf_printToLongBuf(bufw, L"Array '%s' can not be distributed due to different writes to %d dimension, this dimension will deprecated",
__spf_printToLongBuf(bufw, L" Array '%s' can not be distributed due to different writes to %d dimension, this dimension will deprecated",
to_wstring(elem.first->GetShortName()).c_str(), z + 1);
__spf_printToLongBuf(bufR, R85, z + 1,to_wstring(elem.first->GetShortName()).c_str());
@@ -1122,7 +1122,7 @@ void checkArraysMapping(const map<string, vector<LoopGraph*>> &loopGraph, map<st
if (elem->IsAllDeprecated())
{
wstring bufw, bufR;
__spf_printToLongBuf(bufw, L"Array '%s' can not be distributed due to all dimensions will deprecated", to_wstring(elem->GetShortName()).c_str());
__spf_printToLongBuf(bufw, L" Array '%s' can not be distributed due to all dimensions will deprecated", to_wstring(elem->GetShortName()).c_str());
__spf_printToLongBuf(bufR, R86, to_wstring(elem->GetShortName()).c_str());
for (auto &decl : elem->GetDeclInfo())
@@ -1210,7 +1210,7 @@ static void filterArrayInCSRGraph(vector<LoopGraph*> &loops, const map<string, F
if (itA == trees.end() || itA->second < 0)
{
wstring bufw, bufR;
__spf_printToLongBuf(bufw, L"Array '%s' can not be distributed", to_wstring(array->GetShortName()).c_str());
__spf_printToLongBuf(bufw, L" Array '%s' can not be distributed", to_wstring(array->GetShortName()).c_str());
__spf_printToLongBuf(bufR, R87, to_wstring(array->GetShortName()).c_str());
getObjectForFileFromMap(loop->fileName.c_str(), messages).push_back(Messages(NOTE, loop->lineNum, bufR, bufw, 1047));
@@ -1251,7 +1251,7 @@ static void filterArrayInCSRGraph(vector<LoopGraph*> &loops, const map<string, F
if (itA == trees.end() || itA->second != treeNum)
{
wstring bufw, bufR;
__spf_printToLongBuf(bufw, L"Array '%s' can not be distributed", to_wstring(array->GetShortName()).c_str());
__spf_printToLongBuf(bufw, L" Array '%s' can not be distributed", to_wstring(array->GetShortName()).c_str());
__spf_printToLongBuf(bufR, R88, to_wstring(array->GetShortName()).c_str());
getObjectForFileFromMap(loop->fileName.c_str(), messages).push_back(Messages(NOTE, loop->lineNum, bufR, bufw, 1047));
@@ -1283,7 +1283,7 @@ static void filterArrayInCSRGraph(vector<LoopGraph*> &loops, const map<string, F
if (needToDeprecated)
{
wstring bufw, bufR;
__spf_printToLongBuf(bufw, L"Array '%s' can not be distributed", to_wstring(inCall->GetShortName()).c_str());
__spf_printToLongBuf(bufw, L" Array '%s' can not be distributed", to_wstring(inCall->GetShortName()).c_str());
__spf_printToLongBuf(bufR, R89, to_wstring(inCall->GetShortName()).c_str());
getObjectForFileFromMap(loop->fileName.c_str(), messages).push_back(Messages(NOTE, loop->lineNum, bufR, bufw, 1047));

View File

@@ -836,13 +836,13 @@ bool buildGraphFromUserDirectives(const vector<Statement*> &userDvmAlignDirs, DI
string tmp;
for (auto& elem : realAlignArrayRefsSet)
tmp += elem->GetName() + " ";
__spf_print(1, "align array%s '%s' from user dir in line %d\n", (realAlignArrayRefsSet.size() == 1 ? "" : "s"), tmp.c_str(), dir->lineNumber());
__spf_print(1, "template align:\n");
__spf_print(1, " align array%s '%s' from user dir in line %d\n", (realAlignArrayRefsSet.size() == 1 ? "" : "s"), tmp.c_str(), dir->lineNumber());
__spf_print(1, " template align:\n");
for (int i = 0; i < alignTemplate.size(); ++i)
__spf_print(1, "-- %d: %s -- [%d, %d]\n", i, alignTemplate[i].first.c_str(), alignTemplate[i].second.first, alignTemplate[i].second.second);
__spf_print(1, "template align with:\n");
__spf_print(1, " -- %d: %s -- [%d, %d]\n", i, alignTemplate[i].first.c_str(), alignTemplate[i].second.first, alignTemplate[i].second.second);
__spf_print(1, " template align with:\n");
for (int i = 0; i < alignWithTemplate.size(); ++i)
__spf_print(1, "-- %d: %s -- [%d, %d]\n", i, alignWithTemplate[i].first.c_str(), alignWithTemplate[i].second.first, alignWithTemplate[i].second.second);
__spf_print(1, " -- %d: %s -- [%d, %d]\n", i, alignWithTemplate[i].first.c_str(), alignWithTemplate[i].second.first, alignWithTemplate[i].second.second);
for (int i = 0; i < alignTemplate.size(); ++i)
{
@@ -891,6 +891,6 @@ void calculateLinesOfCode(vector<ParallelRegion*> &allRegions)
for (auto &lineV : line.second)
lineCounter += (lineV.lines.second - lineV.lines.first);
__spf_print(1, "Count of lines in region '%s' = %d\n", elem->GetName().c_str(), lineCounter);
__spf_print(1, " Count of lines in region '%s' = %d\n", elem->GetName().c_str(), lineCounter);
}
}

View File

@@ -1278,7 +1278,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
if (loop.second->hasLimitsToParallel())
{
loop.second->addConflictMessages(&SPF_messages[loop.second->fileName]);
__spf_print(1, "added conflict messages to loop on line %d\n", loop.second->lineNum);
__spf_print(1, " added conflict messages to loop on line %d\n", loop.second->lineNum);
}
}
}

View File

@@ -434,7 +434,7 @@ static map<string, vector<Messages>> removeCopies(map<string, vector<Messages>>
__spf_print(1, "%s\n", tmp.c_str());*/
uniq[key] = &message;
}
__spf_print(1, "messages filtering for file '%s': count before %d, count after %d\n", byFile.first.c_str(), byFile.second.size(), uniq.size());
__spf_print(1, " messages filtering for file '%s': count before %d, count after %d\n", byFile.first.c_str(), byFile.second.size(), uniq.size());
vector<Messages> uniqV;
for (auto& elem : uniq)
{

View File

@@ -1,3 +1,3 @@
#pragma once
#define VERSION_SPF "2384"
#define VERSION_SPF "2386"