Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on May 28, 2025. It is now read-only.
/rustPublic archive
forked fromrust-lang/rust

Commit123d79b

Browse files
committed
Auto merge ofrust-lang#130679 - saethlin:inline-usually, r=<try>
Add inline(usually)r? `@ghost`I'm looking into what kind of things could recover the perf improvement detected inrust-lang#121417 (comment)
2 parents7042c26 +5abff9d commit123d79b

File tree

7 files changed

+15
-3
lines changed

7 files changed

+15
-3
lines changed

‎compiler/rustc_attr/src/builtin.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ pub enum InlineAttr {
4646
Hint,
4747
Always,
4848
Never,
49+
Usually,
4950
}
5051

5152
#[derive(Clone,Encodable,Decodable,Debug,PartialEq,Eq,HashStable_Generic)]

‎compiler/rustc_codegen_gcc/src/attributes.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ fn inline_attr<'gcc, 'tcx>(
3030
None
3131
}
3232
}
33+
InlineAttr::Usually =>Some(FnAttribute::Inline),
3334
InlineAttr::None =>None,
3435
}
3536
}

‎compiler/rustc_codegen_llvm/src/attributes.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ fn inline_attr<'ll>(cx: &CodegenCx<'ll, '_>, inline: InlineAttr) -> Option<&'ll
4747
}
4848
}
4949
InlineAttr::None =>None,
50+
InlineAttr::Usually =>{
51+
Some(llvm::CreateAttrStringValue(cx.llcx,"function-inline-cost","0"))
52+
}
5053
}
5154
}
5255

‎compiler/rustc_codegen_ssa/src/codegen_attrs.rs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,9 +525,15 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
525525
.emit();
526526
InlineAttr::None
527527
}elseiflist_contains_name(items, sym::always){
528-
InlineAttr::Always
528+
if tcx.sess.opts.optimize == rustc_session::config::OptLevel::No{
529+
InlineAttr::Usually
530+
}else{
531+
InlineAttr::Always
532+
}
529533
}elseiflist_contains_name(items, sym::never){
530534
InlineAttr::Never
535+
}elseiflist_contains_name(items, sym::usually){
536+
InlineAttr::Usually
531537
}else{
532538
struct_span_code_err!(tcx.dcx(), items[0].span(),E0535,"invalid argument")
533539
.with_help("valid inline arguments are `always` and `never`")

‎compiler/rustc_mir_transform/src/cross_crate_inline.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fn cross_crate_inlinable(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
4646
// #[inline(never)] to force code generation.
4747
match codegen_fn_attrs.inline{
4848
InlineAttr::Never =>returnfalse,
49-
InlineAttr::Hint |InlineAttr::Always =>returntrue,
49+
InlineAttr::Hint |InlineAttr::Always|InlineAttr::Usually=>returntrue,
5050
_ =>{}
5151
}
5252

‎compiler/rustc_mir_transform/src/inline.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ fn inline<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) -> bool {
106106
changed:false,
107107
caller_is_inline_forwarder:matches!(
108108
codegen_fn_attrs.inline,
109-
InlineAttr::Hint |InlineAttr::Always
109+
InlineAttr::Hint |InlineAttr::Always |InlineAttr::Usually
110110
) &&body_is_forwarder(body),
111111
};
112112
let blocks =START_BLOCK..body.basic_blocks.next_index();

‎compiler/rustc_span/src/symbol.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2102,6 +2102,7 @@ symbols! {
21022102
usize_legacy_fn_max_value,
21032103
usize_legacy_fn_min_value,
21042104
usize_legacy_mod,
2105+
usually,
21052106
va_arg,
21062107
va_copy,
21072108
va_end,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp