Use target_mcount

This commit is contained in:
Yuki OKUSHI 2019-03-30 18:50:34 +09:00
parent 8381cbab1a
commit 3281248b88

View file

@ -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,