[llvm] Fix MachineOutliner::createPrinterPass. (PR #115787)

Han Shen via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 11 15:03:19 PST 2024


https://github.com/shenhanc78 created https://github.com/llvm/llvm-project/pull/115787

MachineOutliner is a MachineFunctionPass, so its createPrinterPass should use createMachineFunctionPrinterPass instead of falling back to the default implementation in ModulePass::createPrinterPass.

Crrently "-c -mllvm -print-after=machine-outliner -mllvm -enable-machine-outliner" prints llvm ir instead of llvm machine ir.

This PR fixes the issue.

>From 997cf5864a3f93d1256964124734f92a590739bc Mon Sep 17 00:00:00 2001
From: Han Shen <shenhan at google.com>
Date: Mon, 11 Nov 2024 14:55:39 -0800
Subject: [PATCH] Fix MachineOutliner::createPrinterPass.

MachineOutliner is a MachineFunctionPass, so its createPrinterPass
should use createMachineFunctionPrinterPass instead of falling back to
the default implementation in ModulePass::createPrinterPass.

Crrently "-c -mllvm -print-after=machine-outliner -mllvm
-enable-machine-outliner" prints llvm ir instead of llvm machine ir.
---
 llvm/lib/CodeGen/MachineOutliner.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/llvm/lib/CodeGen/MachineOutliner.cpp b/llvm/lib/CodeGen/MachineOutliner.cpp
index 2ae6b4f2c64c9b..0f1c52758f17ec 100644
--- a/llvm/lib/CodeGen/MachineOutliner.cpp
+++ b/llvm/lib/CodeGen/MachineOutliner.cpp
@@ -460,6 +460,12 @@ struct MachineOutliner : public ModulePass {
 
   StringRef getPassName() const override { return "Machine Outliner"; }
 
+  /// createPrinterPass - Get a machine function printer pass.
+  Pass *createPrinterPass(raw_ostream &OS,
+                          const std::string &Banner) const override {
+    return createMachineFunctionPrinterPass(OS, Banner);
+  }
+
   void getAnalysisUsage(AnalysisUsage &AU) const override {
     AU.addRequired<MachineModuleInfoWrapperPass>();
     AU.addPreserved<MachineModuleInfoWrapperPass>();



More information about the llvm-commits mailing list