-
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
Add eval hack in super_relate_consts
back
#103279
Conversation
super_relate_consts
back
super_relate_consts
backsuper_relate_consts
back
Beta nominating (fixes regression). |
Some changes occurred to the CTFE / Miri engine cc @rust-lang/miri |
The second commit in this stack suppresses a few triggered debug assertions (
These don't necessarily need to be backported since the triggered assertion is a |
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.
nits, then r=me
@@ -587,7 +587,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { | |||
} | |||
mir::ConstantKind::Val(val, ty) => self.const_val_to_op(*val, *ty, layout), | |||
mir::ConstantKind::Unevaluated(uv, _) => { | |||
let instance = self.resolve(uv.def, uv.substs)?; | |||
let substs = self.tcx.normalize_erasing_regions(self.param_env, uv.substs); |
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.
that shouldn't be necessary because the const should already be normalized here. You could add a debug assert that this normalize call would be a noop though.
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 is necessary, because we still triggered a debug assertion without it. Not needed for the backport, per se.
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.
oh, ok 🤔 then we should normalize further above, can keep this with a FIXME
for now ^^
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.
What do you mean further above? The unevaluated constants are the only ones that need normalization, right? edit: nvm i see
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.
Also, to be more clear: this normalization is needed because of the const prop lint in mir_drops_elaborated_and_const_checked
, which happens before optimized MIR. Only after optimizing the MIR can we guarantee that the RevealAll
pass has happened and that the body's constants are normalized, so any call to resolve
before that needs to be manually normalized.
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.
yeah, the const prop lint should still normalize itself if it uses Reveal::All
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.
to not block anything here: can you add a FIXME and then we merge this as is for now?
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.
There's a FIXME now
let substs = self.typeck_results.node_substs(id); | ||
let substs = self | ||
.tcx | ||
.normalize_erasing_regions(param_env_reveal_all, self.typeck_results.node_substs(id)); |
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.
that normalize call seems correct and useful. Considering that we want to backport this, is this call necessary to fix these regressions? I guess I am fine with keeping this even if not 🤷
// HACK(consts): We still need to eagerly evaluate consts when | ||
// relating them because during `normalize_param_env_or_error`, | ||
// we may relate an evaluated constant in a obligation against | ||
// an unnormalized (i.e. unevaluated) const in the param-env. |
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.
// HACK(consts): We still need to eagerly evaluate consts when | |
// relating them because during `normalize_param_env_or_error`, | |
// we may relate an evaluated constant in a obligation against | |
// an unnormalized (i.e. unevaluated) const in the param-env. | |
// HACK(const_generics): We still need to eagerly evaluate consts when | |
// relating them because during `normalize_param_env_or_error`, | |
// we may relate an evaluated constant in a obligation against | |
// an unnormalized (i.e. unevaluated) const in the param-env. | |
// FIXME(generic_const_exprs): Once we always lazily unify unevaluated constants | |
// these `eval` calls can be removed. |
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.
that's also probably broken with feature(generic_const_exprs)
because with that constants can refer to higher ranked lifetimes and some type relations don't actually convert bound variables to placeholders/infer when unifying, so this would cause an ICE.
Can you change this to only run if gce is not enabled.
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 66a57355761afc93595f4bbc6ed50330f408a2cd with merge 165ab7a9eeecf3abb7cf89dd992dd4a1d333ce12... |
☀️ Try build successful - checks-actions |
Queued 165ab7a9eeecf3abb7cf89dd992dd4a1d333ce12 with parent ebdde35, future comparison URL. |
Finished benchmarking commit (165ab7a9eeecf3abb7cf89dd992dd4a1d333ce12): comparison URL. Overall result: ❌ regressions - no action neededBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)This benchmark run did not return any relevant results for this metric. CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Footnotes |
66a5735
to
e590835
Compare
@bors r=lcnr addressed the outstanding nits |
📌 Commit e590835ef69bf5696ca3cdb4708fad409c401c65 has been approved by It is now in the queue for this repository. |
☔ The latest upstream changes (presumably #103426) made this pull request unmergeable. Please resolve the merge conflicts. |
e590835
to
6e6fe30
Compare
@bors r=lcnr |
☀️ Test successful - checks-actions |
Finished benchmarking commit (d49e7e7): comparison URL. Overall result: ❌ regressions - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Footnotes |
…mulacrum [beta] backport rollup * poll_fn and Unpin: fix pinning rust-lang#102737 * Support raw-dylib functions being used inside inlined functions rust-lang#102988 * Fix line numbers for MIR inlined code rust-lang#103071 * Add architectures to fn create_object_file rust-lang#103240 * Add eval hack in super_relate_consts back rust-lang#103279 * Mark std::os::wasi::io::AsFd etc. as stable. rust-lang#103308 * Truncate thread names on Linux and Apple targets rust-lang#103379 * Do not consider repeated lifetime params for elision. rust-lang#103450 * rustdoc: add missing URL redirect rust-lang#103588 * Remove commit_if_ok probe from NLL type relation rust-lang#103601 Also includes a copy of the release notes. r? `@ghost`
… r=lcnr Add eval hack in `super_relate_consts` back Partially reverts 01adb7e. This extra eval call *still* needs to happen, for example, in `normalize_param_env_or_error` when a param-env predicate has an unnormalized constant, since the param-env candidates never get normalized during candidate assembly (everywhere else we can assume that they are normalized fully). r? `@lcnr,` though I feel like I've assigned quite a few PRs to you in the last few days, so feel free to reassign to someone else familiar with this code if you're busy! cc rust-lang#103243 (fixes the issue, but don't want to auto-close that until a backport is performed).
600: Pull changes from upstream `master` r=kirtchev-adacore a=pietroalbini * rust-lang/rust#103605 * rust-lang/rust#103604 * rust-lang/rust#103598 * rust-lang/rust#103596 * rust-lang/rust#103580 * rust-lang/rust#103579 * rust-lang/rust#103567 * rust-lang/rust#103558 * rust-lang/rust#103549 * rust-lang/rust#103537 * rust-lang/rust#103526 * rust-lang/rust#103432 * rust-lang/rust#103571 * rust-lang/rust#103492 * rust-lang/rust#103572 * rust-lang/rust#103554 * rust-lang/rust#103546 * rust-lang/rust#103543 * rust-lang/rust#103428 * rust-lang/rust#102706 * rust-lang/rust#95710 * rust-lang/rust#103284 * rust-lang/rust#103562 * rust-lang/rust#103542 * rust-lang/rust#103536 * rust-lang/rust#103533 * rust-lang/rust#103520 * rust-lang/rust#103444 * rust-lang/rust#103430 * rust-lang/rust#103416 * rust-lang/rust#103287 * rust-lang/rust#103209 * rust-lang/rust#102951 * rust-lang/rust#103279 * rust-lang/rust#103158 Co-authored-by: Lukas Wirth <[email protected]> Co-authored-by: Pietro Albini <[email protected]> Co-authored-by: DropDemBits <[email protected]> Co-authored-by: bors <[email protected]> Co-authored-by: Pietro Albini <[email protected]>
Partially reverts 01adb7e.
This extra eval call still needs to happen, for example, in
normalize_param_env_or_error
when a param-env predicate has an unnormalized constant, since the param-env candidates never get normalized during candidate assembly (everywhere else we can assume that they are normalized fully).r? @lcnr, though I feel like I've assigned quite a few PRs to you in the last few days, so feel free to reassign to someone else familiar with this code if you're busy!
cc #103243 (fixes the issue, but don't want to auto-close that until a backport is performed).