Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
b20bc53
ci: fix explanation why LLVM download is disabled for windows-gnu
mati865 Nov 20, 2024
2c35bd0
`#[optimize(none)]` implies `#[inline(never)]`
clubby789 Jan 31, 2025
8e9422f
Make comma separated lists of anything easier to make for errors
estebank Jan 31, 2025
0751e90
Rework "long type names" printing logic
estebank Jan 31, 2025
24cdaa1
Rename `tcx.ensure()` to `tcx.ensure_ok()`
Zalathar Jan 30, 2025
9e4f10d
Rename `tcx.ensure_with_value()` to `tcx.ensure_done()`
Zalathar Jan 30, 2025
fef46f4
Rename `ensure_forwards_result_if_red` to `return_result_from_ensure_ok`
Zalathar Jan 30, 2025
3581512
Use an explicit type when discarding the result of `tcx.ensure_ok()`
Zalathar Jan 30, 2025
3ae0239
Mark the tcx-ensure wrapper types with `#[must_use]`
Zalathar Jan 30, 2025
0617106
Fix sentence in process::abort
hkBst Jan 27, 2025
028a920
Tweak fn pointer suggestion span
estebank Feb 2, 2025
78794d0
Rollup merge of #133266 - mati865:windows-gnu-llvm-download, r=Kobzol
matthiaskrgr Feb 2, 2025
555dd6f
Rollup merge of #136133 - hkBst:patch-23, r=ibraheemdev
matthiaskrgr Feb 2, 2025
58a5f89
Rollup merge of #136279 - Zalathar:ensure-ok, r=oli-obk
matthiaskrgr Feb 2, 2025
39efaa0
Rollup merge of #136328 - estebank:long-ty-path, r=jieyouxu,lqd
matthiaskrgr Feb 2, 2025
ce5db2f
Rollup merge of #136358 - clubby789:opt-none-noinline, r=saethlin
matthiaskrgr Feb 2, 2025
3559a48
Rollup merge of #136368 - estebank:listify, r=fee1-dead
matthiaskrgr Feb 2, 2025
44def58
Rollup merge of #136412 - estebank:fn-ptr-cast-suggestion, r=jieyouxu
matthiaskrgr Feb 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
#[optimize(none)] implies #[inline(never)]
  • Loading branch information
clubby789 committed Jan 31, 2025
commit 2c35bd0499130af395bdbb49a49d5a019599d22e
6 changes: 5 additions & 1 deletion compiler/rustc_mir_transform/src/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::iter;
use std::ops::{Range, RangeFrom};

use rustc_abi::{ExternAbi, FieldIdx};
use rustc_attr_parsing::InlineAttr;
use rustc_attr_parsing::{InlineAttr, OptimizeAttr};
use rustc_hir::def::DefKind;
use rustc_hir::def_id::DefId;
use rustc_index::Idx;
Expand Down Expand Up @@ -770,6 +770,10 @@ fn check_codegen_attributes<'tcx, I: Inliner<'tcx>>(
return Err("never inline attribute");
}

if let OptimizeAttr::DoNotOptimize = callee_attrs.optimize {
return Err("has DoNotOptimize attribute");
}

// Reachability pass defines which functions are eligible for inlining. Generally inlining
// other functions is incorrect because they could reference symbols that aren't exported.
let is_generic = callsite.callee.args.non_erasable_generics().next().is_some();
Expand Down
21 changes: 21 additions & 0 deletions tests/codegen/issues/issue-136329-optnone-noinline.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//! Ensure that `#[optimize(none)]` functions are never inlined

//@ compile-flags: -Copt-level=3

#![feature(optimize_attribute)]

#[optimize(none)]
pub fn foo() {
let _x = 123;
}

// CHECK-LABEL: define{{.*}}void @bar
// CHECK: start:
// CHECK: {{.*}}call {{.*}}void
// CHECK: ret void
#[no_mangle]
pub fn bar() {
foo();
}

fn main() {}
Loading