coverage: Don't convert symbol names to CString
for FFI
This commit is contained in:
parent
e184118683
commit
4b154bc8e2
3 changed files with 18 additions and 7 deletions
|
@ -25,7 +25,6 @@ use rustc_middle::ty::Instance;
|
|||
use rustc_middle::ty::Ty;
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::ffi::CString;
|
||||
|
||||
pub(crate) mod ffi;
|
||||
pub(crate) mod map_data;
|
||||
|
@ -332,10 +331,15 @@ fn create_pgo_func_name_var<'ll, 'tcx>(
|
|||
cx: &CodegenCx<'ll, 'tcx>,
|
||||
instance: Instance<'tcx>,
|
||||
) -> &'ll llvm::Value {
|
||||
let mangled_fn_name = CString::new(cx.tcx.symbol_name(instance).name)
|
||||
.expect("error converting function name to C string");
|
||||
let mangled_fn_name: &str = cx.tcx.symbol_name(instance).name;
|
||||
let llfn = cx.get_fn(instance);
|
||||
unsafe { llvm::LLVMRustCoverageCreatePGOFuncNameVar(llfn, mangled_fn_name.as_ptr()) }
|
||||
unsafe {
|
||||
llvm::LLVMRustCoverageCreatePGOFuncNameVar(
|
||||
llfn,
|
||||
mangled_fn_name.as_ptr().cast(),
|
||||
mangled_fn_name.len(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn write_filenames_section_to_buffer<'a>(
|
||||
|
|
|
@ -1720,7 +1720,11 @@ extern "C" {
|
|||
BufferOut: &RustString,
|
||||
);
|
||||
|
||||
pub fn LLVMRustCoverageCreatePGOFuncNameVar(F: &Value, FuncName: *const c_char) -> &Value;
|
||||
pub fn LLVMRustCoverageCreatePGOFuncNameVar(
|
||||
F: &Value,
|
||||
FuncName: *const c_char,
|
||||
FuncNameLen: size_t,
|
||||
) -> &Value;
|
||||
pub fn LLVMRustCoverageHashByteArray(Bytes: *const c_char, NumBytes: size_t) -> u64;
|
||||
|
||||
#[allow(improper_ctypes)]
|
||||
|
|
|
@ -161,8 +161,11 @@ extern "C" void LLVMRustCoverageWriteMappingToBuffer(
|
|||
CoverageMappingWriter.write(OS);
|
||||
}
|
||||
|
||||
extern "C" LLVMValueRef LLVMRustCoverageCreatePGOFuncNameVar(LLVMValueRef F, const char *FuncName) {
|
||||
StringRef FuncNameRef(FuncName);
|
||||
extern "C" LLVMValueRef LLVMRustCoverageCreatePGOFuncNameVar(
|
||||
LLVMValueRef F,
|
||||
const char *FuncName,
|
||||
size_t FuncNameLen) {
|
||||
StringRef FuncNameRef(FuncName, FuncNameLen);
|
||||
return wrap(createPGOFuncNameVar(*cast<Function>(unwrap(F)), FuncNameRef));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue