BOLT: Replace MCTargetExpr with MCSpecifierExpr to fix bolt-icf.test on aarch64 host

This commit is contained in:
Fangrui Song
2025-06-07 22:35:20 -07:00
parent 4a6b4d3894
commit cdd0a6c781
5 changed files with 10 additions and 7 deletions

View File

@@ -405,7 +405,7 @@ public:
bool equals(const MCExpr &A, const MCExpr &B, CompFuncTy Comp) const;
virtual bool equals(const MCTargetExpr &A, const MCTargetExpr &B,
virtual bool equals(const MCSpecifierExpr &A, const MCSpecifierExpr &B,
CompFuncTy Comp) const;
virtual bool isBranch(const MCInst &Inst) const {

View File

@@ -67,6 +67,7 @@ std::string hashExpr(BinaryContext &BC, const MCExpr &Expr) {
.append(hashInteger(BinaryExpr.getOpcode()))
.append(hashExpr(BC, *BinaryExpr.getRHS()));
}
case MCExpr::Specifier:
case MCExpr::Target:
return std::string();
}

View File

@@ -114,17 +114,19 @@ bool MCPlusBuilder::equals(const MCExpr &A, const MCExpr &B,
equals(*BinaryA.getRHS(), *BinaryB.getRHS(), Comp);
}
case MCExpr::Target: {
const auto &TargetExprA = cast<MCTargetExpr>(A);
const auto &TargetExprB = cast<MCTargetExpr>(B);
case MCExpr::Specifier: {
const auto &TargetExprA = cast<MCSpecifierExpr>(A);
const auto &TargetExprB = cast<MCSpecifierExpr>(B);
return equals(TargetExprA, TargetExprB, Comp);
}
case MCExpr::Target:
llvm_unreachable("Not implemented");
}
llvm_unreachable("Invalid expression kind!");
}
bool MCPlusBuilder::equals(const MCTargetExpr &A, const MCTargetExpr &B,
bool MCPlusBuilder::equals(const MCSpecifierExpr &A, const MCSpecifierExpr &B,
CompFuncTy Comp) const {
llvm_unreachable("target-specific expressions are unsupported");
}

View File

@@ -177,7 +177,7 @@ public:
return true;
}
bool equals(const MCTargetExpr &A, const MCTargetExpr &B,
bool equals(const MCSpecifierExpr &A, const MCSpecifierExpr &B,
CompFuncTy Comp) const override {
const auto &AArch64ExprA = cast<AArch64MCExpr>(A);
const auto &AArch64ExprB = cast<AArch64MCExpr>(B);

View File

@@ -31,7 +31,7 @@ class RISCVMCPlusBuilder : public MCPlusBuilder {
public:
using MCPlusBuilder::MCPlusBuilder;
bool equals(const MCTargetExpr &A, const MCTargetExpr &B,
bool equals(const MCSpecifierExpr &A, const MCSpecifierExpr &B,
CompFuncTy Comp) const override {
const auto &RISCVExprA = cast<RISCVMCExpr>(A);
const auto &RISCVExprB = cast<RISCVMCExpr>(B);