diff options
Diffstat (limited to 'llvm/lib/IR')
| -rw-r--r-- | llvm/lib/IR/Core.cpp | 1 | ||||
| -rw-r--r-- | llvm/lib/IR/IRPrintingPasses.cpp | 35 | ||||
| -rw-r--r-- | llvm/lib/IR/LegacyPassManager.cpp | 228 | ||||
| -rw-r--r-- | llvm/lib/IR/Pass.cpp | 45 |
4 files changed, 2 insertions, 307 deletions
diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp index a5f46b16e60..03bff7e5fde 100644 --- a/llvm/lib/IR/Core.cpp +++ b/llvm/lib/IR/Core.cpp @@ -47,7 +47,6 @@ void llvm::initializeCore(PassRegistry &Registry) { initializeDominatorTreeWrapperPassPass(Registry); initializePrintModulePassWrapperPass(Registry); initializePrintFunctionPassWrapperPass(Registry); - initializePrintBasicBlockPassPass(Registry); initializeSafepointIRVerifierPass(Registry); initializeVerifierLegacyPassPass(Registry); } diff --git a/llvm/lib/IR/IRPrintingPasses.cpp b/llvm/lib/IR/IRPrintingPasses.cpp index 953cf941016..75850b403fb 100644 --- a/llvm/lib/IR/IRPrintingPasses.cpp +++ b/llvm/lib/IR/IRPrintingPasses.cpp @@ -109,28 +109,6 @@ public: StringRef getPassName() const override { return "Print Function IR"; } }; -class PrintBasicBlockPass : public BasicBlockPass { - raw_ostream &Out; - std::string Banner; - -public: - static char ID; - PrintBasicBlockPass() : BasicBlockPass(ID), Out(dbgs()) {} - PrintBasicBlockPass(raw_ostream &Out, const std::string &Banner) - : BasicBlockPass(ID), Out(Out), Banner(Banner) {} - - bool runOnBasicBlock(BasicBlock &BB) override { - Out << Banner << BB; - return false; - } - - void getAnalysisUsage(AnalysisUsage &AU) const override { - AU.setPreservesAll(); - } - - StringRef getPassName() const override { return "Print BasicBlock IR"; } -}; - } char PrintModulePassWrapper::ID = 0; @@ -139,9 +117,6 @@ INITIALIZE_PASS(PrintModulePassWrapper, "print-module", char PrintFunctionPassWrapper::ID = 0; INITIALIZE_PASS(PrintFunctionPassWrapper, "print-function", "Print function to stderr", false, true) -char PrintBasicBlockPass::ID = 0; -INITIALIZE_PASS(PrintBasicBlockPass, "print-bb", "Print BB to stderr", false, - true) ModulePass *llvm::createPrintModulePass(llvm::raw_ostream &OS, const std::string &Banner, @@ -154,15 +129,9 @@ FunctionPass *llvm::createPrintFunctionPass(llvm::raw_ostream &OS, return new PrintFunctionPassWrapper(OS, Banner); } -BasicBlockPass *llvm::createPrintBasicBlockPass(llvm::raw_ostream &OS, - const std::string &Banner) { - return new PrintBasicBlockPass(OS, Banner); -} - bool llvm::isIRPrintingPass(Pass *P) { const char *PID = (const char*)P->getPassID(); - return (PID == &PrintModulePassWrapper::ID) - || (PID == &PrintFunctionPassWrapper::ID) - || (PID == &PrintBasicBlockPass::ID); + return (PID == &PrintModulePassWrapper::ID) || + (PID == &PrintFunctionPassWrapper::ID); } diff --git a/llvm/lib/IR/LegacyPassManager.cpp b/llvm/lib/IR/LegacyPassManager.cpp index 3a03c493100..b912fd7e6b8 100644 --- a/llvm/lib/IR/LegacyPassManager.cpp +++ b/llvm/lib/IR/LegacyPassManager.cpp @@ -314,64 +314,6 @@ void PassManagerPrettyStackEntry::print(raw_ostream &OS) const { OS << "'\n"; } - -namespace { -//===----------------------------------------------------------------------===// -// BBPassManager -// -/// BBPassManager manages BasicBlockPass. It batches all the -/// pass together and sequence them to process one basic block before -/// processing next basic block. -class BBPassManager : public PMDataManager, public FunctionPass { - -public: - static char ID; - explicit BBPassManager() - : PMDataManager(), FunctionPass(ID) {} - - /// Execute all of the passes scheduled for execution. Keep track of - /// whether any of the passes modifies the function, and if so, return true. - bool runOnFunction(Function &F) override; - - /// Pass Manager itself does not invalidate any analysis info. - void getAnalysisUsage(AnalysisUsage &Info) const override { - Info.setPreservesAll(); - } - - bool doInitialization(Module &M) override; - bool doInitialization(Function &F); - bool doFinalization(Module &M) override; - bool doFinalization(Function &F); - - PMDataManager *getAsPMDataManager() override { return this; } - Pass *getAsPass() override { return this; } - - StringRef getPassName() const override { return "BasicBlock Pass Manager"; } - - // Print passes managed by this manager - void dumpPassStructure(unsigned Offset) override { - dbgs().indent(Offset*2) << "BasicBlockPass Manager\n"; - for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) { - BasicBlockPass *BP = getContainedPass(Index); - BP->dumpPassStructure(Offset + 1); - dumpLastUses(BP, Offset+1); - } - } - - BasicBlockPass *getContainedPass(unsigned N) { - assert(N < PassVector.size() && "Pass number out of range!"); - BasicBlockPass *BP = static_cast<BasicBlockPass *>(PassVector[N]); - return BP; - } - - PassManagerType getPassManagerType() const override { - return PMT_BasicBlockPassManager; - } -}; - -char BBPassManager::ID = 0; -} // End anonymous namespace - namespace llvm { namespace legacy { //===----------------------------------------------------------------------===// @@ -1249,9 +1191,6 @@ void PMDataManager::dumpPassInfo(Pass *P, enum PassDebuggingString S1, break; } switch (S2) { - case ON_BASICBLOCK_MSG: - dbgs() << "' on BasicBlock '" << Msg << "'...\n"; - break; case ON_FUNCTION_MSG: dbgs() << "' on Function '" << Msg << "'...\n"; break; @@ -1368,117 +1307,6 @@ Pass *AnalysisResolver::findImplPass(Pass *P, AnalysisID AnalysisPI, } //===----------------------------------------------------------------------===// -// BBPassManager implementation - -/// Execute all of the passes scheduled for execution by invoking -/// runOnBasicBlock method. Keep track of whether any of the passes modifies -/// the function, and if so, return true. -bool BBPassManager::runOnFunction(Function &F) { - if (F.isDeclaration()) - return false; - - bool Changed = doInitialization(F); - Module &M = *F.getParent(); - - unsigned InstrCount, BBSize = 0; - StringMap<std::pair<unsigned, unsigned>> FunctionToInstrCount; - bool EmitICRemark = M.shouldEmitInstrCountChangedRemark(); - if (EmitICRemark) - InstrCount = initSizeRemarkInfo(M, FunctionToInstrCount); - - for (BasicBlock &BB : F) { - // Collect the initial size of the basic block. - if (EmitICRemark) - BBSize = BB.size(); - for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) { - BasicBlockPass *BP = getContainedPass(Index); - bool LocalChanged = false; - - dumpPassInfo(BP, EXECUTION_MSG, ON_BASICBLOCK_MSG, BB.getName()); - dumpRequiredSet(BP); - - initializeAnalysisImpl(BP); - - { - // If the pass crashes, remember this. - PassManagerPrettyStackEntry X(BP, BB); - TimeRegion PassTimer(getPassTimer(BP)); - LocalChanged |= BP->runOnBasicBlock(BB); - if (EmitICRemark) { - unsigned NewSize = BB.size(); - // Update the size of the basic block, emit a remark, and update the - // size of the module. - if (NewSize != BBSize) { - int64_t Delta = - static_cast<int64_t>(NewSize) - static_cast<int64_t>(BBSize); - emitInstrCountChangedRemark(BP, M, Delta, InstrCount, - FunctionToInstrCount, &F); - InstrCount = static_cast<int64_t>(InstrCount) + Delta; - BBSize = NewSize; - } - } - } - - Changed |= LocalChanged; - if (LocalChanged) - dumpPassInfo(BP, MODIFICATION_MSG, ON_BASICBLOCK_MSG, - BB.getName()); - dumpPreservedSet(BP); - dumpUsedSet(BP); - - verifyPreservedAnalysis(BP); - removeNotPreservedAnalysis(BP); - recordAvailableAnalysis(BP); - removeDeadPasses(BP, BB.getName(), ON_BASICBLOCK_MSG); - } - } - - return doFinalization(F) || Changed; -} - -// Implement doInitialization and doFinalization -bool BBPassManager::doInitialization(Module &M) { - bool Changed = false; - - for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) - Changed |= getContainedPass(Index)->doInitialization(M); - - return Changed; -} - -bool BBPassManager::doFinalization(Module &M) { - bool Changed = false; - - for (int Index = getNumContainedPasses() - 1; Index >= 0; --Index) - Changed |= getContainedPass(Index)->doFinalization(M); - - return Changed; -} - -bool BBPassManager::doInitialization(Function &F) { - bool Changed = false; - - for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) { - BasicBlockPass *BP = getContainedPass(Index); - Changed |= BP->doInitialization(F); - } - - return Changed; -} - -bool BBPassManager::doFinalization(Function &F) { - bool Changed = false; - - for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) { - BasicBlockPass *BP = getContainedPass(Index); - Changed |= BP->doFinalization(F); - } - - return Changed; -} - - -//===----------------------------------------------------------------------===// // FunctionPassManager implementation /// Create new Function pass manager @@ -1998,60 +1826,4 @@ void FunctionPass::assignPassManager(PMStack &PMS, FPP->add(this); } -void BasicBlockPass::preparePassManager(PMStack &PMS) { - // Find BBPassManager - while (!PMS.empty() && - PMS.top()->getPassManagerType() > PMT_BasicBlockPassManager) - PMS.pop(); - - // If this pass is destroying high level information that is used - // by other passes that are managed by BBPM then do not insert - // this pass in current BBPM. Use new BBPassManager. - if (PMS.top()->getPassManagerType() == PMT_BasicBlockPassManager && - !PMS.top()->preserveHigherLevelAnalysis(this)) - PMS.pop(); -} - -/// Find appropriate Basic Pass Manager or Call Graph Pass Manager -/// in the PM Stack and add self into that manager. -void BasicBlockPass::assignPassManager(PMStack &PMS, - PassManagerType PreferredType) { - while (!PMS.empty() && - PMS.top()->getPassManagerType() > PMT_BasicBlockPassManager) - PMS.pop(); - - BBPassManager *BBP; - - // Basic Pass Manager is a leaf pass manager. It does not handle - // any other pass manager. - if (!PMS.empty() && - PMS.top()->getPassManagerType() == PMT_BasicBlockPassManager) { - BBP = (BBPassManager *)PMS.top(); - } else { - // If leaf manager is not Basic Block Pass manager then create new - // basic Block Pass manager. - assert(!PMS.empty() && "Unable to create BasicBlock Pass Manager"); - PMDataManager *PMD = PMS.top(); - - // [1] Create new Basic Block Manager - BBP = new BBPassManager(); - BBP->populateInheritedAnalysis(PMS); - - // [2] Set up new manager's top level manager - // Basic Block Pass Manager does not live by itself - PMTopLevelManager *TPM = PMD->getTopLevelManager(); - TPM->addIndirectPassManager(BBP); - - // [3] Assign manager to manage this new manager. This may create - // and push new managers into PMS - BBP->assignPassManager(PMS, PreferredType); - - // [4] Push new manager into PMS - PMS.push(BBP); - } - - // Assign BBP as the manager of this pass. - BBP->add(this); -} - PassManagerBase::~PassManagerBase() {} diff --git a/llvm/lib/IR/Pass.cpp b/llvm/lib/IR/Pass.cpp index 699a7e17c0c..dbdbbf4cf35 100644 --- a/llvm/lib/IR/Pass.cpp +++ b/llvm/lib/IR/Pass.cpp @@ -176,51 +176,6 @@ bool FunctionPass::skipFunction(const Function &F) const { return false; } -//===----------------------------------------------------------------------===// -// BasicBlockPass Implementation -// - -Pass *BasicBlockPass::createPrinterPass(raw_ostream &OS, - const std::string &Banner) const { - return createPrintBasicBlockPass(OS, Banner); -} - -bool BasicBlockPass::doInitialization(Function &) { - // By default, don't do anything. - return false; -} - -bool BasicBlockPass::doFinalization(Function &) { - // By default, don't do anything. - return false; -} - -static std::string getDescription(const BasicBlock &BB) { - return "basic block (" + BB.getName().str() + ") in function (" + - BB.getParent()->getName().str() + ")"; -} - -bool BasicBlockPass::skipBasicBlock(const BasicBlock &BB) const { - const Function *F = BB.getParent(); - if (!F) - return false; - OptPassGate &Gate = F->getContext().getOptPassGate(); - if (Gate.isEnabled() && !Gate.shouldRunPass(this, getDescription(BB))) - return true; - if (F->hasOptNone()) { - // Report this only once per function. - if (&BB == &F->getEntryBlock()) - LLVM_DEBUG(dbgs() << "Skipping pass '" << getPassName() - << "' on function " << F->getName() << "\n"); - return true; - } - return false; -} - -PassManagerType BasicBlockPass::getPotentialPassManagerType() const { - return PMT_BasicBlockPassManager; -} - const PassInfo *Pass::lookupPassInfo(const void *TI) { return PassRegistry::getPassRegistry()->getPassInfo(TI); } |

