[clang] [clang][AMDGPU][CUDA] Handle __builtin_printf for device printf (PR #68515)

Matt Arsenault via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 5 01:41:01 PST 2024


================
@@ -0,0 +1,21 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm -disable-llvm-optzns -mprintf-kind=hostcall -fno-builtin-printf -fcuda-is-device \
+// RUN:   -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm -disable-llvm-optzns -mprintf-kind=buffered -fno-builtin-printf -fcuda-is-device \
+// RUN:   -o - %s | FileCheck %s
+
+#define __device__ __attribute__((device))
+
+extern "C" __device__ int printf(const char *format, ...);
+
+// CHECK-LABEL: @_Z4foo1v()
+__device__ int foo1() {
+  // CHECK-NOT: call i32 (ptr, ...) @printf
----------------
arsenm wrote:

should add some positive checks 

https://github.com/llvm/llvm-project/pull/68515


More information about the cfe-commits mailing list