fixed inliner

This commit is contained in:
ALEXks
2023-11-05 18:20:31 +03:00
parent 90fb0bf6b9
commit dfb5d4796b
6 changed files with 47 additions and 10 deletions

View File

@@ -1344,7 +1344,7 @@ static bool matchCallAndDefinition(const FuncParam &funcParDef, const FuncParam&
messages[file].push_back(Messages(NOTE, line, bufR, bufE, 1013));
__spf_print(1, "Function '%s': different type of call and def parameter %d\n", funcName.c_str(), i + 1);
}
result = false;
//result = false;
}
}
else //TODO

View File

@@ -211,6 +211,40 @@ static inline SgSymbol* createSymbAndDecl(const string& funcName, const string&
return newS;
}
static SgStatement* findDuplicateInHidden(SgStatement* data)
{
SgStatement* clone = NULL;
auto itF = hiddenData.find(current_file->filename());
if (itF == hiddenData.end())
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
for (auto& func : itF->second)
{
if (func->fileName() != string(data->fileName()))
continue;
SgStatement* st = func->lexNext();
SgStatement* last = func->lastNodeOfStmt();
while (st != last)
{
if (data->lineNumber() == st->lineNumber() && data->variant() == st->variant())
{
clone = st;
break;
}
st = st->lexNext();
}
if (clone)
break;
}
checkNull(clone, convertFileName(__FILE__).c_str(), __LINE__);
return clone;
}
static SgValueExp* oneExpr = NULL;
static SgValueExp* zeroExpr = NULL;
@@ -237,11 +271,14 @@ static vector<SgExpression*> getLowBounds(SgSymbol* arrayS)
int consistInAllocates = 0;
const string origName = OriginalSymbol(copyFrom)->identifier();
for (auto& data : getAttributes<SgStatement*, SgStatement*>(decl, set<int>{ ALLOCATE_STMT }))
for (auto data : getAttributes<SgStatement*, SgStatement*>(decl, set<int>{ ALLOCATE_STMT }))
{
if (data->variant() != ALLOCATE_STMT)
continue;
if (data->getFileId() != current_file_id)
data = findDuplicateInHidden(data);
SgExpression* iter = data->expr(0);
while (iter)

View File

@@ -4218,7 +4218,7 @@ SgProject* createProject(const char* proj_name,
for (int z = 0; z < project->numberOfFiles(); ++z)
removeExecutableFromModuleDeclaration(&(project->file(z)), filesInProj);
removeExecutableFromModuleDeclaration(&(project->file(z)), filesInProj, hiddenData[project->file(z).filename()]);
for (int z = 0; z < project->numberOfFiles(); ++z)
{

View File

@@ -1,3 +1,3 @@
#pragma once
#define VERSION_SPF "2232"
#define VERSION_SPF "2234"

View File

@@ -1153,7 +1153,7 @@ void replaceStructuresToSimpleTypes(SgFile *file)
}
}
void removeExecutableFromModuleDeclaration(SgFile *current, const set<string> &filesInProj)
void removeExecutableFromModuleDeclaration(SgFile *current, const set<string> &filesInProj, vector<SgStatement*>& hiddenData)
{
const string currF = current->filename();
set<string> moduleInFile;
@@ -1164,14 +1164,14 @@ void removeExecutableFromModuleDeclaration(SgFile *current, const set<string> &f
moduleInFile.insert(st->fileName());
}
vector<SgStatement*> toDel;
vector<SgStatement*> toMove;
for (SgStatement* st = current->firstStatement(); st; st = st->lexNext())
{
if (isSgProgHedrStmt(st))
if (moduleInFile.find(st->fileName()) != moduleInFile.end())
toDel.push_back(st);
toMove.push_back(st);
}
for (auto& elem : toDel)
elem->deleteStmt();
for (auto& elem : toMove)
hiddenData.push_back(elem->extractStmt());
}

View File

@@ -49,7 +49,7 @@ void replaceDerivedAssigns(SgFile *file, SgStatement *stToCopy, SgStatement *ins
bool isDerivedAssign(SgStatement *st);
std::map<std::string, SgStatement*> createDerivedTypeDeclMap(SgStatement *forS);
void fillUseStatement(SgStatement* st, std::set<std::string>& useMod, std::map<std::string, std::vector<std::pair<SgSymbol*, SgSymbol*>>>& modByUse, std::map<std::string, std::vector<std::pair<SgSymbol*, SgSymbol*>>>& modByUseOnly);
void removeExecutableFromModuleDeclaration(SgFile* current, const std::set<std::string>& filesInProj);
void removeExecutableFromModuleDeclaration(SgFile* current, const std::set<std::string>& filesInProj, std::vector<SgStatement*>& hiddenData);
bool needToReplaceInterfaceName(SgStatement* interf);
std::string getOrigName(const std::string& file, const std::string& s);