Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,8 @@ void DataSharingProcessor::insertLastPrivateCompare(mlir::Operation *op) {
if (!hasLastPrivate)
return;

if (mlir::isa<mlir::omp::WsloopOp>(op) || mlir::isa<mlir::omp::SimdOp>(op)) {
if (mlir::isa<mlir::omp::WsloopOp>(op) || mlir::isa<mlir::omp::SimdOp>(op) ||
mlir::isa<mlir::omp::TaskloopOp>(op)) {
mlir::omp::LoopRelatedClauseOps result;
llvm::SmallVector<const semantics::Symbol *> iv;
collectLoopRelatedInfo(converter, converter.getCurrentLocation(), eval,
Expand Down Expand Up @@ -408,7 +409,7 @@ void DataSharingProcessor::insertLastPrivateCompare(mlir::Operation *op) {
} else {
TODO(converter.getCurrentLocation(),
"lastprivate clause in constructs other than "
"simd/worksharing-loop");
"simd/worksharing-loop/taskloop");
}
}

Expand Down
4 changes: 2 additions & 2 deletions flang/lib/Lower/OpenMP/OpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1776,8 +1776,8 @@ static void genTaskloopClauses(

cp.processTODO<clause::Allocate, clause::Collapse, clause::Default,
clause::Final, clause::If, clause::InReduction,
clause::Lastprivate, clause::Mergeable, clause::Nogroup,
clause::Priority, clause::Shared, clause::Untied>(
clause::Mergeable, clause::Nogroup, clause::Priority,
clause::Shared, clause::Untied>(
loc, llvm::omp::Directive::OMPD_taskloop);
}

Expand Down
25 changes: 25 additions & 0 deletions flang/test/Lower/OpenMP/taskloop-lastprivate.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
! Test the lastprivate clause when used with the taskloop construct
! RUN: bbc -emit-hlfir -fopenmp -fopenmp-version=45 %s -o - 2>&1 | FileCheck %s
! RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=45 %s -o - 2>&1 | FileCheck %s

! CHECK-LABEL: omp.private
! CHECK-SAME: {type = private} @[[I_PRIVATE:.*]] : i32
! CHECK-LABEL: omp.private
! CHECK-SAME: {type = private} @[[LAST_I_PRIVATE:.*]] : i32

! CHECK: %[[ALLOCA_I:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFlastprivateEi"}
! CHECK: %[[DECLARE_I:.*]]:2 = hlfir.declare %[[ALLOCA_I]] {uniq_name = "_QFlastprivateEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
! CHECK: %[[ALLOCA_LAST_I:.*]] = fir.alloca i32 {bindc_name = "last_i", uniq_name = "_QFlastprivateElast_i"}
! CHECK: %[[DECLARE_LAST_I:.*]]:2 = hlfir.declare %[[ALLOCA_LAST_I]] {uniq_name = "_QFlastprivateElast_i"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)

subroutine lastprivate()
integer :: i, last_i

! CHECK: omp.taskloop
! CHECK-SAME: private(@[[LAST_I_PRIVATE]] %[[DECLARE_LAST_I]]#0 -> %arg0, @[[I_PRIVATE]] %[[DECLARE_I]]#0 -> %arg1 : !fir.ref<i32>, !fir.ref<i32>) {
!$omp taskloop lastprivate(last_i)
do i=1,10
last_i = i
end do
!$omp end taskloop
end