================ @@ -3182,34 +3182,98 @@ class ArrayType : public Type, public llvm::FoldingSetNode { /// For example, the canonical type for 'int A[4 + 4*100]' is a /// ConstantArrayType where the element type is 'int' and the size is 404. class ConstantArrayType final - : public ArrayType, - private llvm::TrailingObjects<ConstantArrayType, const Expr *> { + : public ArrayType { friend class ASTContext; // ASTContext creates these. - friend TrailingObjects; - llvm::APInt Size; // Allows us to unique the type. + struct ExternalSize { + ExternalSize(const llvm::APInt &Sz, const Expr *SE) + : Size(Sz), SizeExpr(SE) {} + llvm::APInt Size; // Allows us to unique the type. + const Expr *SizeExpr; + }; + struct InlineSize { + InlineSize(uint64_t TSz, uint64_t Sz) : ByteWidth(TSz), Size(Sz) {} + uint64_t ByteWidth : 4; + uint64_t Size : 60; + }; + union { + struct InlineSize I; + ExternalSize *SizePtr; + }; - ConstantArrayType(QualType et, QualType can, const llvm::APInt &size, - const Expr *sz, ArraySizeModifier sm, unsigned tq) - : ArrayType(ConstantArray, et, can, sm, tq, sz), Size(size) { - ConstantArrayTypeBits.HasStoredSizeExpr = sz != nullptr; - if (ConstantArrayTypeBits.HasStoredSizeExpr) { - assert(!can.isNull() && "canonical constant array should not have size"); - *getTrailingObjects<const Expr*>() = sz; - } + ConstantArrayType(QualType Et, QualType Can, uint64_t Width, uint64_t Sz, + ArraySizeModifier SM, unsigned TQ) + : ArrayType(ConstantArray, Et, Can, SM, TQ, nullptr), I(Width / 8, Sz) { + ConstantArrayTypeBits.HasExternalSize = false; + assert(Sz < 0x0FFFFFFFFFFFFFFF && "Size must fit in 60 bits"); + assert(Width < 0xFF && "Type width must fit in 8 bits"); ---------------- efriedma-quic wrote:
You divide by 8, then truncate the bits above the lowest 4... so the max value you can actually store is 15*8==120. https://github.com/llvm/llvm-project/pull/85716 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits