5 Commits

Author SHA1 Message Date
Dmitry Chernenkov
9a370a1e58 Reland "For #64088: mark vtable as used if we might emit a reference to it."
This reverts commit 3b34d69ac7a643742364be3591b324ddd14ef9aa.
2023-08-02 08:52:00 +00:00
Dmitry Chernenkov
3b34d69ac7 Revert "For #64088: mark vtable as used if we might emit a reference to it."
This reverts commit b6847edfc235829b37dd6d734ef5bbfa0a58b6fc.
2023-07-28 10:49:53 +00:00
Richard Smith
b6847edfc2 For #64088: mark vtable as used if we might emit a reference to it. 2023-07-25 14:42:10 -07:00
Richard Smith
6cf8179661 Don't perform dynamic_cast optimization at -O0.
It seems preferable to avoid this optimization under -O0, and we're not
set up to emit speculative references to vtables at -O0 in general
anyway.

For #64088.
2023-07-24 22:24:33 -07:00
Richard Smith
9d525bf94b Optimize emission of dynamic_cast to final classes.
- When the destination is a final class type that does not derive from
  the source type, the cast always fails and is now emitted as a null
  pointer or call to __cxa_bad_cast.

- When the destination is a final class type that does derive from the
  source type, emit a direct comparison against the corresponding base
  class vptr value(s). There may be more than one such value in the case
  of multiple inheritance; check them all.

For now, this is supported only for the Itanium ABI. I expect the same thing is
possible for the MS ABI too, but I don't know what guarantees are made about
vfptr uniqueness.

Reviewed By: rjmccall

Differential Revision: https://reviews.llvm.org/D154658
2023-07-21 19:07:59 -07:00