llvm.org GIT mirror llvm / e37b00e
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 Rafael Espindola 4 years ago
1 changed file(s) with 5 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
6161 loadFile(const char *argv0, const std::string &FN, LLVMContext &Context) {
6262 SMDiagnostic Err;
6363 if (Verbose) errs() << "Loading '" << FN << "'\n";
64 std::unique_ptr Result = parseIRFile(FN, Err, Context);
64 std::unique_ptr Result = getLazyIRFileModule(FN, Err, Context);
6565 if (!Result)
6666 Err.print(argv0, errs());
6767
7777 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
7878 cl::ParseCommandLineOptions(argc, argv, "llvm linker\n");
7979
80 unsigned BaseArg = 0;
80 auto Composite = make_unique("llvm-link", Context);
81 Linker L(Composite.get(), SuppressWarnings);
82
8183 std::string ErrorMessage;
82
83 std::unique_ptr Composite =
84 loadFile(argv[0], InputFilenames[BaseArg], Context);
85 if (!Composite.get()) {
86 errs() << argv[0] << ": error loading file '"
87 << InputFilenames[BaseArg] << "'\n";
88 return 1;
89 }
90
91 Linker L(Composite.get(), SuppressWarnings);
92 for (unsigned i = BaseArg+1; i < InputFilenames.size(); ++i) {
84 for (unsigned i = 0; i < InputFilenames.size(); ++i) {
9385 std::unique_ptr M = loadFile(argv[0], InputFilenames[i], Context);
9486 if (!M.get()) {
9587 errs() << argv[0] << ": error loading file '" <