[all-commits] [llvm/llvm-project] 5de5f6: [extract_symbols.py] Better handling of templates

john-brawn-arm via All-commits all-commits at lists.llvm.org
Mon Feb 6 07:36:54 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 5de5f66b984a96cda9ffa1456ca221759d2556c5
      https://github.com/llvm/llvm-project/commit/5de5f66b984a96cda9ffa1456ca221759d2556c5
  Author: John Brawn <john.brawn at arm.com>
  Date:   2023-02-06 (Mon, 06 Feb 2023)

  Changed paths:
    M llvm/utils/extract_symbols.py

  Log Message:
  -----------
  [extract_symbols.py] Better handling of templates

Since commit 846b676 SmallVectorBase<uint32_t> has been explicitly
instantiated, which means that clang.exe must export it for a plugin
to be able to link against it, but the constructor is not exported as
currently no template constructors or destructors are exported.

We can't just export all constructors and destructors, as that puts us
over the symbol limit on Windows, so instead rewrite how we decide
which templates need to be exported to be more precise. Currently we
assume that templates instantiated many times have no explicit
instantiations, but this isn't necessarily true and results also in
exporting implicit template instantiations that we don't need
to. Instead check for references to template members, as this
indicates that the template must be explicitly instantiated (as if it
weren't the template would just be implicitly instantiated on use).

Doing this reduces the number of symbols exported from clang from
66011 to 53993 (in the build configuration that I've been testing). It
also lets us get rid of the special-case handling of Type::getAs, as
its explicit instantiations are now being detected as such.

Differential Revision: https://reviews.llvm.org/D142989




More information about the All-commits mailing list