================ @@ -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<cir::ConstantOp>( - loc, ptrDiffTy, cir::IntAttr::get(ptrDiffTy, 1)); - - ctorCall->moveAfter(one); - ctorCall->setOperand(0, currentElement); - - // Advance pointer and store them to temporary variable - auto nextElement = - builder.create<cir::PtrStrideOp>(loc, eltTy, currentElement, one); + // Array elements get constructed in order but destructed in reverse. + cir::PtrStrideOp nextElement; + if (isCtor) { + mlir::Value stride = builder.getUnsignedInt(loc, 1, sizeTypeSize); + ctorCall->moveBefore(stride.getDefiningOp()); + ctorCall->setOperand(0, currentElement); + nextElement = builder.create<cir::PtrStrideOp>( + loc, eltTy, currentElement, stride); ---------------- xlauko wrote:
```suggestion nextElement = cir::PtrStrideOp::create( builder, loc, eltTy, currentElement, stride); ``` 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