-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Turn const eval queries into canonical queries #67717
Turn const eval queries into canonical queries #67717
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
aa821a8
to
2afeac9
Compare
☔ The latest upstream changes (presumably #67853) made this pull request unmergeable. Please resolve the merge conflicts. |
I spent time on Friday reviewing this, will finish up on Monday |
Presumably this comment can also be removed now: Lines 2399 to 2400 in 8f94d9b
|
This doesn't fully resolve that comment, as |
| ty::Predicate::ClosureKind(..) | ||
| ty::Predicate::ConstEvaluatable(..) => true, | ||
ty::Predicate::TypeOutlives(..) | ty::Predicate::RegionOutlives(..) => false, | ||
} |
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.
Why are we filtering these bounds?
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.
This was an initial hack to remove inference variables from the param_env
before calling subst_and_normalize_erasing_regions
. I since replaced that in a later commit with infcx.at(..).normalize(..)
, which dies handle inference variables.
/// Stores the `Machine` instance. | ||
pub machine: M, | ||
|
||
/// The results of the type checker, from rustc. | ||
pub tcx: TyCtxtAt<'tcx>, | ||
|
||
pub(super) infcx: &'infcx InferCtxt<'infcx, 'tcx>, |
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.
Do we use this field for anything?
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.
Yes we do, for normalizing, Instance::resolve_xxx
calls, and recursive const_eval
queries. We need to use this whenever we pass param_env
into a query as it can contain inference variables.
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.
Why do we use inference variables? Couldn't miri be executed with the canonical form?
Canonical variables in scope would behave like type parameters, wouldn't they?
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.
Hm, I never thought about that, I don't think we actually need inference variables as we aren't actually resolving them. Currently it seems like the canconical form is only ever used in preparing/start of queries, so I'm not sure what problems would there be like what happens to Bound
variables if they are part of a canonical query down the line.
It would certainly make InferCtxt
less invasive, which seems like a good thing. I would like to hear @nikomatsakis thought on this.
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 don't really see a problem with it.
This all looks "basically right" to me. Obviously, it needs to be rebased. I'm wondering also whether we should test performance -- seems like maybe yes? |
inference context into mir execution context.
allow param env to contain inference variables.
`resolve_vtable`.
…gions.rs` so that it's not weirdly on it's own within the codegen module.
…me lifetime parameters.
2afeac9
to
92b63b8
Compare
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
@bors try @rust-timer queue |
Awaiting bors try build completion |
Turn const eval queries into canonical queries This is ground work for lazy normalization of consts. This enables invoking const eval queries even if the current param env has inference variable within it, which can occur during trait selection. r? @nikomatsakis
☀️ Try build successful - checks-azure |
Queued 952f90b with parent 4f074de, future comparison URL. |
Finished benchmarking try commit 952f90b, comparison URL. |
/// Stores the `Machine` instance. | ||
pub machine: M, | ||
|
||
/// The results of the type checker, from rustc. | ||
pub tcx: TyCtxtAt<'tcx>, | ||
|
||
/// The inference context for inference variables that are within this `InterpCx`. Inference | ||
/// variables may be within either the `param_env` or within `substs` of frames. Many operations | ||
/// outside of mir which takes values that may contain variable require this context. |
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.
/// outside of mir which takes values that may contain variable require this context. | |
/// outside of mir which take values that may contain variable require this context. |
Also, what is "outside of mir"?
And -- does this basically mean we have to use this (one way or another) whenever we use param_env
or a frame subst
?
This results in many more queries being invokes in clean incremental builds. |
perf: Eagerly convert literals to consts Previousely even literal constants were being converted to an `Unevaluted` constant for evaluation later. This seems unecessary as no more information is needed to be able to convert the literal to a mir constant. Hopefully this will also minimise the performance impact of #67717, as far less constant evaluations are needed.
perf: Eagerly convert literals to consts Previousely even literal constants were being converted to an `Unevaluted` constant for evaluation later. This seems unecessary as no more information is needed to be able to convert the literal to a mir constant. Hopefully this will also minimise the performance impact of rust-lang#67717, as far less constant evaluations are needed.
perf: Eagerly convert literals to consts Previousely even literal constants were being converted to an `Unevaluted` constant for evaluation later. This seems unecessary as no more information is needed to be able to convert the literal to a mir constant. Hopefully this will also minimise the performance impact of #67717, as far less constant evaluations are needed.
Would it make sense to rebase and do another perf run now that #68118 is merged? |
Sounds good to me! |
Waiting for discussion on whether we can just use the canonical form instead of introducing |
@Skinny121: It looks like that should work, if I understand the linked discussion. |
…komatsakis Canonicalize inputs to const eval where needed Canonicalize inputs to const eval, so that they can contain inference variables. Which enables invoking const eval queries even if the current param env has inference variable within it, which can occur during trait selection. This is a reattempt of #67717, in a far less invasive way. Fixes #68477 r? @nikomatsakis cc @eddyb
This is ground work for lazy normalization of consts. This enables invoking const eval queries even if the current param env has inference variable within it, which can occur during trait selection.
r? @nikomatsakis