From: Rafael Espindola Date: Thu, 23 Oct 2014 19:40:45 +0000 (+0000) Subject: Make llvm-link behave a bit more like LTO. X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=e37b00e50be8b10db6e48b977c1f0d935d5b189d Make llvm-link behave a bit more like LTO. * Read modules lazily * Don't treat the first file specially, instead merge all inputs into an empty module. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220501 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/llvm-link/llvm-link.cpp b/tools/llvm-link/llvm-link.cpp index 17866a06713..7c2894baa1b 100644 --- a/tools/llvm-link/llvm-link.cpp +++ b/tools/llvm-link/llvm-link.cpp @@ -62,7 +62,7 @@ static std::unique_ptr loadFile(const char *argv0, const std::string &FN, LLVMContext &Context) { SMDiagnostic Err; if (Verbose) errs() << "Loading '" << FN << "'\n"; - std::unique_ptr Result = parseIRFile(FN, Err, Context); + std::unique_ptr Result = getLazyIRFileModule(FN, Err, Context); if (!Result) Err.print(argv0, errs()); @@ -78,19 +78,11 @@ int main(int argc, char **argv) { llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. cl::ParseCommandLineOptions(argc, argv, "llvm linker\n"); - unsigned BaseArg = 0; - std::string ErrorMessage; - - std::unique_ptr Composite = - loadFile(argv[0], InputFilenames[BaseArg], Context); - if (!Composite.get()) { - errs() << argv[0] << ": error loading file '" - << InputFilenames[BaseArg] << "'\n"; - return 1; - } - + auto Composite = make_unique("llvm-link", Context); Linker L(Composite.get(), SuppressWarnings); - for (unsigned i = BaseArg+1; i < InputFilenames.size(); ++i) { + + std::string ErrorMessage; + for (unsigned i = 0; i < InputFilenames.size(); ++i) { std::unique_ptr M = loadFile(argv[0], InputFilenames[i], Context); if (!M.get()) { errs() << argv[0] << ": error loading file '" <