Auto merge of #34594 - willcrichton:master, r=nrc

Move LLVM cleanup so modules are accessible during `after_llvm` phase

Fix for #34432. Also added a new phase controller `after_compilation_done` that gets called at the very end (i.e. after linking) at the suggestion of @nrc. The added test will segfault if the modules get deallocated too early, so it ensures the LLVM is not prematurely cleaned up.

r? @nrc
This commit is contained in:
bors 2016-07-04 22:24:08 -07:00 committed by GitHub
commit 499e6f8844
4 changed files with 117 additions and 2 deletions

View file

@ -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>>,