@@ -218,7 +218,7 @@ void LinkerDriver::addFile(InputFile *file) {
218218 << " linked in after "
219219 " doing LTO compilation." ;
220220 }
221- ctx .bitcodeFileInstances .push_back (f);
221+ f-> symtab .bitcodeFileInstances .push_back (f);
222222 } else if (auto *f = dyn_cast<ImportFile>(file)) {
223223 ctx.importFileInstances .push_back (f);
224224 }
@@ -285,7 +285,7 @@ void LinkerDriver::addBuffer(std::unique_ptr<MemoryBuffer> mb,
285285 addFile (make<ArchiveFile>(ctx, mbref));
286286 break ;
287287 case file_magic::bitcode:
288- addFile (make< BitcodeFile> (ctx, mbref, " " , 0 , lazy));
288+ addFile (BitcodeFile::create (ctx, mbref, " " , 0 , lazy));
289289 break ;
290290 case file_magic::coff_object:
291291 case file_magic::coff_import_library:
@@ -374,8 +374,8 @@ void LinkerDriver::addArchiveBuffer(MemoryBufferRef mb, StringRef symName,
374374 if (magic == file_magic::coff_object) {
375375 obj = ObjFile::create (ctx, mb);
376376 } else if (magic == file_magic::bitcode) {
377- obj =
378- make<BitcodeFile>(ctx, mb, parentName, offsetInArchive, /* lazy=*/ false );
377+ obj = BitcodeFile::create (ctx, mb, parentName, offsetInArchive,
378+ /* lazy=*/ false );
379379 } else if (magic == file_magic::coff_cl_gl_object) {
380380 Err (ctx) << mb.getBufferIdentifier ()
381381 << " : is not a native COFF file. Recompile without /GL?" ;
@@ -2571,19 +2571,19 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
25712571 }
25722572 }
25732573
2574- // If any inputs are bitcode files, the LTO code generator may create
2575- // references to library functions that are not explicit in the bitcode
2576- // file's symbol table. If any of those library functions are defined in a
2577- // bitcode file in an archive member, we need to arrange to use LTO to
2578- // compile those archive members by adding them to the link beforehand.
2579- if (!ctx.bitcodeFileInstances .empty ()) {
2580- llvm::Triple TT (
2581- ctx.bitcodeFileInstances .front ()->obj ->getTargetTriple ());
2582- for (auto *s : lto::LTO::getRuntimeLibcallSymbols (TT))
2583- ctx.symtab .addLibcall (s);
2584- }
2585-
25862574 ctx.forEachSymtab ([&](SymbolTable &symtab) {
2575+ // If any inputs are bitcode files, the LTO code generator may create
2576+ // references to library functions that are not explicit in the bitcode
2577+ // file's symbol table. If any of those library functions are defined in
2578+ // a bitcode file in an archive member, we need to arrange to use LTO to
2579+ // compile those archive members by adding them to the link beforehand.
2580+ if (!symtab.bitcodeFileInstances .empty ()) {
2581+ llvm::Triple TT (
2582+ symtab.bitcodeFileInstances .front ()->obj ->getTargetTriple ());
2583+ for (auto *s : lto::LTO::getRuntimeLibcallSymbols (TT))
2584+ symtab.addLibcall (s);
2585+ }
2586+
25872587 // Windows specific -- if __load_config_used can be resolved, resolve
25882588 // it.
25892589 if (symtab.findUnderscore (" _load_config_used" ))
@@ -2639,8 +2639,11 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
26392639 // If we are going to do codegen for link-time optimization, check for
26402640 // unresolvable symbols first, so we don't spend time generating code that
26412641 // will fail to link anyway.
2642- if (!ctx.bitcodeFileInstances .empty () && !config->forceUnresolved )
2643- ctx.symtab .reportUnresolvable ();
2642+ if (!config->forceUnresolved )
2643+ ctx.forEachSymtab ([](SymbolTable &symtab) {
2644+ if (!symtab.bitcodeFileInstances .empty ())
2645+ symtab.reportUnresolvable ();
2646+ });
26442647 if (errorCount ())
26452648 return ;
26462649
@@ -2655,7 +2658,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
26552658 // link those files (unless -thinlto-index-only was given, in which case we
26562659 // resolve symbols and write indices, but don't generate native code or link).
26572660 ltoCompilationDone = true ;
2658- ctx.symtab .compileBitcodeFiles ();
2661+ ctx.forEachSymtab ([](SymbolTable & symtab) { symtab .compileBitcodeFiles (); } );
26592662
26602663 if (Defined *d =
26612664 dyn_cast_or_null<Defined>(ctx.symtab .findUnderscore (" _tls_used" )))
0 commit comments