Clean up MonoItem::instantiation_mode by saethlin · Pull Request #136394 · rust-lang/rust

@rustbot added S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

T-compiler

Relevant to the compiler team, which will review and decide on the PR/issue.

labels

Feb 1, 2025

@saethlin

bors added a commit to rust-lang-ci/rust that referenced this pull request

Feb 1, 2025
…, r=<try>

Clean up MonoItem::instantiation_mode

More progress on cleaning up and documenting instantiation mode selection.

Tests pass locally, but I want this to pass perf first.

r? ghost

@saethlin saethlin marked this pull request as ready for review

February 1, 2025 21:35

compiler-errors

@bors bors added S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

and removed S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

labels

Feb 1, 2025

bors added a commit to rust-lang-ci/rust that referenced this pull request

Feb 1, 2025
… r=<try>

Remove InstanceKind::generates_cgu_internal_copy

This is on top of rust-lang#136394 for now.

`InstanceKind::generates_cgu_internal_copy` was called in two places:

1. By `reachable_non_generics`, but in that case the caller was guaranteed to not be generic and therefore we always fall through to just calling `cross_crate_inlinable`.
2. By `MonoItem::instantiation_mode`, but in that case the *only* thing that it does is some very complicated logic for selecting the instantiation mode for drop glue, and only very recently do we have a single codegen test for this. So I've touched up the logic in `cross_crate_inlinable` so that we don't try to claim that `drop_in_place` isn't cross-crate-inlinable, because it clearly is.

Now off to perf, and if we get regressions I'll start reintroducing the logic about drop glue but, but this time into `MonoItem::instantiation_mode` where it always should have been.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request

Feb 2, 2025
…de, r=compiler-errors

Clean up MonoItem::instantiation_mode

More progress on cleaning up and documenting instantiation mode selection.

This should have no behavior changes at all, it just rearranges the code inside `MonoItem::instantiation_mode` to a more logical flow and I've tried to explain every choice the implementation is making.

This was referenced

Feb 2, 2025

bors added a commit to rust-lang-ci/rust that referenced this pull request

Feb 2, 2025
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#134272 (Remove rustc_encodable_decodable feature)
 - rust-lang#136283 (Update encode_utf16 to mention it is native endian)
 - rust-lang#136394 (Clean up MonoItem::instantiation_mode)
 - rust-lang#136402 (diagnostics: fix borrowck suggestions for if/while let conditionals)
 - rust-lang#136415 (Highlight clarifying information in "expected/found" error)
 - rust-lang#136422 (Convert two `rustc_middle::lint` functions to `Span` methods.)
 - rust-lang#136434 (rustc_allowed_through_unstable_modules: require deprecation message)

r? `@ghost`
`@rustbot` modify labels: rollup

rust-timer added a commit to rust-lang-ci/rust that referenced this pull request

Feb 2, 2025
Rollup merge of rust-lang#136394 - saethlin:clean-up-instantiation-mode, r=compiler-errors

Clean up MonoItem::instantiation_mode

More progress on cleaning up and documenting instantiation mode selection.

This should have no behavior changes at all, it just rearranges the code inside `MonoItem::instantiation_mode` to a more logical flow and I've tried to explain every choice the implementation is making.

@saethlin saethlin deleted the clean-up-instantiation-mode branch

February 2, 2025 22:09

bors added a commit to rust-lang-ci/rust that referenced this pull request

Feb 8, 2025
… r=<try>

Remove InstanceKind::generates_cgu_internal_copy

This is on top of rust-lang#136394 for now.

`InstanceKind::generates_cgu_internal_copy` was called in two places:

1. By `reachable_non_generics`, but in that case the caller was guaranteed to not be generic and therefore we always fall through to just calling `cross_crate_inlinable`.
2. By `MonoItem::instantiation_mode`, but in that case the *only* thing that it does is some very complicated logic for selecting the instantiation mode for drop glue, and only very recently do we have a single codegen test for this. So I've touched up the logic in `cross_crate_inlinable` so that we don't try to claim that `drop_in_place` isn't cross-crate-inlinable, because it clearly is.

Now off to perf, and if we get regressions I'll start reintroducing the logic about drop glue but, but this time into `MonoItem::instantiation_mode` where it always should have been.