diff --git a/bolt/lib/Core/HashUtilities.cpp b/bolt/lib/Core/HashUtilities.cpp --- a/bolt/lib/Core/HashUtilities.cpp +++ b/bolt/lib/Core/HashUtilities.cpp @@ -13,6 +13,7 @@ #include "bolt/Core/HashUtilities.h" #include "bolt/Core/BinaryContext.h" #include "bolt/Core/BinaryFunction.h" +#include "llvm/MC/MCInstPrinter.h" namespace llvm { namespace bolt { @@ -116,13 +117,11 @@ if (IsX86 && BC.MIB->isConditionalBranch(Inst)) Opcode = BC.MIB->getShortBranchOpcode(Opcode); - if (Opcode == 0) + if (Opcode == 0) { HashString.push_back(0); - - while (Opcode) { - uint8_t LSB = Opcode & 0xff; - HashString.push_back(LSB); - Opcode = Opcode >> 8; + } else { + StringRef OpcodeName = BC.InstPrinter->getOpcodeName(Opcode); + HashString.append(OpcodeName.str()); } for (const MCOperand &Op : MCPlus::primeOperands(Inst))