From 4254f2777cd3dccf160c79e36ce091d58b4e99c1 Mon Sep 17 00:00:00 2001 From: Akshat Oke Date: Thu, 20 Mar 2025 12:21:43 +0530 Subject: [PATCH] [CodeGen][NPM] Parse MachineFunctions in NPM driver (#128467) MachineFunctions were not being parsed when target is allowed to build the pipeline. This will allow us to use `-start-before` and other options. --- llvm/tools/llc/NewPMDriver.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/llvm/tools/llc/NewPMDriver.cpp b/llvm/tools/llc/NewPMDriver.cpp index 5c6909d080c7..fa82689ecf9a 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();