https://github.com/AmrDeveloper updated https://github.com/llvm/llvm-project/pull/172861
>From c2364b0b8a140253dda396e2c6dca5d0b6276840 Mon Sep 17 00:00:00 2001 From: Amr Hesham <[email protected]> Date: Thu, 18 Dec 2025 15:43:44 +0100 Subject: [PATCH] [CIR] Mark sizeof & alignof as NYI for scalable Vector --- clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp | 13 +++++++++ .../CIR/CodeGen/unary-expr-or-type-trait.cpp | 28 +++++++++++++------ 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp index 60884aefbfb1f..1954e20ef9b25 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp @@ -2559,6 +2559,19 @@ mlir::Value ScalarExprEmitter::VisitUnaryExprOrTypeTraitExpr( return builder.getConstant( loc, cir::IntAttr::get(cgf.cgm.uInt64Ty, llvm::APSInt(llvm::APInt(64, 1), true))); + } else if (e->getKind() == UETT_VectorElements) { + auto vecTy = cast<cir::VectorType>(convertType(e->getTypeOfArgument())); + if (vecTy.getIsScalable()) { + cgf.getCIRGenModule().errorNYI( + e->getSourceRange(), + "VisitUnaryExprOrTypeTraitExpr: sizeOf scalable vector"); + return builder.getConstant( + loc, cir::IntAttr::get(cgf.cgm.uInt64Ty, + e->EvaluateKnownConstInt(cgf.getContext()))); + } + + return builder.getConstant( + loc, cir::IntAttr::get(cgf.cgm.uInt64Ty, vecTy.getSize())); } return builder.getConstant( diff --git a/clang/test/CIR/CodeGen/unary-expr-or-type-trait.cpp b/clang/test/CIR/CodeGen/unary-expr-or-type-trait.cpp index 071c52a0918e3..3669c45059bd4 100644 --- a/clang/test/CIR/CodeGen/unary-expr-or-type-trait.cpp +++ b/clang/test/CIR/CodeGen/unary-expr-or-type-trait.cpp @@ -7,20 +7,26 @@ void foo() { unsigned long i = sizeof(int); // CHECK: cir.const #cir.int<4> : !u64i - unsigned long l = sizeof(long); + unsigned long l = sizeof(long); // CHECK: cir.const #cir.int<8> : !u64i - unsigned long f = sizeof(float); + unsigned long f = sizeof(float); // CHECK: cir.const #cir.int<4> : !u64i - unsigned long d = sizeof(double); + unsigned long d = sizeof(double); // CHECK: cir.const #cir.int<8> : !u64i unsigned long iArr = sizeof(int[5]); // CHECK: cir.const #cir.int<20> : !u64i - unsigned long dArr = sizeof(double[5]); + unsigned long dArr = sizeof(double[5]); // CHECK: cir.const #cir.int<40> : !u64i + + unsigned long vi4 = sizeof(int __attribute__((vector_size(4)))); + // CHECK: cir.const #cir.int<4> : !u64i + + unsigned long evi4 = sizeof(int __attribute__((ext_vector_type(4)))); + // CHECK: cir.const #cir.int<16> : !u64i } void foo2() { @@ -30,18 +36,24 @@ void foo2() { unsigned long i = alignof(int); // CHECK: cir.const #cir.int<4> : !u64i - unsigned long l = alignof(long); + unsigned long l = alignof(long); // CHECK: cir.const #cir.int<8> : !u64i - unsigned long f = alignof(float); + unsigned long f = alignof(float); // CHECK: cir.const #cir.int<4> : !u64i - unsigned long d = alignof(double); + unsigned long d = alignof(double); // CHECK: cir.const #cir.int<8> : !u64i unsigned long iArr = alignof(int[5]); // CHECK: cir.const #cir.int<4> : !u64i - unsigned long dArr = alignof(double[5]); + unsigned long dArr = alignof(double[5]); // CHECK: cir.const #cir.int<8> : !u64i + + unsigned long vi4 = alignof(int __attribute__((vector_size(4)))); + // CHECK: cir.const #cir.int<4> : !u64i + + unsigned long evi4 = alignof(int __attribute__((ext_vector_type(4)))); + // CHECK: cir.const #cir.int<16> : !u64i } _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
