[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

@@ -530,8 +530,14 @@ Function * Function::clone(const std::string &suffix) const {
}
}
for (const auto &param : blocks.front()->getArguments()) {
newFunction->getEntryBlock()->insertArgument(dynamic_cast<AllocaInst *>(oldNewValueMap.at(param)));
// for (const auto &param : blocks.front()->getArguments()) {
// newFunction->getEntryBlock()->insertArgument(dynamic_cast<AllocaInst *>(oldNewValueMap.at(param)));
// }
for (const auto &arg : arguments) {
auto newArg = dynamic_cast<Argument *>(oldNewValueMap.at(arg));
if (newArg != nullptr) {
newFunction->insertArgument(newArg);
}
}
return newFunction;