27 const mlir::DataLayout &dataLayout,
29 mlir::Value &numElements, mlir::Value &allocPtr,
37 mlir::Value bytePtr = cir::CastOp::create(builder, loc, u8PtrTy,
38 cir::CastKind::bitcast, elementPtr);
40 mlir::Value negCookieSize = cir::ConstantOp::create(
41 builder, loc, cir::IntAttr::get(ptrDiffTy, -cookieSize.
getQuantity()));
42 mlir::Value allocBytePtr =
43 cir::PtrStrideOp::create(builder, loc, u8PtrTy, bytePtr, negCookieSize);
45 allocPtr = cir::CastOp::create(builder, loc, voidPtrTy,
46 cir::CastKind::bitcast, allocBytePtr);
virtual mlir::Value readArrayCookieImpl(mlir::Location loc, mlir::Value allocPtr, clang::CharUnits cookieSize, clang::CharUnits cookieAlignment, const mlir::DataLayout &dataLayout, CIRBaseBuilderTy &builder) const =0
Reads the element count from an array cookie.
void readArrayCookie(mlir::Location loc, mlir::Value elementPtr, clang::CharUnits elementAlign, const mlir::DataLayout &dataLayout, CIRBaseBuilderTy &builder, mlir::Value &numElements, mlir::Value &allocPtr, clang::CharUnits &cookieSize) const
Read the array cookie for a dynamically-allocated array whose first element is at elementPtr.