27 const mlir::DataLayout &dataLayout,
29 mlir::Value &numElements, mlir::Value &allocPtr,
31 mlir::ptr::MemorySpaceAttrInterface addrSpace =
32 mlir::cast<cir::PointerType>(elementPtr.getType()).getAddrSpace();
39 mlir::Value bytePtr = cir::CastOp::create(builder, loc, u8PtrTy,
40 cir::CastKind::bitcast, elementPtr);
42 mlir::Value negCookieSize = cir::ConstantOp::create(
43 builder, loc, cir::IntAttr::get(ptrDiffTy, -cookieSize.
getQuantity()));
44 mlir::Value allocBytePtr =
45 cir::PtrStrideOp::create(builder, loc, u8PtrTy, bytePtr, negCookieSize);
47 allocPtr = cir::CastOp::create(builder, loc, voidPtrTy,
48 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.