[llvm] [BOLT] Use file-disambiguated parent name in registerFragments (PR #93399)

Amir Ayupov via llvm-commits llvm-commits at lists.llvm.org
Sat May 25 22:56:49 PDT 2024


https://github.com/aaupov created https://github.com/llvm/llvm-project/pull/93399

If fragment alias contains a file name (e.g. `func.cold/file`),
construct a matching file-qualified parent name (`func/file`).

Test Plan: TBD.

>From dd0f36ac70d8ada81c9385b090d05dab69c37d97 Mon Sep 17 00:00:00 2001
From: Amir Ayupov <amir.aupov at gmail.com>
Date: Sat, 25 May 2024 22:50:01 -0700
Subject: [PATCH] [BOLT] Use file-disambiguated parent name in
 registerFragments

---
 bolt/lib/Rewrite/RewriteInstance.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp
index 85b39176754b6..7f731e4f5714d 100644
--- a/bolt/lib/Rewrite/RewriteInstance.cpp
+++ b/bolt/lib/Rewrite/RewriteInstance.cpp
@@ -1463,10 +1463,10 @@ void RewriteInstance::registerFragments() {
     for (StringRef Name : Function.getNames()) {
       StringRef BaseName = NR.restore(Name);
       const bool IsGlobal = BaseName == Name;
-      const size_t ColdSuffixPos = BaseName.find(".cold");
-      if (ColdSuffixPos == StringRef::npos)
+      auto [BaseParentName, Suffix] = BaseName.split(".cold");
+      if (BaseParentName == BaseName)
         continue;
-      StringRef ParentName = BaseName.substr(0, ColdSuffixPos);
+      std::string ParentName = (BaseParentName + Suffix).str();
       const BinaryData *BD = BC->getBinaryDataByName(ParentName);
       const uint64_t NumPossibleLocalParents =
           NR.getUniquifiedNameCount(ParentName);



More information about the llvm-commits mailing list