[llvm-branch-commits] [llvm] [BOLT] Match blocks with calls as anchors (PR #96596)

Davide Italiano via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Jul 5 14:18:52 PDT 2024


================
@@ -414,31 +449,59 @@ createFlowFunction(const BinaryFunction::BasicBlockOrderType &BlockOrder) {
 /// matched to a jump in the binary, the count is recorded in CFG.
 size_t matchWeightsByHashes(
     BinaryContext &BC, const BinaryFunction::BasicBlockOrderType &BlockOrder,
-    const yaml::bolt::BinaryFunctionProfile &YamlBF, FlowFunction &Func) {
+    const yaml::bolt::BinaryFunctionProfile &YamlBF, FlowFunction &Func,
+    HashFunction HashFunction,
+    const DenseMap<uint32_t, std::string *> &IdToFunctionName) {
+
   assert(Func.Blocks.size() == BlockOrder.size() + 2);
 
+  std::vector<uint64_t> CallHashes;
   std::vector<FlowBlock *> Blocks;
   std::vector<BlendedBlockHash> BlendedHashes;
   for (uint64_t I = 0; I < BlockOrder.size(); I++) {
     const BinaryBasicBlock *BB = BlockOrder[I];
     assert(BB->getHash() != 0 && "empty hash of BinaryBasicBlock");
+
+    std::string CallHashStr = hashBlockCalls(BC, *BB);
+    if (CallHashStr.empty()) {
+      CallHashes.push_back(0);
+    } else if (HashFunction == HashFunction::StdHash) {
+      CallHashes.push_back(std::hash<std::string>{}(CallHashStr));
+    } else if (HashFunction == HashFunction::XXH3) {
+      CallHashes.push_back(llvm::xxh3_64bits(CallHashStr));
+    } else {
+      llvm_unreachable("Unhandled HashFunction");
----------------
dcci wrote:

maybe you can make this message slightly more verbose/explicative.

https://github.com/llvm/llvm-project/pull/96596


More information about the llvm-branch-commits mailing list