[all-commits] [llvm/llvm-project] 449823: [flang] Fixed IsContiguous check for slices of par...

Slava Zakharin via All-commits all-commits at lists.llvm.org
Wed Aug 2 10:45:18 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 449823e202b421a50bd5ee64b6a4ffbee766fae5
      https://github.com/llvm/llvm-project/commit/449823e202b421a50bd5ee64b6a4ffbee766fae5
  Author: Slava Zakharin <szakharin at nvidia.com>
  Date:   2023-08-02 (Wed, 02 Aug 2023)

  Changed paths:
    M flang/lib/Evaluate/check-expression.cpp
    M flang/test/Evaluate/folding09.f90
    A flang/test/Lower/HLFIR/designators-parameter-array-slice.f90

  Log Message:
  -----------
  [flang] Fixed IsContiguous check for slices of parameter arrays.

A section of a parameter array may be non-contiguous,
so the current !IsVariable(expr) check is too optimistic
to claim contiguity.

This patch fixes issues with incorrect hlfir.designate op generated
during lowering: the lowering queries IsContiguous to decide whether
to use fir.box<fir.array> or plain fir.ref<fir.array> to represent
the designator result.

Reviewed By: klausler

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


  Commit: 315939fd61cc346f699a2e4468c7880d48d4eb5f
      https://github.com/llvm/llvm-project/commit/315939fd61cc346f699a2e4468c7880d48d4eb5f
  Author: Slava Zakharin <szakharin at nvidia.com>
  Date:   2023-08-02 (Wed, 02 Aug 2023)

  Changed paths:
    M flang/lib/Optimizer/CodeGen/CodeGen.cpp
    A flang/test/Fir/embox-char.fir

  Log Message:
  -----------
  [flang] Fixed slice offset computation in XEmbox codegen.

For character type with unknown length we end up generating
a GEP with the base type `llvm.ptr<i[width]>`. The GEP produces
the address of the first element of the slice, and it should be
using the offset computed in the number of characters, while we were
providing the offset in bytes.

Simple reproducer fails with and w/o HLFIR:
```
program test
  integer,parameter :: ck = 4
  character(:,ck),allocatable :: res(:,:)
  allocate(character(3,ck) :: res(2,2))
  res(1,1) = ck_'111'
  res(1,2) = ck_'222'
  res(2,1) = ck_'333'
  res(2,2) = ck_'444'
  call check(res)
contains
  subroutine check(res)
    character(:,ck),allocatable :: res(:,:)
    print *, res(2,:)
  end subroutine check
end program test
```

Reviewed By: clementval

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


Compare: https://github.com/llvm/llvm-project/compare/926f85db98aa...315939fd61cc


More information about the All-commits mailing list