Skip to content

Commit acfceb7

Browse files
authored
[CPUPC-13180][LS-Dyna][OpenMP] Add PointerAssociateScalar to Cray… (llvm#1296)
2 parents 86028f7 + 0b5f153 commit acfceb7

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

flang/lib/Lower/ConvertExprToHLFIR.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ class HlfirDesignatorBuilder {
279279
gen(const Fortran::evaluate::SymbolRef &symbolRef) {
280280
if (std::optional<fir::FortranVariableOpInterface> varDef =
281281
getSymMap().lookupVariableDefinition(symbolRef)) {
282-
if (symbolRef->test(Fortran::semantics::Symbol::Flag::CrayPointee)) {
282+
if (symbolRef.get().GetUltimate().test(Fortran::semantics::Symbol::Flag::CrayPointee)) {
283283
// The pointee is represented with a descriptor inheriting
284284
// the shape and type parameters of the pointee.
285285
// We have to update the base_addr to point to the current
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
! Test lowering of Cray pointee references.
2+
! RUN: bbc -emit-hlfir -fopenmp %s -o - 2>&1 | FileCheck %s
3+
4+
module test_host_assoc_cray_pointer
5+
! CHECK-LABEL: fir.global @_QMtest_host_assoc_cray_pointerEivar : i64
6+
real*8 var(*)
7+
! CHECK-LABEL: fir.global @_QMtest_host_assoc_cray_pointerEvar : !fir.array<?xf64>
8+
pointer(ivar,var)
9+
10+
contains
11+
12+
! CHECK-LABEL: func.func @_QMtest_host_assoc_cray_pointerPset_cray_pointer()
13+
subroutine set_cray_pointer
14+
! CHECK: %[[ALLOCA:.*]] = fir.alloca !fir.box<!fir.ptr<!fir.array<?xf64>>>
15+
! CHECK: %[[IVAR_ADDR:.*]] = fir.address_of(@_QMtest_host_assoc_cray_pointerEivar) : !fir.ref<i64>
16+
! CHECK: %[[IVAR_DECL:.*]]:2 = hlfir.declare %[[IVAR_ADDR]] {uniq_name = "_QMtest_host_assoc_cray_pointerEivar"} : (!fir.ref<i64>) -> (!fir.ref<i64>, !fir.ref<i64>)
17+
! CHECK: %[[VAR_DECL:.*]]:2 = hlfir.declare %[[ALLOCA]] {fortran_attrs = #fir.var_attrs<pointer>, uniq_name = "_QMtest_host_assoc_cray_pointerEvar"} : (!fir.ref<!fir.box<!fir.ptr<!fir.array<?xf64>>>>) -> (!fir.ref<!fir.box<!fir.ptr<!fir.array<?xf64>>>>, !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf64>>>>)
18+
real*8 pointee(2)
19+
pointee(1) = 42.0
20+
21+
ivar = loc(pointee)
22+
23+
!$omp parallel default(none) shared(ivar)
24+
! CHECK: omp.parallel
25+
! CHECK: %[[I_01:.*]] = fir.convert %[[IVAR_DECL]]#0 : (!fir.ref<i64>) -> !fir.ref<!fir.ptr<i64>>
26+
! CHECK: %[[I_02:.*]] = fir.load %[[I_01]] : !fir.ref<!fir.ptr<i64>>
27+
! CHECK: %[[I_03:.*]] = fir.convert %[[VAR_DECL]]#0 : (!fir.ref<!fir.box<!fir.ptr<!fir.array<?xf64>>>>) -> !fir.ref<!fir.box<none>>
28+
! CHECK: %[[I_04:.*]] = fir.convert %[[I_02]] : (!fir.ptr<i64>) -> !fir.llvm_ptr<i8>
29+
! CHECK: fir.call @_FortranAPointerAssociateScalar(%[[I_03]], %[[I_04]]) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> ()
30+
print *, var(1)
31+
!$omp end parallel
32+
end subroutine
33+
end module

0 commit comments

Comments
 (0)