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

Amir Ayupov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Jul 9 13:16:58 PDT 2024


================
@@ -181,20 +182,19 @@ 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, StringRef> &IdToFunctionName,
+hashBlockCalls(const DenseMap<uint32_t, yaml::bolt::BinaryFunctionProfile *>
+                   &IdToYamlFunction,
                const yaml::bolt::BinaryBasicBlockProfile &YamlBB) {
-  std::multiset<std::string> FunctionNames;
+  std::vector<std::string> FunctionNames;
   for (const yaml::bolt::CallSiteInfo &CallSiteInfo : YamlBB.CallSites) {
-    auto It = IdToFunctionName.find(CallSiteInfo.DestId);
-    if (It == IdToFunctionName.end())
+    auto It = IdToYamlFunction.find(CallSiteInfo.DestId);
+    if (It == IdToYamlFunction.end())
       continue;
-    StringRef Name = It->second;
-    const size_t Pos = Name.find("(*");
-    if (Pos != StringRef::npos)
-      Name = Name.substr(0, Pos);
-    FunctionNames.insert(std::string(Name));
+    StringRef Name =
+        NameResolver::removeSuffix(It->second->Name, StringRef("(*"));
----------------
aaupov wrote:

I think the intent of Maksim's comment was to hide an implementation detail (using `(*N)` suffix) in relevant component (NameResolver).

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


More information about the llvm-branch-commits mailing list