Skip to content

Commit 8cc4c6d

Browse files
authored
[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.
1 parent d07abde commit 8cc4c6d

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

flang/lib/Lower/Bridge.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2128,8 +2128,8 @@ class FirConverter : public Fortran::lower::AbstractConverter {
21282128
bool result = rp.processReductionArguments<fir::DeclareReductionOp>(
21292129
toLocation(), *this, info.reduceOperatorList, reduceVars,
21302130
reduceVarByRef, reductionDeclSymbols, info.reduceSymList);
2131-
assert(result && "Failed to process `do concurrent` reductions");
2132-
(void)result;
2131+
if (!result)
2132+
TODO(toLocation(), "Lowering unrecognised reduction type");
21332133

21342134
doConcurrentLoopOp.getReduceVarsMutable().assign(reduceVars);
21352135
doConcurrentLoopOp.setReduceSymsAttr(

flang/lib/Lower/OpenMP/ClauseProcessor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ bool ClauseProcessor::processInReduction(
11211121
std::get<typename omp::clause::ReductionOperatorList>(clause.t),
11221122
inReductionVars, inReduceVarByRef, inReductionDeclSymbols,
11231123
inReductionSyms))
1124-
inReductionSyms.clear();
1124+
TODO(currentLocation, "Lowering unrecognised reduction type");
11251125

11261126
// Copy local lists into the output.
11271127
llvm::copy(inReductionVars, std::back_inserter(result.inReductionVars));
@@ -1467,7 +1467,7 @@ bool ClauseProcessor::processReduction(
14671467
std::get<typename omp::clause::ReductionOperatorList>(clause.t),
14681468
reductionVars, reduceVarByRef, reductionDeclSymbols,
14691469
reductionSyms))
1470-
reductionSyms.clear();
1470+
TODO(currentLocation, "Lowering unrecognised reduction type");
14711471
// Copy local lists into the output.
14721472
llvm::copy(reductionVars, std::back_inserter(result.reductionVars));
14731473
llvm::copy(reduceVarByRef, std::back_inserter(result.reductionByref));
@@ -1494,7 +1494,7 @@ bool ClauseProcessor::processTaskReduction(
14941494
std::get<typename omp::clause::ReductionOperatorList>(clause.t),
14951495
taskReductionVars, taskReduceVarByRef, taskReductionDeclSymbols,
14961496
taskReductionSyms))
1497-
taskReductionSyms.clear();
1497+
TODO(currentLocation, "Lowering unrecognised reduction type");
14981498
// Copy local lists into the output.
14991499
llvm::copy(taskReductionVars,
15001500
std::back_inserter(result.taskReductionVars));
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
! Tests reduction processor behavior when a reduction symbol is not supported.
22

3-
! RUN: %flang_fc1 -emit-hlfir -fopenmp -o - %s 2>&1 | FileCheck %s
3+
! RUN: %not_todo_cmd %flang_fc1 -emit-hlfir -fopenmp -o - %s 2>&1 | FileCheck %s
44

55
subroutine foo
66
implicit none
@@ -12,14 +12,9 @@ function max(m1,m2)
1212
end function
1313
end interface
1414

15+
!CHECK: not yet implemented: Lowering unrecognised reduction type
1516
!$omp do reduction (max: k)
1617
do i=1,10
1718
end do
1819
!$omp end do
1920
end
20-
21-
! Verify that unsupported reduction is ignored.
22-
! CHECK: omp.wsloop
23-
! CHECK-SAME: private(@{{[^[:space:]]+}} %{{[^[:space:]]+}}
24-
! CHECK-SAME: -> %{{[^[:space:]]+}} : !{{[^[:space:]]+}}) {
25-
! CHECK: }

0 commit comments

Comments
 (0)