Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 1ae34a9

Browse files
committed
optimize loading+linking in opt
1 parent d99eb11 commit 1ae34a9

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

tools/opt/opt.cpp

+9-4
Original file line numberDiff line numberDiff line change
@@ -472,8 +472,8 @@ int main(int argc, char **argv) {
472472
M = parseIRFile(InputFilenames[0], Err, Context);
473473
else {
474474
// link them in
475-
M = make_unique<Module>("opt-link", Context);
476-
Linker L(M.get());
475+
M = nullptr;
476+
std::unique_ptr<Linker> L;
477477

478478
for (unsigned i = 0; i < InputFilenames.size(); ++i) {
479479
std::unique_ptr<Module> MM = parseIRFile(InputFilenames[i], Err, Context);
@@ -488,8 +488,13 @@ int main(int argc, char **argv) {
488488
return 1;
489489
}
490490

491-
if (L.linkInModule(MM.get()))
492-
return 1;
491+
if (i == 0) {
492+
M.swap(MM);
493+
L = make_unique<Linker>(M.get());
494+
} else {
495+
if (L->linkInModule(MM.get()))
496+
return 1;
497+
}
493498
}
494499
}
495500

0 commit comments

Comments
 (0)