Skip to content

Commit ce1146a

Browse files
committed
Moved LLVM cleanup to after after_llvm phase
1 parent bbdbe99 commit ce1146a

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/librustc_driver/driver.rs

+2
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ pub fn compile_input(sess: &Session,
225225
phase5_result);
226226
phase5_result?;
227227

228+
write::cleanup_llvm(&trans);
229+
228230
phase_6_link_output(sess, &trans, &outputs);
229231

230232
Ok(())

src/librustc_trans/back/write.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -616,11 +616,19 @@ unsafe fn optimize_and_codegen(cgcx: &CodegenContext,
616616
}
617617
}
618618

619-
llvm::LLVMDisposeModule(llmod);
620-
llvm::LLVMContextDispose(llcx);
621619
llvm::LLVMRustDisposeTargetMachine(tm);
622620
}
623621

622+
623+
pub fn cleanup_llvm(trans: &CrateTranslation) {
624+
for module in trans.modules.iter() {
625+
unsafe {
626+
llvm::LLVMDisposeModule(module.llmod);
627+
llvm::LLVMContextDispose(module.llcx);
628+
}
629+
}
630+
}
631+
624632
pub fn run_passes(sess: &Session,
625633
trans: &CrateTranslation,
626634
output_types: &HashMap<OutputType, Option<PathBuf>>,

0 commit comments

Comments
 (0)