Merge branch 'backend' of gitee.com:lixuanwang/mysysy into backend

This commit is contained in:
Lixuanwang
2025-08-04 16:34:22 +08:00
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>
@@ -182,8 +183,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;