[all-commits] [llvm/llvm-project] 92bdc6: [flang] allow allocation of scalar TYPE(*) descrip...

jeanPerier via All-commits all-commits at lists.llvm.org
Fri Mar 31 00:14:13 PDT 2023

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 92bdc6ad01936cdb7fab389ad94d6f0ae4832021
  Author: Jean Perier <jperier at nvidia.com>
  Date:   2023-03-31 (Fri, 31 Mar 2023)

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

  Log Message:
  [flang] allow allocation of scalar TYPE(*) descriptors

Currently, it is OK to have alloca/store/and reboxed to
fir.box<!fir.array<?xnone>> and fir.class<none>, but not simple
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>.

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

More information about the All-commits mailing list