1
Fork 0

Rollup merge of #66761 - yuyoyuppe:rust_llvm_minor_fix, r=alexcrichton

Use LLVMDisposePassManager instead of raw delete in rustllvm

LLVM has a dedicated API call which wraps the destructor invocation for the PassManager.
Rust invokes it [otherwhere](d63b24ffcc/src/librustc_codegen_llvm/back/write.rs (L446-L447)), but not in the `LLVMRustWriteOutputFile`.

Since `LLVMDisposePassManager` might be extended to perform additional cleanup actions in the future, this change replaces raw destructor invocation with that API call.
This commit is contained in:
Tyler Mandry 2019-11-27 15:28:45 -06:00 committed by GitHub
commit b05f14cc40
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -580,7 +580,7 @@ LLVMRustWriteOutputFile(LLVMTargetMachineRef Target, LLVMPassManagerRef PMR,
// Apparently `addPassesToEmitFile` adds a pointer to our on-the-stack output
// stream (OS), so the only real safe place to delete this is here? Don't we
// wish this was written in Rust?
delete PM;
LLVMDisposePassManager(PMR);
return LLVMRustResult::Success;
}