Repository navigation
Emit printf formats reached through pointer casts as literals - #24
Merged
Merged
Conversation
The LLVM SPIR-V back-end casts the format string variable to `uchar*` before passing it to printf (since llvm/llvm-project#229720), and llvm-spirv bitcasts it to another array type when a module has several formats. We only recognized the variable itself, so we emitted a pointer instead of a string literal, which NVIDIA rejects. Look through bitcasts and zero-offset access chains to find the string. Fixes #23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since llvm/llvm-project#229720 the LLVM SPIR-V back-end casts the printf format string to
uchar*(OpBitcastof theUniformConstantvariable), and we then passed a pointer instead of a string literal, which NVIDIA's compiler rejects ("The first argument for printf must be a string literal!"). llvm-spirv already had the same problem: in a module with several format strings it bitcasts the later ones to the type of the first.string_literal_fornow looks throughOpBitcastand access chains whose indices are all zero before looking up the cached literal. Tested with a new lit case and by building and running a two-printf kernel (compiled by clang + llvm-spirv) on NVIDIA, which failed to build before and prints correctly now.Fixes #23