about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorWill Crichton <wcrichto@stanford.edu>2016-06-30 16:32:13 -0400
committerWill Crichton <wcrichto@stanford.edu>2016-07-04 02:47:19 -0400
commitce1146ac5f4dee7eee135e2ea2a6d3d317b2d36a (patch)
treef37e847ac5ca4e262f816dbcbfc50666072010fa /src
parentbbdbe99c7a6773cba8d0210e6b0a8826f1618d64 (diff)
downloadrust-ce1146ac5f4dee7eee135e2ea2a6d3d317b2d36a.tar.gz
rust-ce1146ac5f4dee7eee135e2ea2a6d3d317b2d36a.zip
Moved LLVM cleanup to after `after_llvm` phase
Diffstat (limited to 'src')
-rw-r--r--src/librustc_driver/driver.rs2
-rw-r--r--src/librustc_trans/back/write.rs12
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<OutputType, Option<PathBuf>>,