From 8094fd57051edb080cfec6e925829c40f60b8cf9 Mon Sep 17 00:00:00 2001 From: rain2133 <1370973498@qq.com> Date: Tue, 19 Aug 2025 09:45:42 +0800 Subject: [PATCH] =?UTF-8?q?[midend]=E5=87=8F=E5=B0=91tmp=5Fcond=E7=9A=84?= =?UTF-8?q?=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/include/midend/IR.h | 1 + src/midend/IR.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/include/midend/IR.h b/src/include/midend/IR.h index 92539dc..9148edc 100644 --- a/src/include/midend/IR.h +++ b/src/include/midend/IR.h @@ -1007,6 +1007,7 @@ class PhiInst : public Instruction { void replaceIncomingBlock(BasicBlock *oldBlock, BasicBlock *newBlock, Value *newValue); void refreshMap() { blk2val.clear(); + vsize = getNumOperands() / 2; for (unsigned i = 0; i < vsize; ++i) { blk2val[getIncomingBlock(i)] = getIncomingValue(i); } diff --git a/src/midend/IR.cpp b/src/midend/IR.cpp index d35e16b..5ed1777 100644 --- a/src/midend/IR.cpp +++ b/src/midend/IR.cpp @@ -757,7 +757,7 @@ void BinaryInst::print(std::ostream &os) const { auto lhs_hash = std::hash{}(static_cast(getLhs())); auto rhs_hash = std::hash{}(static_cast(getRhs())); size_t combined_hash = inst_hash ^ (lhs_hash << 1) ^ (rhs_hash << 2); - std::string tmpName = "tmp_icmp_" + std::to_string(combined_hash % 1000000); + std::string tmpName = "tmp_icmp_" + std::to_string(combined_hash % 1000000007); os << "%" << tmpName << " = " << getKindString() << " " << *getLhs()->getType() << " "; printOperand(os, getLhs()); os << ", "; @@ -772,7 +772,7 @@ void BinaryInst::print(std::ostream &os) const { auto lhs_hash = std::hash{}(static_cast(getLhs())); auto rhs_hash = std::hash{}(static_cast(getRhs())); size_t combined_hash = inst_hash ^ (lhs_hash << 1) ^ (rhs_hash << 2); - std::string tmpName = "tmp_fcmp_" + std::to_string(combined_hash % 1000000); + std::string tmpName = "tmp_fcmp_" + std::to_string(combined_hash % 1000000007); os << "%" << tmpName << " = " << getKindString() << " " << *getLhs()->getType() << " "; printOperand(os, getLhs()); os << ", "; @@ -834,7 +834,7 @@ void CondBrInst::print(std::ostream &os) const { if (condName.empty()) { // 使用条件值地址的哈希值作为唯一标识 auto ptr_hash = std::hash{}(static_cast(condition)); - condName = "const_" + std::to_string(ptr_hash % 100000); + condName = "const_" + std::to_string(ptr_hash % 1000000007); } // 组合指令地址、条件地址和目标块地址的哈希来确保唯一性 @@ -843,7 +843,7 @@ void CondBrInst::print(std::ostream &os) const { auto then_hash = std::hash{}(static_cast(getThenBlock())); auto else_hash = std::hash{}(static_cast(getElseBlock())); size_t combined_hash = inst_hash ^ (cond_hash << 1) ^ (then_hash << 2) ^ (else_hash << 3); - std::string uniqueSuffix = std::to_string(combined_hash % 1000000); + std::string uniqueSuffix = std::to_string(combined_hash % 1000000007); os << "%tmp_cond_" << condName << "_" << uniqueSuffix << " = icmp ne i32 "; printOperand(os, condition);