[llvm] r266845 - ThinLTO: Move alias importing decision on the summary

Mehdi Amini via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 19 18:04:20 PDT 2016


Author: mehdi_amini
Date: Tue Apr 19 20:04:20 2016
New Revision: 266845

URL: http://llvm.org/viewvc/llvm-project?rev=266845&view=rev
Log:
ThinLTO: Move alias importing decision on the summary

From: Mehdi Amini <mehdi.amini at apple.com>

Modified:
    llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp

Modified: llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp?rev=266845&r1=266844&r2=266845&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp Tue Apr 19 20:04:20 2016
@@ -163,10 +163,20 @@ static void computeImportForFunction(
     }
     // "Resolve" the summary, traversing alias,
     const FunctionSummary *ResolvedCalleeSummary;
-    if (isa<AliasSummary>(CalleeSummary))
+    if (isa<AliasSummary>(CalleeSummary)) {
       ResolvedCalleeSummary = cast<FunctionSummary>(
           &cast<AliasSummary>(CalleeSummary)->getAliasee());
-    else
+      if (!GlobalValue::isLinkOnceODRLinkage(
+              ResolvedCalleeSummary->linkage())) {
+        // Alias can't point to "available_externally". However when we import
+        // linkOnceODR the linkage does not change. So we import the alias
+        // and aliasee only in this case.
+        // FIXME: we should import alias as available_externally *function*, the
+        // destination module does need to know it is an alias.
+        DEBUG(dbgs() << "ignored! Aliasee is not linkonce_odr.\n");
+        continue;
+      }
+    } else
       ResolvedCalleeSummary = cast<FunctionSummary>(CalleeSummary);
 
     assert(ResolvedCalleeSummary->instCount() <= Threshold &&
@@ -380,10 +390,11 @@ bool FunctionImporter::importFunctions(
       if (Import) {
         // Alias can't point to "available_externally". However when we import
         // linkOnceODR the linkage does not change. So we import the alias
-        // and aliasee only in this case.
+        // and aliasee only in this case. This has been handled by
+        // computeImportForFunction()
         GlobalObject *GO = GV.getBaseObject();
-        if (!GO->hasLinkOnceODRLinkage())
-          continue;
+        assert(GO->hasLinkOnceODRLinkage() &&
+               "Unexpected alias to a non-linkonceODR in import list");
 #ifndef NDEBUG
         if (!GlobalsToImport.count(GO))
           DEBUG(dbgs() << " alias triggers importing aliasee " << GO->getGUID()




More information about the llvm-commits mailing list