[flang] [llvm] [Frontend][OpenMP] Reduction modifier must be applied somewhere (PR #92160)

Krzysztof Parzyszek via llvm-commits llvm-commits at lists.llvm.org
Wed May 15 04:30:28 PDT 2024


https://github.com/kparzysz updated https://github.com/llvm/llvm-project/pull/92160

>From b63bfe59f2c062e851b40f87089a58d012533c09 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Tue, 14 May 2024 13:23:55 -0500
Subject: [PATCH 1/2] [Frontend][OpenMP] Reduction modifier must be applied
 somewhere

Detect the case when a reduction modifier ends up not being applied after
construct decomposition, treat it as an error.

This fixes a regression in the gfortran test suite after PR90098.
---
 llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h b/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
index 5f12c62b832fc..e5fcc493ea590 100644
--- a/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
+++ b/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
@@ -930,7 +930,8 @@ bool ConstructDecompositionT<C, H>::applyClause(
       // Apply clause without modifier.
       leaf.clauses.push_back(unmodified);
     }
-    applied = true;
+    // The modifier must be applied to some construct.
+    applied = effectiveApplied;
   }
 
   if (!applied)

>From a169830aeaf698b0acc312cb983f0e7f97d7c109 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Wed, 15 May 2024 06:29:58 -0500
Subject: [PATCH 2/2] Add testcase

---
 .../Lower/OpenMP/invalid-reduction-modifier.f90    | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
 create mode 100644 flang/test/Lower/OpenMP/invalid-reduction-modifier.f90

diff --git a/flang/test/Lower/OpenMP/invalid-reduction-modifier.f90 b/flang/test/Lower/OpenMP/invalid-reduction-modifier.f90
new file mode 100644
index 0000000000000..817c5b731c62f
--- /dev/null
+++ b/flang/test/Lower/OpenMP/invalid-reduction-modifier.f90
@@ -0,0 +1,14 @@
+!Remove the --crash below once we can diagnose the issue more gracefully.
+!RUN: not --crash %flang_fc1 -fopenmp -emit-hlfir -o - %s
+
+! Check that we reject the "task" reduction modifier on the "simd" directive.
+
+subroutine fred(x)
+  integer, intent(inout) :: x
+
+  !$omp simd reduction(task, +:x)
+  do i = 1, 100
+    x = foo(i)
+  enddo
+  !$omp end simd
+end



More information about the llvm-commits mailing list