[flang] [llvm] [flang] Implement CFI_show() (PR #155631)

Eugene Epshteyn via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 27 07:39:57 PDT 2025


https://github.com/eugeneepshteyn created https://github.com/llvm/llvm-project/pull/155631

Implement in runtime and add declaration to ISO_Fortran_binding.h

>From a458f6c68b2f1d44120b3f4853046d198ae4fbab Mon Sep 17 00:00:00 2001
From: Eugene Epshteyn <eepshteyn at nvidia.com>
Date: Wed, 27 Aug 2025 10:36:33 -0400
Subject: [PATCH] [flang] Implement CFI_show()

Implement in runtime and add declaration to ISO_Fortran_binding.h
---
 flang-rt/lib/runtime/ISO_Fortran_binding.cpp | 8 ++++++++
 flang/include/flang/ISO_Fortran_binding.h    | 1 +
 2 files changed, 9 insertions(+)

diff --git a/flang-rt/lib/runtime/ISO_Fortran_binding.cpp b/flang-rt/lib/runtime/ISO_Fortran_binding.cpp
index a5f8b357ae0b8..22d32155b915a 100644
--- a/flang-rt/lib/runtime/ISO_Fortran_binding.cpp
+++ b/flang-rt/lib/runtime/ISO_Fortran_binding.cpp
@@ -297,6 +297,14 @@ RT_API_ATTRS int CFI_setpointer(CFI_cdesc_t *result, const CFI_cdesc_t *source,
   return CFI_SUCCESS;
 }
 
+RT_API_ATTRS void CFI_show(void *buf, const CFI_cdesc_t *descr) {
+  FILE *f{stderr};
+  std::fprintf(f, "%p CFI_desc_t: %p\n", buf, descr);
+  if (descr) {
+    reinterpret_cast<const Fortran::runtime::Descriptor *>(descr)->Dump(f);
+  }
+}
+
 RT_EXT_API_GROUP_END
 } // extern "C"
 } // namespace Fortran::ISO
diff --git a/flang/include/flang/ISO_Fortran_binding.h b/flang/include/flang/ISO_Fortran_binding.h
index f5b8d0d2ea610..4e2575ee9a622 100644
--- a/flang/include/flang/ISO_Fortran_binding.h
+++ b/flang/include/flang/ISO_Fortran_binding.h
@@ -208,6 +208,7 @@ RT_API_ATTRS int CFI_select_part(CFI_cdesc_t *, const CFI_cdesc_t *source,
     size_t displacement, size_t elem_len);
 RT_API_ATTRS int CFI_setpointer(
     CFI_cdesc_t *, const CFI_cdesc_t *source, const CFI_index_t lower_bounds[]);
+RT_API_ATTRS void CFI_show(void *buf, const CFI_cdesc_t *descr);
 #ifdef __cplusplus
 } // extern "C"
 #endif



More information about the llvm-commits mailing list