improved and fixed transformAssumedSizeParameters function

This commit is contained in:
ALEXks
2026-04-14 11:47:59 +03:00
parent fb3ac921cc
commit e733d3d68a
2 changed files with 62 additions and 6 deletions

View File

@@ -234,9 +234,8 @@ static bool hasDvmParallel(SgStatement *func)
return false; return false;
} }
void transformAssumedSizeParameters(const map<string, vector<FuncInfo*>>& allFuncInfo) static map<FuncInfo*, bool> createDvmParallelInfo(const map<string, vector<FuncInfo*>>& allFuncInfo) {
{ map<FuncInfo*, bool> hasDvmParallelMap;
map<string, vector<int>> assumedSizeArraysByFunc;
for (auto& funcByFile : allFuncInfo) for (auto& funcByFile : allFuncInfo)
{ {
@@ -249,7 +248,63 @@ void transformAssumedSizeParameters(const map<string, vector<FuncInfo*>>& allFun
if (prog == NULL) if (prog == NULL)
continue; continue;
if (!hasDvmParallel(prog)) hasDvmParallelMap[func] = hasDvmParallel(prog);
}
}
bool changed = true;
while (changed)
{
changed = false;
for (auto& funcByFile : allFuncInfo)
{
for (auto& func : funcByFile.second)
{
if (!hasDvmParallelMap[func])
{
bool hasParallel = false;
for (auto& callF : func->callsFromV)
{
if (hasDvmParallelMap[callF])
{
hasParallel = true;
break;
}
}
if (hasParallel)
{
changed = true;
hasDvmParallelMap[func] = true;
}
}
}
}
}
return hasDvmParallelMap;
}
void transformAssumedSizeParameters(const map<string, vector<FuncInfo*>>& allFuncInfo)
{
map<string, vector<int>> assumedSizeArraysByFunc;
const map<FuncInfo*, bool> hasDvmParallelMap = createDvmParallelInfo(allFuncInfo);
for (auto& funcByFile : allFuncInfo)
{
if (SgFile::switchToFile(funcByFile.first) == -1)
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
for (auto& func : funcByFile.second)
{
SgProgHedrStmt* prog = isSgProgHedrStmt(func->funcPointer->GetOriginal());
if (prog == NULL)
continue;
if (!hasDvmParallelMap.at(func))
continue; continue;
vector<SgSymbol*> parNames; vector<SgSymbol*> parNames;
@@ -259,7 +314,8 @@ void transformAssumedSizeParameters(const map<string, vector<FuncInfo*>>& allFun
bool hasRefs = false; bool hasRefs = false;
for (int z = 0; z < func->funcParams.countOfPars; ++z) for (int z = 0; z < func->funcParams.countOfPars; ++z)
{ {
if (func->funcParams.parametersT[z] == ARRAY_T) if (func->funcParams.parametersT[z] == ARRAY_T ||
func->funcParams.parametersT[z] == STRING_ARRAY_T)
{ {
auto s = prog->parameter(z); auto s = prog->parameter(z);
const string name = s->identifier(); const string name = s->identifier();

View File

@@ -1,3 +1,3 @@
#pragma once #pragma once
#define VERSION_SPF "2476" #define VERSION_SPF "2477"