Revert "[OpenMP] Lower printf to __llvm_omp_vprintf"

This reverts commit db81d8f6c4d6c4f8dfaa036d6959528c9f14e7d7.

GitOrigin-RevId: 0fa45d6d8067d71a8dccac7d942c53b5fd80e499
diff --git a/libomptarget/DeviceRTL/include/Debug.h b/libomptarget/DeviceRTL/include/Debug.h
index f66d566..ee1b485 100644
--- a/libomptarget/DeviceRTL/include/Debug.h
+++ b/libomptarget/DeviceRTL/include/Debug.h
@@ -34,15 +34,23 @@
 ///}
 
 /// Print
-/// printf() calls are rewritten by CGGPUBuiltin to __llvm_omp_vprintf
+/// 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 PRINTF(fmt, ...) (void)printf(fmt, __VA_ARGS__);
 #define PRINT(str) PRINTF("%s", str)
+#else
+#define PRINTF(fmt, ...)
+#define PRINT(str)
+#endif
 
 ///}
 
diff --git a/libomptarget/DeviceRTL/src/Debug.cpp b/libomptarget/DeviceRTL/src/Debug.cpp
index fc9b2ed..4fbd2be 100644
--- a/libomptarget/DeviceRTL/src/Debug.cpp
+++ b/libomptarget/DeviceRTL/src/Debug.cpp
@@ -29,29 +29,6 @@
          assertion);
   __builtin_trap();
 }
-
-#pragma omp begin declare variant match(                                       \
-    device = {arch(nvptx, nvptx64)}, implementation = {extension(match_any)})
-int32_t vprintf(const char *, void *);
-namespace impl {
-static int32_t omp_vprintf(const char *Format, void *Arguments, uint32_t) {
-  return vprintf(Format, Arguments);
-}
-} // namespace impl
-#pragma omp end declare variant
-
-// We do not have a vprintf implementation for AMD GPU yet so we use a stub.
-#pragma omp begin declare variant match(device = {arch(amdgcn)})
-namespace impl {
-static int32_t omp_vprintf(const char *Format, void *Arguments, uint32_t) {
-  return -1;
-}
-} // namespace impl
-#pragma omp end declare variant
-
-int32_t __llvm_omp_vprintf(const char *Format, void *Arguments, uint32_t Size) {
-  return impl::omp_vprintf(Format, Arguments, Size);
-}
 }
 
 /// Current indentation level for the function trace. Only accessed by thread 0.
diff --git a/libomptarget/deviceRTLs/amdgcn/src/target_impl.hip b/libomptarget/deviceRTLs/amdgcn/src/target_impl.hip
index 3298c72..2c6b888 100644
--- a/libomptarget/deviceRTLs/amdgcn/src/target_impl.hip
+++ b/libomptarget/deviceRTLs/amdgcn/src/target_impl.hip
@@ -184,11 +184,6 @@
 }
 __attribute__((weak)) EXTERN void __kmpc_impl_free(void *) {}
 
