Skip to content
Merged
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
8 changes: 7 additions & 1 deletion flang/lib/Lower/OpenMP/OpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2089,7 +2089,13 @@ genSectionsOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
const auto &objList = std::get<ObjectList>(lastp->t);
for (const Object &object : objList) {
semantics::Symbol *sym = object.sym();
converter.copyHostAssociateVar(*sym, &insp, /*hostIsSource=*/false);
if (const auto *common =
sym->detailsIf<semantics::CommonBlockDetails>()) {
for (const auto &obj : common->objects())
converter.copyHostAssociateVar(*obj, &insp, /*hostIsSource=*/false);
} else {
converter.copyHostAssociateVar(*sym, &insp, /*hostIsSource=*/false);
}
}
}
}
Expand Down
19 changes: 18 additions & 1 deletion flang/test/Lower/OpenMP/sections.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

! This test checks the lowering of OpenMP sections construct with several clauses present

! RUN: %flang_fc1 -flang-experimental-hlfir -emit-hlfir %openmp_flags %s -o - | FileCheck %s
! RUN: %flang_fc1 -emit-hlfir %openmp_flags %s -o - | FileCheck %s
! RUN: bbc -hlfir -emit-hlfir %openmp_flags %s -o - | FileCheck %s

!CHECK: func @_QQmain() attributes {fir.bindc_name = "sample"} {
Expand Down Expand Up @@ -263,6 +263,23 @@ subroutine lastprivate2()
!$omp end sections
end subroutine

!CHECK-LABEL: func @_QPlastprivate_common
!CHECK: %[[I:.*]]:2 = hlfir.declare %{{.*}} {uniq_name = "_QFlastprivate_commonEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
!CHECK: %[[I_PRIV:.*]]:2 = hlfir.declare %{{.*}} {uniq_name = "_QFlastprivate_commonEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
!CHECK: omp.sections
!CHECK: omp.section
!CHECK: %[[TMP:.*]] = fir.load %[[I_PRIV]]#0 : !fir.ref<i32>
!CHECK: hlfir.assign %[[TMP]] to %[[I]]#0 : i32, !fir.ref<i32>
subroutine lastprivate_common()
integer :: i
common /com/ i

i = 1
!$omp sections lastprivate(/com/)
i = 2
!$omp end sections
end subroutine

!CHECK-LABEL: func @_QPunstructured_sections_privatization
subroutine unstructured_sections_privatization()
!CHECK: %[[X:.*]] = fir.alloca f32 {bindc_name = "x", uniq_name = "_QFunstructured_sections_privatizationEx"}
Expand Down