aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.h
diff options
context:
space:
mode:
authorRichard Smith <richard@metafoo.co.uk>2023-07-21 17:37:55 -0700
committerRichard Smith <richard@metafoo.co.uk>2023-07-21 19:07:59 -0700
commit9d525bf94b255df89587db955b5fa2d3c03c2c3e (patch)
treeea9df28908ba14a54facb966e9d077b7dadcdf9c /clang/lib/CodeGen/CodeGenModule.h
parent57bd882343f8e4cca598b6ad47da93476cffb987 (diff)
downloadllvm-9d525bf94b255df89587db955b5fa2d3c03c2c3e.zip
llvm-9d525bf94b255df89587db955b5fa2d3c03c2c3e.tar.gz
llvm-9d525bf94b255df89587db955b5fa2d3c03c2c3e.tar.bz2
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
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.h')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h
index 2d2cce8..4903f09 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -926,6 +926,13 @@ public:
// Return the function body address of the given function.
llvm::Constant *GetFunctionStart(const ValueDecl *Decl);
+ // Return whether RTTI information should be emitted for this target.
+ bool shouldEmitRTTI(bool ForEH = false) {
+ return (ForEH || getLangOpts().RTTI) && !getLangOpts().CUDAIsDevice &&
+ !(getLangOpts().OpenMP && getLangOpts().OpenMPIsTargetDevice &&
+ getTriple().isNVPTX());
+ }
+
/// Get the address of the RTTI descriptor for the given type.
llvm::Constant *GetAddrOfRTTIDescriptor(QualType Ty, bool ForEH = false);