diff options
| author | Fangrui Song <maskray@google.com> | 2019-11-28 13:34:32 -0800 |
|---|---|---|
| committer | Fangrui Song <maskray@google.com> | 2019-11-28 13:48:26 -0800 |
| commit | a7abe6eac061a999e88d651e4857872f5ec52e5d (patch) | |
| tree | bb49f40e00f448a2dfc4dc7526fe52b948f26355 /llvm/lib/IR | |
| parent | 674df13b5fa7ffbd273455d547eff4507a2fcaff (diff) | |
| download | bcm5719-llvm-a7abe6eac061a999e88d651e4857872f5ec52e5d.tar.gz bcm5719-llvm-a7abe6eac061a999e88d651e4857872f5ec52e5d.zip | |
[LegacyPassManager] Simplify PMStack pop
Diffstat (limited to 'llvm/lib/IR')
| -rw-r--r-- | llvm/lib/IR/LegacyPassManager.cpp | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/llvm/lib/IR/LegacyPassManager.cpp b/llvm/lib/IR/LegacyPassManager.cpp index 8fe59912f20..f3c13728d0c 100644 --- a/llvm/lib/IR/LegacyPassManager.cpp +++ b/llvm/lib/IR/LegacyPassManager.cpp @@ -1776,16 +1776,10 @@ LLVM_DUMP_METHOD void PMStack::dump() const { void ModulePass::assignPassManager(PMStack &PMS, PassManagerType PreferredType) { // Find Module Pass Manager - while (!PMS.empty()) { - PassManagerType TopPMType = PMS.top()->getPassManagerType(); - if (TopPMType == PreferredType) - break; // We found desired pass manager - else if (TopPMType > PMT_ModulePassManager) - PMS.pop(); // Pop children pass managers - else - break; - } - assert(!PMS.empty() && "Unable to find appropriate Pass Manager"); + PassManagerType T; + while ((T = PMS.top()->getPassManagerType()) > PMT_ModulePassManager && + T != PreferredType) + PMS.pop(); PMS.top()->add(this); } @@ -1793,21 +1787,15 @@ void ModulePass::assignPassManager(PMStack &PMS, /// in the PM Stack and add self into that manager. void FunctionPass::assignPassManager(PMStack &PMS, PassManagerType PreferredType) { - // Find Function Pass Manager - while (!PMS.empty()) { - if (PMS.top()->getPassManagerType() > PMT_FunctionPassManager) - PMS.pop(); - else - break; - } + while (PMS.top()->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 { - assert(!PMS.empty() && "Unable to create Function Pass Manager"); PMDataManager *PMD = PMS.top(); // [1] Create new Function Pass Manager |

