-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Remove InstanceKind::generates_cgu_internal_copy #136410
Conversation
r? @wesleywiser rustbot has assigned @wesleywiser. Use |
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
… 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.
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (69c35dc): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowBenchmarking 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. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Instruction countThis is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.
Max RSS (memory usage)Results (primary 1.7%, secondary 1.5%)This 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.
CyclesResults (primary 15.7%, secondary 13.9%)This 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.
Binary sizeResults (primary 4.0%, secondary -0.2%)This 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.
Bootstrap: 777.275s -> 785.803s (1.10%) |
6e9db01
to
d22354c
Compare
This comment has been minimized.
This comment has been minimized.
8a8bb0c
to
2e0908b
Compare
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
… 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.
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (53335c7): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowBenchmarking 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. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Instruction countThis is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.
Max RSS (memory usage)Results (primary -2.0%)This 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.
CyclesResults (primary 14.1%, secondary 4.8%)This 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.
Binary sizeResults (primary -0.1%, secondary 2.0%)This 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.
Bootstrap: 778.956s -> 782.985s (0.52%) |
codegen tests are expected to fail @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (6a752a8): comparison URL. Overall result: ❌ regressions - please read the text belowBenchmarking 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. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Instruction countThis is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.
Max RSS (memory usage)Results (secondary -0.4%)This 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.
CyclesResults (primary 3.6%, secondary -3.3%)This 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.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 779.565s -> 781.025s (0.19%) |
@rustbot label: +perf-regression-triaged |
r? compiler |
@@ -93,16 +93,11 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<S | |||
return None; | |||
} | |||
|
|||
// Functions marked with #[inline] are codegened with "internal" |
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.
Why'd you remove the comment? Seems valid still to mention the interaction w/ inline.
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.
I removed it because the logic for the inline
attribute and extern indicators is in cross_crate_inlinable
. I can put back a comment if you want 🤷 but one of the purposes of tcx.cross_crate_inlinable
is to be the single point in the compiler that juggles those interactions.
fn opt_incr_drop_glue_mode<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> InstantiationMode { | ||
// Non-ADTs can't have a Drop impl. This case is mostly hit by closures whose captures require | ||
// dropping. | ||
let Some(adt_def) = ty.ty_adt_def() else { |
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.
nit: I prefer let ty::Adt(adt_def, _) = ty.kind()
over ty_adt_def
.
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.
I agree that's better.
|
||
// Types that don't have a direct Drop impl, but have fields that require dropping. | ||
let Some(dtor) = adt_def.destructor(tcx) else { | ||
if adt_def.is_enum() { |
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.
Do you know what motivates this choice of making enums act differently than structs? I mean, both of them have fields after 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.
I know something. I've added a comment that explains what I know and references the PR that landed the logic that I'm rewriting.
r=me after nits or not |
2c32926
to
817e2c5
Compare
Some changes occurred in compiler/rustc_codegen_ssa |
@bors r+ |
☀️ Test successful - checks-actions |
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing e61403a (parent) -> 7d49ae9 (this PR) Test differencesShow 4 test diffsAdditionally, 4 doctest diffs were found. These are ignored, as they are noisy. Job group index |
Finished benchmarking commit (7d49ae9): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results (primary 2.8%, secondary 0.4%)This 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.
CyclesResults (secondary 4.9%)This 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.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 776.063s -> 777.441s (0.18%) |
This PR should not contain any behavior changes. Before this PR, the logic for selecting instantiation mode is spread across all of
instantiation_mode
cross_crate_inlinable
generates_cgu_internal_copy
requires_inline
The last two of those functions are not well-designed. The function that actually decides if we generate a CGU-internal copy is
instantiation_mode
, notgenerates_cgu_internal_copy
. The functionrequires_inline
documents that it is about the LLVMinline
attribute and that it is a hint. The LLVM attribute is calledinlinehint
, this function is also used by other codegen backends, and since it is part of instantiation mode selection it is not a hint.The goal of this PR is to start cleaning up the logic into a sequence of checks that have a more logical flow and are easier to customize in the future (to do things like improve incrementality or improve optimizations without causing obscure linker errors because you forgot to update another part of the compiler).