[flang-commits] [flang] [flang][cuda] Apply implict data attribute to local arrays (PR #120293)
via flang-commits
flang-commits at lists.llvm.org
Tue Dec 17 11:56:22 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-semantics
Author: Valentin Clement (バレンタイン クレメン) (clementval)
<details>
<summary>Changes</summary>
Add the implicit data attribute to local arrays that don't have one. This is simplify the host array detection in semantic.
---
Full diff: https://github.com/llvm/llvm-project/pull/120293.diff
2 Files Affected:
- (modified) flang/lib/Semantics/resolve-names.cpp (+5-5)
- (modified) flang/test/Semantics/cuf09.cuf (+6)
``````````diff
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index 3a1ccec1fdf4bd..51e8b15e6adf02 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -8973,12 +8973,12 @@ void ResolveNamesVisitor::FinishSpecificationPart(
if (NeedsExplicitType(symbol)) {
ApplyImplicitRules(symbol);
}
- if (inDeviceSubprogram && IsDummy(symbol) &&
- symbol.has<ObjectEntityDetails>()) {
- auto *dummy{symbol.detailsIf<ObjectEntityDetails>()};
- if (!dummy->cudaDataAttr() && !IsValue(symbol)) {
+ if (inDeviceSubprogram && symbol.has<ObjectEntityDetails>()) {
+ auto *object{symbol.detailsIf<ObjectEntityDetails>()};
+ if (!object->cudaDataAttr() && !IsValue(symbol) &&
+ (IsDummy(symbol) || object->IsArray())) {
// Implicitly set device attribute if none is set in device context.
- dummy->set_cudaDataAttr(common::CUDADataAttr::Device);
+ object->set_cudaDataAttr(common::CUDADataAttr::Device);
}
}
if (IsDummy(symbol) && isImplicitNoneType() &&
diff --git a/flang/test/Semantics/cuf09.cuf b/flang/test/Semantics/cuf09.cuf
index c551ecbff2cc06..e0ca814aec26a0 100644
--- a/flang/test/Semantics/cuf09.cuf
+++ b/flang/test/Semantics/cuf09.cuf
@@ -22,6 +22,12 @@ module m
!ERROR: Host array 'm' cannot be present in device context
if (i .le. N) a(i) = m(i)
end subroutine
+
+ attributes(global) subroutine localarray()
+ integer :: a(10)
+ i = threadIdx%x
+ a(i) = i
+ end subroutine
end
program main
``````````
</details>
https://github.com/llvm/llvm-project/pull/120293
More information about the flang-commits
mailing list