• Home
  • Raw
  • Download

Lines Matching +full:helper +full:- +full:module +full:- +full:imports

1 //===- llvm-link.cpp - Low-level LLVM linker ------------------------------===//
8 //===----------------------------------------------------------------------===//
11 // llvm-link a.bc b.bc c.bc -o x.bc
13 //===----------------------------------------------------------------------===//
21 #include "llvm/IR/Module.h"
52 // llvm-link to simulate ThinLTO backend processes.
53 static cl::list<std::string> Imports( variable
58 // Option to support testing of function importing. The module summary
59 // must be specified in the case were we request imports via the -import
60 // option, as well as when compiling any module with functions that may be
61 // exported (imported by a different llvm-link -import invocation), to ensure
64 SummaryIndex("summary-index", cl::desc("Module summary index filename"),
68 OutputFilename("o", cl::desc("Override output filename"), cl::init("-"),
75 DisableDITypeMap("disable-debug-info-type-map",
79 OnlyNeeded("only-needed", cl::desc("Link only needed symbols"));
95 SuppressWarnings("suppress-warnings", cl::desc("Suppress all linking warnings"),
99 "preserve-bc-uselistorder",
100 cl::desc("Preserve use-list order when writing LLVM bitcode."),
104 "preserve-ll-uselistorder",
105 cl::desc("Preserve use-list order when writing LLVM assembly."),
111 static std::unique_ptr<Module> loadFile(const char *argv0, in loadFile()
117 std::unique_ptr<Module> Result = in loadFile()
125 Result->materializeMetadata(); in loadFile()
134 /// Helper to load on demand a Module from file and cache it for subsequent
137 /// Cache of lazily loaded module for import.
138 StringMap<std::unique_ptr<Module>> ModuleMap;
140 /// Retrieve a Module from the cache or lazily load it on demand.
141 std::function<std::unique_ptr<Module>(const char *argv0,
146 /// Create the loader, Module will be initialized in \p Context.
147 ModuleLazyLoaderCache(std::function<std::unique_ptr<Module>( in ModuleLazyLoaderCache()
152 /// Retrieve a Module from the cache or lazily load it on demand.
153 Module &operator()(const char *argv0, const std::string &FileName);
155 std::unique_ptr<Module> takeModule(const std::string &FileName) { in takeModule()
158 std::unique_ptr<Module> Ret = std::move(I->second); in takeModule()
164 // Get a Module for \p FileName from the cache, or load it lazily.
165 Module &ModuleLazyLoaderCache::operator()(const char *argv0, in operator ()()
167 auto &Module = ModuleMap[Identifier]; in operator ()() local
168 if (!Module) in operator ()()
169 Module = createLazyModule(argv0, Identifier); in operator ()()
170 return *Module; in operator ()()
199 /// Import any functions requested via the -import option.
213 // Map of Module -> List of globals to import from the Module in importFunctions()
220 for (const auto &Import : Imports) { in importFunctions()
230 // Load the specified source module. in importFunctions()
235 << ": error: input module is broken!\n"; in importFunctions()
241 errs() << "Ignoring import request for non-existent function " in importFunctions()
248 if (F->hasWeakAnyLinkage()) { in importFunctions()
249 errs() << "Ignoring import request for weak-any function " << FunctionName in importFunctions()
260 F->materialize(); in importFunctions()
263 // Do the actual import of globals now, one Module at a time in importFunctions()
265 // Get the module for the import in importFunctions()
267 std::unique_ptr<Module> SrcModule = in importFunctions()
269 assert(&Context == &SrcModule->getContext() && "Context mismatch"); in importFunctions()
273 SrcModule->materializeMetadata(); in importFunctions()
296 std::unique_ptr<Module> M = loadFile(argv0, File, Context); in linkFiles()
303 // doing that debug metadata in the src module might already be pointing to in linkFiles()
306 errs() << argv0 << ": " << File << ": error: input module is broken!\n"; in linkFiles()
310 // If a module summary index is supplied, load it so linkInModule can treat in linkFiles()
353 auto Composite = make_unique<Module>("llvm-link", Context); in main()
366 // Next the -override ones. in main()
371 // Import any functions requested via -import in main()
385 errs() << argv[0] << ": error: linked module is broken!\n"; in main()
391 Composite->print(Out.os(), nullptr, PreserveAssemblyUseListOrder); in main()