[flang-commits] [flang] 8cc4c6d - [flang][Lower] Make reduction processing failure a hard error (#150233)
via flang-commits
flang-commits at lists.llvm.org
Mon Aug 4 04:01:31 PDT 2025
Author: Tom Eccles
Date: 2025-08-04T12:01:27+01:00
New Revision: 8cc4c6d78f08ca38b5051a09a71ec14ae8931cda
URL: https://github.com/llvm/llvm-project/commit/8cc4c6d78f08ca38b5051a09a71ec14ae8931cda
DIFF: https://github.com/llvm/llvm-project/commit/8cc4c6d78f08ca38b5051a09a71ec14ae8931cda.diff
LOG: [flang][Lower] Make reduction processing failure a hard error (#150233)
See #150178
This may regress some test cases which only ever passed by accident.
I've tested SPEC2017 and a sample of applications to check that this
doesn't break anything too obvious. Presumably this was not a widely
used feature or we would have noticed the bug sooner.
I'm unsure whether this should be backported to LLVM 21 or not: I think
it is much better to refuse to compile than to silently produce the
wrong result, but there is a chance this could regress something which
previously worked by accident. Opinions welcome.
Added:
flang/test/Lower/OpenMP/Todo/wsloop-reduction-non-intrinsic.f90
Modified:
flang/lib/Lower/Bridge.cpp
flang/lib/Lower/OpenMP/ClauseProcessor.cpp
Removed:
flang/test/Lower/OpenMP/wsloop-reduction-non-intrinsic.f90
################################################################################
diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp
index 75048c141365e..059b467655358 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -2128,8 +2128,8 @@ class FirConverter : public Fortran::lower::AbstractConverter {
bool result = rp.processReductionArguments<fir::DeclareReductionOp>(
toLocation(), *this, info.reduceOperatorList, reduceVars,
reduceVarByRef, reductionDeclSymbols, info.reduceSymList);
- assert(result && "Failed to process `do concurrent` reductions");
- (void)result;
+ if (!result)
+ TODO(toLocation(), "Lowering unrecognised reduction type");
doConcurrentLoopOp.getReduceVarsMutable().assign(reduceVars);
doConcurrentLoopOp.setReduceSymsAttr(
diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
index 8eabf4f499604..b98ad3cf7b76a 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
@@ -1121,7 +1121,7 @@ bool ClauseProcessor::processInReduction(
std::get<typename omp::clause::ReductionOperatorList>(clause.t),
inReductionVars, inReduceVarByRef, inReductionDeclSymbols,
inReductionSyms))
- inReductionSyms.clear();
+ TODO(currentLocation, "Lowering unrecognised reduction type");
// Copy local lists into the output.
llvm::copy(inReductionVars, std::back_inserter(result.inReductionVars));
@@ -1467,7 +1467,7 @@ bool ClauseProcessor::processReduction(
std::get<typename omp::clause::ReductionOperatorList>(clause.t),
reductionVars, reduceVarByRef, reductionDeclSymbols,
reductionSyms))
- reductionSyms.clear();
+ TODO(currentLocation, "Lowering unrecognised reduction type");
// Copy local lists into the output.
llvm::copy(reductionVars, std::back_inserter(result.reductionVars));
llvm::copy(reduceVarByRef, std::back_inserter(result.reductionByref));
@@ -1494,7 +1494,7 @@ bool ClauseProcessor::processTaskReduction(
std::get<typename omp::clause::ReductionOperatorList>(clause.t),
taskReductionVars, taskReduceVarByRef, taskReductionDeclSymbols,
taskReductionSyms))
- taskReductionSyms.clear();
+ TODO(currentLocation, "Lowering unrecognised reduction type");
// Copy local lists into the output.
llvm::copy(taskReductionVars,
std::back_inserter(result.taskReductionVars));
diff --git a/flang/test/Lower/OpenMP/wsloop-reduction-non-intrinsic.f90 b/flang/test/Lower/OpenMP/Todo/wsloop-reduction-non-intrinsic.f90
similarity index 52%
rename from flang/test/Lower/OpenMP/wsloop-reduction-non-intrinsic.f90
rename to flang/test/Lower/OpenMP/Todo/wsloop-reduction-non-intrinsic.f90
index 70b2ae1111a50..84feb5aeeee7c 100644
--- a/flang/test/Lower/OpenMP/wsloop-reduction-non-intrinsic.f90
+++ b/flang/test/Lower/OpenMP/Todo/wsloop-reduction-non-intrinsic.f90
@@ -1,6 +1,6 @@
! Tests reduction processor behavior when a reduction symbol is not supported.
-! RUN: %flang_fc1 -emit-hlfir -fopenmp -o - %s 2>&1 | FileCheck %s
+! RUN: %not_todo_cmd %flang_fc1 -emit-hlfir -fopenmp -o - %s 2>&1 | FileCheck %s
subroutine foo
implicit none
@@ -12,14 +12,9 @@ function max(m1,m2)
end function
end interface
+ !CHECK: not yet implemented: Lowering unrecognised reduction type
!$omp do reduction (max: k)
do i=1,10
end do
!$omp end do
end
-
-! Verify that unsupported reduction is ignored.
-! CHECK: omp.wsloop
-! CHECK-SAME: private(@{{[^[:space:]]+}} %{{[^[:space:]]+}}
-! CHECK-SAME: -> %{{[^[:space:]]+}} : !{{[^[:space:]]+}}) {
-! CHECK: }
More information about the flang-commits
mailing list