[flang][hlfir] Support polymorphic hlfir.expr values.
authorSlava Zakharin <szakharin@nvidia.com>
Tue, 18 Jul 2023 15:19:44 +0000 (08:19 -0700)
committerSlava Zakharin <szakharin@nvidia.com>
Tue, 18 Jul 2023 16:00:26 +0000 (09:00 -0700)
commitdaa8734233e781efe3ee92c5b6687f409c1fa7b2
tree64870260e0958faf04115b4a2c847c943814ae65
parenteca8b54a5f76c65a055bac05556b70c2a0ec63a1
[flang][hlfir] Support polymorphic hlfir.expr values.

This patch sets 'polymorphic' attribute of hlfir::ExprType when
the value is created from a polymorphic entity.
Memoization of such ExprType involves creating a mutable descriptor
on the stack, which is initialized (as a null box) and passed to
AllocatableApplyMold with the mold being the entity from which
the ExprType value is being created.

This patch fixes "creating polymorphic temporary" TODO and also
several cases of "'fir.convert' op invalid type conversion" error.

Reviewed By: tblah

Differential Revision: https://reviews.llvm.org/D155541
flang/include/flang/Optimizer/Builder/HLFIRTools.h
flang/include/flang/Optimizer/Builder/Runtime/Allocatable.h
flang/lib/Optimizer/Builder/Runtime/Allocatable.cpp
flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
flang/lib/Optimizer/HLFIR/Transforms/BufferizeHLFIR.cpp
flang/test/HLFIR/bufferize-poly-expr.fir [new file with mode: 0644]
flang/test/Lower/HLFIR/polymorphic-expressions.f90 [new file with mode: 0644]