[ThinLTO] Use new in-place symbol changes for exporting module
authorTeresa Johnson <tejohnson@google.com>
Fri, 8 Jan 2016 17:06:29 +0000 (17:06 +0000)
committerTeresa Johnson <tejohnson@google.com>
Fri, 8 Jan 2016 17:06:29 +0000 (17:06 +0000)
Due to the new in-place ThinLTO symbol handling support added in
r257174, we now invoke renameModuleForThinLTO on the current
module from within the FunctionImport pass.

Additionally, renameModuleForThinLTO no longer needs to return the
Module as it is performing the renaming in place on the one provided.

This commit will be immediately preceeded by a companion clang patch to
remove its invocation of renameModuleForThinLTO.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257181 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Linker/Linker.h
lib/Linker/LinkModules.cpp
lib/Transforms/IPO/FunctionImport.cpp

index f09cf1029a4be123645d4d47882d6cf6fed9d5f2..2b051e6d15c944ab516f6505037667b568788c44 100644 (file)
@@ -69,8 +69,7 @@ public:
 
 /// Perform in-place global value handling on the given Module for
 /// exported local functions renamed and promoted for ThinLTO.
 
 /// Perform in-place global value handling on the given Module for
 /// exported local functions renamed and promoted for ThinLTO.
-std::unique_ptr<Module> renameModuleForThinLTO(std::unique_ptr<Module> M,
-                                               const FunctionInfoIndex *Index);
+bool renameModuleForThinLTO(Module &M, const FunctionInfoIndex *Index);
 
 } // End llvm namespace
 
 
 } // End llvm namespace
 
index 653f639f28e5cbf1e2a13fc1b12689c36680d40a..6ffa71e147790f9d410078181fb666f367bf6024 100644 (file)
@@ -863,13 +863,9 @@ bool Linker::linkModules(Module &Dest, std::unique_ptr<Module> Src,
   return L.linkInModule(std::move(Src), Flags);
 }
 
   return L.linkInModule(std::move(Src), Flags);
 }
 
-std::unique_ptr<Module>
-llvm::renameModuleForThinLTO(std::unique_ptr<Module> M,
-                             const FunctionInfoIndex *Index) {
-  ThinLTOGlobalProcessing ThinLTOProcessing(*M, Index);
-  if (ThinLTOProcessing.run())
-    return nullptr;
-  return M;
+bool llvm::renameModuleForThinLTO(Module &M, const FunctionInfoIndex *Index) {
+  ThinLTOGlobalProcessing ThinLTOProcessing(M, Index);
+  return ThinLTOProcessing.run();
 }
 
 //===----------------------------------------------------------------------===//
 }
 
 //===----------------------------------------------------------------------===//
index d194c5e424df9d75fea93294189190cefdcf341d..11418edbf7bc1634f4d42717e17843612cd55225 100644 (file)
@@ -413,14 +413,19 @@ public:
       Index = IndexPtr.get();
     }
 
       Index = IndexPtr.get();
     }
 
+    // First we need to promote to global scope and rename any local values that
+    // are potentially exported to other modules.
+    if (renameModuleForThinLTO(M, Index)) {
+      errs() << "Error renaming module\n";
+      return false;
+    }
+
     // Perform the import now.
     auto ModuleLoader = [&M](StringRef Identifier) {
       return loadFile(Identifier, M.getContext());
     };
     FunctionImporter Importer(*Index, ModuleLoader);
     return Importer.importFunctions(M);
     // Perform the import now.
     auto ModuleLoader = [&M](StringRef Identifier) {
       return loadFile(Identifier, M.getContext());
     };
     FunctionImporter Importer(*Index, ModuleLoader);
     return Importer.importFunctions(M);
-
-    return false;
   }
 };
 } // anonymous namespace
   }
 };
 } // anonymous namespace