Skip to content

Commit

Permalink
Use CString
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnTitor committed Mar 30, 2019
1 parent 3281248 commit 77774e4
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/librustc_codegen_llvm/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,12 @@ pub fn set_instrument_function(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {

// The function name varies on platforms.
// See test/CodeGen/mcount.c in clang.
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();
let mcount_name = CString::new(
cx.sess().target.target.options.target_mcount.as_str().as_bytes()).unwrap();

llvm::AddFunctionAttrStringValue(
llfn, llvm::AttributePlace::Function,
const_cstr!("instrument-function-entry-inlined"), mcount_name);
const_cstr!("instrument-function-entry-inlined"), &mcount_name);
}
}

Expand Down

0 comments on commit 77774e4

Please sign in to comment.