dead code: fix for entry statements, improve perfomance

This commit is contained in:
2024-04-10 18:58:46 +03:00
parent 494a705930
commit ff2a1c69d8
2 changed files with 8 additions and 3 deletions

View File

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

View File

@@ -228,7 +228,9 @@ public:
updated |= updateNextNotEmpty(); updated |= updateNextNotEmpty();
updated |= updateJumpStatus(); updated |= updateJumpStatus();
updated |= this->forwardData({ });
if(updated)
this->forwardData({ });
return updated; return updated;
} }
@@ -316,6 +318,7 @@ public:
{ {
setBlock(block); setBlock(block);
useful.resize(block->getInstructions().size(), false); useful.resize(block->getInstructions().size(), false);
this->forwardData({ });
} }
const vector<bool>& getResult() { return useful; } const vector<bool>& getResult() { return useful; }
@@ -371,7 +374,8 @@ void removeDeadCode(SgStatement* func,
set<SAPFOR::BasicBlock*> reachable; set<SAPFOR::BasicBlock*> reachable;
for (auto b : cfg_pair.second) for (auto b : cfg_pair.second)
if(b->getInstructions().front()->isHeader()) if(b->getInstructions().front()->isHeader() ||
b->getInstructions().front()->getInstruction()->getOperation() == SAPFOR::CFG_OP::ENTRY)
reachable.insert(b); reachable.insert(b);
set<SAPFOR::BasicBlock*> worklist = reachable; set<SAPFOR::BasicBlock*> worklist = reachable;