[clang] [CIR] Upstream RTTI Builder & RTTI for VTable Definitions (PR #160002)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 24 13:08:16 PDT 2025


================
@@ -2171,8 +2171,53 @@ mlir::Attribute CIRGenModule::getAddrOfRTTIDescriptor(mlir::Location loc,
   if (!shouldEmitRTTI(forEh))
     return builder.getConstNullPtrAttr(builder.getUInt8PtrTy());
 
-  errorNYI(loc, "getAddrOfRTTIDescriptor");
-  return mlir::Attribute();
+  if (forEh && ty->isObjCObjectPointerType() &&
+      langOpts.ObjCRuntime.isGNUFamily()) {
+    errorNYI(loc, "getAddrOfRTTIDescriptor: Objc PtrType & Objc RT GUN");
+    return {};
+  }
+
+  return getCXXABI().getAddrOfRTTIDescriptor(loc, ty);
+}
+
+/// TODO(cir): once we have cir.module, add this as a convenience method there.
+///
+/// Look up the specified global in the module symbol table.
+///   1. If it does not exist, add a declaration of the global and return it.
+///   2. Else, the global exists but has the wrong type: return the function
+///      with a constantexpr cast to the right type.
+///   3. Finally, if the existing global is the correct declaration, return the
+///      existing global.
+cir::GlobalOp CIRGenModule::getOrInsertGlobal(
----------------
andykaylor wrote:

This looks very similar to `CIRGenModule::createOrReplaceCXXRuntimeVariable`. I don't think we need a new function.

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


More information about the cfe-commits mailing list