match *self {
MonoItem::Fn(ref instance) => {
let entry_def_id = tcx.entry_fn(LOCAL_CRATE).map(|(id, _)| id);
- // If this function isn't inlined or otherwise has explicit
- // linkage or an extern indicator, then we'll be creating a
- // globally shared version.
- if self.explicit_linkage(tcx).is_some()
+ // If this function isn't inlined or otherwise has an extern
+ // indicator, then we'll be creating a globally shared version.
+ if tcx.codegen_fn_attrs(instance.def_id()).contains_extern_indicator()
|| !instance.def.generates_cgu_internal_copy(tcx)
|| Some(instance.def_id()) == entry_def_id.map(LocalDefId::to_def_id)
{
// At this point we don't have explicit linkage and we're an
// inlined function. If we're inlining into all CGUs then we'll
- // be creating a local copy per CGU. We need to watch out here
- // for an extern indicator as we don't want to optimise away
- // inlined functions that should be exported.
- if generate_cgu_internal_copies
- && !tcx.codegen_fn_attrs(instance.def_id()).contains_extern_indicator()
- {
+ // be creating a local copy per CGU.
+ if generate_cgu_internal_copies {
return InstantiationMode::LocalCopy;
}
#[export_name = "d"]
#[inline]
extern "C" fn d() {}
+
+// CHECK: define void @e()
+#[no_mangle]
+#[inline(always)]
+pub extern "C" fn e() {}
+
+// CHECK: define void @f()
+#[export_name = "f"]
+#[inline(always)]
+pub extern "C" fn f() {}
+
+// CHECK: define void @g()
+#[no_mangle]
+#[inline(always)]
+extern "C" fn g() {}
+
+// CHECK: define void @h()
+#[export_name = "h"]
+#[inline(always)]
+extern "C" fn h() {}
#[export_name = "d"]
#[inline]
extern "C" fn d() {}
+
+// CHECK: define void @e()
+#[no_mangle]
+#[inline(always)]
+pub extern "C" fn e() {}
+
+// CHECK: define void @f()
+#[export_name = "f"]
+#[inline(always)]
+pub extern "C" fn f() {}
+
+// CHECK: define void @g()
+#[no_mangle]
+#[inline(always)]
+extern "C" fn g() {}
+
+// CHECK: define void @h()
+#[export_name = "h"]
+#[inline(always)]
+extern "C" fn h() {}