From f9064106994f11b8cd48423fb249c838e3ccf49d Mon Sep 17 00:00:00 2001 From: Akshat Oke Date: Mon, 24 Feb 2025 06:05:27 +0000 Subject: [PATCH 1/2] [CodeGen][NPM] Parse MachineFunctions in NPM driver --- 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 fa935b895a20a..2b6be34f83485 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->parseMachineFunctions(*M, MAM)) + return 1; + // Before executing passes, print the final values of the LLVM options. cl::PrintOptionValues(); From 3272ba520a42a9620a2093d6ca208c85bc8238e6 Mon Sep 17 00:00:00 2001 From: Akshat Oke Date: Mon, 10 Mar 2025 10:15:48 +0000 Subject: [PATCH 2/2] fix the MIR check --- llvm/tools/llc/NewPMDriver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/tools/llc/NewPMDriver.cpp b/llvm/tools/llc/NewPMDriver.cpp index 2b6be34f83485..bd9a2b5f855c2 100644 --- a/llvm/tools/llc/NewPMDriver.cpp +++ b/llvm/tools/llc/NewPMDriver.cpp @@ -170,7 +170,7 @@ int llvm::compileModuleWithNewPM( return 0; } - if (MIR->parseMachineFunctions(*M, MAM)) + if (MIR && MIR->parseMachineFunctions(*M, MAM)) return 1; // Before executing passes, print the final values of the LLVM options.