[clang] [CIR] Add support for array cleanups (PR #150499)

2025-07-29 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor closed https://github.com/llvm/llvm-project/pull/150499 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Add support for array cleanups (PR #150499)

2025-07-25 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor updated https://github.com/llvm/llvm-project/pull/150499 >From 13c8a3d27a92808485ed594d7f4f57c3597ee884 Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Wed, 23 Jul 2025 11:56:44 -0700 Subject: [PATCH 1/2] [CIR] Initial support for array cleanups This adds initial

[clang] [CIR] Add support for array cleanups (PR #150499)

2025-07-25 Thread Andy Kaylor via cfe-commits
@@ -658,10 +693,38 @@ void CIRGenFunction::emitNullabilityCheck(LValue lhs, mlir::Value rhs, /// elements void CIRGenFunction::emitDestroy(Address addr, QualType type, Destroyer *destroyer) { - if (getContext().getAsArrayType(type)) -cgm

[clang] [CIR] Add support for array cleanups (PR #150499)

2025-07-25 Thread Andy Kaylor via cfe-commits
@@ -649,6 +649,41 @@ void CIRGenFunction::emitNullabilityCheck(LValue lhs, mlir::Value rhs, assert(!cir::MissingFeatures::sanitizers()); } +/// Destroys all the elements of the given array, beginning from last to first. +/// The array cannot be zero-length. +/// +/// \param

[clang] [CIR] Add support for array cleanups (PR #150499)

2025-07-25 Thread Sirui Mu via cfe-commits
@@ -2272,6 +2272,23 @@ def CIR_ArrayCtor : CIR_ArrayInitDestroy<"array.ctor"> { }]; } +def CIR_ArrayDtor : CIR_ArrayInitDestroy<"array.dtor"> { + let summary = "Destroy array elements with C++ dtors"; + let description = [{ +Destroy each array element using the same C+

[clang] [CIR] Add support for array cleanups (PR #150499)

2025-07-25 Thread Morris Hafner via cfe-commits
https://github.com/mmha edited https://github.com/llvm/llvm-project/pull/150499 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Add support for array cleanups (PR #150499)

2025-07-25 Thread Morris Hafner via cfe-commits
https://github.com/mmha edited https://github.com/llvm/llvm-project/pull/150499 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Add support for array cleanups (PR #150499)

2025-07-25 Thread Morris Hafner via cfe-commits
@@ -249,6 +270,8 @@ void LoweringPreparePass::runOnOp(mlir::Operation *op) { lowerCastOp(cast); else if (auto unary = mlir::dyn_cast(op)) lowerUnaryOp(unary); + else if (auto arrayDtor = dyn_cast(op)) mmha wrote: We should try to keep this if/else c

[clang] [CIR] Add support for array cleanups (PR #150499)

2025-07-25 Thread Morris Hafner via cfe-commits
@@ -649,6 +649,41 @@ void CIRGenFunction::emitNullabilityCheck(LValue lhs, mlir::Value rhs, assert(!cir::MissingFeatures::sanitizers()); } +/// Destroys all the elements of the given array, beginning from last to first. +/// The array cannot be zero-length. +/// +/// \param

[clang] [CIR] Add support for array cleanups (PR #150499)

2025-07-25 Thread Morris Hafner via cfe-commits
@@ -658,10 +693,38 @@ void CIRGenFunction::emitNullabilityCheck(LValue lhs, mlir::Value rhs, /// elements void CIRGenFunction::emitDestroy(Address addr, QualType type, Destroyer *destroyer) { - if (getContext().getAsArrayType(type)) -cgm

[clang] [CIR] Add support for array cleanups (PR #150499)

2025-07-25 Thread Morris Hafner via cfe-commits
@@ -658,10 +693,38 @@ void CIRGenFunction::emitNullabilityCheck(LValue lhs, mlir::Value rhs, /// elements void CIRGenFunction::emitDestroy(Address addr, QualType type, Destroyer *destroyer) { - if (getContext().getAsArrayType(type)) -cgm

[clang] [CIR] Add support for array cleanups (PR #150499)

2025-07-25 Thread Morris Hafner via cfe-commits
@@ -213,15 +215,23 @@ static void lowerArrayDtorCtorIntoLoop(cir::CIRBaseBuilderTy &builder, op->walk([&](cir::CallOp c) { ctorCall = c; }); assert(ctorCall && "expected ctor call"); -auto one = builder.create( -loc, ptrDiffTy, cir::IntAttr

[clang] [CIR] Add support for array cleanups (PR #150499)

2025-07-25 Thread Morris Hafner via cfe-commits
https://github.com/mmha commented: Just a couple of nits https://github.com/llvm/llvm-project/pull/150499 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CIR] Add support for array cleanups (PR #150499)

2025-07-25 Thread Henrich Lauko via cfe-commits
@@ -213,15 +215,23 @@ static void lowerArrayDtorCtorIntoLoop(cir::CIRBaseBuilderTy &builder, op->walk([&](cir::CallOp c) { ctorCall = c; }); assert(ctorCall && "expected ctor call"); -auto one = builder.create( -loc, ptrDiffTy, cir::IntAttr

[clang] [CIR] Add support for array cleanups (PR #150499)

2025-07-25 Thread Henrich Lauko via cfe-commits
@@ -2272,6 +2272,23 @@ def CIR_ArrayCtor : CIR_ArrayInitDestroy<"array.ctor"> { }]; } +def CIR_ArrayDtor : CIR_ArrayInitDestroy<"array.dtor"> { + let summary = "Destroy array elements with C++ dtors"; + let description = [{ +Destroy each array element using the same C+

[clang] [CIR] Add support for array cleanups (PR #150499)

2025-07-25 Thread Henrich Lauko via cfe-commits
@@ -658,10 +693,38 @@ void CIRGenFunction::emitNullabilityCheck(LValue lhs, mlir::Value rhs, /// elements void CIRGenFunction::emitDestroy(Address addr, QualType type, Destroyer *destroyer) { - if (getContext().getAsArrayType(type)) -cgm

[clang] [CIR] Add support for array cleanups (PR #150499)

2025-07-25 Thread Henrich Lauko via cfe-commits
@@ -230,6 +240,17 @@ static void lowerArrayDtorCtorIntoLoop(cir::CIRBaseBuilderTy &builder, op->erase(); } +void LoweringPreparePass::lowerArrayDtor(ArrayDtor op) { + CIRBaseBuilderTy builder(getContext()); + builder.setInsertionPointAfter(op.getOperation()); + + mlir::T

[clang] [CIR] Add support for array cleanups (PR #150499)

2025-07-25 Thread Henrich Lauko via cfe-commits
@@ -649,6 +649,41 @@ void CIRGenFunction::emitNullabilityCheck(LValue lhs, mlir::Value rhs, assert(!cir::MissingFeatures::sanitizers()); } +/// Destroys all the elements of the given array, beginning from last to first. +/// The array cannot be zero-length. +/// +/// \param

[clang] [CIR] Add support for array cleanups (PR #150499)

2025-07-25 Thread Henrich Lauko via cfe-commits
@@ -29,6 +29,7 @@ struct LoweringPreparePass : public LoweringPrepareBase { void runOnOp(mlir::Operation *op); void lowerCastOp(cir::CastOp op); void lowerUnaryOp(cir::UnaryOp op); + void lowerArrayDtor(ArrayDtor op); void lowerArrayCtor(ArrayCtor op); --

[clang] [CIR] Add support for array cleanups (PR #150499)

2025-07-25 Thread Henrich Lauko via cfe-commits
@@ -649,6 +649,41 @@ void CIRGenFunction::emitNullabilityCheck(LValue lhs, mlir::Value rhs, assert(!cir::MissingFeatures::sanitizers()); } +/// Destroys all the elements of the given array, beginning from last to first. +/// The array cannot be zero-length. +/// +/// \param

[clang] [CIR] Add support for array cleanups (PR #150499)

2025-07-25 Thread Henrich Lauko via cfe-commits
@@ -213,15 +215,23 @@ static void lowerArrayDtorCtorIntoLoop(cir::CIRBaseBuilderTy &builder, op->walk([&](cir::CallOp c) { ctorCall = c; }); assert(ctorCall && "expected ctor call"); -auto one = builder.create( -loc, ptrDiffTy, cir::IntAttr

[clang] [CIR] Add support for array cleanups (PR #150499)

2025-07-24 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang Author: Andy Kaylor (andykaylor) Changes This adds support for array cleanups, including the ArrayDtor op. --- Patch is 20.81 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/150499.diff 8 Files Affect

[clang] [CIR] Add support for array cleanups (PR #150499)

2025-07-24 Thread Andy Kaylor via cfe-commits
https://github.com/andykaylor created https://github.com/llvm/llvm-project/pull/150499 This adds support for array cleanups, including the ArrayDtor op. >From 13c8a3d27a92808485ed594d7f4f57c3597ee884 Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Wed, 23 Jul 2025 11:56:44 -0700 Subject: [PAT