[flang-commits] [flang] [Flang][Runtime] Improve runtime implementation of the RENAME intrinsic (PR #99445)
Michael Klemm via flang-commits
flang-commits at lists.llvm.org
Thu Jul 18 01:13:22 PDT 2024
https://github.com/mjklemm created https://github.com/llvm/llvm-project/pull/99445
The RENAME implementation in the Fortran runtime had a few glitches that had to be addressed:
- Wrong usage of RTDECL (fixed)
- Issue fatal error when trying to use RENAME on a target device (fixed)
>From 23083f6101d31ff477893015d5641258b923db73 Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Thu, 18 Jul 2024 10:10:40 +0200
Subject: [PATCH] [Flang][Runtime] Improve RENAME construct
The RENAME implementation in the Fortran runtime had a few glitches that
had to be addressed:
- Wrong usage of RTDECL (fixed)
- Issue fatal error when trying to use RENAME on a target device (fixed)
---
flang/runtime/misc-intrinsic.cpp | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/flang/runtime/misc-intrinsic.cpp b/flang/runtime/misc-intrinsic.cpp
index 2f7fcd2e2341f..36264eca99d70 100644
--- a/flang/runtime/misc-intrinsic.cpp
+++ b/flang/runtime/misc-intrinsic.cpp
@@ -56,10 +56,10 @@ static RT_API_ATTRS void TransferImpl(Descriptor &result,
extern "C" {
RT_EXT_API_GROUP_BEGIN
-void RTDECL(Rename)(const Descriptor &path1, const Descriptor &path2,
+void RTDEF(Rename)(const Descriptor &path1, const Descriptor &path2,
const Descriptor *status, const char *sourceFile, int line) {
Terminator terminator{sourceFile, line};
-
+#if !defined(RT_DEVICE_COMPILATION)
char *pathSrc{EnsureNullTerminated(
path1.OffsetElement(), path1.ElementBytes(), terminator)};
char *pathDst{EnsureNullTerminated(
@@ -84,6 +84,9 @@ void RTDECL(Rename)(const Descriptor &path1, const Descriptor &path2,
if (pathDst != path2.OffsetElement()) {
FreeMemory(pathDst);
}
+#else // !defined(RT_DEVICE_COMPILATION)
+ terminator.Crash("RENAME intrinsic is only supported on host devices");
+#endif // !defined(RT_DEVICE_COMPILATION)
}
void RTDEF(Transfer)(Descriptor &result, const Descriptor &source,
More information about the flang-commits
mailing list