about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYuki OKUSHI <huyuumi.dev@gmail.com>2019-03-30 18:50:34 +0900
committerYuki OKUSHI <huyuumi.dev@gmail.com>2019-03-30 18:50:34 +0900
commit3281248b88262687fcf34b2404cece968bcf837c (patch)
treef309547c95491949d05e4f468bf8f067cbcee77f
parent8381cbab1a80b2c71df79fb8c33f480cfbca52bb (diff)
downloadrust-3281248b88262687fcf34b2404cece968bcf837c.tar.gz
rust-3281248b88262687fcf34b2404cece968bcf837c.zip
Use target_mcount
-rw-r--r--src/librustc_codegen_llvm/attributes.rs28
1 files changed, 4 insertions, 24 deletions
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,