From ce1146ac5f4dee7eee135e2ea2a6d3d317b2d36a Mon Sep 17 00:00:00 2001 From: Will Crichton Date: Thu, 30 Jun 2016 16:32:13 -0400 Subject: [PATCH] Moved LLVM cleanup to after `after_llvm` phase --- src/librustc_driver/driver.rs | 2 ++ src/librustc_trans/back/write.rs | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 7fd4e3643be..351f82d3a0b 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -225,6 +225,8 @@ pub fn compile_input(sess: &Session, phase5_result); phase5_result?; + write::cleanup_llvm(&trans); + phase_6_link_output(sess, &trans, &outputs); Ok(()) diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs index 1e5545b00b7..ec20381d189 100644 --- a/src/librustc_trans/back/write.rs +++ b/src/librustc_trans/back/write.rs @@ -616,11 +616,19 @@ unsafe fn optimize_and_codegen(cgcx: &CodegenContext, } } - llvm::LLVMDisposeModule(llmod); - llvm::LLVMContextDispose(llcx); llvm::LLVMRustDisposeTargetMachine(tm); } + +pub fn cleanup_llvm(trans: &CrateTranslation) { + for module in trans.modules.iter() { + unsafe { + llvm::LLVMDisposeModule(module.llmod); + llvm::LLVMContextDispose(module.llcx); + } + } +} + pub fn run_passes(sess: &Session, trans: &CrateTranslation, output_types: &HashMap>,