//===- bolt/Core/HashUtilities.cpp - Misc hash utilities ------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // Computation of hash values over BinaryFunction and BinaryBasicBlock. // //===----------------------------------------------------------------------===// #include "bolt/Core/HashUtilities.h" #include "bolt/Core/BinaryContext.h" #include "bolt/Utils/NameResolver.h" #include "llvm/MC/MCInstPrinter.h" namespace llvm { namespace bolt { std::string hashInteger(uint64_t Value) { … } std::string hashSymbol(BinaryContext &BC, const MCSymbol &Symbol) { … } std::string hashExpr(BinaryContext &BC, const MCExpr &Expr) { … } std::string hashInstOperand(BinaryContext &BC, const MCOperand &Operand) { … } std::string hashBlock(BinaryContext &BC, const BinaryBasicBlock &BB, OperandHashFuncTy OperandHashFunc) { … } /// A "loose" hash of a basic block to use with the stale profile matching. The /// computed value will be the same for blocks with minor changes (such as /// reordering of instructions or using different operands) but may result in /// collisions that need to be resolved by a stronger hashing. std::string hashBlockLoose(BinaryContext &BC, const BinaryBasicBlock &BB) { … } /// An even looser hash level relative to $ hashBlockLoose to use with stale /// profile matching, composed of the names of a block's called functions in /// lexicographic order. std::string hashBlockCalls(BinaryContext &BC, const BinaryBasicBlock &BB) { … } /// The same as the $hashBlockCalls function, but for profiled functions. std::string hashBlockCalls(const DenseMap<uint32_t, yaml::bolt::BinaryFunctionProfile *> &IdToYamlFunction, const yaml::bolt::BinaryBasicBlockProfile &YamlBB) { … } } // namespace bolt } // namespace llvm