deploy-20250820-3 #1
@@ -752,8 +752,12 @@ void BinaryInst::print(std::ostream &os) const {
|
||||
if (kind == kICmpEQ || kind == kICmpNE || kind == kICmpLT ||
|
||||
kind == kICmpGT || kind == kICmpLE || kind == kICmpGE) {
|
||||
// 整数比较指令 - 生成临时i1结果然后转换为i32
|
||||
static int tmpCmpCounter = 0;
|
||||
std::string tmpName = "tmp_icmp_" + std::to_string(++tmpCmpCounter);
|
||||
// 使用指令地址和操作数地址的组合哈希来确保唯一性
|
||||
auto inst_hash = std::hash<const void*>{}(static_cast<const void*>(this));
|
||||
auto lhs_hash = std::hash<const void*>{}(static_cast<const void*>(getLhs()));
|
||||
auto rhs_hash = std::hash<const void*>{}(static_cast<const void*>(getRhs()));
|
||||
size_t combined_hash = inst_hash ^ (lhs_hash << 1) ^ (rhs_hash << 2);
|
||||
std::string tmpName = "tmp_icmp_" + std::to_string(combined_hash % 1000000);
|
||||
os << "%" << tmpName << " = " << getKindString() << " " << *getLhs()->getType() << " ";
|
||||
printOperand(os, getLhs());
|
||||
os << ", ";
|
||||
@@ -763,8 +767,12 @@ void BinaryInst::print(std::ostream &os) const {
|
||||
} else if (kind == kFCmpEQ || kind == kFCmpNE || kind == kFCmpLT ||
|
||||
kind == kFCmpGT || kind == kFCmpLE || kind == kFCmpGE) {
|
||||
// 浮点比较指令 - 生成临时i1结果然后转换为i32
|
||||
static int tmpCmpCounter = 0;
|
||||
std::string tmpName = "tmp_fcmp_" + std::to_string(++tmpCmpCounter);
|
||||
// 使用指令地址和操作数地址的组合哈希来确保唯一性
|
||||
auto inst_hash = std::hash<const void*>{}(static_cast<const void*>(this));
|
||||
auto lhs_hash = std::hash<const void*>{}(static_cast<const void*>(getLhs()));
|
||||
auto rhs_hash = std::hash<const void*>{}(static_cast<const void*>(getRhs()));
|
||||
size_t combined_hash = inst_hash ^ (lhs_hash << 1) ^ (rhs_hash << 2);
|
||||
std::string tmpName = "tmp_fcmp_" + std::to_string(combined_hash % 1000000);
|
||||
os << "%" << tmpName << " = " << getKindString() << " " << *getLhs()->getType() << " ";
|
||||
printOperand(os, getLhs());
|
||||
os << ", ";
|
||||
@@ -799,15 +807,25 @@ void UncondBrInst::print(std::ostream &os) const {
|
||||
void CondBrInst::print(std::ostream &os) const {
|
||||
Value* condition = getCondition();
|
||||
|
||||
// 由于所有条件都是i32类型(包括比较结果),统一转换为i1
|
||||
static int tmpCondCounter = 0;
|
||||
// 使用多个因素的组合哈希来确保唯一性
|
||||
std::string condName = condition->getName();
|
||||
if (condName.empty()) {
|
||||
condName = "const" + std::to_string(++tmpCondCounter);
|
||||
// 使用条件值地址的哈希值作为唯一标识
|
||||
auto ptr_hash = std::hash<const void*>{}(static_cast<const void*>(condition));
|
||||
condName = "const_" + std::to_string(ptr_hash % 100000);
|
||||
}
|
||||
os << "%tmp_cond_" << condName << " = icmp ne i32 ";
|
||||
|
||||
// 组合指令地址、条件地址和目标块地址的哈希来确保唯一性
|
||||
auto inst_hash = std::hash<const void*>{}(static_cast<const void*>(this));
|
||||
auto cond_hash = std::hash<const void*>{}(static_cast<const void*>(condition));
|
||||
auto then_hash = std::hash<const void*>{}(static_cast<const void*>(getThenBlock()));
|
||||
auto else_hash = std::hash<const void*>{}(static_cast<const void*>(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);
|
||||
|
||||
os << "%tmp_cond_" << condName << "_" << uniqueSuffix << " = icmp ne i32 ";
|
||||
printOperand(os, condition);
|
||||
os << ", 0\n br i1 %tmp_cond_" << condName;
|
||||
os << ", 0\n br i1 %tmp_cond_" << condName << "_" << uniqueSuffix;
|
||||
|
||||
os << ", label %";
|
||||
printBlockName(os, getThenBlock());
|
||||
|
||||
Reference in New Issue
Block a user