[clang] [CIR] Make vtable entries a layout-independent type (PR #248772)

Henrich Lauko via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 4 07:48:43 PST 2026


================
@@ -1285,6 +1284,21 @@ mlir::Value CIRAttrToValue::castGlobalAddrToType(mlir::Value addr,
   if (mlir::isa<cir::VPtrType>(attrType))
     return addr;
 
+  // An entry of a vtable is a pointer in the default address space, like the
+  // pointer to the function it stands for was before, whatever the address
+  // space of the function. (The entries of a relative layout vtable are not
+  // built from an address.)
+  if (auto entryTy = mlir::dyn_cast<cir::VTableEntryType>(attrType)) {
----------------
xlauko wrote:

Classic codegen puts vtable entries in the globals address space (`ptr addrspace(1)` on AMDGPU and SPIR-V), while this casts them to address space 0. CIR already did this before this patch. Now that entries have their own type, could they lower to `GlobalsInt8PtrTy` like classic codegen (`CGVTables.cpp:906`)?

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


More information about the cfe-commits mailing list