summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/Linker/Linker.h7
-rw-r--r--llvm/lib/Linker/LinkModules.cpp12
2 files changed, 19 insertions, 0 deletions
diff --git a/llvm/include/llvm/Linker/Linker.h b/llvm/include/llvm/Linker/Linker.h
index f0c8ad979ab..aa430094294 100644
--- a/llvm/include/llvm/Linker/Linker.h
+++ b/llvm/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<Module>
+renameModuleForThinLTO(std::unique_ptr<Module> &M,
+ const FunctionInfoIndex *Index,
+ DiagnosticHandlerFunction DiagnosticHandler);
+
} // End llvm namespace
#endif
diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp
index 88b8e443c48..627137ba3ab 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.
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud