[lld] r286100 - [ELF] Make InputSection<ELFT>::writeTo virtual

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 8 03:27:21 PST 2016


On 8 November 2016 at 06:16, Eugene Leviant <evgeny.leviant at gmail.com> wrote:
> SyntheticInput is not enough, because synthetic sections are written
> on behalf of OutputSection<ELFT>, which maintains a list
> of InputSection<ELFT> objects.
>
> To my understanding an alternative is a check for section kind in
> InputSection<ELFT>::writeTo, which is also a slow-down.
> Will it be faster than virtual function call?

I don't think the problem is the call. The problem is the vtable
pointer in lots of allocations. So yes, checking Kind should help, and
it is probably ok to have just a SyntheticKind and for writing do

if (auto *S = dyn_cast<SyntheticSection<ELFT>>(this)) {
  S->writeSynthetic(); // only virtual method in the hierarchy.
  return;
}

Cheers,
Rafael


More information about the llvm-commits mailing list