Permit MIR inlining without #[inline]

This commit is contained in:
Ben Kimock 2023-03-16 22:18:28 -04:00
parent da636956dd
commit e3126b1084
4 changed files with 5 additions and 11 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

@ -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