================ @@ -592,10 +590,14 @@ void AggExprEmitter::EmitArrayInit(Address DestPtr, llvm::ArrayType *AType, // observed to be unnecessary. if (endOfInit.isValid()) Builder.CreateStore(element, endOfInit); } - - LValue elementLV = CGF.MakeAddrLValue( - Address(element, llvmElementType, elementAlign), elementType); + Address address = Address(element, llvmElementType, elementAlign); + LValue elementLV = CGF.MakeAddrLValue(address, elementType); EmitInitializationToLValue(Args[i], elementLV); + // Schedule to emit element cleanup if we see a branch in the array + // initialisation expression. + if (CGF.needsBranchCleanup(dtorKind)) + CGF.pushDestroy(BranchInExprCleanup, address, elementType, ---------------- efriedma-quic wrote:
The complexity here is basically that we'd have to reimplement mem2reg to compute the correct number of cleanups along every control-flow path. Instead, we store to an alloca, and just let the mem2reg optimization clean it up. On a similar note, because mem2reg cleans up the stores, their overhead is minimal. https://github.com/llvm/llvm-project/pull/80698 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits