aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Linker/LinkModules.cpp
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2015-12-04 23:40:22 +0000
committerTeresa Johnson <tejohnson@google.com>2015-12-04 23:40:22 +0000
commitbae7e75959c1897e54343db410baf2bb7cc48e93 (patch)
tree0a4623ec2665aa0da06cec313851356ddeedeb74 /llvm/lib/Linker/LinkModules.cpp
parentfbf2822e6db21f003deb416cb77e2b31a096439e (diff)
downloadllvm-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.cpp12
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.
//===----------------------------------------------------------------------===//