<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/66909>66909</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            `exclude_from_explicit_instantiation` doesn't seem to exclude virtual methods, causing problems after 84216d1
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:codegen
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          zmodem
      </td>
    </tr>
</table>

<pre>
    Consider:

```
C:\src\llvm-project>cat \src\temp\a.cc
template <typename>
struct Fruit {
 __attribute((exclude_from_explicit_instantiation)) Fruit() {}

 virtual void __attribute((exclude_from_explicit_instantiation)) draw() {}
};

extern template struct Fruit<int>;

int main() {
 Fruit<int> f;
  return 0;
}

C:\src\llvm-project>build\bin\clang-cl \src\temp\a.cc -fuse-ld=lld
lld-link: error: undefined symbol: public: virtual void __cdecl Fruit<int>::draw(void)
>>> referenced by c:\src\temp\a-6ec007.obj:(const Fruit<int>::`vftable')
clang-cl: error: linker command failed with exit code 1 (use -v to see invocation)
```

It seems that despite the `exclude_from_explicit_instantiation` attribute on `Fruit<>::draw`, the explicit instantiation decl prevents the definition from being emitted when referenced by the vtable. Instead the definition of `Fruit<>::draw` will only get emitted once there's an explicit instantiation definition.

However, after 84216d1 that stopped working across DLL boundaries, since the method will no longer be dllimport/export.

It seems the exclusion from explicit instantiation is not working completely.



</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVd2O2joQfhpzMwIZB_JzkYttKDqV-g4rx56AW8eO7Am7nKc_crKksN2tKh0pMsHj-fm-bzyRMZqTQ6zZ_gvbH1ZypLMP9b-919ivWq-vdeNdNBoDy54YPzB-W3P-9kx_m2TeNzEotm-svfTrIfgfqIhlX5UkWGyE_cD2jdwoNXumDSsJgWUNXQd0skeWfZ2NkcKoCI5hNASs-DLvwvOzJAqmHQmZKJko8VXZUeN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