[midend-mem2reg]修改函数参数定义引入argument类,显示为参数创建alloca和store指令

This commit is contained in:
rain2133
2025-07-26 12:30:03 +08:00
parent 04c5c6b44d
commit 2643eb1edd
5 changed files with 73 additions and 36 deletions

View File

@@ -85,7 +85,7 @@ bool SysYCFGOptUtils::SysYBlockMerge(Function *func) {
// std::cout << "merge block: " << blockiter->get()->getName() << std::endl;
BasicBlock* block = blockiter->get();
BasicBlock* nextBlock = blockiter->get()->getSuccessors()[0];
auto nextarguments = nextBlock->getArguments();
// auto nextarguments = nextBlock->getArguments();
// 删除br指令
if (block->getNumInstructions() != 0) {
auto thelastinstinst = block->end();
@@ -108,12 +108,6 @@ bool SysYCFGOptUtils::SysYBlockMerge(Function *func) {
block->getInstructions().emplace_back(institer->release());
institer = nextBlock->getInstructions().erase(institer);
}
// 合并参数
// TODO是否需要去重?
for (auto &argm : nextarguments) {
argm->setParent(block);
block->insertArgument(argm);
}
// 更新前驱后继关系,类似树节点操作
block->removeSuccessor(nextBlock);
nextBlock->removePredecessor(block);