Repository navigation
Declare built-in variables whose pointer escapes a direct load - #18
Merged
Merged
Conversation
Built-in variables were never declared: a load from one is bound to the corresponding work-item query instead. Any other use of the variable, such as the bitcast and byte offset the LLVM SPIR-V back end emits to load a single component of a vector built-in, referred to an undeclared identifier and the program failed to build. Give each function that uses a built-in's pointer that way a private copy, initialized from the queries. Built-ins that are only loaded directly keep the query binding. Fixes #3.
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.
Built-in variables are never declared in the generated C: a load from one is bound to the matching work-item query (
get_local_id(i), ...). Any other use of the variable referred to an undeclared name. The LLVM SPIR-V back end produces such uses when IR loads one component of a vector built-in through a GEP: it emits a bitcast and a byte-offset access chain.Each function that uses a built-in's pointer that way now gets a private copy, initialized from the queries:
The scan also follows uses through module-scope
OpSpecConstantOps, since those are bound to expressions that name the variable. Built-ins that are only loaded directly keep the query binding, so existing output doesn't change.Tested with new lit cases, the module from the issue, and a kernel reading
LocalInvocationId.ythrough a byte offset on Intel CPU, PoCL and NVIDIA.Fixes #3