[llvm] 4adddbd - [LegacyPassManager] Simplify FunctionPass::assignPassManager
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 28 14:08:00 PST 2019
Author: Fangrui Song
Date: 2019-11-28T14:06:55-08:00
New Revision: 4adddbd8ad4f71e8ce4cb4a38c755b126c5e9eff
URL: https://github.com/llvm/llvm-project/commit/4adddbd8ad4f71e8ce4cb4a38c755b126c5e9eff
DIFF: https://github.com/llvm/llvm-project/commit/4adddbd8ad4f71e8ce4cb4a38c755b126c5e9eff.diff
LOG: [LegacyPassManager] Simplify FunctionPass::assignPassManager
And make it clear the parameter PreferredType is unused for FunctionPass.
Added:
Modified:
llvm/lib/IR/LegacyPassManager.cpp
Removed:
################################################################################
diff --git a/llvm/lib/IR/LegacyPassManager.cpp b/llvm/lib/IR/LegacyPassManager.cpp
index f3c13728d0cb..90239bb76298 100644
--- a/llvm/lib/IR/LegacyPassManager.cpp
+++ b/llvm/lib/IR/LegacyPassManager.cpp
@@ -1786,36 +1786,32 @@ void ModulePass::assignPassManager(PMStack &PMS,
/// Find appropriate Function Pass Manager or Call Graph Pass Manager
/// in the PM Stack and add self into that manager.
void FunctionPass::assignPassManager(PMStack &PMS,
- PassManagerType PreferredType) {
+ PassManagerType /*PreferredType*/) {
// Find Function Pass Manager
- while (PMS.top()->getPassManagerType() > PMT_FunctionPassManager)
+ PMDataManager *PM;
+ while (PM = PMS.top(), PM->getPassManagerType() > PMT_FunctionPassManager)
PMS.pop();
// Create new Function Pass Manager if needed.
- FPPassManager *FPP;
- if (PMS.top()->getPassManagerType() == PMT_FunctionPassManager) {
- FPP = (FPPassManager *)PMS.top();
- } else {
- PMDataManager *PMD = PMS.top();
-
+ if (PM->getPassManagerType() != PMT_FunctionPassManager) {
// [1] Create new Function Pass Manager
- FPP = new FPPassManager();
+ auto *FPP = new FPPassManager;
FPP->populateInheritedAnalysis(PMS);
// [2] Set up new manager's top level manager
- PMTopLevelManager *TPM = PMD->getTopLevelManager();
- TPM->addIndirectPassManager(FPP);
+ PM->getTopLevelManager()->addIndirectPassManager(FPP);
// [3] Assign manager to manage this new manager. This may create
// and push new managers into PMS
- FPP->assignPassManager(PMS, PMD->getPassManagerType());
+ FPP->assignPassManager(PMS, PM->getPassManagerType());
// [4] Push new manager into PMS
PMS.push(FPP);
+ PM = FPP;
}
// Assign FPP as the manager of this pass.
- FPP->add(this);
+ PM->add(this);
}
PassManagerBase::~PassManagerBase() {}
More information about the llvm-commits
mailing list