REMOVE_DIST_ARRAYS_FROM_IO: find current FuncInfo properly

This commit is contained in:
2026-04-12 15:32:09 +03:00
parent b71df882fb
commit db5062c416

View File

@@ -541,6 +541,18 @@ static bool ioRegionBorder(SgStatement* stat, SgStatement* last_io_bound)
return false;
}
FuncInfo* getCurrentFuncInfo(const vector<FuncInfo*>& fileFuncInfo, int line)
{
for (auto* func : fileFuncInfo)
{
if (func->linesNum.first <= line && line <= func->linesNum.second)
return func;
}
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
return NULL;
}
void replaceDistributedArraysInIO(vector<ParallelRegion*>& regions,
const map<string, vector<FuncInfo*>>& allFuncInfo,
map<string, vector<Messages>>& SPF_messages,
@@ -560,6 +572,8 @@ void replaceDistributedArraysInIO(vector<ParallelRegion*>& regions,
if (SgFile::switchToFile(current_file_name) == -1)
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
FuncInfo *current_func_info = NULL;
auto func_info_it = allFuncInfo.find(current_file_name);
if (func_info_it == allFuncInfo.end())
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
@@ -586,13 +600,12 @@ void replaceDistributedArraysInIO(vector<ParallelRegion*>& regions,
{
curr_stmt = lines.stats.first->GetOriginal();
end = lines.stats.second->GetOriginal()->lexNext();
current_func_info = getCurrentFuncInfo(func_info_it->second, curr_stmt->lineNumber());
}
map<SgSymbol*, set<SgStatement*>> need_replace;
SgStatement* last_io_bound = NULL;
FuncInfo *current_func_info = NULL;
while (curr_stmt != end)
{
if (!curr_stmt)
@@ -600,21 +613,9 @@ void replaceDistributedArraysInIO(vector<ParallelRegion*>& regions,
auto var = curr_stmt->variant();
// TODO: does not work with user regions
if (var == PROC_HEDR || var == PROG_HEDR || var == FUNC_HEDR)
{
current_func_info = NULL;
for (auto *func_info : func_info_it->second)
{
if (func_info->funcName == curr_stmt->symbol()->identifier())
{
current_func_info = func_info;
break;
}
}
if (!current_func_info)
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
current_func_info = getCurrentFuncInfo(func_info_it->second, curr_stmt->lineNumber());
curr_stmt = curr_stmt->lexNext();
while (curr_stmt && !isSgExecutableStatement(curr_stmt))