[llvm] [AMDGPU] Skip printf runtime binding if function signature is unexpected (PR #177573)
Steffen Larsen via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 26 00:53:06 PST 2026
================
@@ -438,6 +438,20 @@ bool AMDGPUPrintfRuntimeBindingImpl::run(Module &M) {
M.getModuleFlag("openmp"))
return false;
+ // Verify the signature of the printf function and skip if it isn't correct.
+ const FunctionType *PrintfFunctionTy = PrintfFunction->getFunctionType();
+ if (PrintfFunctionTy->getNumParams() != 1 || !PrintfFunctionTy->isVarArg() ||
+ !PrintfFunctionTy->getReturnType()->isIntegerTy(32))
+ return false;
+ Type *PrintfFormatArgTy = PrintfFunctionTy->getParamType(0);
+ if (!PrintfFormatArgTy->isPointerTy() ||
+ !(PrintfFormatArgTy->getPointerAddressSpace() == AMDGPUAS::FLAT_ADDRESS ||
+ PrintfFormatArgTy->getPointerAddressSpace() ==
+ AMDGPUAS::GLOBAL_ADDRESS ||
+ PrintfFormatArgTy->getPointerAddressSpace() ==
+ AMDGPUAS::CONSTANT_ADDRESS))
----------------
steffenlarsen wrote:
Much more elegant, thanks!
https://github.com/llvm/llvm-project/pull/177573
More information about the llvm-commits
mailing list