[llvm] r254802 - [ThinLTO] Helper for performing renaming/promotion on a module
Teresa Johnson via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 4 15:40:22 PST 2015
Author: tejohnson
Date: Fri Dec 4 17:40:22 2015
New Revision: 254802
URL: http://llvm.org/viewvc/llvm-project?rev=254802&view=rev
Log:
[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.
Modified:
llvm/trunk/include/llvm/Linker/Linker.h
llvm/trunk/lib/Linker/LinkModules.cpp
Modified: llvm/trunk/include/llvm/Linker/Linker.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Linker/Linker.h?rev=254802&r1=254801&r2=254802&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Linker/Linker.h (original)
+++ llvm/trunk/include/llvm/Linker/Linker.h Fri Dec 4 17:40:22 2015
@@ -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
Modified: llvm/trunk/lib/Linker/LinkModules.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=254802&r1=254801&r2=254802&view=diff
==============================================================================
--- llvm/trunk/lib/Linker/LinkModules.cpp (original)
+++ llvm/trunk/lib/Linker/LinkModules.cpp Fri Dec 4 17:40:22 2015
@@ -2056,6 +2056,18 @@ bool Linker::linkModules(Module &Dest, M
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.
//===----------------------------------------------------------------------===//
More information about the llvm-commits
mailing list