[all-commits] [llvm/llvm-project] 44261d: [flang][NFC] use hlfir.declare first result when b...

jeanPerier via All-commits all-commits at lists.llvm.org
Fri Mar 21 03:41:26 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 44261dae5b3cd330cfcbd7ada51a8ed532103e98
      https://github.com/llvm/llvm-project/commit/44261dae5b3cd330cfcbd7ada51a8ed532103e98
  Author: jeanPerier <jperier at nvidia.com>
  Date:   2025-03-21 (Fri, 21 Mar 2025)

  Changed paths:
    M flang/lib/Optimizer/Builder/HLFIRTools.cpp
    M flang/test/HLFIR/all-lowering.fir
    M flang/test/HLFIR/any-lowering.fir
    M flang/test/HLFIR/associate-codegen.fir
    M flang/test/HLFIR/assumed-type-actual-args.f90
    M flang/test/HLFIR/boxchar_emboxing.f90
    M flang/test/HLFIR/count-lowering.fir
    M flang/test/HLFIR/cshift-lowering.fir
    M flang/test/HLFIR/dot_product-lowering.fir
    M flang/test/HLFIR/elemental-codegen-nested.fir
    M flang/test/HLFIR/maxloc-lowering.fir
    M flang/test/HLFIR/maxval-lowering.fir
    M flang/test/HLFIR/minloc-lowering.fir
    M flang/test/HLFIR/minval-lowering.fir
    M flang/test/HLFIR/mul_transpose.f90
    M flang/test/HLFIR/opt-bufferization-eval_in_mem.fir
    M flang/test/HLFIR/order_assignments/user-defined-assignment.fir
    M flang/test/HLFIR/product-lowering.fir
    M flang/test/HLFIR/reshape-lowering.fir
    M flang/test/HLFIR/sum-lowering.fir
    M flang/test/HLFIR/transpose-lowering.fir
    M flang/test/Lower/CUDA/cuda-allocatable.cuf
    M flang/test/Lower/CUDA/cuda-data-attribute.cuf
    M flang/test/Lower/CUDA/cuda-data-transfer.cuf
    M flang/test/Lower/CUDA/cuda-device-proc.cuf
    M flang/test/Lower/CUDA/cuda-kernel-calls.cuf
    M flang/test/Lower/CUDA/cuda-kernel-loop-directive.cuf
    M flang/test/Lower/CUDA/cuda-return01.cuf
    M flang/test/Lower/CUDA/cuda-return02.cuf
    M flang/test/Lower/HLFIR/actual_target_for_dummy_pointer.f90
    M flang/test/Lower/HLFIR/allocatable-and-pointer-status-change.f90
    M flang/test/Lower/HLFIR/allocatable-end-of-scope-dealloc.f90
    M flang/test/Lower/HLFIR/allocatable-return.f90
    M flang/test/Lower/HLFIR/allocatables-and-pointers.f90
    M flang/test/Lower/HLFIR/array-ctor-as-elemental.f90
    M flang/test/Lower/HLFIR/array-ctor-derived.f90
    M flang/test/Lower/HLFIR/array-ctor-index.f90
    M flang/test/Lower/HLFIR/associate-construct.f90
    M flang/test/Lower/HLFIR/assumed-rank-iface.f90
    M flang/test/Lower/HLFIR/assumed-rank-inquiries-2.f90
    M flang/test/Lower/HLFIR/assumed-rank-inquiries.f90
    M flang/test/Lower/HLFIR/bindc-entry-stmt.f90
    M flang/test/Lower/HLFIR/bindc-value-derived.f90
    M flang/test/Lower/HLFIR/call-issue-124043.f90
    M flang/test/Lower/HLFIR/call-sequence-associated-descriptors.f90
    M flang/test/Lower/HLFIR/calls-array-results.f90
    M flang/test/Lower/HLFIR/calls-assumed-shape.f90
    M flang/test/Lower/HLFIR/calls-constant-expr-arg.f90
    M flang/test/Lower/HLFIR/calls-f77.f90
    M flang/test/Lower/HLFIR/calls-optional.f90
    M flang/test/Lower/HLFIR/calls-percent-val-ref.f90
    M flang/test/Lower/HLFIR/cray-pointers.f90
    M flang/test/Lower/HLFIR/custom-intrinsic.f90
    M flang/test/Lower/HLFIR/elemental-array-ops.f90
    M flang/test/Lower/HLFIR/elemental-call-vector-subscripts.f90
    M flang/test/Lower/HLFIR/elemental-user-procedure-ref.f90
    M flang/test/Lower/HLFIR/entry_return.f90
    M flang/test/Lower/HLFIR/expr-addr.f90
    M flang/test/Lower/HLFIR/expr-as-inquired.f90
    M flang/test/Lower/HLFIR/function-return-as-expr.f90
    M flang/test/Lower/HLFIR/function-return.f90
    M flang/test/Lower/HLFIR/goto-do-body.f90
    M flang/test/Lower/HLFIR/ignore-rank-unlimited-polymorphic.f90
    M flang/test/Lower/HLFIR/implicit-call-mismatch.f90
    M flang/test/Lower/HLFIR/intentout-allocatable-components.f90
    M flang/test/Lower/HLFIR/internal-procedures.f90
    M flang/test/Lower/HLFIR/intrinsic-dynamically-optional.f90
    M flang/test/Lower/HLFIR/intrinsic-module-procedures.f90
    M flang/test/Lower/HLFIR/intrinsic-subroutines.f90
    M flang/test/Lower/HLFIR/issue80884.f90
    M flang/test/Lower/HLFIR/maxloc.f90
    M flang/test/Lower/HLFIR/maxval.f90
    M flang/test/Lower/HLFIR/minloc.f90
    M flang/test/Lower/HLFIR/minval.f90
    M flang/test/Lower/HLFIR/proc-pointer-comp-nopass.f90
    M flang/test/Lower/HLFIR/proc-pointer-comp-pass.f90
    M flang/test/Lower/HLFIR/procedure-designators.f90
    M flang/test/Lower/HLFIR/procedure-pointer.f90
    M flang/test/Lower/HLFIR/product.f90
    M flang/test/Lower/HLFIR/reshape.f90
    M flang/test/Lower/HLFIR/select-rank.f90
    M flang/test/Lower/HLFIR/select-type-selector.f90
    M flang/test/Lower/HLFIR/structure-constructor.f90
    M flang/test/Lower/HLFIR/sum.f90
    M flang/test/Lower/HLFIR/transformational.f90
    M flang/test/Lower/HLFIR/user-defined-assignment.f90
    M flang/test/Lower/HLFIR/vector-subscript-as-value.f90
    M flang/test/Lower/Intrinsics/associated-proc-pointers.f90
    M flang/test/Lower/Intrinsics/c_f_procpointer.f90
    M flang/test/Lower/Intrinsics/c_ptr_eq_ne.f90
    M flang/test/Lower/Intrinsics/chdir.f90
    M flang/test/Lower/Intrinsics/ieee_rint_int.f90
    M flang/test/Lower/Intrinsics/ieee_rounding.f90
    M flang/test/Lower/Intrinsics/loc.f90
    M flang/test/Lower/Intrinsics/min.f90
    M flang/test/Lower/Intrinsics/reduce.f90
    M flang/test/Lower/Intrinsics/rename.f90
    M flang/test/Lower/Intrinsics/second.f90
    M flang/test/Lower/Intrinsics/selected_logical_kind.f90
    M flang/test/Lower/Intrinsics/shape.f90
    M flang/test/Lower/Intrinsics/signal.f90
    M flang/test/Lower/Intrinsics/system-optional.f90
    M flang/test/Lower/Intrinsics/system.f90
    M flang/test/Lower/OpenACC/acc-atomic-capture.f90
    M flang/test/Lower/OpenACC/acc-atomic-read.f90
    M flang/test/Lower/OpenACC/acc-atomic-update-array.f90
    M flang/test/Lower/OpenACC/acc-atomic-update-hlfir.f90
    M flang/test/Lower/OpenACC/acc-atomic-update.f90
    M flang/test/Lower/OpenACC/acc-atomic-write.f90
    M flang/test/Lower/OpenACC/acc-data-operands-unwrap-defaultbounds.f90
    M flang/test/Lower/OpenACC/acc-data-operands.f90
    M flang/test/Lower/OpenACC/acc-declare-unwrap-defaultbounds.f90
    M flang/test/Lower/OpenACC/acc-declare.f90
    M flang/test/Lower/OpenACC/acc-enter-data-unwrap-defaultbounds.f90
    M flang/test/Lower/OpenACC/acc-enter-data.f90
    M flang/test/Lower/OpenACC/acc-kernels-loop.f90
    M flang/test/Lower/OpenACC/acc-kernels.f90
    M flang/test/Lower/OpenACC/acc-parallel-loop.f90
    M flang/test/Lower/OpenACC/acc-parallel.f90
    M flang/test/Lower/OpenACC/acc-private-unwrap-defaultbounds.f90
    M flang/test/Lower/OpenACC/acc-private.f90
    M flang/test/Lower/OpenACC/acc-serial-loop.f90
    M flang/test/Lower/OpenACC/acc-serial.f90
    M flang/test/Lower/OpenMP/DelayedPrivatization/distribute-standalone-private.f90
    M flang/test/Lower/OpenMP/DelayedPrivatization/wsloop.f90
    M flang/test/Lower/OpenMP/allocatable-array-bounds.f90
    M flang/test/Lower/OpenMP/common-atomic-lowering.f90
    M flang/test/Lower/OpenMP/copyin-order.f90
    M flang/test/Lower/OpenMP/copyin.f90
    M flang/test/Lower/OpenMP/default-clause.f90
    M flang/test/Lower/OpenMP/flush.f90
    M flang/test/Lower/OpenMP/generic-loop-rewriting.f90
    M flang/test/Lower/OpenMP/hlfir-seqloop-parallel.f90
    M flang/test/Lower/OpenMP/lastprivate-allocatable.f90
    M flang/test/Lower/OpenMP/lastprivate-iv.f90
    M flang/test/Lower/OpenMP/lastprivate-simd.f90
    M flang/test/Lower/OpenMP/loop-pointer-variable.f90
    M flang/test/Lower/OpenMP/parallel-lastprivate-clause-scalar.f90
    M flang/test/Lower/OpenMP/parallel-private-clause-fixes.f90
    M flang/test/Lower/OpenMP/parallel-private-clause.f90
    M flang/test/Lower/OpenMP/parallel-reduction-allocatable-array.f90
    M flang/test/Lower/OpenMP/parallel-reduction-pointer-array.f90
    M flang/test/Lower/OpenMP/parallel-reduction3.f90
    M flang/test/Lower/OpenMP/parallel-wsloop-firstpriv.f90
    M flang/test/Lower/OpenMP/parallel-wsloop-lastpriv.f90
    M flang/test/Lower/OpenMP/parallel-wsloop.f90
    M flang/test/Lower/OpenMP/private-commonblock.f90
    M flang/test/Lower/OpenMP/private-derived-type.f90
    M flang/test/Lower/OpenMP/scan.f90
    M flang/test/Lower/OpenMP/shared-loop.f90
    M flang/test/Lower/OpenMP/simd.f90
    M flang/test/Lower/OpenMP/simd_x86_64.f90
    M flang/test/Lower/OpenMP/stop-stmt-in-region.f90
    M flang/test/Lower/OpenMP/target.f90
    M flang/test/Lower/OpenMP/threadprivate-char-array-chararray.f90
    M flang/test/Lower/OpenMP/threadprivate-commonblock.f90
    M flang/test/Lower/OpenMP/threadprivate-hlfir.f90
    M flang/test/Lower/OpenMP/threadprivate-host-association.f90
    M flang/test/Lower/OpenMP/threadprivate-integer-different-kinds.f90
    M flang/test/Lower/OpenMP/threadprivate-pointer-allocatable.f90
    M flang/test/Lower/OpenMP/threadprivate-real-logical-complex-derivedtype.f90
    M flang/test/Lower/OpenMP/threadprivate-use-association-2-hlfir.f90
    M flang/test/Lower/OpenMP/threadprivate-use-association.f90
    M flang/test/Lower/OpenMP/unstructured.f90
    M flang/test/Lower/OpenMP/wsloop-chunks.f90
    M flang/test/Lower/OpenMP/wsloop-collapse.f90
    M flang/test/Lower/OpenMP/wsloop-monotonic.f90
    M flang/test/Lower/OpenMP/wsloop-nonmonotonic.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-add-byref.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-add.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-allocatable-array-minmax.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-allocatable.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-iand-byref.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-iand.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-ieor-byref.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-ieor.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-ior-byref.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-ior.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-logical-and-byref.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-logical-and.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-logical-eqv-byref.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-logical-eqv.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-logical-neqv-byref.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-logical-neqv.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-logical-or-byref.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-logical-or.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-max-byref.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-max.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-min-byref.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-min.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-min2.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-mul-byref.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-mul.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-multiple-clauses.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-pointer.f90
    M flang/test/Lower/OpenMP/wsloop-schedule.f90
    M flang/test/Lower/OpenMP/wsloop-variable.f90
    M flang/test/Lower/OpenMP/wsloop.f90
    M flang/test/Lower/allocatable-polymorphic.f90
    M flang/test/Lower/allocate-source-allocatables-2.f90
    M flang/test/Lower/array-character.f90
    M flang/test/Lower/array-elemental-calls-char-byval.f90
    M flang/test/Lower/array-elemental-calls-char.f90
    M flang/test/Lower/call-by-value-attr.f90
    M flang/test/Lower/components.f90
    M flang/test/Lower/derived-type-temp.f90
    M flang/test/Lower/entry-statement.f90
    M flang/test/Lower/intentout-deallocate.f90
    M flang/test/Lower/io-asynchronous.f90
    M flang/test/Lower/nullify-polymorphic.f90
    M flang/test/Lower/structure-constructors-alloc-comp.f90

  Log Message:
  -----------
  [flang][NFC] use hlfir.declare first result when both results are raw pointers (#132261)

Currently, the helpers to get fir::ExtendedValue out of hlfir::Entity
use hlfir.declare second result (`#1`) in most cases. This is because
this result is the same as the input and matches what FIR was getting
before lowering to HLFIR.

But this creates odd situations when both hlfir.declare are raw pointers
and either result ends-up being used in the IR depending on whether the
code was generated by a helper using fir::ExtendedValue, or via "pure
HLFIR" helpers using the first result.

This will typically prevent simple CSE and easy identification that two
operation (e.g load/store) are touching the exact same memory location
without using alias analysis or "manual detection" (looking for common
hlfir.declare defining op).

Hence, when hlfir.declare results are both raw pointers, use `#0` when
producing `fir::ExtendedValue`.
When `#0` is a fir.box, keep using `#1` because these are not the same. 
The only code change is in HLFIRTools.cpp and is pretty small, but there
is a big test fallout of `#1` to `#0`.



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