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
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
@@ -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
@@ -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
@@ -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+
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
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
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
@@ -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
@@ -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+
@@ -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
@@ -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
@@ -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
@@ -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);
--
@@ -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
@@ -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
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
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
23 matches
Mail list logo