From: Teresa Johnson Date: Fri, 4 Dec 2015 23:40:22 +0000 (+0000) Subject: [ThinLTO] Helper for performing renaming/promotion on a module X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=5143703795b66599df93a9f35462e522f925c0f8;p=oota-llvm.git [ThinLTO] Helper for performing renaming/promotion on a module Creates a module and performs necessary renaming/promotion of locals that may be exported to another module. Split out of D15024. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254802 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Linker/Linker.h b/include/llvm/Linker/Linker.h index f0c8ad979ab..aa430094294 100644 --- a/include/llvm/Linker/Linker.h +++ b/include/llvm/Linker/Linker.h @@ -99,6 +99,13 @@ private: DiagnosticHandlerFunction DiagnosticHandler; }; +/// Create a new module with exported local functions renamed and promoted +/// for ThinLTO. +std::unique_ptr +renameModuleForThinLTO(std::unique_ptr &M, + const FunctionInfoIndex *Index, + DiagnosticHandlerFunction DiagnosticHandler); + } // End llvm namespace #endif diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index 88b8e443c48..627137ba3ab 100644 --- a/lib/Linker/LinkModules.cpp +++ b/lib/Linker/LinkModules.cpp @@ -2056,6 +2056,18 @@ bool Linker::linkModules(Module &Dest, Module &Src, return L.linkInModule(Src, Flags); } +std::unique_ptr +llvm::renameModuleForThinLTO(std::unique_ptr &M, + const FunctionInfoIndex *Index, + DiagnosticHandlerFunction DiagnosticHandler) { + std::unique_ptr RenamedModule( + new llvm::Module(M->getModuleIdentifier(), M->getContext())); + Linker L(*RenamedModule.get(), DiagnosticHandler); + if (L.linkInModule(*M.get(), llvm::Linker::Flags::None, Index)) + return nullptr; + return RenamedModule; +} + //===----------------------------------------------------------------------===// // C API. //===----------------------------------------------------------------------===//