[PATCH] D16638: [CUDA] Added device-side system call decls and related wrappers.

Artem Belevich via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 3 11:13:54 PST 2016


tra added inline comments.

================
Comment at: lib/Headers/__clang_cuda_runtime_wrapper.h:232
@@ +231,3 @@
+// Clang will convert printf into vprintf, but we still need
+// device-side declaration for it.
+__device__ int printf(const char *, ...);
----------------
jlebar wrote:
> I'd prefer to keep the information from the previous comment: This declaration is there for type-safety, not because things will fail to compile if it is removed.
> 
> Otherwise someone may look at this, delete this definition, see that everything still works, and conclude that they can safely remove this line.
I don't quite see what makes vprintf() special compared to other decls here or, let's say, in /usr/include/*.h. I think 'declaration is there for type safety' applies to all of them and does not need to be spelled out for each individual decl.


================
Comment at: lib/Headers/__clang_cuda_runtime_wrapper.h:237
@@ +236,3 @@
+// device-side declaration for it.
+__device__ int printf(const char *, ...);
+} // extern "C"
----------------
jlebar wrote:
> I think we want an attribute on this so that we know it's printf-like, so you get appropriate format-string warnings.  Unless the compiler is going to add said attribute automatically based on the just the function name.
I've verified that lang is already aware that it's printf and checks arguments against format string appropriately.


http://reviews.llvm.org/D16638





More information about the cfe-commits mailing list