[llvm] [WPD]: Enable speculative devirtualizatoin. (PR #159048)

Hassnaa Hamdi via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 27 13:49:27 PDT 2025


================
@@ -1325,10 +1367,10 @@ bool DevirtModule::trySingleImplDevirt(
   if (!IsExported)
     return false;
 
-  // If the only implementation has local linkage, we must promote to external
-  // to make it visible to thin LTO objects. We can only get here during the
-  // ThinLTO export phase.
-  if (TheFn->hasLocalLinkage()) {
+  // Out of speculative devirtualization mode, if the only implementation has
+  // local linkage, we must promote to external to make it visible to thin LTO
+  // objects.
+  if (!DevirtSpeculatively && TheFn->hasLocalLinkage()) {
----------------
hassnaaHamdi wrote:

I think that LTO flag should be passed to the constructor to differentiate between LTO mode and non-LTO mode.
It could happen in some tests that in LTO mode that the ExportSummary is null, ex: llvm/test/Other/new-pm-lto-defaults.ll 

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


More information about the llvm-commits mailing list