[flang-commits] [flang] [flang][cuda] Apply implicit data attribute only in device context (PR #119919)
Valentin Clement バレンタイン クレメン via flang-commits
flang-commits at lists.llvm.org
Fri Dec 13 11:54:08 PST 2024
https://github.com/clementval created https://github.com/llvm/llvm-project/pull/119919
Fix the condition so the implicit device data attribute is not applied when the routine has `attribute(host)`
>From a259e8aefd0c2a093df56bac38a7d868493c7e60 Mon Sep 17 00:00:00 2001
From: Valentin Clement <clementval at gmail.com>
Date: Fri, 13 Dec 2024 11:52:10 -0800
Subject: [PATCH] [flang][cuda] Apply implicit data attribute only in device
context
---
flang/lib/Semantics/resolve-names.cpp | 6 +++---
flang/test/Semantics/modfile55.cuf | 7 +++++++
2 files changed, 10 insertions(+), 3 deletions(-)
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