[flang-commits] [flang] [flang][cuda] Honor component CUDA attrs in assignment copies (PR #220398)

Zhen Wang via flang-commits flang-commits at lists.llvm.org
Tue Sep 1 19:02:28 PDT 2026


================
@@ -1470,15 +1529,20 @@ template <typename A> inline bool IsWholeManagedArray(const A &expr) {
 // Unified data is host memory that the device can also access, so it takes the
 // place of host data in the rules above and an assignment between unified sides
 // is host code.
+// The side of an assignment is classified from the data it designates, so the
+// attribute of a component prevails over the attribute of the object it is
+// taken from.
 // Return true if the assignment is one of the copies above.
 template <typename A, typename B>
 inline bool IsCUDADataTransfer(const A &lhs, const B &rhs) {
+  semantics::UnorderedSymbolSet lhsSymbols{CollectEffectiveCudaSymbols(lhs)};
+  semantics::UnorderedSymbolSet rhsSymbols{CollectEffectiveCudaSymbols(rhs)};
   // Unified data is left out of these counts and checks so that it is handled
   // as host data.
-  bool lhsHasManaged{HasCUDAManagedSymbols(lhs)};
-  bool lhsIsHost{!HasCUDANonUnifiedSymbols(lhs)};
-  int rhsNbManagedSymbols{GetNbOfCUDAManagedSymbols(rhs)};
-  int rhsNbSymbols{GetNbOfCUDANonUnifiedSymbols(rhs)};
----------------
wangzpgi wrote:

Should we also remove the helpers this leaves unused? `HasCUDAManagedSymbols` and `HasCUDANonUnifiedSymbols` lose their only callers, and `GetNbOfCUDAManagedSymbols` / `GetNbOfCUDANonUnifiedSymbols` are then only called by those two.

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


More information about the flang-commits mailing list