[all-commits] [llvm/llvm-project] be68a6: [flang] Error detection/avoidance for TRANSFER wit...

Peter Klausler via All-commits all-commits at lists.llvm.org
Wed Jul 13 16:51:15 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: be68a6adfba29b275272cb36e606bc0cb08518b3
      https://github.com/llvm/llvm-project/commit/be68a6adfba29b275272cb36e606bc0cb08518b3
  Author: Peter Klausler <pklausler at nvidia.com>
  Date:   2022-07-13 (Wed, 13 Jul 2022)

  Changed paths:
    M flang/lib/Evaluate/shape.cpp
    M flang/runtime/misc-intrinsic.cpp

  Log Message:
  -----------
  [flang] Error detection/avoidance for TRANSFER with empty MOLD= type

When MOLD= is an array and there is no SIZE= in a call to TRANSFER(),
the size of an element of the MOLD= is used as the denominator in a
division to establish the extent of the vector result.  When the
total storage size of the SOURCE= is known to be zero, the result is
empty and no division is needed.

To avoid a division by zero at runtime, we need to check for a zero-sized
MOLD= element type when the storage size of SOURCE= is nonzero and there
is no SIZE=.  Further, in the compilation-time rewriting of calls to
SHAPE(TRANSFER(...)) and SIZE(TRANSFER(...)) for constant folding and
simplification purposes, we can't replace the call with an arithmetic
element count expression when the storage size of SOURCE= is not known
to be zero and the element size of MOLD= is not known to be nonzero at
compilation time.

These changes mostly affect tests using a MOLD= argument that is an
assumed-length character.

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




More information about the All-commits mailing list