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

Matt Arsenault via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 29 04:07:38 PST 2024


================
@@ -202,12 +207,20 @@ RValue CodeGenFunction::EmitAMDGPUDevicePrintfCallExpr(const CallExpr *E) {
     Args.push_back(Arg);
   }
 
-  llvm::IRBuilder<> IRB(Builder.GetInsertBlock(), Builder.GetInsertPoint());
-  IRB.SetCurrentDebugLocation(Builder.getCurrentDebugLocation());
+  auto PFK = CGM.getTarget().getTargetOpts().AMDGPUPrintfKindVal;
+  bool isBuffered = (PFK == clang::TargetOptions::AMDGPUPrintfKind::Buffered);
+
+  StringRef FmtStr;
+  if (llvm::getConstantStringInfo(Args[0], FmtStr)) {
+    if (FmtStr.empty())
+      FmtStr = StringRef("", 1);
+  } else {
+    assert(!CGM.getLangOpts().OpenCL &&
+           "OpenCL needs compile time resolvable format string");
----------------
arsenm wrote:

I would remove this assert. It's supposed to be enforced by the frontend, and the emit function should try to gracefully handle the non-literal case 

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


More information about the cfe-commits mailing list