[flang-commits] [flang] [flang][cuda] Allow STOP in device context (PR #120625)
Valentin Clement バレンタイン クレメン via flang-commits
flang-commits at lists.llvm.org
Thu Dec 19 11:40:51 PST 2024
https://github.com/clementval created https://github.com/llvm/llvm-project/pull/120625
STOP statement is allowed in device procedure
>From 6a458654368cef9d4f6577ae69bd2c3127754a12 Mon Sep 17 00:00:00 2001
From: Valentin Clement <clementval at gmail.com>
Date: Thu, 19 Dec 2024 11:39:40 -0800
Subject: [PATCH] [flang][cuda] Allow STOP in device context
---
flang/lib/Semantics/check-cuda.cpp | 7 +++++++
flang/test/Semantics/cuf09.cuf | 5 +++++
2 files changed, 12 insertions(+)
diff --git a/flang/lib/Semantics/check-cuda.cpp b/flang/lib/Semantics/check-cuda.cpp
index bec3969c7a26b7..ba519a4f37d308 100644
--- a/flang/lib/Semantics/check-cuda.cpp
+++ b/flang/lib/Semantics/check-cuda.cpp
@@ -82,6 +82,10 @@ struct DeviceExprChecker
}
}
}
+ // c_devloc is inlined in lowering.
+ if (x.GetName().compare("c_devloc") == 0) {
+ return {};
+ }
} else if (x.GetSpecificIntrinsic()) {
// TODO(CUDA): Check for unsupported intrinsics here
return {};
@@ -350,6 +354,9 @@ template <bool IsCUFKernelDo> class DeviceContextChecker {
void Check(const parser::ActionStmt &stmt, const parser::CharBlock &source) {
common::visit(
common::visitors{
+ [&](const common::Indirection<parser::StopStmt> &) {
+ return;
+ },
[&](const common::Indirection<parser::PrintStmt> &) {},
[&](const common::Indirection<parser::WriteStmt> &x) {
if (x.value().format) { // Formatted write to '*' or '6'
diff --git a/flang/test/Semantics/cuf09.cuf b/flang/test/Semantics/cuf09.cuf
index b45ca6d7d1a9d7..3307e2a8626729 100644
--- a/flang/test/Semantics/cuf09.cuf
+++ b/flang/test/Semantics/cuf09.cuf
@@ -49,6 +49,11 @@ module m
i = threadIdx%x
a(i) = c(10) ! ok, a is device and c is constant
end subroutine
+
+ attributes(global) subroutine stoptest()
+ print*,threadIdx%x
+ stop ! ok
+ end subroutine
end
program main
More information about the flang-commits
mailing list