-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
handling UserSemantic decoration on Input variables #2670
Comments
IMHO the best way to handle it would be to teach replaceUsesOfBuiltinVar that use of the builtin variable might be an annotation intrinsic and in this case annotate the result of the function call that is being generated by replaceUsesOfBuiltinVar. The problem though that LLVM annotation intrinsics aren't matching this role. Alternatively we have a mechanism to represent decorations via !spirv.Decorate metadata, which carries information about the decoration and its values. For the Builtin Variables we may check if they are decorated early on and generate the metadata instead of the annotation intrinsic and then copy this metadata on the function call. Probably this solution is middle term, so for now we can just ignore annotation on the Builtin GV. There is one extra potential issue though, the spec says: "If decorating a variable, it must be in the Input or Output storage classes." about UserSemantic decoration, while we add it for more storage classes. This I don't know how to handle apart of modifying the spec and allowing extra storage classes. |
Yes, we are currently being naughty about UserSemantic decorations, though hopefully only when specific Clang annotations are present. I'm a little surprised that the SPIR-V validator isn't complaining when we use UserSemantic decorations on other variables or functions. See also internal Khronos SPIR-V issue 508. Do we have a use-case for UserSemantic decorations on input variables currently? If not, I'm inclined to ignore them. Since the UserSemantic decorations are intended to express user-facing annotations, not annotations for the driver, this might be the right long-term solution also. |
…ng (#2677) This PR adds "reverse translation" (from SPIR-V to LLVM IR) support for OpDecorateString and OpMemberDecorateString, see #2460 and #2670. These instructions are currently treated as synonyms for OpDecorate and OpMemberDecorate. We'll want to tidy this up at some point, but at least for now we won't crash if we see these instructions. I'll still need to add proper support for decorating variables in the input storage class for #2670, but I'll do that in a separate PR.
Closing - if needed, we can add additional handling for UserSemantic decorations on Input variables in the future, but what we have currently is good enough for now. Thanks! |
…emberDecorateString (KhronosGroup#2677) This PR adds "reverse translation" (from SPIR-V to LLVM IR) support for OpDecorateString and OpMemberDecorateString, see KhronosGroup#2460 and KhronosGroup#2670. These instructions are currently treated as synonyms for OpDecorate and OpMemberDecorate. We'll want to tidy this up at some point, but at least for now we won't crash if we see these instructions. I'll still need to add proper support for decorating variables in the input storage class for KhronosGroup#2670, but I'll do that in a separate PR. (cherry picked from commit f7057b4)
…emberDecorateString (KhronosGroup#2677) This PR adds "reverse translation" (from SPIR-V to LLVM IR) support for OpDecorateString and OpMemberDecorateString, see KhronosGroup#2460 and KhronosGroup#2670. These instructions are currently treated as synonyms for OpDecorate and OpMemberDecorate. We'll want to tidy this up at some point, but at least for now we won't crash if we see these instructions. I'll still need to add proper support for decorating variables in the input storage class for KhronosGroup#2670, but I'll do that in a separate PR. (cherry picked from commit f7057b4)
…emberDecorateString (#2677) (#2767) This PR adds "reverse translation" (from SPIR-V to LLVM IR) support for OpDecorateString and OpMemberDecorateString, see #2460 and #2670. These instructions are currently treated as synonyms for OpDecorate and OpMemberDecorate. We'll want to tidy this up at some point, but at least for now we won't crash if we see these instructions. I'll still need to add proper support for decorating variables in the input storage class for #2670, but I'll do that in a separate PR. (cherry picked from commit f7057b4) Co-authored-by: Ben Ashbaugh <[email protected]>
…emberDecorateString (KhronosGroup#2677) This PR adds "reverse translation" (from SPIR-V to LLVM IR) support for OpDecorateString and OpMemberDecorateString, see KhronosGroup#2460 and KhronosGroup#2670. These instructions are currently treated as synonyms for OpDecorate and OpMemberDecorate. We'll want to tidy this up at some point, but at least for now we won't crash if we see these instructions. I'll still need to add proper support for decorating variables in the input storage class for KhronosGroup#2670, but I'll do that in a separate PR. (cherry picked from commit f7057b4)
…emberDecorateString (KhronosGroup#2677) This PR adds "reverse translation" (from SPIR-V to LLVM IR) support for OpDecorateString and OpMemberDecorateString, see KhronosGroup#2460 and KhronosGroup#2670. These instructions are currently treated as synonyms for OpDecorate and OpMemberDecorate. We'll want to tidy this up at some point, but at least for now we won't crash if we see these instructions. I'll still need to add proper support for decorating variables in the input storage class for KhronosGroup#2670, but I'll do that in a separate PR. (cherry picked from commit f7057b4)
…emberDecorateString (KhronosGroup#2677) This PR adds "reverse translation" (from SPIR-V to LLVM IR) support for OpDecorateString and OpMemberDecorateString, see KhronosGroup#2460 and KhronosGroup#2670. These instructions are currently treated as synonyms for OpDecorate and OpMemberDecorate. We'll want to tidy this up at some point, but at least for now we won't crash if we see these instructions. I'll still need to add proper support for decorating variables in the input storage class for KhronosGroup#2670, but I'll do that in a separate PR. (cherry picked from commit f7057b4)
…emberDecorateString (KhronosGroup#2677) This PR adds "reverse translation" (from SPIR-V to LLVM IR) support for OpDecorateString and OpMemberDecorateString, see KhronosGroup#2460 and KhronosGroup#2670. These instructions are currently treated as synonyms for OpDecorate and OpMemberDecorate. We'll want to tidy this up at some point, but at least for now we won't crash if we see these instructions. I'll still need to add proper support for decorating variables in the input storage class for KhronosGroup#2670, but I'll do that in a separate PR. (cherry picked from commit f7057b4)
…emberDecorateString (KhronosGroup#2677) This PR adds "reverse translation" (from SPIR-V to LLVM IR) support for OpDecorateString and OpMemberDecorateString, see KhronosGroup#2460 and KhronosGroup#2670. These instructions are currently treated as synonyms for OpDecorate and OpMemberDecorate. We'll want to tidy this up at some point, but at least for now we won't crash if we see these instructions. I'll still need to add proper support for decorating variables in the input storage class for KhronosGroup#2670, but I'll do that in a separate PR. (cherry picked from commit f7057b4)
…emberDecorateString (KhronosGroup#2677) This PR adds "reverse translation" (from SPIR-V to LLVM IR) support for OpDecorateString and OpMemberDecorateString, see KhronosGroup#2460 and KhronosGroup#2670. These instructions are currently treated as synonyms for OpDecorate and OpMemberDecorate. We'll want to tidy this up at some point, but at least for now we won't crash if we see these instructions. I'll still need to add proper support for decorating variables in the input storage class for KhronosGroup#2670, but I'll do that in a separate PR. (cherry picked from commit f7057b4)
…emberDecorateString (KhronosGroup#2677) This PR adds "reverse translation" (from SPIR-V to LLVM IR) support for OpDecorateString and OpMemberDecorateString, see KhronosGroup#2460 and KhronosGroup#2670. These instructions are currently treated as synonyms for OpDecorate and OpMemberDecorate. We'll want to tidy this up at some point, but at least for now we won't crash if we see these instructions. I'll still need to add proper support for decorating variables in the input storage class for KhronosGroup#2670, but I'll do that in a separate PR. (cherry picked from commit f7057b4)
…emberDecorateString (KhronosGroup#2677) This PR adds "reverse translation" (from SPIR-V to LLVM IR) support for OpDecorateString and OpMemberDecorateString, see KhronosGroup#2460 and KhronosGroup#2670. These instructions are currently treated as synonyms for OpDecorate and OpMemberDecorate. We'll want to tidy this up at some point, but at least for now we won't crash if we see these instructions. I'll still need to add proper support for decorating variables in the input storage class for KhronosGroup#2670, but I'll do that in a separate PR. (cherry picked from commit f7057b4)
…emberDecorateString (KhronosGroup#2677) This PR adds "reverse translation" (from SPIR-V to LLVM IR) support for OpDecorateString and OpMemberDecorateString, see KhronosGroup#2460 and KhronosGroup#2670. These instructions are currently treated as synonyms for OpDecorate and OpMemberDecorate. We'll want to tidy this up at some point, but at least for now we won't crash if we see these instructions. I'll still need to add proper support for decorating variables in the input storage class for KhronosGroup#2670, but I'll do that in a separate PR. (cherry picked from commit f7057b4)
…emberDecorateString (KhronosGroup#2677) This PR adds "reverse translation" (from SPIR-V to LLVM IR) support for OpDecorateString and OpMemberDecorateString, see KhronosGroup#2460 and KhronosGroup#2670. These instructions are currently treated as synonyms for OpDecorate and OpMemberDecorate. We'll want to tidy this up at some point, but at least for now we won't crash if we see these instructions. I'll still need to add proper support for decorating variables in the input storage class for KhronosGroup#2670, but I'll do that in a separate PR. (cherry picked from commit f7057b4)
…emberDecorateString (KhronosGroup#2677) This PR adds "reverse translation" (from SPIR-V to LLVM IR) support for OpDecorateString and OpMemberDecorateString, see KhronosGroup#2460 and KhronosGroup#2670. These instructions are currently treated as synonyms for OpDecorate and OpMemberDecorate. We'll want to tidy this up at some point, but at least for now we won't crash if we see these instructions. I'll still need to add proper support for decorating variables in the input storage class for KhronosGroup#2670, but I'll do that in a separate PR. (cherry picked from commit f7057b4)
…emberDecorateString (KhronosGroup#2677) This PR adds "reverse translation" (from SPIR-V to LLVM IR) support for OpDecorateString and OpMemberDecorateString, see KhronosGroup#2460 and KhronosGroup#2670. These instructions are currently treated as synonyms for OpDecorate and OpMemberDecorate. We'll want to tidy this up at some point, but at least for now we won't crash if we see these instructions. I'll still need to add proper support for decorating variables in the input storage class for KhronosGroup#2670, but I'll do that in a separate PR. (cherry picked from commit f7057b4)
…emberDecorateString (KhronosGroup#2677) This PR adds "reverse translation" (from SPIR-V to LLVM IR) support for OpDecorateString and OpMemberDecorateString, see KhronosGroup#2460 and KhronosGroup#2670. These instructions are currently treated as synonyms for OpDecorate and OpMemberDecorate. We'll want to tidy this up at some point, but at least for now we won't crash if we see these instructions. I'll still need to add proper support for decorating variables in the input storage class for KhronosGroup#2670, but I'll do that in a separate PR. (cherry picked from commit f7057b4)
…emberDecorateString (KhronosGroup#2677) This PR adds "reverse translation" (from SPIR-V to LLVM IR) support for OpDecorateString and OpMemberDecorateString, see KhronosGroup#2460 and KhronosGroup#2670. These instructions are currently treated as synonyms for OpDecorate and OpMemberDecorate. We'll want to tidy this up at some point, but at least for now we won't crash if we see these instructions. I'll still need to add proper support for decorating variables in the input storage class for KhronosGroup#2670, but I'll do that in a separate PR. (cherry picked from commit f7057b4)
…emberDecorateString (KhronosGroup#2677) This PR adds "reverse translation" (from SPIR-V to LLVM IR) support for OpDecorateString and OpMemberDecorateString, see KhronosGroup#2460 and KhronosGroup#2670. These instructions are currently treated as synonyms for OpDecorate and OpMemberDecorate. We'll want to tidy this up at some point, but at least for now we won't crash if we see these instructions. I'll still need to add proper support for decorating variables in the input storage class for KhronosGroup#2670, but I'll do that in a separate PR. (cherry picked from commit f7057b4)
…emberDecorateString (#2677) (#2774) This PR adds "reverse translation" (from SPIR-V to LLVM IR) support for OpDecorateString and OpMemberDecorateString, see #2460 and #2670. These instructions are currently treated as synonyms for OpDecorate and OpMemberDecorate. We'll want to tidy this up at some point, but at least for now we won't crash if we see these instructions. I'll still need to add proper support for decorating variables in the input storage class for #2670, but I'll do that in a separate PR. (cherry picked from commit f7057b4) Co-authored-by: Ben Ashbaugh <[email protected]>
…emberDecorateString (#2677) (#2775) This PR adds "reverse translation" (from SPIR-V to LLVM IR) support for OpDecorateString and OpMemberDecorateString, see #2460 and #2670. These instructions are currently treated as synonyms for OpDecorate and OpMemberDecorate. We'll want to tidy this up at some point, but at least for now we won't crash if we see these instructions. I'll still need to add proper support for decorating variables in the input storage class for #2670, but I'll do that in a separate PR. (cherry picked from commit f7057b4) Co-authored-by: Ben Ashbaugh <[email protected]>
…emberDecorateString (#2677) (#2776) This PR adds "reverse translation" (from SPIR-V to LLVM IR) support for OpDecorateString and OpMemberDecorateString, see #2460 and #2670. These instructions are currently treated as synonyms for OpDecorate and OpMemberDecorate. We'll want to tidy this up at some point, but at least for now we won't crash if we see these instructions. I'll still need to add proper support for decorating variables in the input storage class for #2670, but I'll do that in a separate PR. (cherry picked from commit f7057b4) Co-authored-by: Ben Ashbaugh <[email protected]>
…emberDecorateString (#2677) (#2777) This PR adds "reverse translation" (from SPIR-V to LLVM IR) support for OpDecorateString and OpMemberDecorateString, see #2460 and #2670. These instructions are currently treated as synonyms for OpDecorate and OpMemberDecorate. We'll want to tidy this up at some point, but at least for now we won't crash if we see these instructions. I'll still need to add proper support for decorating variables in the input storage class for #2670, but I'll do that in a separate PR. (cherry picked from commit f7057b4) Co-authored-by: Ben Ashbaugh <[email protected]>
…emberDecorateString (#2677) (#2778) This PR adds "reverse translation" (from SPIR-V to LLVM IR) support for OpDecorateString and OpMemberDecorateString, see #2460 and #2670. These instructions are currently treated as synonyms for OpDecorate and OpMemberDecorate. We'll want to tidy this up at some point, but at least for now we won't crash if we see these instructions. I'll still need to add proper support for decorating variables in the input storage class for #2670, but I'll do that in a separate PR. (cherry picked from commit f7057b4) Co-authored-by: Ben Ashbaugh <[email protected]>
I've been slowly adding testing for SPIR-V 1.4 features and I found an issue UserSemantic decorations on Input variables. My test can be found here:
KhronosGroup/OpenCL-CTS@main...bashbaug:OpenCL-CTS:spirv-14-part3
There seems to be two problems:
The SPIR-V LLVM Translator currently doesn't handle the OpDecorateString and OpMemberDecorateString instructions (see also Missing SPIR-V 1.4 features/changes #2460). This one seems pretty straightforward, and we should just parse OpDecorateString similar to the way we are currently parsing OpDecorate, at least for now. Once we sort out the difference between OpDecorate and OpDecorateString we might only want to parse the UserSematic decoration using OpDecorateString, but we can cross that bridge when we come to it.
The SPIR-V LLVM Translator also doesn't seem to be properly handling the UserSemantic decoration on Input variables. When there are UserSemantic decorations on an input variable, it turns into an "llvm.global.annotation":
This case is not currently handled by
replaceUsesOfBuiltinVar
, so we hit anllvm_unreachable
and we crash.I'm open to suggestions how best to solve this issue. Here are a few possibilities I can think of Most of these options assume we don't care about preserving the UserSemantic decoration:
a. If a UserSematic decoration is on a variable in the Input storage class, just ignore it, since it's going to cause trouble later on.
b. If the use of the builtin var is a ConstantExpr, like it is in the snip above, replace the use with some other safe value (maybe NULL?).
Is there some other clever way to preserve the UserSemantic decoration?
The text was updated successfully, but these errors were encountered: