[flang-commits] [PATCH] D148910: [flang] Turn on use-desc-for-alloc by default

Jean Perier via Phabricator via flang-commits flang-commits at lists.llvm.org
Fri Apr 21 02:27:08 PDT 2023


jeanPerier created this revision.
jeanPerier added reviewers: vzakhari, tblah, kiranchandramohan, Leporacanthicus.
jeanPerier added a project: Flang.
Herald added subscribers: sunshaoce, mehdi_amini, jdoerfert.
Herald added a reviewer: sscalpone.
Herald added a reviewer: clementval.
Herald added a project: All.
jeanPerier requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: jplehr, sstefan1.

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(x(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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D148910

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148910.515657.patch
Type: text/x-patch
Size: 15960 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230421/0965bc3f/attachment-0001.bin>


More information about the flang-commits mailing list