[llvm] r264536 - [ThinLTO] Don't try to import alias unless aliasee can be imported

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 27 08:01:12 PDT 2016


Author: tejohnson
Date: Sun Mar 27 10:01:11 2016
New Revision: 264536

URL: http://llvm.org/viewvc/llvm-project?rev=264536&view=rev
Log:
[ThinLTO] Don't try to import alias unless aliasee can be imported

With r264503, aliases are now being added to the GlobalsToImport set
even when their aliasees can't be imported due to their linkage type.
While the importing worked correctly (the aliases imported as
declarations) due to the logic in doImportAsDefinition, there is no
point to adding them to the GlobalsToImport set.

Additionally, with D18487 it was resulting in incorrectly printing a
message indicating that the alias was imported.

To avoid this, delay adding aliases to the GlobalsToImport set until
after the linkage type of the aliasee is checked.

This patch is part of D18487.

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=264536&r1=264535&r2=264536&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp Sun Mar 27 10:01:11 2016
@@ -322,14 +322,14 @@ bool FunctionImporter::importFunctions(
         continue;
       auto GUID = GV.getGUID();
       if (ImportGUIDs.count(GUID)) {
-        GV.materialize();
-        GlobalsToImport.insert(&GV);
         // Alias can't point to "available_externally". However when we import
-        // linkOnceODR the linkage does not change. So we import the aliasee
-        // only in this case
+        // linkOnceODR the linkage does not change. So we import the alias
+        // and aliasee only in this case.
         const GlobalObject *GO = GV.getBaseObject();
         if (!GO->hasLinkOnceODRLinkage())
           continue;
+        GV.materialize();
+        GlobalsToImport.insert(&GV);
         GlobalsToImport.insert(GO);
       }
     }




More information about the llvm-commits mailing list