Skip to content

Commit 7e2a641

Browse files
authored
Unrolled build for rust-lang#136358
Rollup merge of rust-lang#136358 - clubby789:opt-none-noinline, r=saethlin `#[optimize(none)]` implies `#[inline(never)]` Fixes rust-lang#136329
2 parents 6dd75f0 + 2c35bd0 commit 7e2a641

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

compiler/rustc_mir_transform/src/inline.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::iter;
44
use std::ops::{Range, RangeFrom};
55

66
use rustc_abi::{ExternAbi, FieldIdx};
7-
use rustc_attr_parsing::InlineAttr;
7+
use rustc_attr_parsing::{InlineAttr, OptimizeAttr};
88
use rustc_hir::def::DefKind;
99
use rustc_hir::def_id::DefId;
1010
use rustc_index::Idx;
@@ -770,6 +770,10 @@ fn check_codegen_attributes<'tcx, I: Inliner<'tcx>>(
770770
return Err("never inline attribute");
771771
}
772772

773+
if let OptimizeAttr::DoNotOptimize = callee_attrs.optimize {
774+
return Err("has DoNotOptimize attribute");
775+
}
776+
773777
// Reachability pass defines which functions are eligible for inlining. Generally inlining
774778
// other functions is incorrect because they could reference symbols that aren't exported.
775779
let is_generic = callsite.callee.args.non_erasable_generics().next().is_some();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//! Ensure that `#[optimize(none)]` functions are never inlined
2+
3+
//@ compile-flags: -Copt-level=3
4+
5+
#![feature(optimize_attribute)]
6+
7+
#[optimize(none)]
8+
pub fn foo() {
9+
let _x = 123;
10+
}
11+
12+
// CHECK-LABEL: define{{.*}}void @bar
13+
// CHECK: start:
14+
// CHECK: {{.*}}call {{.*}}void
15+
// CHECK: ret void
16+
#[no_mangle]
17+
pub fn bar() {
18+
foo();
19+
}
20+
21+
fn main() {}

0 commit comments

Comments
 (0)