Skip to content

Commit e3126b1

Browse files
committed
Permit MIR inlining without #[inline]
1 parent da63695 commit e3126b1

File tree

4 files changed

+5
-11
lines changed

4 files changed

+5
-11
lines changed

compiler/rustc_mir_transform/src/inline.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -350,14 +350,8 @@ impl<'tcx> Inliner<'tcx> {
350350
callsite: &CallSite<'tcx>,
351351
callee_attrs: &CodegenFnAttrs,
352352
) -> Result<(), &'static str> {
353-
match callee_attrs.inline {
354-
InlineAttr::Never => return Err("never inline hint"),
355-
InlineAttr::Always | InlineAttr::Hint => {}
356-
InlineAttr::None => {
357-
if self.tcx.sess.mir_opt_level() <= 2 {
358-
return Err("at mir-opt-level=2, only #[inline] is inlined");
359-
}
360-
}
353+
if let InlineAttr::Never = callee_attrs.inline {
354+
return Err("never inline hint");
361355
}
362356

363357
// Only inline local functions if they would be eligible for cross-crate

tests/codegen/array-map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub fn short_integer_map(x: [u32; 8]) -> [u32; 8] {
2121
pub fn short_integer_zip_map(x: [u32; 8], y: [u32; 8]) -> [u32; 8] {
2222
// CHECK: %[[A:.+]] = load <8 x i32>
2323
// CHECK: %[[B:.+]] = load <8 x i32>
24-
// CHECK: sub <8 x i32> %[[A]], %[[B]]
24+
// CHECK: sub <8 x i32> %[[B]], %[[A]]
2525
// CHECK: store <8 x i32>
2626
x.zip(y).map(|(x, y)| x - y)
2727
}

tests/codegen/inline-hint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Checks that closures, constructors, and shims except
22
// for a drop glue receive inline hint by default.
33
//
4-
// compile-flags: -Cno-prepopulate-passes -Csymbol-mangling-version=v0
4+
// compile-flags: -Cno-prepopulate-passes -Csymbol-mangling-version=v0 -Zinline-mir=no
55
#![crate_type = "lib"]
66

77
pub fn f() {

tests/codegen/local-generics-in-exe-internalized.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// compile-flags: -C no-prepopulate-passes -Zshare-generics=yes
1+
// compile-flags: -C no-prepopulate-passes -Zshare-generics=yes -Zinline-mir=no
22

33
// Check that local generics are internalized if they are in the same CGU
44

0 commit comments

Comments
 (0)