[all-commits] [llvm/llvm-project] b9031d: [flang] Ensure pointer components are always estab...

jeanPerier via All-commits all-commits at lists.llvm.org
Tue May 9 09:27:03 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b9031d327929c160293f38b0afbf7facec0f591c
      https://github.com/llvm/llvm-project/commit/b9031d327929c160293f38b0afbf7facec0f591c
  Author: Jean Perier <jperier at nvidia.com>
  Date:   2023-05-09 (Tue, 09 May 2023)

  Changed paths:
    M flang/lib/Lower/ConvertVariable.cpp
    M flang/test/Lower/call-copy-in-out.f90
    A flang/test/Lower/pointer-default-init.f90

  Log Message:
  -----------
  [flang] Ensure pointer components are always established

Follow up of https://reviews.llvm.org/D149979 for lowering.

In Fortran, it is possible to assign a pointer to another pointer
with an undefined association status.
When using the runtime do to none trivial pointer association, if the
descriptor are garbage, the runtime cannot safely detect that it has
a garbage descriptor, and it cannot safely know the descriptor size
leading to undefined behavior.
Another reason to initialize descriptor of pointers is to record any
non deferred length parameter value.
Hence, although this is not required by Fortran, f18 always initialize
pointers to NULL().
This was already done in lowering for whole pointer object, but not for
pointer components.

This patch uses the related semantics patch that updated
derivedTypeSpe::HasDefaultInitialization to ensure pointer components
of local and global object are always initialized.

It adds tests to ensure that allocation of such derived type uses the
runtime to ensure the storage is initialized, and that structure
constructors are setting the descriptor component to NULL() if no
initial target is given.

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




More information about the All-commits mailing list