From: Yuki OKUSHI Date: Sat, 30 Mar 2019 09:50:34 +0000 (+0900) Subject: Use target_mcount X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=3281248b88262687fcf34b2404cece968bcf837c;p=rust.git Use target_mcount --- diff --git a/src/librustc_codegen_llvm/attributes.rs b/src/librustc_codegen_llvm/attributes.rs index e765b986d62..9aaad60cd6d 100644 --- a/src/librustc_codegen_llvm/attributes.rs +++ b/src/librustc_codegen_llvm/attributes.rs @@ -80,30 +80,10 @@ pub fn set_instrument_function(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) { // The function name varies on platforms. // See test/CodeGen/mcount.c in clang. - let mcount_name = if cfg!(target_os = "netbsd") { - const_cstr!("__mcount") - } else if cfg!(any( - target_arch = "mips", target_arch = "mips64", - target_arch = "powerpc", target_arch = "powerpc64")) { - const_cstr!("_mcount") - } else if cfg!(target_os = "darwin") { - const_cstr!("\01mcount") - } else if cfg!(target_arch = "aarch64") - && (cfg!(target_os = "linux") - || (cfg!(target_os = "unknown") && cfg!(target_env = "gnu"))) - { - const_cstr!("\01_mcount") - } else if cfg!(target_arch = "arm") - && cfg!(any(target_os = "linux", target_os = "unknown")) - { - if cfg!(target_env = "gnu") { - const_cstr!("\01__gnu_mcount_nc") - } else { - const_cstr!("\01mcount") - } - } else { - const_cstr!("mcount") - }; + use std::ffi::CStr; + let target_mcount = format!("{}{}", + &cx.sess().target.target.options.target_mcount, "\0"); + let mcount_name = CStr::from_bytes_with_nul(target_mcount.as_bytes()).unwrap(); llvm::AddFunctionAttrStringValue( llfn, llvm::AttributePlace::Function,