Skip to content

Commit 6a454ed

Browse files
committed
Dispose LLVM context after TargetMachine
The TargetMachine may be referencing data in the context. In particular, at least the GlobalISel instruction selector stored in the TM may reference a TrackedMDNode DebugLoc that destruction of the TargetMachine will try to untrack.
1 parent d20e798 commit 6a454ed

File tree

1 file changed

+1
-1
lines changed
  • compiler/rustc_codegen_llvm/src

1 file changed

+1
-1
lines changed

compiler/rustc_codegen_llvm/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,8 @@ impl ModuleLlvm {
352352
impl Drop for ModuleLlvm {
353353
fn drop(&mut self) {
354354
unsafe {
355-
llvm::LLVMContextDispose(&mut *(self.llcx as *mut _));
356355
llvm::LLVMRustDisposeTargetMachine(&mut *(self.tm as *mut _));
356+
llvm::LLVMContextDispose(&mut *(self.llcx as *mut _));
357357
}
358358
}
359359
}

0 commit comments

Comments
 (0)