AMDGPU: Fix broken and permissive handling of printf format strings
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Thu, 22 Dec 2022 16:09:31 +0000 (11:09 -0500)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Thu, 5 Jan 2023 14:18:00 +0000 (09:18 -0500)
commit7b922fc0c3f1e12a1e34508f50c1c52dad762916
tree1c4b1288c07edb4626c4a7f19ee44a996ccc9c4d
parentc9bce9fea0edfbb4d42885f9e9b45e4c8440f16c
AMDGPU: Fix broken and permissive handling of printf format strings

This was completely broken with opaque pointers because it was
specifically looking for a constant expression with the global
variable as the first operand. Strip casts like normal, and properly
validate all of the restrictions rather than silently ignoring any
unhandled cases. Also be stricter that we aren't calling into some
unresolved or non-constant format string.

Also converts the test to opaque pointers and generated tests. There's
more broken initializer handling for strings inside the format string
processing too, but there's just no test coverage for this at all.
llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp
llvm/test/CodeGen/AMDGPU/opencl-printf-unsupported.ll [new file with mode: 0644]
llvm/test/CodeGen/AMDGPU/opencl-printf.ll