[backend]修复寄存器分配算法死循环bug,89通过

This commit is contained in:
2025-08-04 16:04:35 +08:00
parent 208d5528b5
commit 7e5f6800b7
3 changed files with 73 additions and 15 deletions

View File

@@ -1,4 +1,5 @@
#include "RISCv64ISel.h"
#include "IR.h" // For GlobalValue
#include <stdexcept>
#include <set>
#include <functional>
@@ -209,8 +210,12 @@ void RISCv64ISel::selectNode(DAGNode* node) {
case DAGNode::CONSTANT:
case DAGNode::ALLOCA_ADDR:
if (node->value) {
// 确保它有一个关联的虚拟寄存器即可,不生成代码。
getVReg(node->value);
// GlobalValue objects (global variables) should not get virtual registers
// since they represent memory addresses, not register-allocated values
if (dynamic_cast<GlobalValue*>(node->value) == nullptr) {
// 确保它有一个关联的虚拟寄存器即可,不生成代码。
getVReg(node->value);
}
}
break;