[clang] [clang] Check inline defs when emitting speculative vtable (PR #100785)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 14 11:09:07 PDT 2024


https://github.com/efriedma-quic approved this pull request.

LGTM... but please consider submitting a patch to expand the explanation in ItaniumCXXABI::canSpeculativelyEmitVTableAsBaseClass.

If I'm following correctly, the function in question is, in fact, odr-used in the translation unit in question: constructing an object is an odr-use all virtual members.  So we could emit it if we wanted to.  But we currently don't because we emit inline functions lazily, and the lazy emission doesn't account for vtables.  If we don't emit it, we can't reliably refer to it.

This applies equally to a function where the initial declaration is inline, and a function where the initial declaration is not inline, but a later definition is; this fix makes sure we treat both situations equivalently.

It might be worth trying to sort out this situation at some point; the inability to emit these functions seems like this makes devirtualization significantly weaker.

https://github.com/llvm/llvm-project/pull/100785


More information about the cfe-commits mailing list