fixed module symbol analysis

This commit is contained in:
ALEXks
2025-02-10 13:13:01 +03:00
parent 1504504d96
commit f135cd6d06
2 changed files with 46 additions and 7 deletions

View File

@@ -167,11 +167,11 @@ void DvmhRegionInserter::updateParallelFunctions(const map<string, vector<LoopGr
} }
static void findByUse(map<string, vector<pair<SgSymbol*, SgSymbol*>>> &modByUse, const string& varName, static void findByUse(map<string, vector<pair<SgSymbol*, SgSymbol*>>> &modByUse, const string& varName,
const string& locName, vector<string> &altNames) const set<string>& locNames, vector<string> &altNames)
{ {
for (auto& elem : modByUse) for (auto& elem : modByUse)
{ {
if (elem.first == locName) if (locNames.count(elem.first))
{ {
for (auto& byUse : elem.second) for (auto& byUse : elem.second)
{ {
@@ -217,6 +217,8 @@ static string getNameByUse(SgStatement *place, const string &varName, const stri
return varName; return varName;
else else
{ {
map<string, set<string>> graphUse;
set<string> useMod; set<string> useMod;
map<string, vector<pair<SgSymbol*, SgSymbol*>>> modByUse; map<string, vector<pair<SgSymbol*, SgSymbol*>>> modByUse;
map<string, vector<pair<SgSymbol*, SgSymbol*>>> modByUseOnly; map<string, vector<pair<SgSymbol*, SgSymbol*>>> modByUseOnly;
@@ -241,12 +243,22 @@ static string getNameByUse(SgStatement *place, const string &varName, const stri
if (useModDone.find(useM) == useModDone.end()) if (useModDone.find(useM) == useModDone.end())
{ {
auto modSt = findModWithName(modules, useM); auto modSt = findModWithName(modules, useM);
if (modSt == NULL && useM == "dvmh_template_mod") if (modSt == NULL || useM == "dvmh_template_mod")
continue; continue;
checkNull(modSt, convertFileName(__FILE__).c_str(), __LINE__); checkNull(modSt, convertFileName(__FILE__).c_str(), __LINE__);
fillInfo(modSt, newUseMod, modByUse, modByUseOnly);
set<string> tmpUse;
fillInfo(modSt, tmpUse, modByUse, modByUseOnly);
useModDone.insert(useM); useModDone.insert(useM);
for (auto& use : tmpUse)
{
newUseMod.insert(use);
if (use != "dvmh_template_mod")
graphUse[use].insert(useM);
}
} }
} }
@@ -261,9 +273,36 @@ static string getNameByUse(SgStatement *place, const string &varName, const stri
} }
vector<string> altNames; vector<string> altNames;
findByUse(modByUse, varName, locName, altNames); findByUse(modByUse, varName, { locName }, altNames);
findByUse(modByUseOnly, varName, locName, altNames); findByUse(modByUseOnly, varName, { locName }, altNames);
if (altNames.size() == 0)
{
set<string> locations = { locName };
bool changed = true;
while (changed)
{
changed = false;
for (auto& loc : locations)
{
if (graphUse.find(loc) != graphUse.end())
{
for (auto& use : graphUse[loc])
{
if (locations.find(use) == locations.end())
{
locations.insert(use);
changed = true;
}
}
}
}
}
findByUse(modByUse, varName, locations, altNames);
findByUse(modByUseOnly, varName, locations, altNames);
}
if (altNames.size() == 0) if (altNames.size() == 0)
return varName; return varName;
else if (altNames.size() >= 1) else if (altNames.size() >= 1)

View File

@@ -1,3 +1,3 @@
#pragma once #pragma once
#define VERSION_SPF "2387" #define VERSION_SPF "2388"