[all-commits] [llvm/llvm-project] b3bb4d: [flang][hlfir] Lower pointer and allocatable sub-p...

jeanPerier via All-commits all-commits at lists.llvm.org
Fri Jan 20 02:31:42 PST 2023


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

  Changed paths:
    M flang/include/flang/Optimizer/Builder/HLFIRTools.h
    M flang/lib/Lower/ConvertExprToHLFIR.cpp
    A flang/test/Lower/HLFIR/allocatable-and-pointer-subparts.f90

  Log Message:
  -----------
  [flang][hlfir] Lower pointer and allocatable sub-part references

The previous patches dealt with allocatable and pointer symbol
and component whole references.
This one deals with the remaining sub-part case where a dereference
must be created before applying the sub-part reference on the target.

With this patch the support to designate allocatable and pointer in
HLFIR is complete, but some use points will need to be updated to
use HLFIR designator lowering (at least allocate/deallocate statement
and whole allocatable assignment).

The partInfo.base had to be turned into an std::optional<hlfir::Entity>
because loads of allocatable/pointers do create a
fir::FortranVariableOpInterface (there is no need to). The optional part
comes from the fact that the partInfo.base is not set when creating the
partInfo, but later when visiting the designator parts.

They are three cases when dereferences must be inserted:
- The pointer/allocatable is a symbol followed by a sub-part that is not
a component ref. This is done in visit(Symbol).
- The pointer/allocatable is a component followed by a sub-part that is
not another component ref. This is done in visit(Component).
- The pointer/allocatable is followed by a component ref. This case is
special since it does not call the above "visit" but instead calls "gen"
to break the visit and generate an hlfir.designate for the component
base (since one hlfir.designate can only represent one Fortran part-ref,
and must be chained to implement a Fortran designator with several part
refs). This is done in visitComponentImpl().

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




More information about the All-commits mailing list