This commit is contained in:
ALEXks
2024-04-12 15:25:48 +03:00
parent 5b1e18cdfd
commit 18f58020f5
3 changed files with 12 additions and 35 deletions

View File

@@ -1029,7 +1029,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne
auto funcsForFile = getObjectForFileFromMap(file_name, allFuncInfo);
for (auto& func : funcsForFile)
if(func->funcPointer->variant() != ENTRY_STAT)
removeDeadCode(func->funcPointer, allFuncInfo, commonBlocks);
countOfTransform += removeDeadCode(func->funcPointer, allFuncInfo, commonBlocks);
}
else if (curr_regime == TEST_PASS)
{

View File

@@ -472,34 +472,21 @@ int removeDeadCode(SgStatement* func,
READ_STAT
};
static const set<int> skip =
{
PROG_HEDR,
PROC_HEDR,
FUNC_HEDR
};
vector<SgStatement*> remove;
SgStatement* start = intervalDelStart ? intervalDelStart : func;
SgStatement* end = intervalDelEnd ? intervalDelEnd : func->lastNodeOfStmt();
auto st = start;
if (skip.find(st->variant()) != skip.end())
st = st->lexNext();
for (; st != end; st = st->lexNext())
for (auto st = start; st != end; st = st->lexNext())
{
if (skip.find(st->variant()) != skip.end())
{
st = st->lastNodeOfStmt();
continue;
}
if (removable.find(st->variant()) != removable.end() && useful.find(st) == useful.end())
const int var = st->variant();
if (removable.find(var) != removable.end() && useful.find(st) == useful.end())
{
remove.push_back(st);
st = st->lastNodeOfStmt();
}
if (var == CONTAINS_STMT)
break;
}
for (auto& rem : remove)
@@ -513,21 +500,9 @@ int removeDeadCode(SgStatement* func,
do
{
remove.clear();
st = start;
if (skip.find(st->variant()) != skip.end())
st = st->lexNext();
for (; st != end; st = st->lexNext())
for (auto st = start; st != end; st = st->lexNext())
{
const int var = st->variant();
if (skip.find(var) != skip.end())
{
st = st->lastNodeOfStmt();
continue;
}
if ((var == FOR_NODE || var == WHILE_NODE || var == SWITCH_NODE) &&
st->lexNext()->variant() == CONTROL_END)
{
@@ -550,6 +525,9 @@ int removeDeadCode(SgStatement* func,
}
//TODO: SWITCH and other block statements
if (var == CONTAINS_STMT)
break;
}
@@ -562,6 +540,5 @@ int removeDeadCode(SgStatement* func,
} while (remove.size());
deleteCFG(cfg);
return countOfTransform;
}

View File

@@ -1,3 +1,3 @@
#pragma once
#define VERSION_SPF "2314"
#define VERSION_SPF "2315"