From 4a8e6a36b668dc22ac9ffae8b4914eee5693e02b Mon Sep 17 00:00:00 2001 From: Maksim Panchenko Date: Wed, 17 Dec 2025 21:05:54 -0800 Subject: [PATCH] [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. --- bolt/lib/Core/HashUtilities.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bolt/lib/Core/HashUtilities.cpp b/bolt/lib/Core/HashUtilities.cpp index e01768387d6c..7bb3bd061c56 100644 --- a/bolt/lib/Core/HashUtilities.cpp +++ b/bolt/lib/Core/HashUtilities.cpp @@ -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(Expr); + return hashInteger(SpecExpr.getSpecifier()) + .append(hashExpr(BC, *SpecExpr.getSubExpr())); + } case MCExpr::Target: return std::string(); }