Skip to content

Commit 612683c

Browse files
committed
[OpenMP] Fix use_device_ptr(addr) mapping in absence of explicit map clause
This patch fixes a bug which was preventing proper processing of all the MapInfoOps related to use_device_addr(ptr) clauses when map clauses for these are absent.
1 parent 76e5ad0 commit 612683c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -2089,6 +2089,7 @@ getRefPtrIfDeclareTarget(mlir::Value value,
20892089
struct MapInfoData : llvm::OpenMPIRBuilder::MapInfosTy {
20902090
llvm::SmallVector<bool, 4> IsDeclareTarget;
20912091
llvm::SmallVector<bool, 4> IsAMember;
2092+
llvm::SmallVector<bool, 4> IsAMapping;
20922093
llvm::SmallVector<mlir::Operation *, 4> MapClause;
20932094
llvm::SmallVector<llvm::Value *, 4> OriginalValue;
20942095
// Stripped off array/pointer to get the underlying
@@ -2208,6 +2209,7 @@ void collectMapDataFromMapOperands(
22082209
mapData.Names.push_back(LLVM::createMappingInformation(
22092210
mapOp.getLoc(), *moduleTranslation.getOpenMPBuilder()));
22102211
mapData.DevicePointers.push_back(llvm::OpenMPIRBuilder::DeviceInfoTy::None);
2212+
mapData.IsAMapping.push_back(true);
22112213

22122214
// Check if this is a member mapping and correctly assign that it is, if
22132215
// it is a member of a larger object.
@@ -2234,7 +2236,7 @@ void collectMapDataFromMapOperands(
22342236
bool found = false;
22352237
index = 0;
22362238
for (llvm::Value *basePtr : mapData.OriginalValue) {
2237-
if (basePtr == val) {
2239+
if (basePtr == val && mapData.IsAMapping[index]) {
22382240
found = true;
22392241
mapData.Types[index] |=
22402242
llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_RETURN_PARAM;
@@ -2272,6 +2274,7 @@ void collectMapDataFromMapOperands(
22722274
mapData.Names.push_back(LLVM::createMappingInformation(
22732275
mapOp.getLoc(), *moduleTranslation.getOpenMPBuilder()));
22742276
mapData.DevicePointers.push_back(devInfoTy);
2277+
mapData.IsAMapping.push_back(false);
22752278

22762279
// Check if this is a member mapping and correctly assign that it is, if
22772280
// it is a member of a larger object.

0 commit comments

Comments
 (0)