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:
commit
499e6f8844
4 changed files with 117 additions and 2 deletions
|
|
@ -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>>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue