Auto merge of #109247 - saethlin:inline-without-inline, r=oli-obk

Permit MIR inlining without #[inline]

I noticed that there are at least a handful of portable-simd functions that have no `#[inline]` but compile to an assign + return.

I locally benchmarked inlining thresholds between 0 and 50 in increments of 5, and 50 seems to be the best. Interesting. That didn't include check builds though, ~maybe perf will have something to say about that~.

Perf has little useful to say about this. We generally regress all the check builds, as best as I can tell, due to a number of small codegen changes in a particular hot function in the compiler. Probably this is because we've nudged the inlining outcomes all over, and uses of `#[inline(always)]`/`#[inline(never)]` might need to be adjusted.
This commit is contained in:
bors 2023-04-17 02:36:38 +00:00
commit 5546cb64f6
13 changed files with 16 additions and 22 deletions

View File

@ -350,14 +350,8 @@ impl<'tcx> Inliner<'tcx> {
callsite: &CallSite<'tcx>,
callee_attrs: &CodegenFnAttrs,
) -> Result<(), &'static str> {
match callee_attrs.inline {
InlineAttr::Never => return Err("never inline hint"),
InlineAttr::Always | InlineAttr::Hint => {}
InlineAttr::None => {
if self.tcx.sess.mir_opt_level() <= 2 {
return Err("at mir-opt-level=2, only #[inline] is inlined");
}
}
if let InlineAttr::Never = callee_attrs.inline {
return Err("never inline hint");
}
// Only inline local functions if they would be eligible for cross-crate

View File

@ -1,4 +1,4 @@
// compile-flags:-Zprint-mono-items=eager
// compile-flags:-Zprint-mono-items=eager -Zinline-mir=no
#![deny(dead_code)]
#![feature(start)]

View File

@ -1,5 +1,4 @@
//
// compile-flags:-Zprint-mono-items=eager
// compile-flags:-Zprint-mono-items=eager -Zinline-mir=no
#![deny(dead_code)]
#![feature(start)]

View File

@ -1,4 +1,4 @@
// compile-flags:-Zprint-mono-items=eager
// compile-flags:-Zprint-mono-items=eager -Zinline-mir=no
#![deny(dead_code)]
#![feature(start)]

View File

@ -1,4 +1,4 @@
// compile-flags:-Zprint-mono-items=eager
// compile-flags:-Zprint-mono-items=eager -Zinline-mir=no
#![deny(dead_code)]
#![feature(start)]

View File

@ -1,4 +1,4 @@
// compile-flags:-Zprint-mono-items=eager
// compile-flags:-Zprint-mono-items=eager -Zinline-mir=no
#![deny(dead_code)]
#![feature(start)]

View File

@ -1,5 +1,4 @@
//
// compile-flags:-Zprint-mono-items=eager
// compile-flags:-Zprint-mono-items=eager -Zinline-mir=no
#![deny(dead_code)]
#![feature(start)]

View File

@ -1,4 +1,4 @@
// compile-flags:-Zprint-mono-items=eager -Zpolymorphize=on
// compile-flags:-Zprint-mono-items=eager -Zpolymorphize=on -Zinline-mir=no
#![deny(dead_code)]
#![feature(start)]

View File

@ -21,7 +21,7 @@ pub fn short_integer_map(x: [u32; 8]) -> [u32; 8] {
pub fn short_integer_zip_map(x: [u32; 8], y: [u32; 8]) -> [u32; 8] {
// CHECK: %[[A:.+]] = load <8 x i32>
// CHECK: %[[B:.+]] = load <8 x i32>
// CHECK: sub <8 x i32> %[[A]], %[[B]]
// CHECK: sub <8 x i32> %[[B]], %[[A]]
// CHECK: store <8 x i32>
x.zip(y).map(|(x, y)| x - y)
}

View File

@ -1,7 +1,7 @@
// Checks that closures, constructors, and shims except
// for a drop glue receive inline hint by default.
//
// compile-flags: -Cno-prepopulate-passes -Csymbol-mangling-version=v0
// compile-flags: -Cno-prepopulate-passes -Csymbol-mangling-version=v0 -Zinline-mir=no
#![crate_type = "lib"]
pub fn f() {

View File

@ -1,4 +1,4 @@
// compile-flags: -C no-prepopulate-passes -Zshare-generics=yes
// compile-flags: -C no-prepopulate-passes -Zshare-generics=yes -Zinline-mir=no
// Check that local generics are internalized if they are in the same CGU

View File

@ -3,4 +3,6 @@
#![crate_type = "lib"]
pub fn foo<T>() {}
pub fn foo<T: Default>() -> T {
T::default()
}

View File

@ -7,7 +7,7 @@
extern crate xcrate_generic;
pub fn foo() {
xcrate_generic::foo::<u32>();
println!("{}", xcrate_generic::foo::<u32>());
}
// Here we check that local debuginfo is mapped correctly.