[flang-commits] [flang] 16e3464 - [flang][cuda] Enforce PINNED attribute when ALLOCATE with PINNED option (#89455)
via flang-commits
flang-commits at lists.llvm.org
Fri Apr 19 14:58:27 PDT 2024
Author: Valentin Clement (バレンタイン クレメン)
Date: 2024-04-19T14:58:22-07:00
New Revision: 16e3464852efe3001060ff7feb3261dd397bfe84
URL: https://github.com/llvm/llvm-project/commit/16e3464852efe3001060ff7feb3261dd397bfe84
DIFF: https://github.com/llvm/llvm-project/commit/16e3464852efe3001060ff7feb3261dd397bfe84.diff
LOG: [flang][cuda] Enforce PINNED attribute when ALLOCATE with PINNED option (#89455)
When the PINNED option is specified on an ALLOCATE statement, the object
must have the PINNED attribute.
Added:
Modified:
flang/lib/Semantics/check-allocate.cpp
flang/test/Semantics/cuf07.cuf
Removed:
################################################################################
diff --git a/flang/lib/Semantics/check-allocate.cpp b/flang/lib/Semantics/check-allocate.cpp
index a7244e1c58330a..7bfd86262b3d62 100644
--- a/flang/lib/Semantics/check-allocate.cpp
+++ b/flang/lib/Semantics/check-allocate.cpp
@@ -611,6 +611,13 @@ bool AllocationCheckerHelper::RunChecks(SemanticsContext &context) {
return false;
}
}
+ if (allocateInfo_.gotPinned) {
+ std::optional<common::CUDADataAttr> cudaAttr{GetCUDADataAttr(ultimate_)};
+ if (!cudaAttr || *cudaAttr != common::CUDADataAttr::Pinned) {
+ context.Say(name_.source,
+ "Object in ALLOCATE must have PINNED attribute when PINNED option is specified"_err_en_US);
+ }
+ }
return RunCoarrayRelatedChecks(context);
}
diff --git a/flang/test/Semantics/cuf07.cuf b/flang/test/Semantics/cuf07.cuf
index b520b5da51264b..91a78e124c593b 100644
--- a/flang/test/Semantics/cuf07.cuf
+++ b/flang/test/Semantics/cuf07.cuf
@@ -23,4 +23,12 @@ module m
!BECAUSE: 'ma' is a host-associated allocatable and is not definable in a device subprogram
deallocate(ma)
end subroutine
+
+ subroutine hostsub()
+ integer, allocatable, device :: ia(:)
+ logical :: plog
+
+ !ERROR: Object in ALLOCATE must have PINNED attribute when PINNED option is specified
+ allocate(ia(100), pinned = plog)
+ end subroutine
end module
More information about the flang-commits
mailing list