about summary refs log tree commit diff
path: root/compiler/rustc_data_structures/src/lib.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-10-18 02:00:44 +0000
committerbors <bors@rust-lang.org>2023-10-18 02:00:44 +0000
commit5d5edf0248d967baa6ac5cbea09b91c7c9947942 (patch)
treef25d7284cfee91d52927cec8f62b66516990ed21 /compiler/rustc_data_structures/src/lib.rs
parentca89f732ec0f910fc92111a45dd7e6829baa9d4b (diff)
parenta76cae02345a861285334446cd24c6eb9616866a (diff)
downloadrust-5d5edf0248d967baa6ac5cbea09b91c7c9947942.tar.gz
rust-5d5edf0248d967baa6ac5cbea09b91c7c9947942.zip
Auto merge of #116505 - saethlin:infer-inline, r=cjgillot
Automatically enable cross-crate inlining for small functions

This is basically reviving https://github.com/rust-lang/rust/pull/70550

The `#[inline]` attribute can have a significant impact on code generation or runtime performance (because it enables inlining between CGUs where it would normally not happen) and also on compile-time performance (because it enables MIR inlining). But it has to be added manually, which is awkward.

This PR factors whether a DefId is cross-crate inlinable into a query, and replaces all uses of `CodegenFnAttrs::requests_inline` with this new query. The new query incorporates all the other logic that is used to determine whether a Def should be treated as cross-crate-inlinable, and as a last step inspects the function's optimized_mir to determine if it should be treated as cross-crate-inlinable.

The heuristic implemented here is deliberately conservative; we only infer inlinability for functions whose optimized_mir does not contain any calls or asserts. I plan to study adjusting the cost model later, but for now the compile time implications of this change are so significant that I think this very crude heuristic is well worth landing.
Diffstat (limited to 'compiler/rustc_data_structures/src/lib.rs')
0 files changed, 0 insertions, 0 deletions