[flang-commits] [flang] e970f59 - [flang][OpenMP] Reintroduce TODO for FIR lowering of linear clause (#144883)
via flang-commits
flang-commits at lists.llvm.org
Fri Jun 20 04:53:02 PDT 2025
Author: NimishMishra
Date: 2025-06-20T04:53:00-07:00
New Revision: e970f59e6b20dddc4369735affb79ca9be240c1c
URL: https://github.com/llvm/llvm-project/commit/e970f59e6b20dddc4369735affb79ca9be240c1c
DIFF: https://github.com/llvm/llvm-project/commit/e970f59e6b20dddc4369735affb79ca9be240c1c.diff
LOG: [flang][OpenMP] Reintroduce TODO for FIR lowering of linear clause (#144883)
Current design of the linear clause lowering and translation shifts all
responsibility for handling the clause (like privatisation, linear
stepping, finalisation, and emission of synchronisation barriers) to the
IRBuilder. However in certain corner cases (like associated loops in or
before OpenMP version 4.5), variables are are implicitly linear. This
currently causes a problem with the existing linear clause
implementation. Hence, re-introduce TODO on the linear clause until the
linear clause lowering/translation are robust enough to handle such
cases as well.
Fixes https://github.com/llvm/llvm-project/issues/142935
Added:
Modified:
flang/lib/Lower/OpenMP/OpenMP.cpp
Removed:
flang/test/Lower/OpenMP/wsloop-linear.f90
################################################################################
diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp
index ddf58fd874440..ebd1d038716e4 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -1968,13 +1968,13 @@ static void genWsloopClauses(
llvm::SmallVectorImpl<const semantics::Symbol *> &reductionSyms) {
ClauseProcessor cp(converter, semaCtx, clauses);
cp.processNowait(clauseOps);
- cp.processLinear(clauseOps);
cp.processOrder(clauseOps);
cp.processOrdered(clauseOps);
cp.processReduction(loc, clauseOps, reductionSyms);
cp.processSchedule(stmtCtx, clauseOps);
- cp.processTODO<clause::Allocate>(loc, llvm::omp::Directive::OMPD_do);
+ cp.processTODO<clause::Allocate, clause::Linear>(
+ loc, llvm::omp::Directive::OMPD_do);
}
//===----------------------------------------------------------------------===//
diff --git a/flang/test/Lower/OpenMP/wsloop-linear.f90 b/flang/test/Lower/OpenMP/wsloop-linear.f90
deleted file mode 100644
index b99677108be2f..0000000000000
--- a/flang/test/Lower/OpenMP/wsloop-linear.f90
+++ /dev/null
@@ -1,57 +0,0 @@
-! This test checks lowering of OpenMP DO Directive (Worksharing)
-! with linear clause
-
-! RUN: %flang_fc1 -fopenmp -emit-hlfir %s -o - 2>&1 | FileCheck %s
-
-!CHECK: %[[X_alloca:.*]] = fir.alloca i32 {bindc_name = "x", uniq_name = "_QFsimple_linearEx"}
-!CHECK: %[[X:.*]]:2 = hlfir.declare %[[X_alloca]] {uniq_name = "_QFsimple_linearEx"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
-!CHECK: %[[const:.*]] = arith.constant 1 : i32
-subroutine simple_linear
- implicit none
- integer :: x, y, i
- !CHECK: omp.wsloop linear(%[[X]]#0 = %[[const]] : !fir.ref<i32>) {{.*}}
- !$omp do linear(x)
- !CHECK: %[[LOAD:.*]] = fir.load %[[X]]#0 : !fir.ref<i32>
- !CHECK: %[[const:.*]] = arith.constant 2 : i32
- !CHECK: %[[RESULT:.*]] = arith.addi %[[LOAD]], %[[const]] : i32
- do i = 1, 10
- y = x + 2
- end do
- !$omp end do
-end subroutine
-
-
-!CHECK: %[[X_alloca:.*]] = fir.alloca i32 {bindc_name = "x", uniq_name = "_QFlinear_stepEx"}
-!CHECK: %[[X:.*]]:2 = hlfir.declare %[[X_alloca]] {uniq_name = "_QFlinear_stepEx"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
-subroutine linear_step
- implicit none
- integer :: x, y, i
- !CHECK: %[[const:.*]] = arith.constant 4 : i32
- !CHECK: omp.wsloop linear(%[[X]]#0 = %[[const]] : !fir.ref<i32>) {{.*}}
- !$omp do linear(x:4)
- !CHECK: %[[LOAD:.*]] = fir.load %[[X]]#0 : !fir.ref<i32>
- !CHECK: %[[const:.*]] = arith.constant 2 : i32
- !CHECK: %[[RESULT:.*]] = arith.addi %[[LOAD]], %[[const]] : i32
- do i = 1, 10
- y = x + 2
- end do
- !$omp end do
-end subroutine
-
-!CHECK: %[[A_alloca:.*]] = fir.alloca i32 {bindc_name = "a", uniq_name = "_QFlinear_exprEa"}
-!CHECK: %[[A:.*]]:2 = hlfir.declare %[[A_alloca]] {uniq_name = "_QFlinear_exprEa"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
-!CHECK: %[[X_alloca:.*]] = fir.alloca i32 {bindc_name = "x", uniq_name = "_QFlinear_exprEx"}
-!CHECK: %[[X:.*]]:2 = hlfir.declare %[[X_alloca]] {uniq_name = "_QFlinear_exprEx"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
-subroutine linear_expr
- implicit none
- integer :: x, y, i, a
- !CHECK: %[[LOAD_A:.*]] = fir.load %[[A]]#0 : !fir.ref<i32>
- !CHECK: %[[const:.*]] = arith.constant 4 : i32
- !CHECK: %[[LINEAR_EXPR:.*]] = arith.addi %[[LOAD_A]], %[[const]] : i32
- !CHECK: omp.wsloop linear(%[[X]]#0 = %[[LINEAR_EXPR]] : !fir.ref<i32>) {{.*}}
- !$omp do linear(x:a+4)
- do i = 1, 10
- y = x + 2
- end do
- !$omp end do
-end subroutine
More information about the flang-commits
mailing list