add multifile support

This commit is contained in:
2025-10-30 06:04:02 +03:00
parent 47e2b961e2
commit 4981cad758
4 changed files with 28 additions and 9 deletions

View File

@@ -123,17 +123,31 @@ static void SolveDataFlow(Region* DFG)
map<LoopGraph*, ArrayAccessingIndexes> FindPrivateArrays(map<string, vector<LoopGraph*>> &loopGraph, map<FuncInfo*, vector<SAPFOR::BasicBlock*>>& FullIR)
{
map<LoopGraph*, ArrayAccessingIndexes> result;
for (const auto& [loopName, loops] : loopGraph)
map<LoopGraph*, ArrayAccessingIndexes> result;
for (const auto& [fileName, loops] : loopGraph)
{
SgFile::switchToFile(fileName);
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)
{
Region* loopRegion = new Region(loop, blocks);
SolveDataFlow(loopRegion);
result[loop] = loopRegion->array_priv;
delete(loopRegion);
if (funcInfo->fileName == fileName && funcInfo->funcPointer->GetOriginal() == search_func)
{
Region* loopRegion = new Region(loop, blocks);
if (loopRegion->getBasickBlocks().size() <= 1)
{
delete(loopRegion);
continue;
}
SolveDataFlow(loopRegion);
result[loop] = loopRegion->array_priv;
delete(loopRegion);
}
}
}
}

View File

@@ -10,10 +10,15 @@
#include "SgUtils.h"
#if __SPF
extern std::map<PTR_BFND, std::pair<std::string, int> > sgStats;
#endif
using namespace std;
static bool isParentStmt(SgStatement* stmt, SgStatement* parent)
{
// && sgStats.find(stmt->thebif) == sgStats.end()
for (; stmt; stmt = stmt->controlParent())
if (stmt == parent)
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)
countOfTransform += removeDeadCode(func->funcPointer, allFuncInfo, commonBlocks);
}
else if (curr_regime == FIND_PRIVATE_ARRAYS)
FindPrivateArrays(loopGraph, fullIR);
else if (curr_regime == 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)
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 elapsedGlobal = duration_cast<milliseconds>(high_resolution_clock::now() - globalTime).count() / 1000.;