Add rigid alias marker#156742
Conversation
|
Unfinished. Let's have a look at the perf impact nonetheless. @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
[Experiment] Add rigid alias marker
This comment has been minimized.
This comment has been minimized.
|
💔 Test for 73eccb5 failed: CI. Failed job:
|
This comment has been minimized.
This comment has been minimized.
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
[Experiment] Add rigid alias marker
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (42e2939): comparison URL. Overall result: ❌ regressions - please read:Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf. Next, please: If you can, justify the regressions found in this try perf run in writing along with @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 1.6%, secondary -1.7%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 2.5%, secondary 17.8%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 0.0%, secondary 0.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 510.83s -> 514.725s (0.76%) |
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
[Experiment] Add rigid alias marker
This comment has been minimized.
This comment has been minimized.
|
Some changes occurred in compiler/rustc_sanitizers cc @rcvalle Some changes occurred in cc @BoxyUwU Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt HIR ty lowering was modified cc @fmease
cc @rust-lang/clippy Some changes occurred to the CTFE machinery
cc @bjorn3 changes to the core type system cc @lcnr Some changes occurred to the core trait solver cc @rust-lang/initiative-trait-system-refactor Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri |
| ty, | ||
| // FIXME(rigid_aliases_marker): types coming out of `item_bounds` | ||
| // are marked as non-rigid while the visited ty can be rigid. | ||
| ty::set_aliases_to_non_rigid(tcx, ty), |
There was a problem hiding this comment.
surprising. If args contain something that's rigid, shouldn't it be fine to keep that as rigid?
There was a problem hiding this comment.
Relating of AliasTy now checks rigidness. And we have relating in test_type_match::extract_verify_if_eq.
Ah this reminds me that if the args contains rigid aliases, setting them to non-rigid would also cause discrepancy with the type instantiated from item bound.
There was a problem hiding this comment.
as in, we relate non-rigid with rigid aliases here?
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (ac2cd6c): comparison URL. Overall result: ❌✅ regressions and improvements - please read:Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf. Next, please: If you can, justify the regressions found in this try perf run in writing along with @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -0.3%, secondary 0.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary -8.8%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary -0.0%, secondary 0.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 525.47s -> 527.211s (0.33%) |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
there are a few eager normalization changes in your PR which probably don't have to be here 🤔
I would really like to change the matches on ty::Alias which treat the alias as potentially normalizeable to explicitly check for "is_rigid" themselves. I dislike the way e.g. the normalization visitors currently just match on ty::Alias. For future PR
while there are a few things I kinda dislike about this PR as is, it is a large change and we can clean them up afterwards
| ty, | ||
| // FIXME(rigid_aliases_marker): types coming out of `item_bounds` | ||
| // are marked as non-rigid while the visited ty can be rigid. | ||
| ty::set_aliases_to_non_rigid(tcx, ty), |
There was a problem hiding this comment.
as in, we relate non-rigid with rigid aliases here?
| } | ||
|
|
||
| /// Return whether we should consider the current place as a drop guard and skip reporting. | ||
| fn maybe_drop_guard<'tcx>( |
There was a problem hiding this comment.
hmm, why does liveness use PostAnalysis at all?
It is running on mir_promoted and should just use the typing mode of its MIR body 🤔
There was a problem hiding this comment.
No idea, but it does use PostAnalysis 😢
| // FIXME(rigid_aliases_marker): ideally we set aliases to non_rigid right after | ||
| // the typing mode is set to `PostAnalysis`. | ||
| // But modifying local decls in MIR body is inconvenient. And we can't fold | ||
| // `PlaceRef` in `checked_places`. |
There was a problem hiding this comment.
| // FIXME(rigid_aliases_marker): ideally we set aliases to non_rigid right after | |
| // the typing mode is set to `PostAnalysis`. | |
| // But modifying local decls in MIR body is inconvenient. And we can't fold | |
| // `PlaceRef` in `checked_places`. | |
| // FIXME(rigid_aliases_marker): Liveness uses `TypingMode::PostAnalysis` | |
| // even though its run on `mir_promoted` which is still | |
| // in an earlier `TypingMode`. This is odd and we have to | |
| // manually mark aliases as non-rigid here. |
I think we just shouldn't use PostAnalysis here?
There was a problem hiding this comment.
I can try with a different typing mode, perhaps PostBorrowckAnalysis? and we then don't need to change rigidness manually here.
There was a problem hiding this comment.
I think changing rigidness and keeping this FIXME is fine. Should look into this in a separate PR though :>
| { | ||
| if let Ok(c) = self.tcx.try_normalize_erasing_regions( | ||
| self.typing_env, | ||
| Unnormalized::new_wip(ty::set_aliases_to_non_rigid(self.tcx, constant.const_)), |
There was a problem hiding this comment.
should set_aliases_to_non_rigid just return Unnormalized?
There was a problem hiding this comment.
It could, but Unnormalized is kinda unwieldy as noted in its cons?
There was a problem hiding this comment.
yeah, I think it results in a nicer temporary state to do this I think
| pub fn eager_resolve_vars_with_infcx<Infcx: InferCtxtLike, T: TypeFoldable<Infcx::Interner>>( | ||
| delegate: &Infcx, | ||
| value: T, | ||
| ) -> T { |
There was a problem hiding this comment.
do we need both of these or could we just change the signature of eager_resolve_vars and that's good enough
| "directory into which to write optimization remarks (if not specified, they will be \ | ||
| written to standard error output)"), | ||
| renormalize_rigid_aliases: bool = (false, parse_bool, [TRACKED], | ||
| "do not skip rigid aliases in normalization"), |
There was a problem hiding this comment.
| "do not skip rigid aliases in normalization"), | |
| "do not skip rigid aliases in normalization for internal debugging"), |
| // FIXME: why don't we also instantiate const and region params with infer vars | ||
| // here? |
There was a problem hiding this comment.
that fixme shouldn't be on the Alias branch 🤣
the reason we don't is "diagnostics code isn't soundness critical, wildly out of date, and poorly tested" 😁
| // FIXME: This can't handle `AliasTerm`. Unsure if this is a problem in practice. | ||
| // We can't assert about `AliasTerm` as well since it doesn't affect type flags. |
There was a problem hiding this comment.
that seems fine to me 😁
if you have an AliasTerm you should already know whether to treat it as rigid or not 😁
|
|
||
| // Alias tend to mostly already be handled downstream due to normalization. | ||
| (ty::Alias(a), ty::Alias(b)) => { | ||
| (ty::Alias(a), ty::Alias(b)) if a.is_rigid == b.is_rigid => { |
|
I just saw the latest review comments right now. Will try to resolve them tomorrow. |
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
☔ The latest upstream changes (presumably #157794) made this pull request unmergeable. Please resolve the merge conflicts. |
View all comments
This PR adds a rigidness marker to
AliasTy/AliasTerm/UnevaluatedConst.It's used to skip renormalization of rigid aliases.
The difficulty is that rigid aliases are only valid in their own
TypingEnvso we need to treat them as non-rigid when entering anotherTypingEnv.This PR also adds a flag
-Zrenormalize-rigid-aliasesto test whether we properly handle typing mode change.Currently only
tests/ui/traits/next-solver/assembly/ambiguity-due-to-uniquification-4.rsfails this check.r? lcnr