Skip to content

Commit 6f95445

Browse files
committed
Kept blockArgs for consistency.
Added lowering test.
1 parent 04e64fc commit 6f95445

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

flang/lib/Optimizer/OpenMP/MapInfoFinalization.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,11 @@ class MapInfoFinalizationPass
812812
argIface.getUseDeviceAddrBlockArgsStart() +
813813
argIface.numUseDeviceAddrBlockArgs());
814814

815+
mlir::MutableOperandRange useDevPtrMutableOpRange =
816+
targetDataOp.getUseDevicePtrVarsMutable();
817+
addOperands(useDevPtrMutableOpRange, target,
818+
argIface.getUseDevicePtrBlockArgsStart() +
819+
argIface.numUseDevicePtrBlockArgs());
815820
} else if (auto targetOp = llvm::dyn_cast<mlir::omp::TargetOp>(target)) {
816821
mlir::MutableOperandRange hasDevAddrMutableOpRange =
817822
targetOp.getHasDeviceAddrVarsMutable();
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
! RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=50 %s -o - | FileCheck %s
2+
!
3+
! Checks:
4+
! - C_PTR mappings expand to `__address` member with CLOSE under USM paths.
5+
! - use_device_ptr does not implicitly expand member operands in the clause.
6+
7+
subroutine only_cptr_use_device_ptr
8+
use iso_c_binding
9+
type(c_ptr) :: cptr
10+
integer :: i
11+
12+
!$omp target data use_device_ptr(cptr) map(tofrom: i)
13+
!$omp end target data
14+
end subroutine
15+
16+
! CHECK-LABEL: func.func @_QPonly_cptr_use_device_ptr()
17+
! CHECK: %[[I_MAP:.*]] = omp.map.info var_ptr(%{{.*}} : !fir.ref<i32>, i32) map_clauses(tofrom) capture(ByRef) -> !fir.ref<i32> {name = "i"}
18+
! CHECK: %[[CP_MAP:.*]] = omp.map.info var_ptr(%{{.*}} : !fir.ref<!fir.type<{{.*}}__builtin_c_ptr{{.*}}>>, !fir.type<{{.*}}__builtin_c_ptr{{.*}}>) map_clauses(return_param) capture(ByRef) -> !fir.ref<!fir.type<{{.*}}__builtin_c_ptr{{.*}}>>
19+
! CHECK: omp.target_data map_entries(%[[I_MAP]] : !fir.ref<i32>) use_device_ptr(%[[CP_MAP]] -> %{{.*}} : !fir.ref<!fir.type<{{.*}}__builtin_c_ptr{{.*}}>>) {
20+
! CHECK: omp.terminator
21+
! CHECK: }

0 commit comments

Comments
 (0)