[clang] [llvm] [AMDGPU] Enable OpenCL hostcall printf (WIP) (PR #72556)

Matt Arsenault via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 15 08:57:18 PDT 2024


================
@@ -2550,6 +2550,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;
----------------
arsenm wrote:

I think all you need is to add the CustomTypeChecking attribute to the printf definition, and then add language specific type checking on the string argument 

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


More information about the cfe-commits mailing list