[flang-commits] [flang] 3273d0b - [flang][cuda] Apply implicit data attribute only in device context (#119919)

via flang-commits flang-commits at lists.llvm.org
Fri Dec 13 13:43:37 PST 2024


Author: Valentin Clement (バレンタイン クレメン)
Date: 2024-12-13T13:43:33-08:00
New Revision: 3273d0bb148795ead4d6e29177bd63346bb6362a

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

LOG: [flang][cuda] Apply implicit data attribute only in device context (#119919)

Fix the condition so the implicit device data attribute is not applied
when the routine has `attribute(host)`

Added: 
    

Modified: 
    flang/lib/Semantics/resolve-names.cpp
    flang/test/Semantics/modfile55.cuf

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index aef2898919f3ff..6a920cff83b51d 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -8958,9 +8958,9 @@ void ResolveNamesVisitor::FinishSpecificationPart(
               ? currScope().symbol()->detailsIf<SubprogramDetails>()
               : nullptr}) {
     if (auto attrs{subp->cudaSubprogramAttrs()}) {
-      if (*attrs != common::CUDASubprogramAttrs::Device ||
-          *attrs != common::CUDASubprogramAttrs::Global ||
-          *attrs != common::CUDASubprogramAttrs::Grid_Global) {
+      if (*attrs == common::CUDASubprogramAttrs::Device ||
+          *attrs == common::CUDASubprogramAttrs::Global ||
+          *attrs == common::CUDASubprogramAttrs::Grid_Global) {
         inDeviceSubprogram = true;
       }
     }

diff  --git a/flang/test/Semantics/modfile55.cuf b/flang/test/Semantics/modfile55.cuf
index 6c0d152a382a88..90c384cbd55b9c 100644
--- a/flang/test/Semantics/modfile55.cuf
+++ b/flang/test/Semantics/modfile55.cuf
@@ -14,6 +14,10 @@ module m
   attributes(host,device) real function foo(x)
     foo = x + 1.
   end function
+  attributes(host) subroutine hostsub(a)
+    integer, intent(out) :: a(14)
+    a = 99
+  end subroutine
 end
 
 !Expect: m.mod
@@ -39,4 +43,7 @@ end
 !real(4)::x
 !real(4)::foo
 !end
+attributes(host)subroutinehostsub(a)
+integer(4),intent(out)::a(1_8:14_8)
+end
 !end


        


More information about the flang-commits mailing list