-
Notifications
You must be signed in to change notification settings - Fork 19
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
LLVM Opaque Pointers feature not compatible with named pointers for Qubit and Result #30
Comments
The "target extension type" concept being introduced in https://reviews.llvm.org/D135202 may be of interest to you. It addresses similar needs that have been encountered with SPIR-V. |
First thoughts on this. I wouldn't like seeing: To someone consuming the code, they can't quickly verify the difference between these two pointers were it not for the To the point about replacing |
@nikic Thank for pointing out the target extension type! If I'm understanding it correctly, a target extension type can optionally include type information, but if it doesn't, then it can't be introspected. Is that correct? If so, that does seem to match the intended behavior of |
So you're currently doing something like |
It's been 6 months since the last post on this topic. Any thoughts or recommendations? |
The LLVM project has had an ongoing workstream to define behavior for treating all pointers as opaque by default (see Opaque Pointers in the LLVM docs), and the feature is on by default in LLVM 15 with typed pointers being removed in the upcoming LLVM 16. This means the current mechanism used by QIR to identify qubit and result types as distinct from other values via named pointer types will no longer work. For example, the measurement call in the base profile that today looks like this:
would become this:
As noted in the opaque pointers documentation,
This means that type information for pointers is explicitly and intentionally no longer included in the LLVM IR and meant to inserted when the pointer is read from or written to via
load
andstore
instructions. This does not map well to the current design for%Qubit*
and%Result*
which expects that these values are never loaded or stored and are merely identified as distinct by their named types.As a possible design solution going forward, the
%Qubit
and%Result
types could be more formally defined as distinct, sized structs, which would allow them to retain their type information in the IR. Correspondingly, the specifications and profiles would need to updated with this definition and the signatures of all relevant APIs updated to reflect that. A similar effort would need to be undertake for other types currently defined as typed pointers such as the%String*
,%BigInt*
,%Tuple*
, and%Array*
.The text was updated successfully, but these errors were encountered: