diff --git a/llvm/tools/llc/NewPMDriver.cpp b/llvm/tools/llc/NewPMDriver.cpp index fa935b895a20a..bd9a2b5f855c2 100644 --- a/llvm/tools/llc/NewPMDriver.cpp +++ b/llvm/tools/llc/NewPMDriver.cpp @@ -153,13 +153,12 @@ int llvm::compileModuleWithNewPM( FPM.addPass(createFunctionToMachineFunctionPassAdaptor(std::move(MFPM))); MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM))); - if (MIR->parseMachineFunctions(*M, MAM)) - return 1; } else { ExitOnErr(Target->buildCodeGenPipeline( MPM, *OS, DwoOut ? &DwoOut->os() : nullptr, FileType, Opt, &PIC)); } + // If user only wants to print the pipeline, print it before parsing the MIR. if (PrintPipelinePasses) { std::string PipelineStr; raw_string_ostream OS(PipelineStr); @@ -171,6 +170,9 @@ int llvm::compileModuleWithNewPM( return 0; } + if (MIR && MIR->parseMachineFunctions(*M, MAM)) + return 1; + // Before executing passes, print the final values of the LLVM options. cl::PrintOptionValues();