================ @@ -198,15 +213,31 @@ RValue CodeGenFunction::EmitAMDGPUDevicePrintfCallExpr(const CallExpr *E) { } llvm::Value *Arg = A.getRValue(*this).getScalarVal(); + if (isString(A.getType().getTypePtr()) && CGM.getLangOpts().OpenCL) + Arg = Builder.CreateAddrSpaceCast(Arg, CGM.Int8PtrTy); 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 { + if (CGM.getLangOpts().OpenCL) { ---------------- ssahasra wrote:
This looks like the wrong place for a diagnostic. For an OpenCL program, shouldn't Sema have already verified that the arguments match the required types, such as "constant address space" for the format string? https://github.com/llvm/llvm-project/pull/72556 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits