Skip to content

Conversation

@rovka
Copy link
Collaborator

@rovka rovka commented Nov 25, 2025

Make it possible to inherit from the FPPassManager and override the
runOnFunction method. Also use the already virtual getPassName when
dumping the pass structure, so we get the correct name for subclasses.

Make it possible to inherit from the `FPPassManager` and override the
`runOnFunction` method. Also use the already virtual `getPassName` when
dumping the pass structure, so we get the correct name for subclasses.
Copy link
Collaborator Author

rovka commented Nov 25, 2025

@rovka rovka marked this pull request as ready for review November 25, 2025 10:08
@llvmbot
Copy link
Member

llvmbot commented Nov 25, 2025

@llvm/pr-subscribers-backend-aarch64

@llvm/pr-subscribers-llvm-ir

Author: Diana Picus (rovka)

Changes

Make it possible to inherit from the FPPassManager and override the
runOnFunction method. Also use the already virtual getPassName when
dumping the pass structure, so we get the correct name for subclasses.


Full diff: https://github.com/llvm/llvm-project/pull/169475.diff

2 Files Affected:

  • (modified) llvm/include/llvm/IR/LegacyPassManagers.h (+6-2)
  • (modified) llvm/lib/IR/LegacyPassManager.cpp (+1-1)
diff --git a/llvm/include/llvm/IR/LegacyPassManagers.h b/llvm/include/llvm/IR/LegacyPassManagers.h
index d25bcafc9cc05..b1a2148f08894 100644
--- a/llvm/include/llvm/IR/LegacyPassManagers.h
+++ b/llvm/include/llvm/IR/LegacyPassManagers.h
@@ -461,7 +461,7 @@ class LLVM_ABI FPPassManager : public ModulePass, public PMDataManager {
 
   /// run - Execute all of the passes scheduled for execution.  Keep track of
   /// whether any of the passes modifies the module, and if so, return true.
-  bool runOnFunction(Function &F);
+  virtual bool runOnFunction(Function &F);
   bool runOnModule(Module &M) override;
 
   /// cleanup - After running all passes, clean up pass manager cache.
@@ -496,7 +496,7 @@ class LLVM_ABI FPPassManager : public ModulePass, public PMDataManager {
   // Print passes managed by this manager
   void dumpPassStructure(unsigned Offset) override;
 
-  StringRef getPassName() const override { return "Function Pass Manager"; }
+  StringRef getPassName() const override { return "FunctionPass Manager"; }
 
   FunctionPass *getContainedPass(unsigned N) {
     assert ( N < PassVector.size() && "Pass number out of range!");
@@ -507,6 +507,10 @@ class LLVM_ABI FPPassManager : public ModulePass, public PMDataManager {
   PassManagerType getPassManagerType() const override {
     return PMT_FunctionPassManager;
   }
+
+protected:
+  // So subclasses can pass their own ID.
+  explicit FPPassManager(char &ID) : ModulePass(ID) {}
 };
 }
 
diff --git a/llvm/lib/IR/LegacyPassManager.cpp b/llvm/lib/IR/LegacyPassManager.cpp
index 47a828842b481..00b8c68b28a92 100644
--- a/llvm/lib/IR/LegacyPassManager.cpp
+++ b/llvm/lib/IR/LegacyPassManager.cpp
@@ -1342,7 +1342,7 @@ void FPPassManager::cleanup() {
 char FPPassManager::ID = 0;
 /// Print passes managed by this manager
 void FPPassManager::dumpPassStructure(unsigned Offset) {
-  dbgs().indent(Offset*2) << "FunctionPass Manager\n";
+  dbgs().indent(Offset * 2) << getPassName() << '\n';
   for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
     FunctionPass *FP = getContainedPass(Index);
     FP->dumpPassStructure(Offset + 1);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants