-
Notifications
You must be signed in to change notification settings - Fork 199
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
Strengthen address space pointer checks #1963
base: main
Are you sure you want to change the base?
Conversation
Add negative tests for address space casts.
Formatting violations should be ignored here. |
Reviewing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not convinced these "negative tests" are possible without a spec clarification.
These to_xxx
functions currently say, for example:
Returns a pointer that points to a region in the global address space if to_global can cast ptr to the global address space. Otherwise it returns NULL.
... but they don't make any guarantees when the pointer cannot be converted to the requested address space. You could imagine some CPU devices, for example, where a generic pointer could be converted to any arbitrary address space and, at least, be safely dereferenced.
FWIW, the same is true for the SPIR-V instruction OpGenericCastToPtrExplicit, which says:
[...] If the cast fails, the instruction result is an OpConstantNull pointer in the Storage Storage Class.
... but never says when the cast may / must / should "fail". See internal SPIR-V GitLab issue 741.
To be clear, I think it would be great to strengthen the spec so we can add these tests also, but I think we'll need the spec change first.
Reviewing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing "focused review" while we are discussing related spec changes.
Add negative tests for address space casts.