From 7a298181fa411edbbcf014062dd9c3a8969d8e76 Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Wed, 21 Feb 2024 17:42:43 -0500 Subject: [PATCH] Ignore inline(always) in unoptimized builds --- compiler/rustc_codegen_llvm/src/attributes.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_codegen_llvm/src/attributes.rs b/compiler/rustc_codegen_llvm/src/attributes.rs index f9eaa0d94cbbd..3952e95af8772 100644 --- a/compiler/rustc_codegen_llvm/src/attributes.rs +++ b/compiler/rustc_codegen_llvm/src/attributes.rs @@ -41,7 +41,13 @@ fn inline_attr<'ll>(cx: &CodegenCx<'ll, '_>, inline: InlineAttr) -> Option<&'ll } match inline { InlineAttr::Hint => Some(AttributeKind::InlineHint.create_attr(cx.llcx)), - InlineAttr::Always => Some(AttributeKind::AlwaysInline.create_attr(cx.llcx)), + InlineAttr::Always => { + if matches!(cx.sess().opts.optimize, OptLevel::No) { + Some(AttributeKind::InlineHint.create_attr(cx.llcx)) + } else { + Some(AttributeKind::AlwaysInline.create_attr(cx.llcx)) + } + } InlineAttr::Never => { if cx.sess().target.arch != "amdgpu" { Some(AttributeKind::NoInline.create_attr(cx.llcx))