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

Matt Arsenault via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 18 04:08:35 PDT 2024


================
@@ -3616,6 +3617,12 @@ unsigned FunctionDecl::getBuiltinID(bool ConsiderWrapperFunctions) const {
   if (!ConsiderWrapperFunctions && getStorageClass() == SC_Static)
     return 0;
 
+  // AMDGCN implementation supports printf as a builtin
+  // for OpenCL
+  if (Context.getTargetInfo().getTriple().isAMDGCN() &&
+      Context.getLangOpts().OpenCL && BuiltinID == AMDGPU::BIprintf)
+    return BuiltinID;
----------------
arsenm wrote:

> . Meanwhile, can this go ahead as an AMDGPU specific workaround for now so that we have the intended feature in place

No. That cleanup will never happen.

> PS :Ah, I see another issue . OpenCL v1.2 s6.9.f states none of the functions defined in C99 headers are available. This would mean std printf is supposed to be treated differently than OpenCL builtins and consequently the builtin IDs assigned to them "need" to be different

That's not what that means 

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


More information about the cfe-commits mailing list