Skip to content

Commit 3281248

Browse files
committed
Use target_mcount
1 parent 8381cba commit 3281248

File tree

1 file changed

+4
-24
lines changed

1 file changed

+4
-24
lines changed

src/librustc_codegen_llvm/attributes.rs

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -80,30 +80,10 @@ pub fn set_instrument_function(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
8080

8181
// The function name varies on platforms.
8282
// See test/CodeGen/mcount.c in clang.
83-
let mcount_name = if cfg!(target_os = "netbsd") {
84-
const_cstr!("__mcount")
85-
} else if cfg!(any(
86-
target_arch = "mips", target_arch = "mips64",
87-
target_arch = "powerpc", target_arch = "powerpc64")) {
88-
const_cstr!("_mcount")
89-
} else if cfg!(target_os = "darwin") {
90-
const_cstr!("\01mcount")
91-
} else if cfg!(target_arch = "aarch64")
92-
&& (cfg!(target_os = "linux")
93-
|| (cfg!(target_os = "unknown") && cfg!(target_env = "gnu")))
94-
{
95-
const_cstr!("\01_mcount")
96-
} else if cfg!(target_arch = "arm")
97-
&& cfg!(any(target_os = "linux", target_os = "unknown"))
98-
{
99-
if cfg!(target_env = "gnu") {
100-
const_cstr!("\01__gnu_mcount_nc")
101-
} else {
102-
const_cstr!("\01mcount")
103-
}
104-
} else {
105-
const_cstr!("mcount")
106-
};
83+
use std::ffi::CStr;
84+
let target_mcount = format!("{}{}",
85+
&cx.sess().target.target.options.target_mcount, "\0");
86+
let mcount_name = CStr::from_bytes_with_nul(target_mcount.as_bytes()).unwrap();
10787

10888
llvm::AddFunctionAttrStringValue(
10989
llfn, llvm::AttributePlace::Function,

0 commit comments

Comments
 (0)