[all-commits] [llvm/llvm-project] 101b2c: [flang][OpenMP] Fix declare reduction lookup for U...

Matt via All-commits all-commits at lists.llvm.org
Wed Jun 24 22:45:56 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 101b2cdd2266d683ed8d9ff58cac8d70ff5b816e
      https://github.com/llvm/llvm-project/commit/101b2cdd2266d683ed8d9ff58cac8d70ff5b816e
  Author: Matt <MattPD at users.noreply.github.com>
  Date:   2026-06-25 (Thu, 25 Jun 2026)

  Changed paths:
    M flang/lib/Semantics/check-omp-structure.cpp
    M flang/lib/Semantics/mod-file.cpp
    M flang/lib/Semantics/resolve-names-utils.cpp
    M flang/lib/Semantics/resolve-names-utils.h
    M flang/lib/Semantics/resolve-names.cpp
    A flang/test/Semantics/OpenMP/declare-reduction-overbroad-lookup.f90
    A flang/test/Semantics/OpenMP/declare-reduction-use-mixed-merged.f90
    A flang/test/Semantics/OpenMP/declare-reduction-use-only-defined-op.f90
    A flang/test/Semantics/OpenMP/declare-reduction-use-only-merged.f90
    A flang/test/Semantics/OpenMP/declare-reduction-use-only-renamed.f90
    A flang/test/Semantics/OpenMP/declare-reduction-use-only.f90
    A flang/test/Semantics/OpenMP/declare-reduction-use-reexport-merged.f90
    A flang/test/Semantics/OpenMP/declare-reduction-use-reexport-remerge.f90
    A flang/test/Semantics/OpenMP/declare-reduction-use-shadow-merged.f90
    A flang/test/Semantics/OpenMP/declare-reduction-use-shadow.f90

  Log Message:
  -----------
  [flang][OpenMP] Fix declare reduction lookup for USE...ONLY imports

CheckSymbolSupportsType walked every module in the global scope to find
declare-reduction declarations. That accepted reductions from modules
that were never USE'd, or were excluded via USE...ONLY, and it still
rejected some valid imports such as a renamed operator.

Replace the global scan with FindUserReduction(), which resolves the
reduction the way name resolution resolves the operator. It checks a
directly visible reduction first, then follows the operator's USE
associations and merged-generic sources to the declaring modules,
re-deriving the source module's mangled name for renamed operators. The
search recurses through re-exporting (facade) modules and is type-aware,
so an operator that carries reductions for several types resolves to the
one supporting the requested type. A locally declared reduction is
authoritative and shadows reductions reachable through the operator.

Consolidate the duplicated GetReductionFortranId() (formerly static in
both resolve-names.cpp and mod-file.cpp) into a shared utility, fixing a
latent bug where defined operators were not correctly reverse-mapped.

This corrects the semantic check only. The local lowering ICE for a
user-defined operator declare reduction was fixed separately in
https://github.com/llvm/llvm-project/issues/204299. The cross-module
cases this change additionally accepts (USE-associated, renamed, or
merged operators) now emit a clean "not yet implemented" diagnostic in
lowering. Completing their lowering is a follow-up.

Fixes https://github.com/llvm/llvm-project/issues/200300.

Assisted-by: Claude Opus 4.8.



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