File tree 3 files changed +18
-7
lines changed
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;
25
25
use rustc_middle:: ty:: Ty ;
26
26
27
27
use std:: cell:: RefCell ;
28
- use std:: ffi:: CString ;
29
28
30
29
pub ( crate ) mod ffi;
31
30
pub ( crate ) mod map_data;
@@ -332,10 +331,15 @@ fn create_pgo_func_name_var<'ll, 'tcx>(
332
331
cx : & CodegenCx < ' ll , ' tcx > ,
333
332
instance : Instance < ' tcx > ,
334
333
) -> & ' 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 ;
337
335
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
+ }
339
343
}
340
344
341
345
pub ( crate ) fn write_filenames_section_to_buffer < ' a > (
Original file line number Diff line number Diff line change @@ -1720,7 +1720,11 @@ extern "C" {
1720
1720
BufferOut : & RustString ,
1721
1721
) ;
1722
1722
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 ;
1724
1728
pub fn LLVMRustCoverageHashByteArray ( Bytes : * const c_char , NumBytes : size_t ) -> u64 ;
1725
1729
1726
1730
#[ allow( improper_ctypes) ]
Original file line number Diff line number Diff line change @@ -161,8 +161,11 @@ extern "C" void LLVMRustCoverageWriteMappingToBuffer(
161
161
CoverageMappingWriter.write (OS);
162
162
}
163
163
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);
166
169
return wrap (createPGOFuncNameVar (*cast<Function>(unwrap (F)), FuncNameRef));
167
170
}
168
171
You can’t perform that action at this time.
0 commit comments