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,6 +1028,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);
}
else if (curr_regime == TEST_PASS)

View File

@@ -228,7 +228,9 @@ public:
updated |= updateNextNotEmpty();
updated |= updateJumpStatus();
updated |= this->forwardData({ });
if(updated)
this->forwardData({ });
return updated;
}
@@ -316,6 +318,7 @@ public:
{
setBlock(block);
useful.resize(block->getInstructions().size(), false);
this->forwardData({ });
}
const vector<bool>& getResult() { return useful; }
@@ -371,7 +374,8 @@ void removeDeadCode(SgStatement* func,
set<SAPFOR::BasicBlock*> reachable;
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);
set<SAPFOR::BasicBlock*> worklist = reachable;