diff options
| author | Ralf Jung <post@ralfj.de> | 2025-01-26 14:36:23 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-26 14:36:23 +0000 |
| commit | d7e942eb91111f3db249842ea1866e5bbf405538 (patch) | |
| tree | 8db5894ece32ab3228cf11299b855c55cc1ce76e /compiler/rustc_codegen_llvm/src | |
| parent | 57eabac8351013154cef7bac0f27759094ff5a96 (diff) | |
| parent | c688ecf4680b18734690159de7ba1ebf0c7e4026 (diff) | |
| download | rust-d7e942eb91111f3db249842ea1866e5bbf405538.tar.gz rust-d7e942eb91111f3db249842ea1866e5bbf405538.zip | |
Merge pull request #4151 from rust-lang/rustup-2025-01-26
Automatic Rustup
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/attributes.rs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/compiler/rustc_codegen_llvm/src/attributes.rs b/compiler/rustc_codegen_llvm/src/attributes.rs index 95e0481b035..3d7afa17bdf 100644 --- a/compiler/rustc_codegen_llvm/src/attributes.rs +++ b/compiler/rustc_codegen_llvm/src/attributes.rs @@ -333,9 +333,12 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>( let mut to_add = SmallVec::<[_; 16]>::new(); match codegen_fn_attrs.optimize { - OptimizeAttr::None => { + OptimizeAttr::Default => { to_add.extend(default_optimisation_attrs(cx)); } + OptimizeAttr::DoNotOptimize => { + to_add.push(llvm::AttributeKind::OptimizeNone.create_attr(cx.llcx)); + } OptimizeAttr::Size => { to_add.push(llvm::AttributeKind::MinSize.create_attr(cx.llcx)); to_add.push(llvm::AttributeKind::OptimizeForSize.create_attr(cx.llcx)); @@ -343,12 +346,12 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>( OptimizeAttr::Speed => {} } - let inline = - if codegen_fn_attrs.inline == InlineAttr::None && instance.def.requires_inline(cx.tcx) { - InlineAttr::Hint - } else { - codegen_fn_attrs.inline - }; + // `optnone` requires `noinline` + let inline = match (codegen_fn_attrs.inline, &codegen_fn_attrs.optimize) { + (_, OptimizeAttr::DoNotOptimize) => InlineAttr::Never, + (InlineAttr::None, _) if instance.def.requires_inline(cx.tcx) => InlineAttr::Hint, + (inline, _) => inline, + }; to_add.extend(inline_attr(cx, inline)); // The `uwtable` attribute according to LLVM is: |
