[backend]修复了溢出位置错误的问题

This commit is contained in:
Lixuanwang
2025-08-03 23:28:38 +08:00
parent e4ad23a1a5
commit c8a8bf9a37

View File

@ -656,7 +656,7 @@ void RISCv64RegAlloc::rewriteProgram() {
StackFrameInfo& frame_info = MFunc->getFrameInfo();
// 使用 EFI Pass 确定的 locals_end_offset 作为溢出分配的基准。
// locals_end_offset 本身是负数,代表局部变量区域的下边界地址。
int spill_current_offset = frame_info.locals_end_offset;
int spill_current_offset = frame_info.locals_end_offset - frame_info.spill_size;
// 保存溢出区域的起始点,用于最后计算总的 spill_size
const int spill_start_offset = frame_info.locals_end_offset;
@ -787,6 +787,11 @@ void RISCv64RegAlloc::rewriteProgram() {
std::make_unique<ImmOperand>(frame_info.spill_offsets.at(old_vreg))
));
new_instructions.push_back(std::move(store));
if (DEEPERDEBUG) {
std::cerr << "[Spill] Inserted spill store for %vreg" << old_vreg
<< " at offset " << frame_info.spill_offsets.at(old_vreg)
<< " with new temp vreg " << regIdToString(new_temp_vreg) << ".\n";
}
}
}
mbb->getInstructions() = std::move(new_instructions);