[all-commits] [llvm/llvm-project] ffe402: [flang] Turn on use-desc-for-alloc by default

jeanPerier via All-commits all-commits at lists.llvm.org
Mon Apr 24 00:08:54 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ffe4029d92da0e4377622e5f83d6854eab6f789e
      https://github.com/llvm/llvm-project/commit/ffe4029d92da0e4377622e5f83d6854eab6f789e
  Author: Jean Perier <jperier at nvidia.com>
  Date:   2023-04-24 (Mon, 24 Apr 2023)

  Changed paths:
    M flang/lib/Lower/Allocatable.cpp
    M flang/test/Lower/Intrinsics/c_loc.f90
    M flang/test/Lower/Intrinsics/iall.f90
    M flang/test/Lower/Intrinsics/iany.f90
    M flang/test/Lower/Intrinsics/iparity.f90
    M flang/test/Lower/Intrinsics/len.f90
    M flang/test/Lower/Intrinsics/loc.f90
    M flang/test/Lower/Intrinsics/move_alloc.f90
    M flang/test/Lower/Intrinsics/product.f90
    M flang/test/Lower/Intrinsics/sum.f90
    M flang/test/Lower/Intrinsics/system_clock.f90
    M flang/test/Lower/OpenACC/acc-data-operands.f90
    M flang/test/Lower/OpenMP/atomic-read.f90
    M flang/test/Lower/OpenMP/atomic-update.f90
    M flang/test/Lower/OpenMP/atomic-write.f90
    M flang/test/Lower/OpenMP/parallel-private-clause.f90
    M flang/test/Lower/allocatable-assignment.f90
    M flang/test/Lower/allocatable-polymorphic.f90
    M flang/test/Lower/allocatables.f90
    M flang/test/Lower/allocate-mold.f90
    M flang/test/Lower/allocate-source-allocatables.f90
    M flang/test/Lower/allocate-source-pointers.f90
    M flang/test/Lower/array-constructor-2.f90
    M flang/test/Lower/character-assignment.f90
    M flang/test/Lower/derived-type-finalization.f90
    M flang/test/Lower/do_loop.f90
    M flang/test/Lower/forall/array-pointer.f90
    M flang/test/Lower/forall/forall-allocatable.f90
    M flang/test/Lower/intentout-deallocate.f90
    M flang/test/Lower/io-implied-do-fixes.f90
    M flang/test/Lower/parent-component.f90
    M flang/test/Lower/pointer-assignments.f90
    M flang/test/Lower/polymorphic.f90

  Log Message:
  -----------
  [flang] Turn on use-desc-for-alloc by default

Currently, local allocatables and contiguous/scalar pointers (and some
other conditions) are lowered to a set of independent variables in FIR
(one for the address, one for each bound and one for character length).
The intention was to help LLVM get rids of descriptors. But LLVM knows
how to do that anyway in those cases:

```
subroutine foo(x)
 real, target :: x(100)
 real, pointer, contiguous :: p(:)
 p => x
 call bar(p(50))
end subroutine
```

The output fir the option on or off is the same after llvm opt -O1,
there is no descriptor anymore, the indirection is removed.

```
define void @foo_(ptr %0) local_unnamed_addr {
  %2 = getelementptr [100 x float], ptr %0, i64 0, i64 49
  tail call void @bar_(ptr %2)
  ret void
}
```

So the benefit of not using a descriptor in lowering is questionable,
and although it is abstracted as much as possible in the so called
MutableBoxValue class that represent allocatable/pointer in lowering
it is still causing bugs from time to time, and will also be a bit
problematic when emitting debug info for the pointer/allocatable.

In HLFIR lowering, the simplification to always use a descriptor in
lowering was already made. This patch allows decorrelating the impact
from this change from the bigger impact HLFIR will have so that it
is easier to get feedback if this causes performance issues.

The lowering tests relying on the previous behavior are only updated
to set back this option to true. The reason is that I think we should
preserve coverage of the code dealing with the "non descriptor" approach
in lowering until we actually get rid of it. The other reason is that
the test will have to be or are already covered by equivalent HLFIR
tests, which use descriptors.

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




More information about the All-commits mailing list