[all-commits] [llvm/llvm-project] 504fc8: [flang][OpenMP] Fix user-defined reduction shadowi...
Carlos Seo via All-commits
all-commits at lists.llvm.org
Thu Jul 2 10:02:52 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 504fc83820b4fa5cf2edd86a5f4661d4dd310933
https://github.com/llvm/llvm-project/commit/504fc83820b4fa5cf2edd86a5f4661d4dd310933
Author: Carlos Seo <carlos.seo at linaro.org>
Date: 2026-07-02 (Thu, 02 Jul 2026)
Changed paths:
M flang/lib/Lower/OpenMP/ClauseProcessor.cpp
M flang/lib/Lower/Support/ReductionProcessor.cpp
A flang/test/Lower/OpenMP/declare-reduction-logical-init.f90
A flang/test/Lower/OpenMP/declare-reduction-shadows-intrinsic-other-type.f90
A flang/test/Lower/OpenMP/declare-reduction-shadows-intrinsic.f90
Log Message:
-----------
[flang][OpenMP] Fix user-defined reduction shadowing an intrinsic name (#205893)
A user-defined reduction whose identifier is one of the intrinsic
reduction names (max, min, iand, ior, ieor) was mishandled during
lowering, causing a crash. This was due to two different problems:
1. Intrinsic shadowing: a reduction(max:var) clause resolves its
identifier to the intrinsic procedure rather than to the user's
declaration, so lowering applied the built-in reduction and ignored the
declared one. For integer variables this silently used the wrong
combiner/initializer; for a LOGICAL variable it crashed, because the
built-in MAX/MIN initializer calls getIntOrFloatBitWidth() on a
fir.logical type.
Per OpenMP 6.0 7.6.14, a user-defined reduction has the same visibility
and accessibility as a variable declared at the same location, so a
visible declaration must take precedence over a same-named intrinsic.
This is handled the same way as for user-defined operator reductions.
TODO: imported, renamed, or multiple-declaration/type reductions are
currently not implemented.
2. LOGICAL initializer type: a user-defined reduction on a LOGICAL
variable with a logical-literal initializer (e.g. omp_priv = .false.)
lowered the literal to an i1 and yielded it from the init region, but
the reduction type is !fir.logical<4>. The omp.declare_reduction
verifier then rejected the op ("expects initializer region to yield a
value of the reduction type"). Convert the initializer result to the
reduction type when they are convertible trivial types, so the init
region yields the reduction type.
Fixes #188880
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