-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Split ConstValue
#54738
Comments
Actually, the function producing an immediate doesn't even have to be a query. It could just be a convenience function provided by |
yes. I think we talked about this before and I'm still very much in favour. |
This seems potentially slow, I'd like to get const generics and lazy normalization first, then we can see if we can do this efficiently - I suspect so, but I'm not sure exactly what we'd need. |
What do you think is slow about this? |
@RalfJung I mean, getting the actual value would take an extra operation, but I suppose we can rely on the query being "fast enough" for this to not matter at all. |
Usually we only need that value once or twice. Extracting the value from the memory is just a few instructions. At this point we don't even need an |
No, miri engine needs the |
Well, yes XD, then we can do |
Get rid of the `Scalar` and `ScalarPair` variants of `ConstValue`... ... by always using `ByRef` and reading the scalars from the backing `Allocation` where desired Oh god this uncovered so many bugs and bugs-just-waiting-to-happen. I'm still not fully done, but I don't want to grow this PR any further. It is in a sane state except for the `const_field` function, which was hacky to begin with. fixes #54738 r? @RalfJung
closing in favour of #59210 |
The
ConstValue
type serves different purposes currently. As return value ofconst_eval
for statics, consts and promoteds, we could instead always return anAllocId
+ offset (i.e., aPointer
) and avoid even thinking about whether we want the value to be immediate instead. Some places want an immediate (array lengths, pattern matching), they could get a different query returning a different type that "wraps" the main query.So, I imagine something like: We have one type that serves the current role of
ConstValue
and a new one
(I called the latter
ConstValue
for symmetry with theValue
type. But maybe it's better to not change too many names, and call the 2nd typeConstImmediate
or so.)Then we make the
const_eval
query return aPointer
, and we add a new queryconst_eval_value
returning aConstValue
.Overall, this uses the type system to encode that the queries never return
Unevaluated
, and it lets most callers handle everything uniformly (no need to deal with immediates unless needed).Cc @oli-obk @eddyb -- does this make any sense?
The text was updated successfully, but these errors were encountered: