diff --git a/llvm/lib/CodeGen/LLVMTargetMachine.cpp b/llvm/lib/CodeGen/LLVMTargetMachine.cpp --- a/llvm/lib/CodeGen/LLVMTargetMachine.cpp +++ b/llvm/lib/CodeGen/LLVMTargetMachine.cpp @@ -277,8 +277,13 @@ MCCodeEmitter *MCE = getTarget().createMCCodeEmitter(*getMCInstrInfo(), *Ctx); MCAsmBackend *MAB = getTarget().createMCAsmBackend(STI, MRI, Options.MCOptions); - if (!MCE || !MAB) + if (!MCE || !MAB) { + if (MCE) + delete MCE; + if (MAB) + delete MAB; return true; + } const Triple &T = getTargetTriple(); std::unique_ptr AsmStreamer(getTarget().createMCObjectStreamer(