[llvm] [ThinLTO][WPD] Simplify check for local summary for efficiency (NFCI) (PR #164859)

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 23 10:52:07 PDT 2025


https://github.com/teresajohnson created https://github.com/llvm/llvm-project/pull/164859

Use the new HasLocal flag to avoid looking through all summaries to see
if there is a local copy.


>From 153710645e2332e0caca82fc236e7be9c5d41241 Mon Sep 17 00:00:00 2001
From: Teresa Johnson <tejohnson at google.com>
Date: Thu, 23 Oct 2025 10:48:13 -0700
Subject: [PATCH] [ThinLTO][WPD] Simplify check for local summary for
 efficiency (NFCI)

Use the new HasLocal flag to avoid looking through all summaries to see
if there is a local copy.
---
 llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
index 6909a282b3129..faae54ebcdc9b 100644
--- a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
+++ b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
@@ -1408,9 +1408,8 @@ bool DevirtIndex::trySingleImplDevirt(MutableArrayRef<ValueInfo> TargetsForSlot,
 
   // If the summary list contains multiple summaries where at least one is
   // a local, give up, as we won't know which (possibly promoted) name to use.
-  for (const auto &S : TheFn.getSummaryList())
-    if (GlobalValue::isLocalLinkage(S->linkage()) && Size > 1)
-      return false;
+  if (TheFn.hasLocal() && Size > 1)
+    return false;
 
   // Collect functions devirtualized at least for one call site for stats.
   if (PrintSummaryDevirt || AreStatisticsEnabled())



More information about the llvm-commits mailing list