2018-11-29 16:05:23 -06:00
|
|
|
//@ compile-flags: -C no-prepopulate-passes
|
2018-11-26 20:59:49 -06:00
|
|
|
// `#[no_mangle]`d functions always have external linkage, i.e., no `internal` in their `define`s
|
2018-09-21 17:58:11 -05:00
|
|
|
|
|
|
|
#![crate_type = "lib"]
|
|
|
|
#![no_std]
|
|
|
|
|
2021-03-27 17:11:24 -05:00
|
|
|
// CHECK: define{{( dso_local)?}} void @a()
|
2018-09-21 17:58:11 -05:00
|
|
|
#[no_mangle]
|
|
|
|
fn a() {}
|
|
|
|
|
2021-03-27 17:11:24 -05:00
|
|
|
// CHECK: define{{( dso_local)?}} void @b()
|
2018-09-21 17:58:11 -05:00
|
|
|
#[no_mangle]
|
|
|
|
pub fn b() {}
|
|
|
|
|
|
|
|
mod private {
|
2021-03-27 17:11:24 -05:00
|
|
|
// CHECK: define{{( dso_local)?}} void @c()
|
2018-09-21 17:58:11 -05:00
|
|
|
#[no_mangle]
|
|
|
|
fn c() {}
|
|
|
|
|
2021-03-27 17:11:24 -05:00
|
|
|
// CHECK: define{{( dso_local)?}} void @d()
|
2018-09-21 17:58:11 -05:00
|
|
|
#[no_mangle]
|
|
|
|
pub fn d() {}
|
|
|
|
}
|
|
|
|
|
|
|
|
const HIDDEN: () = {
|
2021-03-27 17:11:24 -05:00
|
|
|
// CHECK: define{{( dso_local)?}} void @e()
|
2018-09-21 17:58:11 -05:00
|
|
|
#[no_mangle]
|
|
|
|
fn e() {}
|
|
|
|
|
2021-03-27 17:11:24 -05:00
|
|
|
// CHECK: define{{( dso_local)?}} void @f()
|
2018-09-21 17:58:11 -05:00
|
|
|
#[no_mangle]
|
|
|
|
pub fn f() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
// The surrounding item should not accidentally become external
|
2019-04-13 11:03:02 -05:00
|
|
|
// CHECK-LABEL: ; external_no_mangle_fns::x
|
|
|
|
// CHECK-NEXT: ; Function Attrs:
|
|
|
|
// CHECK-NEXT: define internal
|
2018-09-21 17:58:11 -05:00
|
|
|
#[inline(never)]
|
|
|
|
fn x() {
|
2021-03-27 17:11:24 -05:00
|
|
|
// CHECK: define{{( dso_local)?}} void @g()
|
2018-09-21 17:58:11 -05:00
|
|
|
#[no_mangle]
|
|
|
|
fn g() {
|
|
|
|
x();
|
|
|
|
}
|
|
|
|
|
2021-03-27 17:11:24 -05:00
|
|
|
// CHECK: define{{( dso_local)?}} void @h()
|
2018-09-21 17:58:11 -05:00
|
|
|
#[no_mangle]
|
|
|
|
pub fn h() {}
|
|
|
|
|
|
|
|
// side effect to keep `x` around
|
|
|
|
unsafe {
|
|
|
|
core::ptr::read_volatile(&42);
|
|
|
|
}
|
|
|
|
}
|
2020-06-08 03:37:11 -05:00
|
|
|
|
2021-03-27 17:11:24 -05:00
|
|
|
// CHECK: define{{( dso_local)?}} void @i()
|
2020-06-08 03:37:11 -05:00
|
|
|
#[no_mangle]
|
|
|
|
#[inline]
|
|
|
|
fn i() {}
|
|
|
|
|
2021-03-27 17:11:24 -05:00
|
|
|
// CHECK: define{{( dso_local)?}} void @j()
|
2020-06-08 03:37:11 -05:00
|
|
|
#[no_mangle]
|
|
|
|
#[inline]
|
|
|
|
pub fn j() {}
|
2020-06-09 09:49:59 -05:00
|
|
|
|
2021-03-27 17:11:24 -05:00
|
|
|
// CHECK: define{{( dso_local)?}} void @k()
|
2020-06-09 09:49:59 -05:00
|
|
|
#[no_mangle]
|
|
|
|
#[inline(always)]
|
|
|
|
fn k() {}
|
|
|
|
|
2021-03-27 17:11:24 -05:00
|
|
|
// CHECK: define{{( dso_local)?}} void @l()
|
2020-06-09 09:49:59 -05:00
|
|
|
#[no_mangle]
|
|
|
|
#[inline(always)]
|
|
|
|
pub fn l() {}
|