about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/callee.rs
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2024-11-23 13:19:17 -0500
committerMark Rousskov <mark.simulacrum@gmail.com>2024-11-28 13:43:05 -0500
commit4a216a25d143e88eefac2655c1fce042571e1f6e (patch)
treedd8b394804ef4dcee527cfa8e31f3b2ebded7612 /compiler/rustc_codegen_llvm/src/callee.rs
parent39cb3386ddc6c71657418be28dbb3987eea4aa4b (diff)
downloadrust-4a216a25d143e88eefac2655c1fce042571e1f6e.tar.gz
rust-4a216a25d143e88eefac2655c1fce042571e1f6e.zip
Share inline(never) generics across crates
This reduces code sizes and better respects programmer intent when
marking inline(never). Previously such a marking was essentially ignored
for generic functions, as we'd still inline them in remote crates.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/callee.rs')
-rw-r--r--compiler/rustc_codegen_llvm/src/callee.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_llvm/src/callee.rs b/compiler/rustc_codegen_llvm/src/callee.rs
index e0a2de3366c..ec77f32caf4 100644
--- a/compiler/rustc_codegen_llvm/src/callee.rs
+++ b/compiler/rustc_codegen_llvm/src/callee.rs
@@ -104,7 +104,10 @@ pub(crate) fn get_fn<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'t
 
             let is_hidden = if is_generic {
                 // This is a monomorphization of a generic function.
-                if !cx.tcx.sess.opts.share_generics() {
+                if !(cx.tcx.sess.opts.share_generics()
+                    || tcx.codegen_fn_attrs(instance_def_id).inline
+                        == rustc_attr::InlineAttr::Never)
+                {
                     // When not sharing generics, all instances are in the same
                     // crate and have hidden visibility.
                     true