1
Fork 0

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. // The function name varies on platforms.
// See test/CodeGen/mcount.c in clang. // See test/CodeGen/mcount.c in clang.
let mcount_name = if cfg!(target_os = "netbsd") { use std::ffi::CStr;
const_cstr!("__mcount") let target_mcount = format!("{}{}",
} else if cfg!(any( &cx.sess().target.target.options.target_mcount, "\0");
target_arch = "mips", target_arch = "mips64", let mcount_name = CStr::from_bytes_with_nul(target_mcount.as_bytes()).unwrap();
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")
};
llvm::AddFunctionAttrStringValue( llvm::AddFunctionAttrStringValue(
llfn, llvm::AttributePlace::Function, llfn, llvm::AttributePlace::Function,