diff --git a/llvm/tools/llc/llc.cpp b/llvm/tools/llc/llc.cpp --- a/llvm/tools/llc/llc.cpp +++ b/llvm/tools/llc/llc.cpp @@ -699,13 +699,17 @@ if (!MIR) { WithColor::warning(errs(), argv[0]) << "run-pass is for .mir file only.\n"; + delete MMIWP; return 1; } - TargetPassConfig &TPC = *LLVMTM.createPassConfig(PM); + TargetPassConfig *PTPC = LLVMTM.createPassConfig(PM); + TargetPassConfig &TPC = *PTPC; if (TPC.hasLimitedCodeGenPipeline()) { WithColor::warning(errs(), argv[0]) << "run-pass cannot be used with " << TPC.getLimitedCodeGenPipelineReason(" and ") << ".\n"; + delete PTPC; + delete MMIWP; return 1; }