[midend][backend]修复了全局常量数组的访问错误

This commit is contained in:
Lixuanwang
2025-07-30 18:23:56 +08:00
parent 38bee5d5ac
commit 48b0aec6c3
2 changed files with 40 additions and 13 deletions

View File

@@ -862,6 +862,11 @@ void RISCv64ISel::selectNode(DAGNode* node) {
la_instr->addOperand(std::make_unique<RegOperand>(current_addr_vreg));
la_instr->addOperand(std::make_unique<LabelOperand>(global_base->getName()));
CurMBB->addInstruction(std::move(la_instr));
} else if (auto const_global_base = dynamic_cast<ConstantVariable*>(base_ptr_node->value)) {
auto la_instr = std::make_unique<MachineInstr>(RVOpcodes::LA);
la_instr->addOperand(std::make_unique<RegOperand>(current_addr_vreg));
la_instr->addOperand(std::make_unique<LabelOperand>(const_global_base->getName()));
CurMBB->addInstruction(std::move(la_instr));
} else {
auto base_vreg = getVReg(base_ptr_node->value);
auto mv = std::make_unique<MachineInstr>(RVOpcodes::MV);