[llvm] [ThinLTO] Do not duplicate import a function that is actually defined in the current module (PR #110064)

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 26 08:06:22 PDT 2024


================
@@ -595,11 +595,15 @@ Value *IRLinker::materialize(Value *V, bool ForIndirectSymbol) {
   if (!SGV)
     return nullptr;
 
+  // If SGV is from dest, it is already materialized when dest was loaded.
+  if (SGV->getParent() == &DstM)
+    return nullptr;
+
   // When linking a global from other modules than source & dest, skip
   // materializing it because it would be mapped later when its containing
   // module is linked. Linking it now would potentially pull in many types that
   // may not be mapped properly.
-  if (SGV->getParent() != &DstM && SGV->getParent() != SrcM.get())
+  if (SGV->getParent() != SrcM.get())
----------------
teresajohnson wrote:

It's been awhile since I looked at this code, but from the guards that existed here and the comment block, it sounds like we previously expected that the symbol might be from the dest module. Can you look at how that worked ok for other symbols coming from dest? You might be able to add an assert and run through the llvm tests to see where that case pops up.

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


More information about the llvm-commits mailing list