[flang-commits] [flang] dec17c4 - [flang][cuda] Fix matching distance for use_device and none (#223849)

via flang-commits flang-commits at lists.llvm.org
Tue Sep 15 20:55:17 PDT 2026


Author: Valentin Clement (バレンタイン クレメン)
Date: 2026-09-15T20:55:12-07:00
New Revision: dec17c44def4439db47a888341191d49f33e6891

URL: https://github.com/llvm/llvm-project/commit/dec17c44def4439db47a888341191d49f33e6891
DIFF: https://github.com/llvm/llvm-project/commit/dec17c44def4439db47a888341191d49f33e6891.diff

LOG: [flang][cuda] Fix matching distance for use_device and none (#223849)

https://docs.nvidia.com/hpc-sdk/compilers/cuda-fortran-prog-guide/#unified-data
the table set the matching distance for actual `use_device` and dummy
argument `none` to 1 but the implementation set it to 3.

@wangzpgi Was there a specific reason to set 3 instead of 1?

Added: 
    

Modified: 
    flang/lib/Semantics/expression.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/expression.cpp b/flang/lib/Semantics/expression.cpp
index 91e98d5c8018c..1ee41c6eb49fe 100644
--- a/flang/lib/Semantics/expression.cpp
+++ b/flang/lib/Semantics/expression.cpp
@@ -3101,10 +3101,10 @@ static int GetMatchingDistance(const common::LanguageFeatureControl &features,
   // host_data use_device clause: the variable itself is host-resident, but
   // inside the host_data region it is referenced via its device address.
   // It matches a Device dummy with distance 0, a host dummy (no attribute)
-  // with distance 3, and is incompatible with any other dummy attribute.
+  // with distance 1, and is incompatible with any other dummy attribute.
   if (actualDataAttr && *actualDataAttr == common::CUDADataAttr::UseDevice) {
     if (!dummyDataAttr)
-      return 3;
+      return 1;
     if (*dummyDataAttr == common::CUDADataAttr::Device)
       return 0;
   }


        


More information about the flang-commits mailing list