[Openmp-commits] [PATCH] D109728: [OpenMP][DeviceRTL] Add the support for printf in a freestanding way

Shilei Tian via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Thu Oct 7 19:15:55 PDT 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaf4599b8abca: [OpenMP][DeviceRTL] Add the support for printf in a freestanding way (authored by tianshilei1992).

Changed prior to commit:
  https://reviews.llvm.org/D109728?vs=374633&id=378064#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109728/new/

https://reviews.llvm.org/D109728

Files:
  openmp/libomptarget/DeviceRTL/include/Debug.h


Index: openmp/libomptarget/DeviceRTL/include/Debug.h
===================================================================
--- openmp/libomptarget/DeviceRTL/include/Debug.h
+++ openmp/libomptarget/DeviceRTL/include/Debug.h
@@ -25,9 +25,24 @@
 
 ///}
 
-// TODO: We need to allow actual printf.
-#define PRINTF(fmt, ...) (void)fmt;
+/// Print
+/// TODO: For now we have to use macros to guard the code because Clang lowers
+/// `printf` to different function calls on NVPTX and AMDGCN platforms, and it
+/// doesn't work for AMDGCN. After it can work on AMDGCN, we will remove the
+/// macro.
+/// {
+
+#ifndef __AMDGCN__
+extern "C" {
+int printf(const char *format, ...);
+}
+
+#define PRINTF(fmt, ...) (void)printf(fmt, __VA_ARGS__);
 #define PRINT(str) PRINTF("%s", str)
+#else
+#define PRINTF(fmt, ...)
+#define PRINT(str)
+#endif
 
 ///}
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109728.378064.patch
Type: text/x-patch
Size: 843 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20211008/f873578e/attachment.bin>


More information about the Openmp-commits mailing list