[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.
Welcome to the LLVM project!
This repository contains the source code for LLVM, a toolkit for the construction of highly optimized compilers, optimizers, and run-time environments.
The LLVM project has multiple components. The core of the project is itself called “LLVM”. This contains all of the tools, libraries, and header files needed to process intermediate representations and convert them into object files. Tools include an assembler, disassembler, bitcode analyzer, and bitcode optimizer.
C-like languages use the Clang frontend. This component compiles C, C++, Objective-C, and Objective-C++ code into LLVM bitcode -- and from there into object files, using LLVM.
Other components include: the libc++ C++ standard library, the LLD linker, and more.
Consult the Getting Started with LLVM page for information on building and running LLVM.
For information on how to contribute to the LLVM project, please take a look at the Contributing to LLVM guide.
Join the LLVM Discourse forums, Discord chat, LLVM Office Hours or Regular sync-ups.
The LLVM project has adopted a code of conduct for participants to all modes of communication within the project.