[flang-commits] [flang] [flang][cuda] Exclude device variables from host debug info (PR #222241)

via flang-commits flang-commits at lists.llvm.org
Wed Sep 9 16:51:28 PDT 2026


================
@@ -199,6 +200,35 @@ static bool isModuleLevelName(const fir::NameUniquer::DeconstructedName &name) {
   return name.procs.empty() && !name.modules.empty();
 }
 
+// Check if the storage of a variable with the given CUDA Fortran data
+// attribute can be addressed by the host.
+static bool isHostAddressable(cuf::DataAttributeAttr dataAttr) {
+  if (!dataAttr)
+    return true;
+  switch (dataAttr.getValue()) {
+  case cuf::DataAttribute::Constant:
+  case cuf::DataAttribute::Device:
+  case cuf::DataAttribute::Shared:
+    return false;
+  case cuf::DataAttribute::Managed:
+  case cuf::DataAttribute::Pinned:
+  case cuf::DataAttribute::Unified:
+    return true;
+  }
+  llvm_unreachable("unknown CUDA Fortran data attribute");
+}
+
+// Check if the operation belongs to a procedure that is compiled for the
+// device, whose debug info is generated separately.
+static bool isInDeviceProcedure(mlir::Operation *op) {
+  auto funcOp = op->getParentOfType<mlir::func::FuncOp>();
+  if (!funcOp)
+    return false;
+  auto procAttr =
+      funcOp->getAttrOfType<cuf::ProcAttributeAttr>(cuf::getProcAttrName());
+  return procAttr && procAttr.getValue() != cuf::ProcAttribute::Host;
----------------
jiel-nv wrote:

Good catch! Addressed via 87f99bd659acf0d04ee28d3f20189f78290abf66 .

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


More information about the flang-commits mailing list