[all-commits] [llvm/llvm-project] 9d525b: Optimize emission of `dynamic_cast` to final classes.
Richard Smith via All-commits
all-commits at lists.llvm.org
Fri Jul 21 19:08:23 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 9d525bf94b255df89587db955b5fa2d3c03c2c3e
https://github.com/llvm/llvm-project/commit/9d525bf94b255df89587db955b5fa2d3c03c2c3e
Author: Richard Smith <richard at metafoo.co.uk>
Date: 2023-07-21 (Fri, 21 Jul 2023)
Changed paths:
M clang/include/clang/Basic/CodeGenOptions.def
M clang/include/clang/Driver/Options.td
M clang/lib/AST/ExprCXX.cpp
M clang/lib/CodeGen/CGCXXABI.h
M clang/lib/CodeGen/CGExprCXX.cpp
M clang/lib/CodeGen/CodeGenModule.cpp
M clang/lib/CodeGen/CodeGenModule.h
M clang/lib/CodeGen/ItaniumCXXABI.cpp
M clang/lib/CodeGen/MicrosoftCXXABI.cpp
M clang/lib/Driver/ToolChains/Clang.cpp
M clang/test/CodeGenCXX/dynamic-cast-always-null.cpp
A clang/test/CodeGenCXX/dynamic-cast-exact-disabled.cpp
A clang/test/CodeGenCXX/dynamic-cast-exact.cpp
A clang/test/Driver/fassume-unique-vtables.cpp
Log Message:
-----------
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
More information about the All-commits
mailing list