[clang] [CIR][AMDGPU] Route printf in device code through the OpenCL runtime (PR #226435)
Steffen Larsen via cfe-commits
cfe-commits at lists.llvm.org
Sun Sep 27 23:49:24 PDT 2026
================
@@ -5930,6 +5917,49 @@ void populateCIRToLLVMPasses(mlir::OpPassManager &pm, bool enableOpenMP) {
pm.addPass(mlir::omp::createHostOpFilteringPass());
}
+// Expand calls to the internal __cir_amdgpu_printf marker CIRGen emits for a
+// device-side printf into the real AMDGPU sequence.
+void expandAMDGPUDevicePrintf(llvm::Module &module) {
+ llvm::Function *marker = module.getFunction("__cir_amdgpu_printf");
+ if (!marker)
+ return;
+
+ // CIR records the requested lowering as a module flag.
+ bool isBuffered = false;
+ if (llvm::Metadata *md =
+ module.getModuleFlag(cir::CIRDialect::getAMDGPUPrintfKindAttrName()))
+ if (auto *mdStr = llvm::dyn_cast<llvm::MDString>(md))
----------------
steffenlarsen wrote:
You're absolutely right! It was not well tested, so it slipped under the radar. It now has a test and the right handling is implemented.
https://github.com/llvm/llvm-project/pull/226435
More information about the cfe-commits
mailing list