[clang] [lld] [llvm] [ThinLTO] Reduce the number of renaming due to promotions (PR #178587)

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 12 08:56:18 PST 2026


================
@@ -480,12 +481,19 @@ static void thinLTOInternalizeAndPromoteGUID(
       VI.getSummaryList().size() == 1 &&
       !GlobalValue::isLocalLinkage(VI.getSummaryList().front()->linkage());
 
+  bool NameInGlobals = false;
   for (auto &S : VI.getSummaryList()) {
     // First see if we need to promote an internal value because it is not
     // exported.
     if (isExported(S->modulePath(), VI)) {
-      if (GlobalValue::isLocalLinkage(S->linkage()))
+      if (GlobalValue::isLocalLinkage(S->linkage())) {
         S->setLinkage(GlobalValue::ExternalLinkage);
+        if (!NameInGlobals) {
+          if (Globals.insert(VI.name()).second)
+            S->setRenameOnPromotion(false);
----------------
teresajohnson wrote:

Chat is confused. It is confusing the way we construct the name for the GUID hash (where for locals it prepends the source file name), and the name we use when renaming after promotion (where the module hash is appended). See llvm/test/ThinLTO/X86/devirt_local_same_guid.ll for an example of how to get the same GUID for locals in different modules.

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


More information about the llvm-commits mailing list