[flang-commits] [PATCH] D147224: [flang] move ASSOCIATED intrinsic optional TARGET handling

Jean Perier via Phabricator via flang-commits flang-commits at lists.llvm.org
Thu Mar 30 05:45:49 PDT 2023


jeanPerier created this revision.
jeanPerier added reviewers: clementval, vzakhari.
jeanPerier added a project: Flang.
Herald added subscribers: sunshaoce, mehdi_amini, jdoerfert.
Herald added a reviewer: sscalpone.
Herald added a project: All.
jeanPerier requested review of this revision.

ASSOCIATED intrinsic TARGET handling is weird for OPTIONAL, because as
opposed to other intrinsic arguments, OPTIONAL allocatable and pointers
may be absent when passed to it, and a diassociated pointer TARGET is not
the same as when TARGET is not provided. Hence, it needs custom
handling in lowering.

The handling was done late (in genIntrinsicCall, without the semantic
context), and assumed it would be possible to retrieve the optionality
aspects, but this is brittle, and hard to share with HLFIR.
Move it in CustomIntrinsicCall that is intended to deal with these
corner case.

Also avoid using fir.box<None> as the related fir.if result, and used
the correct fir.box/fir.class type for the target: using a fir.box<None>
here is risky since fir.box<None> are now meant for scalar TYPE(*), and
the TARGET may be ranked.

Move the introduction of the fir.box<None> around the runtime (when
assumed rank are supported, these will become !fir.box<!fir.array<..xNone>>).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147224

Files:
  flang/include/flang/Lower/CustomIntrinsicCall.h
  flang/lib/Lower/ConvertExpr.cpp
  flang/lib/Lower/CustomIntrinsicCall.cpp
  flang/lib/Optimizer/Builder/IntrinsicCall.cpp
  flang/test/Lower/Intrinsics/associated.f90

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147224.509631.patch
Type: text/x-patch
Size: 25532 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230330/37793502/attachment-0001.bin>


More information about the flang-commits mailing list