[PATCH] D50475: ELF: Only add libcall symbols to the link if defined in bitcode.

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 8 16:42:04 PDT 2018


pcc added inline comments.


================
Comment at: lld/ELF/Driver.cpp:1221
+
+  MemoryBufferRef MB;
+  if (auto *LO = dyn_cast<LazyObject>(Sym))
----------------
ruiu wrote:
> ruiu wrote:
> > pcc wrote:
> > > ruiu wrote:
> > > > Is it too expensive or is there any problem if we simply call `Sym->fetch()` and see if the returned value is of BitcodeFile (and if so, add to the symbol table)?
> > > I don't think that would work because subsequent calls to `fetch` would return nullptr. That means that if the object file actually turns out to be required, we wouldn't end up adding it.
> > Can you return right here if it is not isLazy?
> I mean, I think something like this is a bit easier to grasp.
> 
>   if (!Sym->isLazy())
>     return
> 
>   if (auto *LO = dyn_cast<LazyObject>(Sym))
>     MB = LO->File->MB;
>   else
>     MB = cast<LazyArchive>(Sym)->getMemberBuffer();
Yes. Thinking about it more I think we can simplify a little further: we don't need to set `IsUsedInRegularObj` at all because the libcall symbols are kept alive because of D49434.


Repository:
  rL LLVM

https://reviews.llvm.org/D50475





More information about the llvm-commits mailing list