[flang-commits] [flang] d06b55e - [Flang][Runtime] Improve runtime implementation of the RENAME intrinsic (#99445)

via flang-commits flang-commits at lists.llvm.org
Thu Jul 18 09:46:27 PDT 2024


Author: Michael Klemm
Date: 2024-07-18T18:46:24+02:00
New Revision: d06b55e7934635049d55efff2dc9e745f911240c

URL: https://github.com/llvm/llvm-project/commit/d06b55e7934635049d55efff2dc9e745f911240c
DIFF: https://github.com/llvm/llvm-project/commit/d06b55e7934635049d55efff2dc9e745f911240c.diff

LOG: [Flang][Runtime] Improve runtime implementation of the RENAME intrinsic (#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)

Added: 
    

Modified: 
    flang/runtime/misc-intrinsic.cpp

Removed: 
    


################################################################################
diff  --git a/flang/runtime/misc-intrinsic.cpp b/flang/runtime/misc-intrinsic.cpp
index 2f7fcd2e2341f..f7d893829fc0d 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