[clang] [clang][AMDGPU] Evaluate deferred constant printf formats (PR #231967)
Eli Friedman via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 29 11:54:06 PDT 2026
================
@@ -181,6 +182,16 @@ RValue CodeGenFunction::EmitAMDGPUDevicePrintfCallExpr(const CallExpr *E) {
Args.push_back(Arg);
}
+ // The expansion reads the format from the initializer of the global it points
+ // to, which may not be emitted yet for a deferred constant array. Pass a copy
+ // of the evaluated format instead.
+ StringRef FmtStr;
+ if (!llvm::getConstantStringInfo(Args[0], FmtStr))
+ if (std::optional<std::string> Fmt =
+ E->getArg(0)->tryEvaluateString(getContext()))
----------------
efriedma-quic wrote:
Doesn't your commit message explain how non-constant printf doesn't work because we need to transform the arguments?
I guess we could draw a distinction between printf's that don't have arguments that need to be transformed, and those which do, but that seems likely to blow up.
https://github.com/llvm/llvm-project/pull/231967
More information about the cfe-commits
mailing list