add multifile support

This commit is contained in:
2025-10-30 06:04:02 +03:00
parent b95b336372
commit 21b5340e98
4 changed files with 23 additions and 8 deletions

View File

@@ -124,16 +124,30 @@ static void SolveDataFlow(Region* DFG)
map<LoopGraph*, ArrayAccessingIndexes> FindPrivateArrays(map<string, vector<LoopGraph*>> &loopGraph, map<FuncInfo*, vector<SAPFOR::BasicBlock*>>& FullIR) map<LoopGraph*, ArrayAccessingIndexes> FindPrivateArrays(map<string, vector<LoopGraph*>> &loopGraph, map<FuncInfo*, vector<SAPFOR::BasicBlock*>>& FullIR)
{ {
map<LoopGraph*, ArrayAccessingIndexes> result; map<LoopGraph*, ArrayAccessingIndexes> result;
for (const auto& [loopName, loops] : loopGraph) for (const auto& [fileName, loops] : loopGraph)
{ {
SgFile::switchToFile(fileName);
for (const auto& loop : loops) for (const auto& loop : loops)
{ {
SgStatement* search_func = loop->loop->GetOriginal();
while (search_func && (!isSgProgHedrStmt(search_func)))
search_func = search_func->controlParent();
for (const auto& [funcInfo, blocks]: FullIR) for (const auto& [funcInfo, blocks]: FullIR)
{ {
Region* loopRegion = new Region(loop, blocks); if (funcInfo->fileName == fileName && funcInfo->funcPointer->GetOriginal() == search_func)
SolveDataFlow(loopRegion); {
result[loop] = loopRegion->array_priv; Region* loopRegion = new Region(loop, blocks);
delete(loopRegion); if (loopRegion->getBasickBlocks().size() <= 1)
{
delete(loopRegion);
continue;
}
SolveDataFlow(loopRegion);
result[loop] = loopRegion->array_priv;
delete(loopRegion);
}
} }
} }
} }

View File

@@ -14,6 +14,7 @@ using namespace std;
static bool isParentStmt(SgStatement* stmt, SgStatement* parent) static bool isParentStmt(SgStatement* stmt, SgStatement* parent)
{ {
// && sgStats.find(stmt->thebif) == sgStats.end()
for (; stmt; stmt = stmt->controlParent()) for (; stmt; stmt = stmt->controlParent())
if (stmt == parent) if (stmt == parent)
return true; return true;

View File

@@ -1019,8 +1019,6 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
if(func->funcPointer->variant() != ENTRY_STAT) if(func->funcPointer->variant() != ENTRY_STAT)
countOfTransform += removeDeadCode(func->funcPointer, allFuncInfo, commonBlocks); countOfTransform += removeDeadCode(func->funcPointer, allFuncInfo, commonBlocks);
} }
else if (curr_regime == FIND_PRIVATE_ARRAYS)
FindPrivateArrays(loopGraph, fullIR);
else if (curr_regime == TEST_PASS) else if (curr_regime == TEST_PASS)
{ {
//test pass //test pass
@@ -1916,6 +1914,8 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
} }
else if (curr_regime == TRANSFORM_ASSUMED_SIZE_PARAMETERS) else if (curr_regime == TRANSFORM_ASSUMED_SIZE_PARAMETERS)
transformAssumedSizeParameters(allFuncInfo); transformAssumedSizeParameters(allFuncInfo);
else if (curr_regime == FIND_PRIVATE_ARRAYS)
auto result = FindPrivateArrays(loopGraph, fullIR);
const float elapsed = duration_cast<milliseconds>(high_resolution_clock::now() - timeForPass).count() / 1000.; const float elapsed = duration_cast<milliseconds>(high_resolution_clock::now() - timeForPass).count() / 1000.;
const float elapsedGlobal = duration_cast<milliseconds>(high_resolution_clock::now() - globalTime).count() / 1000.; const float elapsedGlobal = duration_cast<milliseconds>(high_resolution_clock::now() - globalTime).count() / 1000.;