[flang-commits] [flang] [llvm] [Flang][OpenMP] Improve use_device_addr code generation (PR #221265)

Michael Klemm via flang-commits flang-commits at lists.llvm.org
Wed Sep 9 03:30:06 PDT 2026


mjklemm wrote:

> * Is it legal to use use_device_addr on an assume shape argument? The OpenMP wording for 6.0 only specifies assumed size, but I'm not sure if the specification is using assumed size as a catch all for assumed shape as well here.

That's backwards.  What the specification is trying to say is that everything is allowed, incl. array sections and assumed-size arrays (which are only known by their position in memory, as they do not have a descriptor).


> * Also more generally curious on the wording "If the list item is present in the device data environment on entry to the construct, the list item is treated as if it is implicitly mapped by a map clause on the construct with a map-type of storage", I actually don't understand what this is implying I think, it seems to indicate that the runtime (as the compiler will have no idea if it's in the device data environment without great effort in certain cases) should create an imlpicit allocation map if the data is already resident on device, which seems like it would generally be a no-op (although, I am likely misunderstanding), is there some scenario this wording would be relevant I'm missing?

I guess what that means is that while a `target data` region is active with `use_device_addr` and if the address exists, then you need to increment the reference count on the device to make sure that the item does not go out of scope while the address translation is being used.


https://github.com/llvm/llvm-project/pull/221265


More information about the flang-commits mailing list