From 8acdcf4016876d122733991561be706b64026e73 Mon Sep 17 00:00:00 2001 From: Alex Voicu Date: Wed, 19 Jul 2023 18:04:31 +0100 Subject: [Clang][CodeGen]`vtable`, `typeinfo` et al. are globals All data structures and values associated with handling virtual functions / inheritance, as well as RTTI, are globals and thus can only reside in the global address space. This was not taken fully taken into account because for most targets, global & generic appear to coincide. However, on targets where global & generic ASes differ (e.g. AMDGPU), this was problematic, since it led to the generation of invalid bitcasts (which would trigger asserts in Debug) and less than optimal code. This patch does two things: ensures that vtables, vptrs, vtts, typeinfo are generated in the right AS, and populated accordingly; removes a bunch of bitcasts which look like left-overs from the typed ptr era. Reviewed By: yxsamliu Differential Revision: https://reviews.llvm.org/D153092 --- clang/lib/CodeGen/CodeGenModule.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 7dbe9d6c9ea0..2d0d40b19948 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -7155,7 +7155,7 @@ llvm::Constant *CodeGenModule::GetAddrOfRTTIDescriptor(QualType Ty, if ((!ForEH && !getLangOpts().RTTI) || getLangOpts().CUDAIsDevice || (getLangOpts().OpenMP && getLangOpts().OpenMPIsTargetDevice && getTriple().isNVPTX())) - return llvm::Constant::getNullValue(Int8PtrTy); + return llvm::Constant::getNullValue(GlobalsInt8PtrTy); if (ForEH && Ty->isObjCObjectPointerType() && LangOpts.ObjCRuntime.isGNUFamily()) -- cgit v1.2.3