about summary refs log tree commit diff
path: root/tests/codegen/inline-function-args-debug-info.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 /tests/codegen/inline-function-args-debug-info.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 'tests/codegen/inline-function-args-debug-info.rs')
-rw-r--r--tests/codegen/inline-function-args-debug-info.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/tests/codegen/inline-function-args-debug-info.rs b/tests/codegen/inline-function-args-debug-info.rs
index e3d8caa49d4..ffae99e0f24 100644
--- a/tests/codegen/inline-function-args-debug-info.rs
+++ b/tests/codegen/inline-function-args-debug-info.rs
@@ -6,6 +6,7 @@
 
 #![crate_type = "lib"]
 
+#[inline(never)]
 pub fn outer_function(x: usize, y: usize) -> usize {
     inner_function(x, y) + 1
 }
@@ -13,8 +14,8 @@ pub fn outer_function(x: usize, y: usize) -> usize {
 #[inline]
 fn inner_function(aaaa: usize, bbbb: usize) -> usize {
     // CHECK: !DILocalVariable(name: "aaaa", arg: 1
-    // CHECK-SAME: line: 14
+    // CHECK-SAME: line: 15
     // CHECK: !DILocalVariable(name: "bbbb", arg: 2
-    // CHECK-SAME: line: 14
+    // CHECK-SAME: line: 15
     aaaa + bbbb
 }