@@ -262,17 +262,26 @@ class MapInfoFinalizationPass
262
262
// / allowing `to` mappings, and `target update` not allowing both `to` and
263
263
// / `from` simultaneously. We currently try to maintain the `implicit` flag
264
264
// / where necessary, although it does not seem strictly required.
265
+ // /
266
+ // / Currently, if it is a has_device_addr clause, we opt to not apply the
267
+ // / descriptor tag to it as it's used differently to a regular mapping
268
+ // / and some of the runtime descriptor behaviour at the moment can cause
269
+ // / issues.
265
270
unsigned long getDescriptorMapType (unsigned long mapTypeFlag,
266
- mlir::Operation *target) {
271
+ mlir::Operation *target,
272
+ bool IsHasDeviceAddr) {
267
273
using mapFlags = llvm::omp::OpenMPOffloadMappingFlags;
274
+
268
275
if (llvm::isa_and_nonnull<mlir::omp::TargetExitDataOp,
269
- mlir::omp::TargetUpdateOp>(target))
270
- return llvm::to_underlying (
271
- mapFlags (mapTypeFlag) |
272
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_DESCRIPTOR);
276
+ mlir::omp::TargetUpdateOp>(target)) {
277
+ mapFlags flags = mapFlags (mapTypeFlag);
278
+ if (!IsHasDeviceAddr)
279
+ flags |= mapFlags::OMP_MAP_DESCRIPTOR;
280
+ return llvm::to_underlying (flags);
281
+ }
273
282
274
283
mapFlags flags = mapFlags::OMP_MAP_TO |
275
- (mapFlags (mapTypeFlag) & mapFlags::OMP_MAP_IMPLICIT);
284
+ (mapFlags (mapTypeFlag) & mapFlags::OMP_MAP_IMPLICIT);
276
285
// Descriptors for objects will always be copied. This is because the
277
286
// descriptor can be rematerialized by the compiler, and so the addres
278
287
// of the descriptor for a given object at one place in the code may
@@ -286,7 +295,8 @@ class MapInfoFinalizationPass
286
295
mapFlags::OMP_MAP_CLOSE)
287
296
? mapFlags::OMP_MAP_CLOSE
288
297
: mapFlags::OMP_MAP_ALWAYS;
289
- flags |= mapFlags::OMP_MAP_DESCRIPTOR;
298
+ if (!IsHasDeviceAddr)
299
+ flags |= mapFlags::OMP_MAP_DESCRIPTOR;
290
300
return llvm::to_underlying (flags);
291
301
}
292
302
@@ -381,7 +391,7 @@ class MapInfoFinalizationPass
381
391
mlir::TypeAttr::get (fir::unwrapRefType (descriptor.getType ())),
382
392
builder.getIntegerAttr (
383
393
builder.getIntegerType (64 , false ),
384
- getDescriptorMapType (op.getMapType (), target)),
394
+ getDescriptorMapType (op.getMapType (), target, IsHasDeviceAddr )),
385
395
op.getMapCaptureTypeAttr (), /* varPtrPtr=*/ mlir::Value{}, newMembers,
386
396
newMembersAttr, /* bounds=*/ mlir::SmallVector<mlir::Value>{},
387
397
/* mapperId*/ mlir::FlatSymbolRefAttr (), op.getNameAttr (),
0 commit comments