diff options
author | Teresa Johnson <tejohnson@google.com> | 2015-12-04 23:40:22 +0000 |
---|---|---|
committer | Teresa Johnson <tejohnson@google.com> | 2015-12-04 23:40:22 +0000 |
commit | bae7e75959c1897e54343db410baf2bb7cc48e93 (patch) | |
tree | 0a4623ec2665aa0da06cec313851356ddeedeb74 /llvm/lib/Linker/LinkModules.cpp | |
parent | fbf2822e6db21f003deb416cb77e2b31a096439e (diff) | |
download | llvm-bae7e75959c1897e54343db410baf2bb7cc48e93.zip llvm-bae7e75959c1897e54343db410baf2bb7cc48e93.tar.gz llvm-bae7e75959c1897e54343db410baf2bb7cc48e93.tar.bz2 |
[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.
llvm-svn: 254802
Diffstat (limited to 'llvm/lib/Linker/LinkModules.cpp')
-rw-r--r-- | llvm/lib/Linker/LinkModules.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp index 88b8e44..627137b 100644 --- a/llvm/lib/Linker/LinkModules.cpp +++ b/llvm/lib/Linker/LinkModules.cpp @@ -2056,6 +2056,18 @@ bool Linker::linkModules(Module &Dest, Module &Src, return L.linkInModule(Src, Flags); } +std::unique_ptr<Module> +llvm::renameModuleForThinLTO(std::unique_ptr<Module> &M, + const FunctionInfoIndex *Index, + DiagnosticHandlerFunction DiagnosticHandler) { + std::unique_ptr<llvm::Module> 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. //===----------------------------------------------------------------------===// |