[all-commits] [llvm/llvm-project] 332ac6: [flang][hlfir] do not propagate polymorphic tempor...

jeanPerier via All-commits all-commits at lists.llvm.org
Tue Jun 3 07:04:27 PDT 2025


  Branch: refs/heads/users/jperier/associate_poly_type
  Home:   https://github.com/llvm/llvm-project
  Commit: 332ac6e96a7d04ecf1ae68f1931c787917ee692c
      https://github.com/llvm/llvm-project/commit/332ac6e96a7d04ecf1ae68f1931c787917ee692c
  Author: Jean Perier <jperier at nvidia.com>
  Date:   2025-06-03 (Tue, 03 Jun 2025)

  Changed paths:
    M flang/include/flang/Optimizer/Builder/FIRBuilder.h
    M flang/include/flang/Optimizer/Builder/MutableBox.h
    M flang/include/flang/Optimizer/Dialect/FIRType.h
    M flang/lib/Optimizer/Builder/FIRBuilder.cpp
    M flang/lib/Optimizer/Builder/HLFIRTools.cpp
    M flang/lib/Optimizer/Builder/MutableBox.cpp
    M flang/lib/Optimizer/CodeGen/LowerRepackArrays.cpp
    M flang/lib/Optimizer/Dialect/FIRType.cpp
    M flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
    M flang/lib/Optimizer/HLFIR/Transforms/BufferizeHLFIR.cpp
    M flang/test/HLFIR/as_expr-codegen-polymorphic.fir
    M flang/test/HLFIR/as_expr-codegen.fir
    M flang/test/HLFIR/associate-codegen.fir
    M flang/test/HLFIR/bufferize-poly-expr.fir
    M flang/test/HLFIR/element-codegen-issue-118922.fir
    M flang/test/HLFIR/elemental-codegen.fir
    M flang/test/Lower/OpenMP/DelayedPrivatization/target-private-multiple-variables.f90
    M flang/test/Lower/OpenMP/delayed-privatization-allocatable-array.f90
    M flang/test/Lower/OpenMP/delayed-privatization-array.f90
    M flang/test/Lower/OpenMP/parallel-reduction-allocatable-array.f90
    M flang/test/Lower/OpenMP/parallel-reduction-array-lb.f90
    M flang/test/Lower/OpenMP/parallel-reduction-array.f90
    M flang/test/Lower/OpenMP/parallel-reduction-array2.f90
    M flang/test/Lower/OpenMP/parallel-reduction-pointer-array.f90
    M flang/test/Lower/OpenMP/parallel-reduction3.f90
    M flang/test/Lower/OpenMP/reduction-array-intrinsic.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-allocatable-array-minmax.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-array-assumed-shape.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-array.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-array2.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-multiple-clauses.f90
    M flang/test/Transforms/lower-repack-arrays.fir

  Log Message:
  -----------
  [flang][hlfir] do not propagate polymorphic temporary as allocatables

Polymorphic temporary are currently propagated as fir.ref<fir.class<fir.heap<>>>
because their allocation may be delayed to the hlfir.assign copy (using realloc).

This patch moves away from this and directly allocate the temp and propagate it
as a fir.class.

The polymorphic temporaries creating is also simplified by avoiding the need to
call the runtime to setup the descriptor altogether (the runtime is still call
for the allocation currently because alloca/allocmem do not support polymorphism).

Rational:

- this lower complexity and reduce the need to add codes to special case
  polymorphic handling

- I want to move towards a point where where we can use fir.alloca/fir.allocmem
  to allocate polymorphic temporary so that LLVM can better understand the
  shape and size of the data after inlining.

- I want to strengthen hlfir.declare box value result to not have the
  allocatable attribute to have the declare symbol attribute and the runtime
  attribute inside the descriptor in sync and avoid situation where the runtime
  thinks it can reallocate things that are not allocatable at that point of the
  program. This will fix a bug with SELECT TYPE lowering.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list