[clang] [CIR] Add array new cookie support (PR #163649)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 17 14:43:34 PDT 2025


================
@@ -1977,3 +1983,72 @@ mlir::Value CIRGenItaniumCXXABI::emitDynamicCast(CIRGenFunction &cgf,
   return cgf.getBuilder().createDynCast(loc, src.getPointer(), destCIRTy,
                                         isRefCast, castInfo);
 }
+
+/************************** Array allocation cookies **************************/
+
+CharUnits CIRGenItaniumCXXABI::getArrayCookieSizeImpl(QualType elementType) {
+  // The array cookie is a size_t; pad that up to the element alignment.
+  // The cookie is actually right-justified in that space.
+  return std::max(
+      CharUnits::fromQuantity(cgm.SizeSizeInBytes),
----------------
andykaylor wrote:

```suggestion
      cgm.getSizeSize(),
```

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


More information about the cfe-commits mailing list