Allow MIR-inlining Drop terminators too#144561
Draft
scottmcm wants to merge 4 commits intorust-lang:mainfrom
Draft
Allow MIR-inlining Drop terminators too#144561scottmcm wants to merge 4 commits intorust-lang:mainfrom
Drop terminators too#144561scottmcm wants to merge 4 commits intorust-lang:mainfrom
Conversation
scottmcm
commented
Jul 28, 2025
| let source_info = terminator.source_info; | ||
| let drop_ty = place.ty(&caller_body.local_decls, tcx).ty; | ||
| if !drop_ty.needs_drop(tcx, inliner.typing_env()) { | ||
| //return None; |
This comment has been minimized.
This comment has been minimized.
Collaborator
|
☔ The latest upstream changes (presumably #144543) made this pull request unmergeable. Please resolve the merge conflicts. |
Contributor
|
You'll probably need to change the mir shim pass. The current implementation only reliably supports monomorphic types. |
Zalathar
added a commit
to Zalathar/rust
that referenced
this pull request
Jul 29, 2025
Simplify `align_of_val::<[T]>(…)` → `align_of::<T>()` I spotted this while working on the inliner (rust-lang#144561). In particular, if [`Layout::for_value`](https://doc.rust-lang.org/std/alloc/struct.Layout.html#method.for_value) inlines, then it can be pretty easy to end up with an `align_of_val::<[T]>` today (demo: <https://rust.godbolt.org/z/Tesnscj4a>) where we can save at least a block, if not more, by using the version that's an rvalue and not a call.
rust-timer
added a commit
that referenced
this pull request
Jul 29, 2025
Rollup merge of #144566 - scottmcm:align-of-slice, r=oli-obk Simplify `align_of_val::<[T]>(…)` → `align_of::<T>()` I spotted this while working on the inliner (#144561). In particular, if [`Layout::for_value`](https://doc.rust-lang.org/std/alloc/struct.Layout.html#method.for_value) inlines, then it can be pretty easy to end up with an `align_of_val::<[T]>` today (demo: <https://rust.godbolt.org/z/Tesnscj4a>) where we can save at least a block, if not more, by using the version that's an rvalue and not a call.
Member
Author
|
Hmm, looks like you're right. Just trying to guard requesting the mir doesn't work since it's a concrete outer type, just with field issues. Tricky; I'll have to spend some time grokking the shim pass. |
This comment has been minimized.
This comment has been minimized.
GuillaumeGomez
added a commit
to GuillaumeGomez/rust
that referenced
this pull request
Aug 1, 2025
Fortify RemoveUnneededDrops test. Test tweak that is useful in preparation for rust-lang#144561
samueltardieu
added a commit
to samueltardieu/rust
that referenced
this pull request
Aug 2, 2025
Fortify RemoveUnneededDrops test. Test tweak that is useful in preparation for rust-lang#144561
samueltardieu
added a commit
to samueltardieu/rust
that referenced
this pull request
Aug 2, 2025
Fortify RemoveUnneededDrops test. Test tweak that is useful in preparation for rust-lang#144561
Collaborator
|
☔ The latest upstream changes (presumably #144814) made this pull request unmergeable. Please resolve the merge conflicts. |
github-actions bot
pushed a commit
to rust-lang/rustc-dev-guide
that referenced
this pull request
Aug 4, 2025
Fortify RemoveUnneededDrops test. Test tweak that is useful in preparation for rust-lang/rust#144561
This comment has been minimized.
This comment has been minimized.
Collaborator
|
The job Click to see the possible cause of the failure (guessed by this bot) |
Zalathar
added a commit
to Zalathar/rust
that referenced
this pull request
Aug 9, 2025
…lace, r=nnethercote Remove unneeded `drop_in_place` calls Might as well pull this out from rust-lang#144561 because this is still used in things like `Vec::truncate` where it'd be nice to allow it be removed if inlined enough to see that the type is `Copy`. So long as perf says it's ok, at least 🤞
rust-timer
added a commit
that referenced
this pull request
Aug 9, 2025
Rollup merge of #144883 - scottmcm:remove-unneeded-drop_in_place, r=nnethercote Remove unneeded `drop_in_place` calls Might as well pull this out from #144561 because this is still used in things like `Vec::truncate` where it'd be nice to allow it be removed if inlined enough to see that the type is `Copy`. So long as perf says it's ok, at least 🤞
rust-cloud-vms bot
pushed a commit
to makai410/rustc_public
that referenced
this pull request
Aug 16, 2025
…nethercote Remove unneeded `drop_in_place` calls Might as well pull this out from rust-lang/rust#144561 because this is still used in things like `Vec::truncate` where it'd be nice to allow it be removed if inlined enough to see that the type is `Copy`. So long as perf says it's ok, at least 🤞
rust-cloud-vms bot
pushed a commit
to makai410/rustc_public
that referenced
this pull request
Aug 20, 2025
…nethercote Remove unneeded `drop_in_place` calls Might as well pull this out from rust-lang/rust#144561 because this is still used in things like `Vec::truncate` where it'd be nice to allow it be removed if inlined enough to see that the type is `Copy`. So long as perf says it's ok, at least 🤞
makai410
pushed a commit
to makai410/rust
that referenced
this pull request
Nov 8, 2025
…lace, r=nnethercote Remove unneeded `drop_in_place` calls Might as well pull this out from rust-lang#144561 because this is still used in things like `Vec::truncate` where it'd be nice to allow it be removed if inlined enough to see that the type is `Copy`. So long as perf says it's ok, at least 🤞
makai410
pushed a commit
to makai410/rust
that referenced
this pull request
Nov 10, 2025
…lace, r=nnethercote Remove unneeded `drop_in_place` calls Might as well pull this out from rust-lang#144561 because this is still used in things like `Vec::truncate` where it'd be nice to allow it be removed if inlined enough to see that the type is `Copy`. So long as perf says it's ok, at least 🤞
makai410
pushed a commit
to makai410/rustc_public
that referenced
this pull request
Nov 16, 2025
…nethercote Remove unneeded `drop_in_place` calls Might as well pull this out from rust-lang/rust#144561 because this is still used in things like `Vec::truncate` where it'd be nice to allow it be removed if inlined enough to see that the type is `Copy`. So long as perf says it's ok, at least 🤞
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We've already been able to do this if
drop(_1)was spelled_2 = &raw mut _1; drop_in_place(move _2), so this just needs to do the necessary updates to the query-cycle-avoidance check and to look forDrops in the normal (non-force) inliner.This tries to avoid turning
drops intodrop_in_placecalls if they're likely not going to be inlined, since theCallneeds an extra local and an extra statement.r? cjgillot