-EXTERN
-int32_t __llvm_omp_vprintf(const char *Format, void *Arguments, uint32_t) {
-  return -1;
-}
-
 EXTERN void __kmpc_impl_unpack(uint64_t val, uint32_t &lo, uint32_t &hi) {
   lo = (uint32_t)(val & UINT64_C(0x00000000FFFFFFFF));
   hi = (uint32_t)((val & UINT64_C(0xFFFFFFFF00000000)) >> 32);
diff --git a/libomptarget/deviceRTLs/nvptx/src/target_impl.cu b/libomptarget/deviceRTLs/nvptx/src/target_impl.cu
index d9d1403..11f017c 100644
--- a/libomptarget/deviceRTLs/nvptx/src/target_impl.cu
+++ b/libomptarget/deviceRTLs/nvptx/src/target_impl.cu
@@ -184,15 +184,9 @@
 extern "C" {
 void *malloc(size_t);
 void free(void *);
-int32_t vprintf(const char *, void *);
 }
 
 EXTERN void *__kmpc_impl_malloc(size_t x) { return malloc(x); }
 EXTERN void __kmpc_impl_free(void *x) { free(x); }
 
-EXTERN int32_t __llvm_omp_vprintf(const char *Format, void *Arguments,
-                                  uint32_t) {
-  return vprintf(Format, Arguments);
-}
-
 #pragma omp end declare target
diff --git a/libomptarget/test/mapping/data_member_ref.cpp b/libomptarget/test/mapping/data_member_ref.cpp
index 5ac1a0b..dff5987 100644
--- a/libomptarget/test/mapping/data_member_ref.cpp
+++ b/libomptarget/test/mapping/data_member_ref.cpp
@@ -1,6 +1,6 @@
 // RUN: %libomptarget-compilexx-run-and-check-generic
 
-// Wrong results on amdgpu
+// amdgcn does not have printf definition
 // XFAIL: amdgcn-amd-amdhsa
 // XFAIL: amdgcn-amd-amdhsa-newRTL
 
diff --git a/libomptarget/test/mapping/declare_mapper_nested_default_mappers.cpp b/libomptarget/test/mapping/declare_mapper_nested_default_mappers.cpp
index 00d8572..7825d98 100644
--- a/libomptarget/test/mapping/declare_mapper_nested_default_mappers.cpp
+++ b/libomptarget/test/mapping/declare_mapper_nested_default_mappers.cpp
@@ -1,6 +1,6 @@
 // RUN: %libomptarget-compilexx-run-and-check-generic
 
-// Wrong results on amdgpu
+// amdgcn does not have printf definition
 // XFAIL: amdgcn-amd-amdhsa
 // XFAIL: amdgcn-amd-amdhsa-newRTL
 
diff --git a/libomptarget/test/mapping/declare_mapper_nested_mappers.cpp b/libomptarget/test/mapping/declare_mapper_nested_mappers.cpp
index eadf460..bf2addd 100644
--- a/libomptarget/test/mapping/declare_mapper_nested_mappers.cpp
+++ b/libomptarget/test/mapping/declare_mapper_nested_mappers.cpp
@@ -1,6 +1,6 @@
 // RUN: %libomptarget-compilexx-run-and-check-generic
 
-// Wrong results on amdgpu
+// amdgcn does not have printf definition
 // XFAIL: amdgcn-amd-amdhsa
 // XFAIL: amdgcn-amd-amdhsa-newRTL
 
diff --git a/libomptarget/test/mapping/lambda_by_value.cpp b/libomptarget/test/mapping/lambda_by_value.cpp
index 711decb..9cd3833 100644
--- a/libomptarget/test/mapping/lambda_by_value.cpp
+++ b/libomptarget/test/mapping/lambda_by_value.cpp
@@ -1,6 +1,6 @@
 // RUN: %libomptarget-compilexx-run-and-check-generic
 
-// Wrong results on amdgpu
+// amdgcn does not have printf definition
 // XFAIL: amdgcn-amd-amdhsa
 // XFAIL: amdgcn-amd-amdhsa-newRTL
 
diff --git a/libomptarget/test/mapping/ompx_hold/struct.c b/libomptarget/test/mapping/ompx_hold/struct.c
index 450b601..fc63e86 100644
--- a/libomptarget/test/mapping/ompx_hold/struct.c
+++ b/libomptarget/test/mapping/ompx_hold/struct.c
@@ -1,7 +1,7 @@
 // RUN: %libomptarget-compile-generic -fopenmp-extensions
 // RUN: %libomptarget-run-generic | %fcheck-generic -strict-whitespace
 
-// Wrong results on amdgpu
+// amdgcn does not have printf definition
 // XFAIL: amdgcn-amd-amdhsa
 // XFAIL: amdgcn-amd-amdhsa-newRTL
 
diff --git a/libomptarget/test/mapping/ptr_and_obj_motion.c b/libomptarget/test/mapping/ptr_and_obj_motion.c
index a975ed6..4852561 100644
--- a/libomptarget/test/mapping/ptr_and_obj_motion.c
+++ b/libomptarget/test/mapping/ptr_and_obj_motion.c
@@ -1,5 +1,9 @@
 // RUN: %libomptarget-compile-run-and-check-generic
 
+// amdgcn does not have printf definition
+// XFAIL: amdgcn-amd-amdhsa
+// XFAIL: amdgcn-amd-amdhsa-newRTL
+
 #include <stdio.h>
 
 typedef struct {
diff --git a/libomptarget/test/mapping/reduction_implicit_map.cpp b/libomptarget/test/mapping/reduction_implicit_map.cpp
index 2f64b95..24b97bd 100644
--- a/libomptarget/test/mapping/reduction_implicit_map.cpp
+++ b/libomptarget/test/mapping/reduction_implicit_map.cpp
@@ -1,8 +1,8 @@
 // RUN: %libomptarget-compilexx-run-and-check-generic
 
-// Wrong results on amdgpu
-// XFAIL: amdgcn-amd-amdhsa
-// XFAIL: amdgcn-amd-amdhsa-newRTL
+// amdgcn does not have printf definition
+// UNSUPPORTED: amdgcn-amd-amdhsa
+// UNSUPPORTED: amdgcn-amd-amdhsa-newRTL
 
 #include <stdio.h>
 
diff --git a/libomptarget/test/offloading/bug49021.cpp b/libomptarget/test/offloading/bug49021.cpp
index 42e5573..1e456af 100644
--- a/libomptarget/test/offloading/bug49021.cpp
+++ b/libomptarget/test/offloading/bug49021.cpp
@@ -1,7 +1,8 @@
 // RUN: %libomptarget-compilexx-generic -O3 && %libomptarget-run-generic
 
-// Wrong results on amdgpu
-// XFAIL: amdgcn-amd-amdhsa
+// Wrong results on amdgcn
+// UNSUPPORTED: amdgcn-amd-amdhsa
+// UNSUPPORTED: amdgcn-amd-amdhsa-newRTL
 
 #include <iostream>
 
diff --git a/libomptarget/test/offloading/bug50022.cpp b/libomptarget/test/offloading/bug50022.cpp
index 54ce06e..ca1f0e1 100644
--- a/libomptarget/test/offloading/bug50022.cpp
+++ b/libomptarget/test/offloading/bug50022.cpp
@@ -1,5 +1,8 @@
 // RUN: %libomptarget-compilexx-and-run-generic
 
+// UNSUPPORTED: amdgcn-amd-amdhsa
+// UNSUPPORTED: amdgcn-amd-amdhsa-newRTL
+
 #include <cassert>
 #include <iostream>
 #include <stdexcept>
diff --git a/libomptarget/test/offloading/host_as_target.c b/libomptarget/test/offloading/host_as_target.c
index 1fa7116..1e7cdef 100644
--- a/libomptarget/test/offloading/host_as_target.c
+++ b/libomptarget/test/offloading/host_as_target.c
@@ -7,7 +7,7 @@
 
 // RUN: %libomptarget-compile-run-and-check-generic
 
-// amdgpu does not have a working printf definition
+// amdgcn does not have printf definition
 // XFAIL: amdgcn-amd-amdhsa
 // XFAIL: amdgcn-amd-amdhsa-newRTL
 
diff --git a/libomptarget/test/unified_shared_memory/api.c b/libomptarget/test/unified_shared_memory/api.c
index f2882f2..fcb5318 100644
--- a/libomptarget/test/unified_shared_memory/api.c
+++ b/libomptarget/test/unified_shared_memory/api.c
@@ -2,7 +2,7 @@
 // XFAIL: nvptx64-nvidia-cuda
 // XFAIL: nvptx64-nvidia-cuda-newRTL
 
-// Fails on amdgpu with error: GPU Memory Error
+// Fails on amdgcn with error: GPU Memory Error
 // XFAIL: amdgcn-amd-amdhsa
 // XFAIL: amdgcn-amd-amdhsa-newRTL
 
diff --git a/libomptarget/test/unified_shared_memory/close_enter_exit.c b/libomptarget/test/unified_shared_memory/close_enter_exit.c
index 7f1abe3..62555d2 100644
--- a/libomptarget/test/unified_shared_memory/close_enter_exit.c
+++ b/libomptarget/test/unified_shared_memory/close_enter_exit.c
@@ -3,7 +3,7 @@
 // REQUIRES: unified_shared_memory
 // UNSUPPORTED: clang-6, clang-7, clang-8, clang-9
 
-// Fails on amdgpu with error: GPU Memory Error
+// Fails on amdgcn with error: GPU Memory Error
 // XFAIL: amdgcn-amd-amdhsa
 // XFAIL: amdgcn-amd-amdhsa-newRTL
 
diff --git a/libomptarget/test/unified_shared_memory/close_modifier.c b/libomptarget/test/unified_shared_memory/close_modifier.c
index ce368a3..98f1322 100644
--- a/libomptarget/test/unified_shared_memory/close_modifier.c
+++ b/libomptarget/test/unified_shared_memory/close_modifier.c
@@ -3,9 +3,9 @@
 // REQUIRES: unified_shared_memory
 // UNSUPPORTED: clang-6, clang-7, clang-8, clang-9
 
-// amdgpu runtime crash
-// UNSUPPORTED: amdgcn-amd-amdhsa
-
+// amdgcn does not have printf definition
+// XFAIL: amdgcn-amd-amdhsa
+// XFAIL: amdgcn-amd-amdhsa-newRTL
 
 #include <omp.h>
 #include <stdio.h>
diff --git a/libomptarget/test/unified_shared_memory/shared_update.c b/libomptarget/test/unified_shared_memory/shared_update.c
index b211d33..2b90cf3 100644
--- a/libomptarget/test/unified_shared_memory/shared_update.c
+++ b/libomptarget/test/unified_shared_memory/shared_update.c
@@ -2,8 +2,9 @@
 
 // REQUIRES: unified_shared_memory
 
-// amdgpu runtime crash
-// UNSUPPORTED: amdgcn-amd-amdhsa
+// amdgcn does not have printf definition
+// XFAIL: amdgcn-amd-amdhsa
+// XFAIL: amdgcn-amd-amdhsa-newRTL
 
 #include <stdio.h>
 #include <omp.h>