[flang-commits] [flang] [flang][hlfir] Fixed some finalization/deallocation issues. (PR #67047)

Slava Zakharin via flang-commits flang-commits at lists.llvm.org
Fri Sep 22 09:25:36 PDT 2023


================
@@ -1237,10 +1237,28 @@ void hlfir::AssociateOp::build(mlir::OpBuilder &builder,
 void hlfir::EndAssociateOp::build(mlir::OpBuilder &builder,
                                   mlir::OperationState &result,
                                   hlfir::AssociateOp associate) {
-  return build(builder, result, associate.getFirBase(),
+  mlir::Value hlfirBase = associate.getBase();
+  mlir::Value firBase = associate.getFirBase();
+  // If EndAssociateOp may need to initiate the deallocation
+  // of allocatable components, it has to have access to the variable
+  // definition, so we cannot use the FIR base as the operand.
----------------
vzakhari wrote:

I believe this would introduce redundant `BoxAddr` in cases where finalization/deallocation is not needed, i.e. where we could just use the raw pointer for `free`.  I am not sure if this will matter at all for performance, but I decided to be conservative here.

https://github.com/llvm/llvm-project/pull/67047


More information about the flang-commits mailing list