mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-29 07:53:31 +00:00
[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
This commit is contained in:
parent
2174f151dc
commit
5143703795
@ -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
|
||||
|
@ -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.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
Loading…
Reference in New Issue
Block a user