[clang] [AMDGPU] Treat printf as builtin for OpenCL (PR #72554)

Joseph Huber via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 16 11:21:03 PST 2023


================
@@ -2458,6 +2458,11 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
       &getTarget().getLongDoubleFormat() == &llvm::APFloat::IEEEquad())
     BuiltinID = mutateLongDoubleBuiltin(BuiltinID);
 
+   // Mutate the printf builtin ID so that we use the same CodeGen path for
+   // HIP and OpenCL with AMDGPU targets.
+   if (getTarget().getTriple().isAMDGCN() && BuiltinID == AMDGPU::BIprintf)
+     BuiltinID = Builtin::BIprintf;
----------------
jhuber6 wrote:

I'm very close to landing 'real' printf support in the GPU libc where `printf` is just a regular function call. Will this change the handling for that in any way? I've already had to make the backend pass respect `-fno-builtins` and remove `ockl` from OpenMP to make that possible so I'm hoping we don't end up with a lot more special casing for `printf`.

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


More information about the cfe-commits mailing list