File tree Expand file tree Collapse file tree 3 files changed +18
-7
lines changed Expand file tree Collapse file tree 3 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,6 @@ use rustc_middle::ty::Instance;
2525use rustc_middle:: ty:: Ty ;
2626
2727use std:: cell:: RefCell ;
28- use std:: ffi:: CString ;
2928
3029pub ( crate ) mod ffi;
3130pub ( crate ) mod map_data;
@@ -332,10 +331,15 @@ fn create_pgo_func_name_var<'ll, 'tcx>(
332331 cx : & CodegenCx < ' ll , ' tcx > ,
333332 instance : Instance < ' tcx > ,
334333) -> & ' ll llvm:: Value {
335- let mangled_fn_name = CString :: new ( cx. tcx . symbol_name ( instance) . name )
336- . expect ( "error converting function name to C string" ) ;
334+ let mangled_fn_name: & str = cx. tcx . symbol_name ( instance) . name ;
337335 let llfn = cx. get_fn ( instance) ;
338- unsafe { llvm:: LLVMRustCoverageCreatePGOFuncNameVar ( llfn, mangled_fn_name. as_ptr ( ) ) }
336+ unsafe {
337+ llvm:: LLVMRustCoverageCreatePGOFuncNameVar (
338+ llfn,
339+ mangled_fn_name. as_ptr ( ) . cast ( ) ,
340+ mangled_fn_name. len ( ) ,
341+ )
342+ }
339343}
340344
341345pub ( crate ) fn write_filenames_section_to_buffer < ' a > (
Original file line number Diff line number Diff line change @@ -1720,7 +1720,11 @@ extern "C" {
17201720 BufferOut : & RustString ,
17211721 ) ;
17221722
1723- pub fn LLVMRustCoverageCreatePGOFuncNameVar ( F : & Value , FuncName : * const c_char ) -> & Value ;
1723+ pub fn LLVMRustCoverageCreatePGOFuncNameVar (
1724+ F : & Value ,
1725+ FuncName : * const c_char ,
1726+ FuncNameLen : size_t ,
1727+ ) -> & Value ;
17241728 pub fn LLVMRustCoverageHashByteArray ( Bytes : * const c_char , NumBytes : size_t ) -> u64 ;
17251729
17261730 #[ allow( improper_ctypes) ]
Original file line number Diff line number Diff line change @@ -161,8 +161,11 @@ extern "C" void LLVMRustCoverageWriteMappingToBuffer(
161161 CoverageMappingWriter.write (OS);
162162}
163163
164- extern " C" LLVMValueRef LLVMRustCoverageCreatePGOFuncNameVar (LLVMValueRef F, const char *FuncName) {
165- StringRef FuncNameRef (FuncName);
164+ extern " C" LLVMValueRef LLVMRustCoverageCreatePGOFuncNameVar (
165+ LLVMValueRef F,
166+ const char *FuncName,
167+ size_t FuncNameLen) {
168+ StringRef FuncNameRef (FuncName, FuncNameLen);
166169 return wrap (createPGOFuncNameVar (*cast<Function>(unwrap (F)), FuncNameRef));
167170}
168171
You can’t perform that action at this time.
0 commit comments