fixed functions purifying

This commit is contained in:
ALEXks
2023-11-15 13:20:28 +03:00
parent 768a280f09
commit b8da3d5eb1
5 changed files with 28 additions and 10 deletions

View File

@@ -1129,9 +1129,6 @@ void DvmhRegionInserter::createInterfaceBlockForOutCalls(FuncInfo* func)
if (func->interfaceBlocks.find(callFrom->funcName) == func->interfaceBlocks.end()
&& isPure(callFrom->funcPointer->GetOriginal()))
{
if (callFrom->fileName != func->fileName)
insertRoutine(func->funcPointer->GetOriginal());
func->interfaceBlocks[callFrom->funcName] = callFrom;
insertInterface(func->funcPointer, getInterfaceBlock(callFrom->funcPointer->GetOriginal(), callFrom->funcParams), callFrom->funcName);
}

View File

@@ -2137,6 +2137,16 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
regionInserter->addUsedWriteArrays(usedWriteArraysInRegions);
setPureStatus(regionInserter->getParallelFunctions());
}
for (int i = n - 1, k = 0; i >= 0; --i, ++k)
{
SgFile* file = &(project.file(i));
DvmhRegionInserter* regionInserter = inserters[k];
for (auto& func : regionInserter->getParallelFunctions())
createInterfacesForOutCalls(func);
// create interface for 'parallel' functions and
// insert ROUTINE directive if needed

View File

@@ -39,6 +39,15 @@ bool checkOutCalls(const set<string>& outCalls)
return false;
}
void createInterfacesForOutCalls(FuncInfo* func) {
if (func->isPure && !func->isMain)
{
bool hasOutCalls = checkOutCalls(func->callsFrom);
if (hasOutCalls)
DvmhRegionInserter::createInterfaceBlockForOutCalls(func);
}
}
static void setPureStatus(FuncInfo* func)
{
if (func->isPure && !func->isMain)
@@ -52,13 +61,10 @@ static void setPureStatus(FuncInfo* func)
for (int z = 0; z < func->funcParams.countOfPars; ++z)
hasOut |= func->funcParams.isArgOut(z);
bool hasPure = (header->expr(2) != NULL) || ((header->symbol()->attributes() & PURE_BIT) != 0);
bool hasOutCalls = checkOutCalls(func->callsFrom);
bool hasIO = func->linesOfIO.size() || func->linesOfStop.size();
//TODO: with hasOutCalls
if (!hasPure && !hasIO && !hasOutCalls && ((isFunc == false) || (isFunc && hasOut == false)))
if (!hasPure && !hasIO && ((isFunc == false) || (isFunc && hasOut == false)))
{
DvmhRegionInserter::createInterfaceBlockForOutCalls(func);
header->setExpression(2, new SgExpression(PURE_OP));
header->symbol()->setAttribute(header->symbol()->attributes() | PURE_BIT);
}
@@ -76,6 +82,10 @@ void setPureStatus(const map<string, vector<FuncInfo*>>& allFuncInfo)
for (auto& funcByFile : allFuncInfo)
for (auto& func : funcByFile.second)
setPureStatus(func);
for (auto& funcByFile : allFuncInfo)
for (auto& func : funcByFile.second)
createInterfacesForOutCalls(func);
}
map<SgStatement*, set<string>> fillFromIntent(SgStatement* header)

View File

@@ -4,6 +4,7 @@ bool checkOutCalls(const std::set<std::string>& outCalls);
std::map<SgStatement*, std::set<std::string>> fillFromIntent(SgStatement* header);
void intentInsert(const std::vector<FuncInfo*>& allFuncInfo);
void intentInsertToInterfaces(const std::map<std::string, std::vector<FuncInfo*>>& allFuncInfo);
void createInterfacesForOutCalls(FuncInfo* func);
void setPureStatus(const std::set<FuncInfo*>& funcInfo);
void setPureStatus(const std::map<std::string, std::vector<FuncInfo*>>& allFuncInfo);

View File

@@ -1,3 +1,3 @@
#pragma once
#define VERSION_SPF "2237"
#define VERSION_SPF "2238"