@@ -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 ! ( "\0 1mcount" )
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 ! ( "\0 1_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 ! ( "\0 1__gnu_mcount_nc" )
101- } else {
102- const_cstr ! ( "\0 1mcount" )
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