Skip to content

Commit d90934c

Browse files
committed
Fix use after drop in self-profile with llvm events
1 parent 50f9f78 commit d90934c

File tree

1 file changed

+6
-4
lines changed
  • compiler/rustc_codegen_llvm/src/back

1 file changed

+6
-4
lines changed

compiler/rustc_codegen_llvm/src/back/write.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -405,13 +405,15 @@ pub(crate) unsafe fn optimize_with_new_llvm_pass_manager(
405405
None
406406
};
407407

408-
let llvm_selfprofiler = if cgcx.prof.llvm_recording_enabled() {
409-
let mut llvm_profiler = LlvmSelfProfiler::new(cgcx.prof.get_self_profiler().unwrap());
410-
&mut llvm_profiler as *mut _ as *mut c_void
408+
let mut llvm_profiler = if cgcx.prof.llvm_recording_enabled() {
409+
Some(LlvmSelfProfiler::new(cgcx.prof.get_self_profiler().unwrap()))
411410
} else {
412-
std::ptr::null_mut()
411+
None
413412
};
414413

414+
let llvm_selfprofiler =
415+
llvm_profiler.as_mut().map(|s| s as *mut _ as *mut c_void).unwrap_or(std::ptr::null_mut());
416+
415417
let extra_passes = config.passes.join(",");
416418

417419
// FIXME: NewPM doesn't provide a facility to pass custom InlineParams.

0 commit comments

Comments
 (0)