[BOLT][AArch64] Speed up ICF pass (#172783)

Add hashing support for MCSpecifierExpr, which is frequently used as an
operand in AArch64 instructions. Proper hashing reduces collisions when
placing functions into buckets, resulting in shorter Identical Code
Folding (ICF) pass runtime.

In one benchmark, the ICF wall time decreased from 272s to 124s.
This commit is contained in:
Maksim Panchenko 2025-12-17 21:05:54 -08:00 committed by GitHub
parent 188bf2769a
commit 4a8e6a36b6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -67,7 +67,11 @@ std::string hashExpr(BinaryContext &BC, const MCExpr &Expr) {
.append(hashInteger(BinaryExpr.getOpcode()))
.append(hashExpr(BC, *BinaryExpr.getRHS()));
}
case MCExpr::Specifier:
case MCExpr::Specifier: {
const auto &SpecExpr = cast<MCSpecifierExpr>(Expr);
return hashInteger(SpecExpr.getSpecifier())
.append(hashExpr(BC, *SpecExpr.getSubExpr()));
}
case MCExpr::Target:
return std::string();
}