[flang-commits] [flang] [flang][hlfir] Resolve shape_of users when bufferizing eval_in_mem (PR #201214)
via flang-commits
flang-commits at lists.llvm.org
Wed Jun 3 01:52:48 PDT 2026
================
@@ -638,16 +638,26 @@ tryUsingAssignLhsDirectly(hlfir::EvaluateInMemoryOp evalInMem,
mlir::Location loc = evalInMem.getLoc();
hlfir::DestroyOp destroy;
hlfir::AssignOp assign;
- for (auto user : llvm::enumerate(evalInMem->getUsers())) {
- if (user.index() > 2)
+ // A hlfir.shape_of of the result only needs the shape, which the
+ // eval_in_mem already carries as an operand, so it can be redirected to that
+ // operand and does not prevent the in-place rewrite below. Any other user
+ // would dangle when the eval_in_mem is erased, so bail out on it.
----------------
jeanPerier wrote:
nit: rephrase to something like:
"To evaluate directly the hlfir.eval_in_mem into the LHS, the result must only be used in the assignment, in a destroy, and in hlfir.shape_of (which can be replaced by direct use of the shape operand)".
https://github.com/llvm/llvm-project/pull/201214
More information about the flang-commits
mailing list