[all-commits] [llvm/llvm-project] c373ee: [flang][hlfir] Add move semantics to hlfir.as_expr.

jeanPerier via All-commits all-commits at lists.llvm.org
Tue Jan 17 02:24:08 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c373eeb1c5cc99cad338af083b106c27d2779a53
      https://github.com/llvm/llvm-project/commit/c373eeb1c5cc99cad338af083b106c27d2779a53
  Author: Jean Perier <jperier at nvidia.com>
  Date:   2023-01-17 (Tue, 17 Jan 2023)

  Changed paths:
    M flang/include/flang/Optimizer/HLFIR/HLFIROps.td
    M flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
    M flang/lib/Optimizer/HLFIR/Transforms/BufferizeHLFIR.cpp
    M flang/test/HLFIR/as_expr-codegen.fir
    M flang/test/HLFIR/as_expr.fir

  Log Message:
  -----------
  [flang][hlfir] Add move semantics to hlfir.as_expr.

hlfir.as_expr allows turning an array, character, or derived type
variable into a value when it the usage require an hlfir.expr (e.g,
when returning the element value inside and hlfir.elemental).

The default implementation of this operation in bufferization is to
make a copy of the variable into a temporary buffer.
This adds a time and memory overhead in cases where such copy is not
needed because the variable is already a temporary that was created
in lowering to compute the expression value, and the "as_expr" is
the sole usage of the variable.

This is for instance the case for many transformational intrinsics
that do not have hlfir.expr operation (at least for now, but some may
never benefit from having one) and must be implemented "on memory"
in lowering.

This patch adds a way to "move" the variable storage along its value.
It allows the bufferization to re-use the variable storage for the
hlfir.expr created by hlfir.as_expr, and in exchange, the
responsibility of deallocating the buffer (if the variable was heap
allocated) if passed along to the hlfir.expr, and will need to be
done after the last hlfir.expr usage.

Differential Revision: https://reviews.llvm.org/D141832




More information about the All-commits mailing list