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

Vikram Hegde via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 4 02:08:51 PST 2023


================
@@ -4742,6 +4742,16 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
     Args.ClaimAllArgs(options::OPT_gen_cdb_fragment_path);
   }
 
+  if (TC.getTriple().isAMDGPU() && types::isOpenCL(Input.getType())) {
+    if (Args.getLastArg(options::OPT_mprintf_kind_EQ)) {
+      CmdArgs.push_back(Args.MakeArgString(
+          "-mprintf-kind=" +
+          Args.getLastArgValue(options::OPT_mprintf_kind_EQ)));
+      // Force compiler error on invalid conversion specifiers
+      CmdArgs.push_back(Args.MakeArgString("-Werror=format-invalid-specifier"));
----------------
vikramRH wrote:

This was just so that we could error out instead of undefined behaviors due to wrong specifiers. I have no preference here and would be okay to change it if you feel so.

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


More information about the cfe-commits mailing list