[flang-commits] [flang] [Flang][OpenMP] Correct ArrayElements in Reduction Clause (PR #196094)

Jack Styles via flang-commits flang-commits at lists.llvm.org
Tue May 26 06:36:42 PDT 2026


================
@@ -1592,6 +1592,29 @@ static bool hasDeferredCharacterLength(const Fortran::semantics::Symbol &sym) {
          type->characterTypeSpec().length().isDeferred();
 }
 
+static mlir::Value
+findOverriddenExprValue(const Fortran::lower::ExprToValueMap &map,
+                        const Fortran::lower::SomeExpr &expr) {
+  if (auto match = map.find(&expr); match != map.end())
+    return match->second;
+
+  if (!Fortran::evaluate::IsArrayElement(expr))
+    return {};
+
+  for (auto [key, value] : map) {
+    if (key == llvm::DenseMapInfo<
+                   const Fortran::lower::SomeExpr *>::getEmptyKey() ||
+        key == llvm::DenseMapInfo<
+                   const Fortran::lower::SomeExpr *>::getTombstoneKey())
+      continue;
+    if (Fortran::evaluate::IsArrayElement(*key) &&
+        key->AsFortran() == expr.AsFortran())
----------------
Stylie777 wrote:

Unfortunately using ArrayRef's here has exposed a bug in Windows MSSTL that is crashing when comparing the two, this was tracked down to be a bug in <variant> and not in my implementation. I have tested with Fortran::Lower::isEqual here and it works so will use this instead.

https://github.com/llvm/llvm-project/pull/196094


More information about the flang-commits mailing list