[flang-commits] [PATCH] D141832: [flang][hlfir] Add move semantics to hlfir.as_expr.
Jean Perier via Phabricator via flang-commits
flang-commits at lists.llvm.org
Mon Jan 16 02:21:46 PST 2023
jeanPerier created this revision.
jeanPerier added reviewers: clementval, PeteSteinfeld, vzakhari.
jeanPerier added a project: Flang.
Herald added subscribers: sunshaoce, mehdi_amini, jdoerfert.
Herald added a project: All.
jeanPerier requested review of this revision.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D141832
Files:
flang/include/flang/Optimizer/HLFIR/HLFIROps.td
flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
flang/lib/Optimizer/HLFIR/Transforms/BufferizeHLFIR.cpp
flang/test/HLFIR/as_expr-codegen.fir
flang/test/HLFIR/as_expr.fir
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141832.489471.patch
Type: text/x-patch
Size: 6798 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230116/ad2d2b21/attachment-0001.bin>
More information about the flang-commits
mailing list