Conversation
Fixes 144621
|
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
| } | ||
| if let ty::Adt(def, _args) = ty.kind() | ||
| && tcx.is_lang_item(def.did(), LangItem::DynMetadata) | ||
| && (def.repr().simd() || tcx.is_lang_item(def.did(), LangItem::DynMetadata)) |
There was a problem hiding this comment.
Please update the doc comment on this function.
Also, could you rename this function? Calling it escaping_locals seems a bit misleading given it has opt-outs for locals that are not necessarily escaping.
This comment has been minimized.
This comment has been minimized.
d942a9d to
ec7e4f9
Compare
compiler-errors
left a comment
There was a problem hiding this comment.
I'm pretty confused about how this was refactored. This code distinguishes escaping and excluded, but AFAICT escaping is a superset of the two that shouldn't change. Is there something I'm misunderstanding about the code, or are there further simplifications we can do here?
| let mut excluded = excluded_locals(body); | ||
| let typing_env = body.typing_env(tcx); | ||
| loop { | ||
| add_type_based_exclusions(tcx, &mut excluded, body); |
There was a problem hiding this comment.
Does this need to happen in the loop? The set of excluded locals based off of type exclusions shouldn't change, right?
There was a problem hiding this comment.
Since we're in a loop I think it can because SRoA might add extra locals in the loop?
We can SRoA a (__m128, __m128), adding new locals which themselves need to not get SRoA'd.
| body: &Body<'tcx>, | ||
| ) -> DenseBitSet<Local> { | ||
| ) { | ||
| let is_excluded_ty = |ty: Ty<'tcx>| { |
There was a problem hiding this comment.
Why not just inline this closure? It's just a simple match on ADT, even if it's not written like that today.
| let mut set = DenseBitSet::new_empty(body.local_decls.len()); | ||
| set.insert_range(RETURN_PLACE..=Local::from_usize(body.arg_count)); | ||
| for (local, decl) in body.local_decls().iter_enumerated() { | ||
| if excluded.contains(local) || is_excluded_ty(decl.ty) { | ||
| for local in body.local_decls().indices() { | ||
| if excluded.contains(local) { | ||
| set.insert(local); | ||
| } | ||
| } |
There was a problem hiding this comment.
This is morally just a clone of excluded, right?
There was a problem hiding this comment.
Hmm, probably. I'll give it a shot. (I don't know if there's potentially different lengths because of changing numbers of locals.)
|
Actually, @compiler-errors, would you be ok with just doing the first commit here for now -- since beta branches in 2 days and we should have a fix for this -- as a partial revert of #144543, and then doing the refactor in another PR? |
|
Sure |
|
r=me on the first commit |
ec7e4f9 to
fe08ba0
Compare
|
@bors r=compiler-errors |
|
I've been thinking about the structure here and pondering whether there's some useful loop invariants that can simplify the refactor. Notably, since we're already blocking Still TBD on trying that out and seeing how it feels, though. |
Rollup of 3 pull requests Successful merges: - rust-lang/rust#144657 (fix: Only "close the window" when its the last annotated file) - rust-lang/rust#144665 (Re-block SRoA on SIMD types) - rust-lang/rust#144713 (`rustc_middle::ty` cleanups) r? `@ghost` `@rustbot` modify labels: rollup
Fixes #144621