For NVPTX, `printf` can be used just with a function declaration. For AMDGCN, an
function definition is added, but it simply returns.
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D109728
///}
-// 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
///}