[midend]部分DCE遍实现(传播活跃代码),修改优化遍运行逻辑,TODO:完善优化遍的getAnalysisUsage,删除无用代码

This commit is contained in:
rain2133
2025-07-24 14:36:33 +08:00
parent f4d231b989
commit 4b9d067c12
10 changed files with 175 additions and 781 deletions

View File

@@ -167,14 +167,14 @@ bool SysYCFGOptUtils::SysYDelNoPreBLock(Function *func) {
// 删除不可达基本块指令
for (auto blockIter = func->getBasicBlocks().begin(); blockIter != func->getBasicBlocks().end(); blockIter++) {
if (!blockIter->get()->getreachable()) {
for (auto instIter = blockIter->get()->getInstructions().begin();
instIter != blockIter->get()->getInstructions().end();) {
SysYIROptUtils::usedelete(instIter->get());
instIter = blockIter->get()->getInstructions().erase(instIter);
if (!blockIter->get()->getreachable()) {
for (auto instIter = blockIter->get()->getInstructions().begin();
instIter != blockIter->get()->getInstructions().end();) {
SysYIROptUtils::usedelete(instIter->get());
instIter = blockIter->get()->getInstructions().erase(instIter);
}
}
}
}
for (auto blockIter = func->getBasicBlocks().begin(); blockIter != func->getBasicBlocks().end();) {