File tree Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -371,6 +371,19 @@ void ReductionProcessor::addReductionDecl(
371
371
std::get<Fortran::parser::OmpReductionOperator>(reduction.t )};
372
372
const auto &objectList{std::get<Fortran::parser::OmpObjectList>(reduction.t )};
373
373
374
+ if (!std::holds_alternative<Fortran::parser::DefinedOperator>(
375
+ redOperator.u )) {
376
+ if (const auto *reductionIntrinsic =
377
+ std::get_if<Fortran::parser::ProcedureDesignator>(&redOperator.u )) {
378
+ if (!ReductionProcessor::supportedIntrinsicProcReduction (
379
+ *reductionIntrinsic)) {
380
+ return ;
381
+ }
382
+ } else {
383
+ return ;
384
+ }
385
+ }
386
+
374
387
// initial pass to collect all recuction vars so we can figure out if this
375
388
// should happen byref
376
389
for (const Fortran::parser::OmpObject &ompObject : objectList.v ) {
Original file line number Diff line number Diff line change
1
+ ! RUN: bbc -emit-hlfir -fopenmp -o - %s | FileCheck %s
2
+ ! RUN: %flang_fc1 -emit-hlfir -fopenmp -o - %s | FileCheck %s
3
+
4
+ ! regression test for crash
5
+
6
+ program reduce
7
+ integer :: i = 0
8
+ integer :: r = 0
9
+
10
+ ! $omp parallel do reduction(min:r)
11
+ do i= 0 ,10
12
+ r = i
13
+ enddo
14
+ ! $omp end parallel do
15
+
16
+ print * ,r
17
+
18
+ end program
19
+
20
+ ! TODO: the reduction is not curently lowered correctly. This test is checking
21
+ ! that we do not crash and we still produce the same broken IR as before.
22
+
23
+ ! CHECK-LABEL: func.func @_QQmain() attributes {fir.bindc_name = "reduce"} {
24
+ ! CHECK: %[[VAL_0:.*]] = fir.address_of(@_QFEi) : !fir.ref<i32>
25
+ ! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]] {uniq_name = "_QFEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
26
+ ! CHECK: %[[VAL_2:.*]] = fir.address_of(@_QFEr) : !fir.ref<i32>
27
+ ! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_2]] {uniq_name = "_QFEr"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
28
+ ! CHECK: omp.parallel {
29
+ ! CHECK: %[[VAL_4:.*]] = fir.alloca i32 {adapt.valuebyref, pinned}
30
+ ! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_4]] {uniq_name = "_QFEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
31
+ ! CHECK: %[[VAL_6:.*]] = arith.constant 0 : i32
32
+ ! CHECK: %[[VAL_7:.*]] = arith.constant 10 : i32
33
+ ! CHECK: %[[VAL_8:.*]] = arith.constant 1 : i32
34
+ ! CHECK: omp.wsloop for (%[[VAL_9:.*]]) : i32 = (%[[VAL_6]]) to (%[[VAL_7]]) inclusive step (%[[VAL_8]]) {
35
+ ! CHECK: fir.store %[[VAL_9]] to %[[VAL_5]]#1 : !fir.ref<i32>
36
+ ! CHECK: %[[VAL_10:.*]] = fir.load %[[VAL_5]]#0 : !fir.ref<i32>
37
+ ! CHECK: hlfir.assign %[[VAL_10]] to %[[VAL_3]]#0 : i32, !fir.ref<i32>
38
+ ! CHECK: omp.yield
39
+ ! CHECK: }
40
+ ! CHECK: omp.terminator
41
+ ! CHECK: }
You can’t perform that action at this time.
0 commit comments