[Openmp-commits] [llvm] [openmp] [OpenMP][Offload] Add `LIBOMPTARGET_TREAT_ATTACH_AUTO_AS_ALWAYS` to treat `attach(auto)` as `attach(always)`. (PR #172382)

Abhinav Gaba via Openmp-commits openmp-commits at lists.llvm.org
Tue Dec 16 10:22:50 PST 2025


================
@@ -798,7 +798,15 @@ int processAttachEntries(DeviceTy &Device, AttachInfoTy &AttachInfo,
                       << ", PtrSize=" << PtrSize << ", MapType=0x"
                       << llvm::utohexstr(MapType);
 
-    const bool IsAttachAlways = MapType & OMP_TGT_MAPTYPE_ALWAYS;
+    bool IsAttachAlways = MapType & OMP_TGT_MAPTYPE_ALWAYS;
+
+    // Treat ATTACH(auto) as ATTACH(always) if environment variable is set
+    if (!IsAttachAlways && MappingConfig::get().TreatAttachAutoAsAlways) {
+      IsAttachAlways = true;
+      ODBG(ODT_Mapping) << "ATTACH(auto) will be treated as ATTACH(always) "
----------------
abhinavgaba wrote:

There are no other debug prints in Mapping.h. That means unless we want to include debug headers from Mapping.h, we would move the constructor of MappingConfig out to the cpp file. Or, we can print the message once per construct, before looping over individual attach entries.

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


More information about the Openmp-commits mailing list