finalyze first version of private arrays search
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include "SgUtils.h"
|
||||
#include "graph_loops.h"
|
||||
#include "CFGraph/CFGraph.h"
|
||||
#include "utils.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -136,11 +137,11 @@ unsigned long long CalculateLength(const AccessingSet& array)
|
||||
return result;
|
||||
}
|
||||
|
||||
void AddPrivateArraysToLoop(LoopGraph* loop, ArrayAccessingIndexes privates)
|
||||
void AddPrivateArraysToLoop(LoopGraph* loop, const ArrayAccessingIndexes& privates, set<SgStatement*>& insertedPrivates)
|
||||
{
|
||||
SgStatement* spfStat = new SgStatement(SPF_ANALYSIS_DIR);
|
||||
spfStat->setlineNumber(loop->lineNum);
|
||||
spfStat->setFileName((char*)loop->loop->fileName());
|
||||
spfStat->setlineNumber(loop->loop->lineNumber());
|
||||
spfStat->setFileName(loop->loop->fileName());
|
||||
SgExpression* toAdd = new SgExpression(EXPR_LIST, new SgExpression(ACC_PRIVATE_OP), NULL, NULL);
|
||||
set<SgSymbol*> arraysToInsert;
|
||||
for (const auto& [_, accessingSet] : privates)
|
||||
@@ -171,11 +172,15 @@ void AddPrivateArraysToLoop(LoopGraph* loop, ArrayAccessingIndexes privates)
|
||||
}
|
||||
toAdd->setLhs(new SgVarRefExp(elem));
|
||||
}
|
||||
|
||||
if (arraysToInsert.size() == 0)
|
||||
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||
|
||||
loop->loop->addAttribute(SPF_ANALYSIS_DIR, spfStat, sizeof(SgStatement));
|
||||
loop->loop->insertStmtBefore(*spfStat, *loop->loop->controlParent());
|
||||
insertedPrivates.insert(spfStat);
|
||||
}
|
||||
|
||||
map<LoopGraph*, ArrayAccessingIndexes> FindPrivateArrays(map<string, vector<LoopGraph*>> &loopGraph, map<FuncInfo*, vector<SAPFOR::BasicBlock*>>& FullIR)
|
||||
void FindPrivateArrays(map<string, vector<LoopGraph*>> &loopGraph, map<FuncInfo*, vector<SAPFOR::BasicBlock*>>& FullIR, set<SgStatement*> &insertedPrivates)
|
||||
{
|
||||
map<LoopGraph*, ArrayAccessingIndexes> result;
|
||||
for (const auto& [fileName, loops] : loopGraph)
|
||||
@@ -203,11 +208,9 @@ map<LoopGraph*, ArrayAccessingIndexes> FindPrivateArrays(map<string, vector<Loo
|
||||
delete(loopRegion);
|
||||
}
|
||||
}
|
||||
|
||||
if (result.find(loop) != result.end() && !result[loop].empty())
|
||||
{
|
||||
AddPrivateArraysToLoop(loop, result[loop]);
|
||||
}
|
||||
AddPrivateArraysToLoop(loop, result[loop], insertedPrivates);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user