[flang-commits] [PATCH] D147237: [flang] allow allocation of scalar TYPE(*) descriptors

Jean Perier via Phabricator via flang-commits flang-commits at lists.llvm.org
Thu Mar 30 07:58:08 PDT 2023


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

Currently, it is OK to have alloca/store/and reboxed to
fir.box<!fir.array<?xnone>> and fir.class<none>, but not simple
fir.box<none>.
This restriction is a legacy from a time where it was thought TYPE(*)
descriptor size would not be statically known, but the way polymorphism
was implemented actually allows knowing its size: a scalar descriptor
with an addendum (in case it is a derived type).
Note that this assumes fir.box<none> are always scalars. There are currently
a few cast from ranked descriptor to !fir.box<None> around runtime calls.
These are simple casts before runtime call, so there are no load/stores
to the resulting fir.box<None> and it is OK.
When assumed rank are supported, some legacy usage of fir.box<none> as the "any"
descriptor in the runtime interface will be replaced to avoid any issues there.

This change will be required to fix an undefined behavior with NULL() that
requires allocation of a fir.box<None>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147237

Files:
  flang/include/flang/Optimizer/Dialect/FIRType.h
  flang/lib/Optimizer/Dialect/FIRType.cpp
  flang/test/Fir/alloc.fir
  flang/test/Fir/convert-to-llvm.fir
  flang/test/Fir/rebox.fir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147237.509682.patch
Type: text/x-patch
Size: 6728 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230330/6b20c04b/attachment-0001.bin>


More information about the flang-commits mailing list