================
@@ -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),
+      cgm.getASTContext().getPreferredTypeAlignInChars(elementType));
+}
+
+Address CIRGenItaniumCXXABI::initializeArrayCookie(CIRGenFunction &cgf,
+                                                   Address newPtr,
+                                                   mlir::Value numElements,
+                                                   const CXXNewExpr *e,
+                                                   QualType elementType) {
+  assert(requiresArrayCookie(e));
+
+  // TODO: Get the address space when sanitizer support is implemented.
----------------
andykaylor wrote:

```suggestion
  // TODO: When sanitizer support is implemented, we'll need to
  // get the address space from `newPtr`.
  assert(!cir::MissingFeatures::addressSpace());
  assert(!cir::MissingFeatures::sanitizers());
```
It took me a minute to see what this had to do with the sanitizer. When the 
sanitizer check is implemented, it will only check the cookie for address space 
zero.

https://github.com/llvm/llvm-project/pull/163649
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to