-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Make legacy FPPassManager more inheritable #169475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
@llvm/pr-subscribers-backend-aarch64 @llvm/pr-subscribers-llvm-ir Author: Diana Picus (rovka) ChangesMake it possible to inherit from the Full diff: https://github.com/llvm/llvm-project/pull/169475.diff 2 Files Affected:
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);
|

Make it possible to inherit from the
FPPassManagerand override therunOnFunctionmethod. Also use the already virtualgetPassNamewhendumping the pass structure, so we get the correct name for subclasses.