[all-commits] [llvm/llvm-project] 5e5176: [flang] Don't fold operation when shapes differ

Leandro Lupori via All-commits all-commits at lists.llvm.org
Fri Mar 31 05:13:44 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 5e5176adb1834b215412a90acadfa0d14c18de8f
      https://github.com/llvm/llvm-project/commit/5e5176adb1834b215412a90acadfa0d14c18de8f
  Author: Leandro Lupori <leandro.lupori at linaro.org>
  Date:   2023-03-31 (Fri, 31 Mar 2023)

  Changed paths:
    M flang/lib/Evaluate/fold-implementation.h
    M flang/test/Evaluate/rewrite01.f90
    M flang/test/Lower/array-expression.f90

  Log Message:
  -----------
  [flang] Don't fold operation when shapes differ

When folding a binary operation between two array constructors, it
is necessary to check if each value contained in the left operand
has the same rank and shape as the one on the right.
Otherwise, lowering would end up with an operation between values
of different ranks/shapes, which could result in a crash.

For instance, the following code was crashing the compiler:
integer :: x(4), y(2, 2), z(4)

z = (/x/) + (/y/)

Fixes #60229

Reviewed By: klausler, jeanPerier

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




More information about the All-commits mailing list