Lines Matching +full:depth +full:- +full:wise
1 //===- LegacyPassManager.cpp - LLVM Pass Infrastructure Implementation ----===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
37 //===----------------------------------------------------------------------===//
40 // debugging on, a command line option (--debug-pass) is enabled that causes the
52 "debug-pass", cl::Hidden,
60 /// isPassDebuggingExecutionsOrMore - Return true if -debug-pass=Executions
68 // Only calculate getInstructionCount if the size-info remark is requested.
72 // per-function size remarks later.
93 // that the only passes that return non-null with getAsPMDataManager are pass
96 if (P->getAsPMDataManager())
116 It->second.second = FnSize;
143 BasicBlock &BB = *F->begin();
144 OptimizationRemarkAnalysis R("size-info", "IRSizeChange",
148 R << DiagnosticInfoOptimizationBase::Argument("Pass", P->getPassName())
155 F->getContext().diagnose(R); // Not using ORE for layering reasons.
157 // Emit per-function size change remarks separately.
158 std::string PassName = P->getPassName().str();
166 int64_t FnDelta = static_cast<int64_t>(FnCountAfter) -
176 // whole-module size change remarks really ought not to have source
178 OptimizationRemarkAnalysis FR("size-info", "FunctionIRSizeChange",
191 F->getContext().diagnose(FR);
204 EmitFunctionSizeChangedRemark(F->getName().str());
213 OS << P->getPassName() << "'";
216 OS << " on module '" << M->getModuleIdentifier() << "'.\n";
233 V->printAsOperand(OS, /*PrintType=*/false, M);
241 //===----------------------------------------------------------------------===//
262 /// createPrinterPass - Get a function printer pass.
272 /// run - Execute all of the passes scheduled for execution. Keep track of
276 /// doInitialization - Run all of the initializers for the function passes.
280 /// doFinalization - Run all of the finalizers for the function passes.
304 getContainedManager(I)->dumpPassStructure(Offset);
312 //===----------------------------------------------------------------------===//
322 Changed |= ImPass->doInitialization(M);
325 Changed |= getContainedManager(Index)->doInitialization(M);
333 for (int Index = getNumContainedManagers() - 1; Index >= 0; --Index)
334 Changed |= getContainedManager(Index)->doFinalization(M);
337 Changed |= ImPass->doFinalization(M);
347 for (unsigned Index = 0; Index < FPPM->getNumContainedPasses(); ++Index) {
348 FPPM->getContainedPass(Index)->releaseMemory();
361 Changed |= getContainedManager(Index)->runOnFunction(F);
366 getContainedManager(Index)->cleanup();
375 //===----------------------------------------------------------------------===//
394 /// createPrinterPass - Get a module printer pass.
400 /// run - Execute all of the passes scheduled for execution. Keep track of
433 MP->dumpPassStructure(Offset + 1);
437 I->second->dumpPassStructure(Offset + 2);
462 //===----------------------------------------------------------------------===//
482 /// createPrinterPass - Get a module printer pass.
488 /// run - Execute all of the passes scheduled for execution. Keep track of
517 //===----------------------------------------------------------------------===//
521 /// run - Execute all of the passes scheduled for execution. Keep track of
530 // DbgVariableRecord representation of debug-info for the duration of these
535 Changed |= ImPass->doInitialization(M);
539 Changed |= getContainedManager(Index)->runOnModule(M);
544 Changed |= ImPass->doFinalization(M);
551 //===----------------------------------------------------------------------===//
556 PMDM->setTopLevelManager(this);
565 if (P->getResolver())
566 PDepth = P->getResolver()->getPMDataManager().getDepth();
581 const AnalysisUsage::VectorType &IDs = AnUsage->getRequiredTransitiveSet();
587 AnalysisResolver *AR = AnalysisPass->getResolver();
589 unsigned APDepth = AR->getPMDataManager().getDepth();
601 if (P->getResolver())
602 setLastUser(LastPMUses, P->getResolver()->getPMDataManager().getAsPass());
621 auto &LU = DMI->second;
629 AnUsage = DMI->second;
638 P->getAnalysisUsage(AU);
652 AnUsageMap[P] = &Node->AU;
653 AnUsage = &Node->AU;
663 // TODO : Allocate function manager for this pass, other wise required set
667 P->preparePassManager(activeStack);
672 const PassInfo *PI = findAnalysisPassInfo(P->getPassID());
673 if (PI && PI->isAnalysis() && findAnalysisPass(P->getPassID())) {
686 const AnalysisUsage::VectorType &RequiredSet = AnUsage->getRequiredSet();
695 dbgs() << "Pass '" << P->getPassName() << "' is not initialized." << "\n";
703 dbgs() << "\t" << AnalysisPass2->getPassName() << "\n";
706 dbgs() << "\t\t" << "- Pass misconfiguration (e.g.: missing macros)" << "\n";
707 dbgs() << "\t\t" << "- Corruption of the global PassRegistry" << "\n";
713 AnalysisPass = PI->createPass();
714 if (P->getPotentialPassManagerType () ==
715 AnalysisPass->getPotentialPassManagerType())
718 else if (P->getPotentialPassManagerType () >
719 AnalysisPass->getPotentialPassManagerType()) {
734 if (ImmutablePass *IP = P->getAsImmutablePass()) {
739 P->setResolver(AR);
740 DM->initializeAnalysisImpl(P);
742 DM->recordAvailableAnalysis(IP);
746 if (PI && !PI->isAnalysis() && shouldPrintBeforePass(PI->getPassArgument())) {
748 P->createPrinterPass(dbgs(), ("*** IR Dump Before " + P->getPassName() +
749 " (" + PI->getPassArgument() + ") ***")
751 PP->assignPassManager(activeStack, getTopLevelPassManagerType());
755 P->assignPassManager(activeStack, getTopLevelPassManagerType());
757 if (PI && !PI->isAnalysis() && shouldPrintAfterPass(PI->getPassArgument())) {
759 P->createPrinterPass(dbgs(), ("*** IR Dump After " + P->getPassName() +
760 " (" + PI->getPassArgument() + ") ***")
762 PP->assignPassManager(activeStack, getTopLevelPassManagerType());
777 if (Pass *P = PassManager->findAnalysisPass(AID, false))
782 if (Pass *P = IndirectPassManager->findAnalysisPass(AID, false))
791 PI = PassRegistry::getPassRegistry()->getPassInfo(AID);
793 assert(PI == PassRegistry::getPassRegistry()->getPassInfo(AID) &&
800 P->initializePass();
806 AnalysisID AID = P->getPassID();
818 Pass->dumpPassStructure(0);
825 Manager->getAsPass()->dumpPassStructure(1);
835 if (const PassInfo *PI = findAnalysisPassInfo(P->getPassID())) {
837 dbgs() << " -" << PI->getPassArgument();
840 PM->dumpPassArguments();
846 PM->initializeAnalysisInfo();
850 IPM->initializeAnalysisInfo();
862 //===----------------------------------------------------------------------===//
867 AnalysisID PI = P->getPassID();
875 AnalysisUsage *AnUsage = TPM->findAnalysisUsage(P);
876 if (AnUsage->getPreservesAll())
879 const AnalysisUsage::VectorType &PreservedSet = AnUsage->getPreservedSet();
881 if (P1->getAsImmutablePass() == nullptr &&
882 !is_contained(PreservedSet, P1->getPassID()))
889 /// verifyPreservedAnalysis -- Verify analysis preserved by pass P.
895 AnalysisUsage *AnUsage = TPM->findAnalysisUsage(P);
896 const AnalysisUsage::VectorType &PreservedSet = AnUsage->getPreservedSet();
902 AP->verifyAnalysis();
909 AnalysisUsage *AnUsage = TPM->findAnalysisUsage(P);
910 if (AnUsage->getPreservesAll())
913 const AnalysisUsage::VectorType &PreservedSet = AnUsage->getPreservedSet();
917 if (Info->second->getAsImmutablePass() == nullptr &&
918 !is_contained(PreservedSet, Info->first)) {
921 Pass *S = Info->second;
922 dbgs() << " -- '" << P->getPassName() << "' is not preserving '";
923 dbgs() << S->getPassName() << "'\n";
935 for (DenseMap<AnalysisID, Pass *>::iterator I = IA->begin(),
936 E = IA->end();
939 if (Info->second->getAsImmutablePass() == nullptr &&
940 !is_contained(PreservedSet, Info->first)) {
943 Pass *S = Info->second;
944 dbgs() << " -- '" << P->getPassName() << "' is not preserving '";
945 dbgs() << S->getPassName() << "'\n";
947 IA->erase(Info);
963 TPM->collectLastUses(DeadPasses, P);
966 dbgs() << " -*- '" << P->getPassName();
984 P->releaseMemory();
988 AvailableAnalysis.erase(P->getPassID());
997 P->setResolver(AR);
1014 unsigned PDepth = this->getDepth();
1020 assert(PUsed->getResolver() && "Analysis Resolver is not set");
1021 PMDataManager &DM = PUsed->getResolver()->getPMDataManager();
1038 if (!P->getAsPMDataManager())
1040 TPM->setLastUser(LastUses, P);
1044 TPM->setLastUser(TransferLastUses, My_PM);
1050 const PassInfo *PI = TPM->findAnalysisPassInfo(ID);
1051 Pass *AnalysisPass = PI->createPass();
1052 this->addLowerLevelRequiredPass(P, AnalysisPass);
1071 AnalysisUsage *AnUsage = TPM->findAnalysisUsage(P);
1073 for (const auto &UsedID : AnUsage->getUsedSet())
1077 for (const auto &RequiredID : AnUsage->getRequiredSet())
1090 AnalysisUsage *AnUsage = TPM->findAnalysisUsage(P);
1092 for (const AnalysisID ID : AnUsage->getRequiredSet()) {
1098 AnalysisResolver *AR = P->getResolver();
1100 AR->addAnalysisImplsPair(ID, Impl);
1112 return I->second;
1116 return TPM->findAnalysisPass(AID);
1132 TPM->collectLastUses(LUses, P);
1135 dbgs() << "--" << std::string(Offset*2, ' ');
1136 P->dumpPassStructure(0);
1142 if (PMDataManager *PMD = P->getAsPMDataManager())
1143 PMD->dumpPassArguments();
1144 else if (const PassInfo *PI = TPM->findAnalysisPassInfo(P->getPassID()))
1145 dbgs() << " -" << PI->getPassArgument();
1158 dbgs() << "Executing Pass '" << P->getPassName();
1161 dbgs() << "Made Modification '" << P->getPassName();
1164 dbgs() << " Freeing Pass '" << P->getPassName();
1195 P->getAnalysisUsage(analysisUsage);
1204 P->getAnalysisUsage(analysisUsage);
1213 P->getAnalysisUsage(analysisUsage);
1225 const PassInfo *PInf = TPM->findAnalysisPassInfo(Set[i]);
1232 dbgs() << ' ' << PInf->getPassName();
1243 TPM->dumpArguments();
1244 TPM->dumpPasses();
1257 dbgs() << "Unable to schedule '" << RequiredPass->getPassName();
1258 dbgs() << "' required by '" << P->getPassName() << "'\n";
1274 //===----------------------------------------------------------------------===//
1276 // getAnalysisIfAvailable - Return analysis result or null if it doesn't exist.
1289 //===----------------------------------------------------------------------===//
1296 FPM->setTopLevelManager(FPM);
1299 FPM->setResolver(AR);
1307 FPM->add(P);
1310 /// run - Execute all of the passes scheduled for execution. Keep
1318 return FPM->run(F);
1322 /// doInitialization - Run all of the initializers for the function passes.
1325 return FPM->doInitialization(*M);
1328 /// doFinalization - Run all of the finalizers for the function passes.
1331 return FPM->doFinalization(*M);
1336 /// cleanup - After running all passes, clean up pass manager cache.
1340 AnalysisResolver *AR = FP->getResolver();
1342 AR->clearAnalysisImpls();
1347 //===----------------------------------------------------------------------===//
1356 FP->dumpPassStructure(Offset + 1);
1371 populateInheritedAnalysis(TPM->activeStack);
1393 "RunPass", [FP]() { return std::string(FP->getPassName()); });
1404 uint64_t RefHash = FP->structuralHash(F);
1406 LocalChanged |= FP->runOnFunction(F);
1409 if (!LocalChanged && (RefHash != FP->structuralHash(F))) {
1411 << FP->getPassName() << "\n";
1422 int64_t Delta = static_cast<int64_t>(NewSize) -
1461 Changed |= getContainedPass(Index)->doInitialization(M);
1469 for (int Index = getNumContainedPasses() - 1; Index >= 0; --Index)
1470 Changed |= getContainedPass(Index)->doFinalization(M);
1475 //===----------------------------------------------------------------------===//
1487 // Initialize on-the-fly passes
1490 Changed |= FPP->doInitialization(M);
1495 Changed |= getContainedPass(Index)->doInitialization(M);
1518 uint64_t RefHash = MP->structuralHash(M);
1521 LocalChanged |= MP->runOnModule(M);
1524 assert((LocalChanged || (RefHash == MP->structuralHash(M))) &&
1532 int64_t Delta = static_cast<int64_t>(ModuleCount) -
1556 for (int Index = getNumContainedPasses() - 1; Index >= 0; --Index)
1557 Changed |= getContainedPass(Index)->doFinalization(M);
1559 // Finalize on-the-fly passes
1562 // We don't know when is the last time an on-the-fly pass is run,
1564 FPP->releaseMemoryOnTheFly();
1565 Changed |= FPP->doFinalization(M);
1576 assert(P->getPotentialPassManagerType() == PMT_ModulePassManager &&
1578 assert((P->getPotentialPassManagerType() <
1579 RequiredPass->getPotentialPassManagerType()) &&
1586 FPP->setTopLevelManager(FPP);
1591 TPM->findAnalysisPassInfo(RequiredPass->getPassID());
1594 if (RequiredPassPI && RequiredPassPI->isAnalysis()) {
1596 ((PMTopLevelManager*)FPP)->findAnalysisPass(RequiredPass->getPassID());
1602 FPP->add(RequiredPass);
1607 FPP->setLastUser(LU, P);
1618 FPP->releaseMemoryOnTheFly();
1619 bool Changed = FPP->run(F);
1620 return std::make_tuple(((PMTopLevelManager *)FPP)->findAnalysisPass(PI),
1627 //===----------------------------------------------------------------------===//
1634 PM->setTopLevelManager(PM);
1642 PM->add(P);
1645 /// run - Execute all of the passes scheduled for execution. Keep track of
1648 return PM->run(M);
1653 //===----------------------------------------------------------------------===//
1660 PMDataManager *Top = this->top();
1661 Top->initializeAnalysisInfo();
1669 assert(PM->getDepth()==0 && "Pass Manager depth set too early");
1671 if (!this->empty()) {
1672 assert(PM->getPassManagerType() > this->top()->getPassManagerType()
1674 PMTopLevelManager *TPM = this->top()->getTopLevelManager();
1677 TPM->addIndirectPassManager(PM);
1678 PM->setTopLevelManager(TPM);
1679 PM->setDepth(this->top()->getDepth()+1);
1681 assert((PM->getPassManagerType() == PMT_ModulePassManager
1682 || PM->getPassManagerType() == PMT_FunctionPassManager)
1684 PM->setDepth(1);
1693 dbgs() << Manager->getAsPass()->getPassName() << ' ';
1705 while ((T = PMS.top()->getPassManagerType()) > PMT_ModulePassManager &&
1708 PMS.top()->add(this);
1717 while (PM = PMS.top(), PM->getPassManagerType() > PMT_FunctionPassManager)
1721 if (PM->getPassManagerType() != PMT_FunctionPassManager) {
1724 FPP->populateInheritedAnalysis(PMS);
1727 PM->getTopLevelManager()->addIndirectPassManager(FPP);
1731 FPP->assignPassManager(PMS, PM->getPassManagerType());
1739 PM->add(this);