33 #include <unordered_set> 49 Disabled,
Arguments, Structure, Executions, Details
55 cl::desc(
"Print PassManager debugging information"),
57 clEnumVal(Disabled ,
"disable debug output"),
59 clEnumVal(Structure ,
"print pass structure before run()"),
60 clEnumVal(Executions,
"print pass name before it is executed"),
61 clEnumVal(Details ,
"print pass details when it is executed")));
88 cl::desc(
"When printing IR for print-[before|after]{-all} " 89 "always print a module IR"),
94 cl::desc(
"Only print IR for functions whose name " 95 "match this for all print-[before|after][-all] " 103 PassOptionList &PassesToPrint) {
104 for (
auto *PassInf : PassesToPrint) {
128 static std::unordered_set<std::string> PrintFuncNames(PrintFuncsList.begin(),
129 PrintFuncsList.end());
130 return PrintFuncNames.empty() || PrintFuncNames.count(FunctionName);
135 return PassDebugging >= Executions;
144 unsigned CountBefore) {
150 [](
const Function &Fn) {
return !Fn.empty(); });
163 if (CountBefore == CountAfter)
176 static_cast<int64_t
>(CountAfter) - static_cast<int64_t>(CountBefore);
184 <<
": IR instruction count changed from " 195 OS <<
"Releasing pass '";
197 OS <<
"Running pass '";
199 OS <<
P->getPassName() <<
"'";
202 OS <<
" on module '" << M->getModuleIdentifier() <<
"'.\n";
211 if (isa<Function>(V))
213 else if (isa<BasicBlock>(V))
219 V->printAsOperand(OS,
false, M);
235 explicit BBPassManager()
247 bool doInitialization(
Module &M)
override;
249 bool doFinalization(
Module &M)
override;
252 PMDataManager *getAsPMDataManager()
override {
return this; }
253 Pass *getAsPass()
override {
return this; }
255 StringRef getPassName()
const override {
return "BasicBlock Pass Manager"; }
258 void dumpPassStructure(
unsigned Offset)
override {
259 dbgs().
indent(Offset*2) <<
"BasicBlockPass Manager\n";
263 dumpLastUses(BP, Offset+1);
268 assert(N < PassVector.size() &&
"Pass number out of range!");
290 virtual void anchor();
306 const std::string &Banner)
const override {
312 void releaseMemoryOnTheFly();
320 bool doInitialization(
Module &M)
override;
324 bool doFinalization(
Module &M)
override;
339 assert(N < PassManagers.size() &&
"Pass number out of range!");
345 void FunctionPassManagerImpl::anchor() {}
361 explicit MPPassManager() :
365 ~MPPassManager()
override {
366 for (
auto &OnTheFlyManager : OnTheFlyManagers) {
374 const std::string &Banner)
const override {
380 bool runOnModule(
Module &M);
393 void addLowerLevelRequiredPass(
Pass *
P,
Pass *RequiredPass)
override;
400 StringRef getPassName()
const override {
return "Module Pass Manager"; }
402 PMDataManager *getAsPMDataManager()
override {
return this; }
403 Pass *getAsPass()
override {
return this; }
406 void dumpPassStructure(
unsigned Offset)
override {
407 dbgs().
indent(Offset*2) <<
"ModulePass Manager\n";
412 OnTheFlyManagers.find(MP);
413 if (I != OnTheFlyManagers.
end())
414 I->second->dumpPassStructure(Offset + 2);
415 dumpLastUses(MP, Offset+1);
420 assert(N < PassVector.size() &&
"Pass number out of range!");
447 virtual void anchor();
462 const std::string &Banner)
const override {
485 assert(N < PassManagers.size() &&
"Pass number out of range!");
486 MPPassManager *MP =
static_cast<MPPassManager *
>(PassManagers[
N]);
491 void PassManagerImpl::anchor() {}
512 TimingInfo() : TG(
"pass",
"... Pass execution timing report ...") {}
518 for (
auto &
I : TimingData)
526 static void createTheTimeInfo();
544 PassArgument = PI->getPassArgument();
545 T =
new Timer(PassArgument.
empty() ? PassName : PassArgument, PassName,
562 addPassManager(PMDM);
563 activeStack.push(PMDM);
573 for (
Pass *AP : AnalysisPasses) {
585 Pass *AnalysisPass = findAnalysisPass(
ID);
586 assert(AnalysisPass &&
"Expected analysis pass to exist.");
588 assert(AR &&
"Expected analysis resolver to exist.");
591 if (PDepth == APDepth)
593 else if (PDepth > APDepth)
597 setLastUser(LastUses, P);
607 for (
auto LU : LastUser) {
611 LastUser[LU.first] =
P;
620 InversedLastUser.
find(P);
621 if (DMI == InversedLastUser.
end())
625 for (
Pass *LUP : LU) {
633 auto DMI = AnUsageMap.find(P);
634 if (DMI != AnUsageMap.end())
635 AnUsage = DMI->second;
646 AUFoldingSetNode* Node =
nullptr;
648 AUFoldingSetNode::Profile(ID, AU);
650 if (
auto *
N = UniqueAnalysisUsages.FindNodeOrInsertPos(ID, IP))
653 Node =
new (AUFoldingSetNodeAllocator.Allocate()) AUFoldingSetNode(AU);
654 UniqueAnalysisUsages.InsertNode(Node, IP);
656 assert(Node &&
"cached analysis usage must be non null");
658 AnUsageMap[
P] = &Node->AU;
686 bool checkAnalysis =
true;
687 while (checkAnalysis) {
688 checkAnalysis =
false;
693 Pass *AnalysisPass = findAnalysisPass(
ID);
695 const PassInfo *PI = findAnalysisPassInfo(
ID);
699 dbgs() <<
"Pass '" << P->
getPassName() <<
"' is not initialized." <<
"\n";
700 dbgs() <<
"Verify if there is a pass dependency cycle." <<
"\n";
701 dbgs() <<
"Required Passes:" <<
"\n";
705 Pass *AnalysisPass2 = findAnalysisPass(ID2);
709 dbgs() <<
"\t" <<
"Error: Required pass not found! Possible causes:" <<
"\n";
710 dbgs() <<
"\t\t" <<
"- Pass misconfiguration (e.g.: missing macros)" <<
"\n";
711 dbgs() <<
"\t\t" <<
"- Corruption of the global PassRegistry" <<
"\n";
716 assert(PI &&
"Expected required passes to be initialized");
721 schedulePass(AnalysisPass);
725 schedulePass(AnalysisPass);
728 checkAnalysis =
true;
745 addImmutablePass(IP);
772 if (
Pass *
P = ImmutablePassMap.lookup(AID))
781 for (
PMDataManager *IndirectPassManager : IndirectPassManagers)
782 if (
Pass *
P = IndirectPassManager->findAnalysisPass(AID,
false))
789 const PassInfo *&PI = AnalysisPassInfos[AID];
794 "The pass info pointer changed for an analysis ID!");
801 ImmutablePasses.push_back(P);
807 ImmutablePassMap[AID] =
P;
811 const PassInfo *PassInf = findAnalysisPassInfo(AID);
812 assert(PassInf &&
"Expected all immutable passes to be initialized");
814 ImmutablePassMap[ImmPI->getTypeInfo()] =
P;
820 if (PassDebugging < Structure)
824 for (
unsigned i = 0, e = ImmutablePasses.size(); i != e; ++i) {
825 ImmutablePasses[i]->dumpPassStructure(0);
833 Manager->getAsPass()->dumpPassStructure(1);
841 dbgs() <<
"Pass Arguments: ";
843 if (
const PassInfo *PI = findAnalysisPassInfo(
P->getPassID())) {
844 assert(PI &&
"Expected all immutable passes to be initialized");
845 if (!PI->isAnalysisGroup())
846 dbgs() <<
" -" << PI->getPassArgument();
849 PM->dumpPassArguments();
855 PM->initializeAnalysisInfo();
859 IPM->initializeAnalysisInfo();
861 for (
auto LU : LastUser) {
883 AvailableAnalysis[PI] =
P;
885 assert(!AvailableAnalysis.empty());
889 const PassInfo *PInf = TPM->findAnalysisPassInfo(PI);
892 for (
unsigned i = 0, e = II.size(); i != e; ++i)
893 AvailableAnalysis[II[i]->getTypeInfo()] =
P;
904 for (
Pass *P1 : HigherLevelAnalysis) {
905 if (P1->getAsImmutablePass() ==
nullptr &&
924 if (
Pass *AP = findAnalysisPass(AID,
true)) {
926 AP->verifyAnalysis();
939 E = AvailableAnalysis.end();
I !=
E; ) {
941 if (Info->second->getAsImmutablePass() ==
nullptr &&
944 if (PassDebugging >= Details) {
945 Pass *S = Info->second;
949 AvailableAnalysis.erase(Info);
957 if (!InheritedAnalysis[
Index])
961 I = InheritedAnalysis[Index]->
begin(),
962 E = InheritedAnalysis[Index]->
end();
I !=
E; ) {
964 if (Info->second->getAsImmutablePass() ==
nullptr &&
967 if (PassDebugging >= Details) {
968 Pass *S = Info->second;
972 InheritedAnalysis[
Index]->erase(Info);
988 TPM->collectLastUses(DeadPasses, P);
990 if (PassDebugging >= Details && !DeadPasses.
empty()) {
992 dbgs() <<
"' is the last user of following pass instances.";
993 dbgs() <<
" Free these instances\n";
996 for (
Pass *P : DeadPasses)
997 freePass(P, Msg, DBG_STR);
1013 if (
const PassInfo *PInf = TPM->findAnalysisPassInfo(PI)) {
1015 AvailableAnalysis.erase(PI);
1019 const std::vector<const PassInfo*> &II = PInf->getInterfacesImplemented();
1020 for (
unsigned i = 0, e = II.size(); i != e; ++i) {
1022 AvailableAnalysis.find(II[i]->getTypeInfo());
1023 if (Pos != AvailableAnalysis.end() && Pos->second ==
P)
1024 AvailableAnalysis.erase(Pos);
1041 if (!ProcessAnalysis) {
1052 unsigned PDepth = this->getDepth();
1054 collectRequiredAndUsedAnalyses(UsedPasses, ReqAnalysisNotAvailable, P);
1055 for (
Pass *PUsed : UsedPasses) {
1056 unsigned RDepth = 0;
1058 assert(PUsed->getResolver() &&
"Analysis Resolver is not set");
1059 PMDataManager &DM = PUsed->getResolver()->getPMDataManager();
1060 RDepth = DM.getDepth();
1062 if (PDepth == RDepth)
1064 else if (PDepth > RDepth) {
1068 HigherLevelAnalysis.push_back(PUsed);
1078 TPM->setLastUser(LastUses, P);
1080 if (!TransferLastUses.
empty()) {
1081 Pass *My_PM = getAsPass();
1082 TPM->setLastUser(TransferLastUses, My_PM);
1083 TransferLastUses.
clear();
1088 const PassInfo *PI = TPM->findAnalysisPassInfo(
ID);
1090 this->addLowerLevelRequiredPass(P, AnalysisPass);
1095 removeNotPreservedAnalysis(P);
1096 recordAvailableAnalysis(P);
1099 PassVector.push_back(P);
1111 for (
const auto &UsedID : AnUsage->
getUsedSet())
1112 if (
Pass *AnalysisPass = findAnalysisPass(UsedID,
true))
1116 if (
Pass *AnalysisPass = findAnalysisPass(RequiredID,
true))
1122 if (
Pass *AnalysisPass = findAnalysisPass(RequiredID,
true))
1137 Pass *Impl = findAnalysisPass(
ID,
true);
1143 assert(AR &&
"Analysis Resolver is not set");
1155 if (I != AvailableAnalysis.end())
1160 return TPM->findAnalysisPass(AID);
1174 TPM->collectLastUses(LUses, P);
1176 for (
Pass *P : LUses) {
1177 dbgs() <<
"--" << std::string(Offset*2,
' ');
1183 for (
Pass *
P : PassVector) {
1185 PMD->dumpPassArguments();
1188 TPM->findAnalysisPassInfo(
P->getPassID()))
1189 if (!PI->isAnalysisGroup())
1190 dbgs() <<
" -" << PI->getPassArgument();
1197 if (PassDebugging < Executions)
1200 << std::string(getDepth() * 2 + 1,
' ');
1216 dbgs() <<
"' on BasicBlock '" << Msg <<
"'...\n";
1219 dbgs() <<
"' on Function '" << Msg <<
"'...\n";
1222 dbgs() <<
"' on Module '" << Msg <<
"'...\n";
1225 dbgs() <<
"' on Region '" << Msg <<
"'...\n";
1228 dbgs() <<
"' on Loop '" << Msg <<
"'...\n";
1231 dbgs() <<
"' on Call Graph Nodes '" << Msg <<
"'...\n";
1239 if (PassDebugging < Details)
1244 dumpAnalysisUsage(
"Required", P, analysisUsage.
getRequiredSet());
1248 if (PassDebugging < Details)
1257 if (PassDebugging < Details)
1262 dumpAnalysisUsage(
"Used", P, analysisUsage.
getUsedSet());
1265 void PMDataManager::dumpAnalysisUsage(
StringRef Msg,
const Pass *
P,
1267 assert(PassDebugging >= Details);
1270 dbgs() << (
const void*)P << std::string(getDepth()*2+3,
' ') << Msg <<
" Analyses:";
1271 for (
unsigned i = 0; i != Set.
size(); ++i) {
1272 if (i)
dbgs() <<
',';
1273 const PassInfo *PInf = TPM->findAnalysisPassInfo(Set[i]);
1277 dbgs() <<
" Uninitialized Pass";
1291 TPM->dumpArguments();
1317 for (
Pass *P : PassVector)
1325 return PM.findAnalysisPass(ID, dir);
1330 return PM.getOnTheFlyPass(P, AnalysisPI, F);
1343 bool Changed = doInitialization(F);
1351 bool LocalChanged =
false;
1354 dumpRequiredSet(BP);
1356 initializeAnalysisImpl(BP);
1363 InstrCount = initSizeRemarkInfo(M);
1366 emitInstrCountChangedRemark(BP, M, InstrCount);
1369 Changed |= LocalChanged;
1373 dumpPreservedSet(BP);
1376 verifyPreservedAnalysis(BP);
1377 removeNotPreservedAnalysis(BP);
1378 recordAvailableAnalysis(BP);
1382 return doFinalization(F) || Changed;
1386 bool BBPassManager::doInitialization(
Module &M) {
1387 bool Changed =
false;
1390 Changed |= getContainedPass(
Index)->doInitialization(M);
1395 bool BBPassManager::doFinalization(
Module &M) {
1396 bool Changed =
false;
1399 Changed |= getContainedPass(
Index)->doFinalization(M);
1404 bool BBPassManager::doInitialization(
Function &F) {
1405 bool Changed =
false;
1415 bool BBPassManager::doFinalization(
Function &F) {
1416 bool Changed =
false;
1476 bool Changed =
false;
1482 Changed |= ImPass->doInitialization(M);
1485 Changed |= getContainedManager(
Index)->doInitialization(M);
1491 bool Changed =
false;
1494 Changed |= getContainedManager(
Index)->doFinalization(M);
1497 Changed |= ImPass->doFinalization(M);
1507 assert(AR &&
"Analysis Resolver is not set");
1515 for (
unsigned Index = 0;
Index < getNumContainedManagers(); ++
Index) {
1527 bool Changed =
false;
1528 TimingInfo::createTheTimeInfo();
1530 initializeAllAnalysisInfo();
1531 for (
unsigned Index = 0;
Index < getNumContainedManagers(); ++
Index) {
1532 Changed |= getContainedManager(
Index)->runOnFunction(F);
1537 getContainedManager(
Index)->cleanup();
1549 dbgs().
indent(Offset*2) <<
"FunctionPass Manager\n";
1553 dumpLastUses(FP, Offset+1);
1565 bool Changed =
false;
1568 populateInheritedAnalysis(TPM->activeStack);
1574 bool LocalChanged =
false;
1577 dumpRequiredSet(FP);
1579 initializeAnalysisImpl(FP);
1585 InstrCount = initSizeRemarkInfo(M);
1588 emitInstrCountChangedRemark(FP, M, InstrCount);
1591 Changed |= LocalChanged;
1594 dumpPreservedSet(FP);
1597 verifyPreservedAnalysis(FP);
1598 removeNotPreservedAnalysis(FP);
1599 recordAvailableAnalysis(FP);
1606 bool Changed =
false;
1615 bool Changed =
false;
1618 Changed |= getContainedPass(
Index)->doInitialization(M);
1624 bool Changed =
false;
1627 Changed |= getContainedPass(
Index)->doFinalization(M);
1639 MPPassManager::runOnModule(
Module &M) {
1640 bool Changed =
false;
1643 for (
auto &OnTheFlyManager : OnTheFlyManagers) {
1650 Changed |= getContainedPass(
Index)->doInitialization(M);
1656 bool LocalChanged =
false;
1659 dumpRequiredSet(MP);
1661 initializeAnalysisImpl(MP);
1668 InstrCount = initSizeRemarkInfo(M);
1671 emitInstrCountChangedRemark(MP, M, InstrCount);
1674 Changed |= LocalChanged;
1678 dumpPreservedSet(MP);
1681 verifyPreservedAnalysis(MP);
1682 removeNotPreservedAnalysis(MP);
1683 recordAvailableAnalysis(MP);
1689 Changed |= getContainedPass(
Index)->doFinalization(M);
1692 for (
auto &OnTheFlyManager : OnTheFlyManagers) {
1706 void MPPassManager::addLowerLevelRequiredPass(
Pass *P,
Pass *RequiredPass) {
1708 "Unable to handle Pass that requires lower level Analysis pass");
1711 "Unable to handle Pass that requires lower level Analysis pass");
1721 OnTheFlyManagers[
P] = FPP;
1724 TPM->findAnalysisPassInfo(RequiredPass->
getPassID());
1726 Pass *FoundPass =
nullptr;
1727 if (RequiredPassPI && RequiredPassPI->
isAnalysis()) {
1732 FoundPass = RequiredPass;
1735 FPP->
add(RequiredPass);
1748 assert(FPP &&
"Unable to find on the fly pass");
1763 bool Changed =
false;
1764 TimingInfo::createTheTimeInfo();
1770 Changed |= ImPass->doInitialization(M);
1772 initializeAllAnalysisInfo();
1773 for (
unsigned Index = 0;
Index < getNumContainedManagers(); ++
Index) {
1774 Changed |= getContainedManager(
Index)->runOnModule(M);
1779 Changed |= ImPass->doFinalization(M);
1791 PM->setTopLevelManager(PM);
1814 cl::desc(
"Time each pass, printing elapsed time for each on exit"));
1819 void TimingInfo::createTheTimeInfo() {
1826 TheTimeInfo = &*TTI;
1832 return TheTimeInfo->getPassTimer(P);
1840 TheTimeInfo->print();
1858 assert(PM &&
"Unable to push. Pass Manager expected");
1861 if (!this->empty()) {
1863 &&
"pushing bad pass manager to PMStack");
1866 assert(TPM &&
"Unable to find top level manager");
1867 TPM->addIndirectPassManager(PM);
1869 PM->
setDepth(this->top()->getDepth()+1);
1873 &&
"pushing bad pass manager to PMStack");
1883 dbgs() << Manager->getAsPass()->getPassName() <<
' ';
1894 while (!PMS.
empty()) {
1896 if (TopPMType == PreferredType)
1903 assert(!PMS.
empty() &&
"Unable to find appropriate Pass Manager");
1913 while (!PMS.
empty()) {
1925 assert(!PMS.
empty() &&
"Unable to create Function Pass Manager");
1958 BBP = (BBPassManager *)PMS.
top();
1962 assert(!PMS.
empty() &&
"Unable to create BasicBlock Pass Manager");
1966 BBP =
new BBPassManager();
1975 BBP->assignPassManager(PMS, PreferredType);
Pass interface - Implemented by all 'passes'.
const PassInfo * getPassInfo(const void *TI) const
getPassInfo - Look up a pass' corresponding PassInfo, indexed by the pass' type identifier (&MyPass::...
bool preserveHigherLevelAnalysis(Pass *P)
void push_back(const T &Elt)
const_iterator end(StringRef path)
Get end iterator over path.
PassManagerType
Different types of internal pass managers.
static TimingInfo * TheTimeInfo
void initializeAllAnalysisInfo()
bool forcePrintModuleIR()
forcePrintModuleIR - returns true if IR printing passes should
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
Pass * findAnalysisPass(AnalysisID AID, bool Direction)
Find the pass that implements Analysis AID.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Compute iterated dominance frontiers using a linear time algorithm.
virtual PMDataManager * getAsPMDataManager()
virtual void dumpPassStructure(unsigned Offset=0)
virtual bool runOnModule(Module &M)=0
runOnModule - Virtual method overriden by subclasses to process the module being operated on...
void dumpLastUses(Pass *P, unsigned Offset) const
A Module instance is used to store all the information related to an LLVM module. ...
FunctionPassManagerImpl manages FPPassManagers.
bool doInitialization(Module &M) override
doInitialization - Run all of the initializers for the function passes.
virtual void releaseMemory()
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
void assignPassManager(PMStack &PMS, PassManagerType T) override
Find appropriate Function Pass Manager or Call Graph Pass Manager in the PM Stack and add self into t...
static cl::opt< enum PassDebugLevel > PassDebugging("debug-pass", cl::Hidden, cl::desc("Print PassManager debugging information"), cl::values(clEnumVal(Disabled, "disable debug output"), clEnumVal(Arguments, "print pass arguments to pass to 'opt'"), clEnumVal(Structure, "print pass structure before run()"), clEnumVal(Executions, "print pass name before it is executed"), clEnumVal(Details, "print pass details when it is executed")))
FunctionPass * createPrintFunctionPass(raw_ostream &OS, const std::string &Banner="")
Create and return a pass that prints functions to the specified raw_ostream as they are processed...
virtual bool doInitialization(Function &)
doInitialization - Virtual method overridden by BasicBlockPass subclasses to do any necessary per-fun...
raw_ostream & indent(unsigned NumSpaces)
indent - Insert 'NumSpaces' spaces.
PMDataManager * getAsPMDataManager() override
static PassOptionList PrintBefore("print-before", llvm::cl::desc("Print IR before specified passes"), cl::Hidden)
static bool ShouldPrintBeforeOrAfterPass(const PassInfo *PI, PassOptionList &PassesToPrint)
This is a helper to determine whether to print IR before or after a pass.
void collectRequiredAndUsedAnalyses(SmallVectorImpl< Pass *> &UsedPasses, SmallVectorImpl< AnalysisID > &ReqPassNotAvailable, Pass *P)
Populate UsedPasses with analysis pass that are used or required by pass P and are available...
This class implements a map that also provides access to all stored values in a deterministic order...
const VectorType & getUsedSet() const
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds...
void yield()
Calls the yield callback (if applicable).
Pass * getAsPass() override
static unsigned InstrCount
const VectorType & getRequiredSet() const
void emitInstrCountChangedRemark(Pass *P, Module &M, unsigned CountBefore)
Emit a remark signifying that the number of IR instructions in the module changed.
PMTopLevelManager(PMDataManager *PMDM)
Initialize top level manager. Create first pass manager.
AnalysisResolver * getResolver() const
virtual void preparePassManager(PMStack &)
Check if available pass managers are suitable for this pass or not.
Base class for error info classes.
void dumpPassInfo(Pass *P, enum PassDebuggingString S1, enum PassDebuggingString S2, StringRef Msg)
void reportAndResetTimings()
If -time-passes has been specified, report the timings immediately and then reset the timers to zero...
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
virtual void initializePass()
initializePass - This method may be overriden by immutable passes to allow them to perform various in...
void setResolver(AnalysisResolver *AR)
PMTopLevelManager manages LastUser info and collects common APIs used by top level pass managers...
Timer * getPassTimer(Pass *)
If TimingInfo is enabled then start pass timer.
void setDepth(unsigned newDepth)
bool doFinalization(Module &M) override
doFinalization - Run all of the finalizers for the function passes.
AnalysisResolver - Simple interface used by Pass objects to pull all analysis information out of pass...
The TimeRegion class is used as a helper class to call the startTimer() and stopTimer() methods of th...
void schedulePass(Pass *P)
Schedule pass P for execution.
void dumpPassArguments() const
void add(Pass *P) override
Add a pass to the queue of passes to run.
virtual PassManagerType getPotentialPassManagerType() const
Return what kind of Pass Manager can manage this pass.
void freePass(Pass *P, StringRef Msg, enum PassDebuggingString)
Remove P.
void dumpPassStructure(unsigned Offset) override
Print passes managed by this manager.
LLVMContext & getContext() const
Get the global data context.
virtual ~PMTopLevelManager()
Destructor.
virtual bool doFinalization(Module &)
doFinalization - Virtual method overriden by subclasses to do any necessary clean up after all passes...
unsigned getInstructionCount()
Returns the number of non-debug IR instructions in the module.
void verifyPreservedAnalysis(Pass *P)
verifyPreservedAnalysis – Verify analysis presreved by pass P.
static const PassInfo * getPassInfo(StringRef PassName)
void initializeAnalysisInfo()
Initialize available analysis information.
static cl::opt< bool > PrintModuleScope("print-module-scope", cl::desc("When printing IR for print-[before|after]{-all} " "always print a module IR"), cl::init(false), cl::Hidden)
virtual void addLowerLevelRequiredPass(Pass *P, Pass *RequiredPass)
Add RequiredPass into list of lower level passes required by pass P.
const VectorType & getPreservedSet() const
void populateInheritedAnalysis(PMStack &PMS)
FPPassManager manages BBPassManagers and FunctionPasses.
PMStack - This class implements a stack data structure of PMDataManager pointers. ...
void initializeAnalysisImpl(Pass *P)
All Required analyses should be available to the pass as it runs! Here we fill in the AnalysisImpls m...
#define clEnumVal(ENUMVAL, DESC)
PassManagerPrettyStackEntry - This is used to print informative information about what pass is runnin...
void assignPassManager(PMStack &PMS, PassManagerType T) override
Find appropriate Module Pass Manager in the PM Stack and add self into that manager.
static cl::opt< bool, true > EnableTiming("time-passes", cl::location(TimePassesIsEnabled), cl::Hidden, cl::desc("Time each pass, printing elapsed time for each on exit"))
bool isPassDebuggingExecutionsOrMore() const
isPassDebuggingExecutionsOrMore - Return true if -debug-pass=Executions or higher is specified...
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
This class is used to track the amount of time spent between invocations of its startTimer()/stopTime...
PassManagerType getTopLevelPassManagerType() override
void add(Pass *P, bool ProcessAnalysis=true)
Add pass P into the PassVector.
bool run(Module &M)
run - Execute all of the passes scheduled for execution.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
PassManagerType getTopLevelPassManagerType() override
void add(Pass *P) override
Add a pass to the queue of passes to run.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
virtual Pass * getAsPass()=0
bool doFinalization(Module &M) override
doFinalization - Run all of the finalizers for the function passes.
virtual bool doFinalization(Function &)
doFinalization - Virtual method overriden by BasicBlockPass subclasses to do any post processing need...
std::unique_ptr< raw_fd_ostream > CreateInfoOutputFile()
Return a file stream to print our output on.
bool run(Function &F)
run - Execute all of the passes scheduled for execution.
virtual ImmutablePass * getAsImmutablePass()
static const PassInfo * lookupPassInfo(const void *TI)
virtual bool doInitialization(Module &)
doInitialization - Virtual method overridden by subclasses to do any necessary initialization before ...
iterator find(const_arg_type_t< KeyT > Val)
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
void dumpUsedSet(const Pass *P) const
static PassOptionList PrintAfter("print-after", llvm::cl::desc("Print IR after specified passes"), cl::Hidden)
static bool runOnFunction(Function &F, bool PostInlining)
initializer< Ty > init(const Ty &Val)
void assignPassManager(PMStack &PMS, PassManagerType T) override
Find appropriate Basic Pass Manager or Call Graph Pass Manager in the PM Stack and add self into that...
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
FPPassManager * getContainedManager(unsigned N)
LLVM Basic Block Representation.
void print(raw_ostream &OS) const override
print - Emit information about this stack frame to OS.
AnalysisID getPassID() const
getPassID - Return the PassID number that corresponds to this pass.
void releaseMemoryOnTheFly()
bool shouldEmitInstrCountChangedRemark()
Return true if size-info optimization remark is enabled, false otherwise.
void addIndirectPassManager(PMDataManager *Manager)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
Pass * getAsPass() override
virtual PassManagerType getPassManagerType() const
void collectLastUses(SmallVectorImpl< Pass *> &LastUses, Pass *P)
Collect passes whose last user is P.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
AMDGPU Lower Kernel Arguments
static sys::TimePoint< std::chrono::seconds > now(bool Deterministic)
const PassInfo * findAnalysisPassInfo(AnalysisID AID) const
Retrieve the PassInfo for an analysis.
Represent the analysis usage information of a pass.
PassManagerImpl manages MPPassManagers.
FunctionPass class - This class is used to implement most global optimizations.
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
void getAnalysisUsage(AnalysisUsage &Info) const override
Pass Manager itself does not invalidate any analysis info.
auto find_if(R &&Range, UnaryPredicate P) -> decltype(adl_begin(Range))
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly...
Pass * getAnalysisIfAvailable(AnalysisID ID, bool Direction) const
Return analysis result or null if it doesn't exist.
Error materialize()
Make sure this GlobalValue is fully read.
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
PassInfo class - An instance of this class exists for every pass known by the system, and can be obtained from a live Pass by calling its getPassInfo() method.
Used in the streaming interface as the general argument type.
bool doInitialization(Module &M) override
doInitialization - Run all of the initializers for the function passes.
bool run(Module &M)
run - Execute all of the passes scheduled for execution.
const std::string & getModuleIdentifier() const
Get the module identifier which is, essentially, the name of the module.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
BasicBlockPass class - This class is used to implement most local optimizations.
void print(raw_ostream &OS)
Print any started timers in this group and zero them.
bool runOnModule(Module &M) override
runOnModule - Virtual method overriden by subclasses to process the module being operated on...
void getAnalysisUsage(AnalysisUsage &Info) const override
Pass Manager itself does not invalidate any analysis info.
void addImmutablePass(ImmutablePass *P)
Add immutable pass and initialize it.
void handleAllErrors(Error E, HandlerTs &&... Handlers)
Behaves the same as handleErrors, except that by contract all errors must be handled by the given han...
static bool ShouldPrintBeforePass(const PassInfo *PI)
This is a utility to check whether a pass should have IR dumped before it.
void dumpArguments() const
print lazy value Lazy Value Info Printer Pass
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
static bool ShouldPrintAfterPass(const PassInfo *PI)
This is a utility to check whether a pass should have IR dumped after it.
virtual ~PassManagerBase()
ImmutablePass class - This class is used to provide information that does not need to be run...
void recordAvailableAnalysis(Pass *P)
Augment AvailableAnalysis by adding analysis made available by pass P.
FunctionPassManagerImpl()
FunctionPassManager(Module *M)
FunctionPassManager ctor - This initializes the pass manager.
void dumpRequiredSet(const Pass *P) const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
void removeNotPreservedAnalysis(Pass *P)
Remove Analysis that is not preserved by the pass.
Module.h This file contains the declarations for the Module class.
typename VectorType::const_iterator const_iterator
PMDataManager * getAsPMDataManager() override
void addAnalysisImplsPair(AnalysisID PI, Pass *P)
bool runOnFunction(Function &F)
run - Execute all of the passes scheduled for execution.
bool doFinalization()
doFinalization - Run all of the finalizers for the function passes.
void removeDeadPasses(Pass *P, StringRef Msg, enum PassDebuggingString)
Remove dead passes used by P.
virtual Pass * getOnTheFlyPass(Pass *P, AnalysisID PI, Function &F)
bool isFunctionInPrintList(StringRef FunctionName)
isFunctionInPrintList - returns true if a function should be printed via
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void clearAnalysisImpls()
Clear cache that is used to connect a pass to the analysis (PassInfo).
Pass * createPass() const
createPass() - Use this method to create an instance of this pass.
Pass * findImplPass(AnalysisID PI)
Find pass that is implementing PI.
void setPreservesAll()
Set by analyses that do not transform their input at all.
const VectorType & getRequiredTransitiveSet() const
AnalysisUsage * findAnalysisUsage(Pass *P)
Find analysis usage information for the pass P.
void add(Pass *P)
Add a pass to the queue of passes to run.
void setTopLevelManager(PMTopLevelManager *T)
void setLastUser(ArrayRef< Pass *> AnalysisPasses, Pass *P)
Set pass P as the last user of the given analysis passes.
Manages a sequence of passes over a particular unit of IR.
LLVM_NODISCARD bool empty() const
PMDataManager & getPMDataManager()
FunctionPass * getContainedPass(unsigned N)
static cl::opt< bool > PrintBeforeAll("print-before-all", llvm::cl::desc("Print IR before each pass"), cl::init(false), cl::Hidden)
StringRef getName() const
Return a constant reference to the value's name.
StringRef getPassName() const
getPassName - Return the friendly name for the pass, never returns null
void cleanup()
cleanup - After running all passes, clean up pass manager cache.
The TimerGroup class is used to group together related timers into a single report that is printed wh...
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
void push(PMDataManager *PM)
PMDataManager provides the common place to manage the analysis data used by pass managers.
ModulePass * createPrintModulePass(raw_ostream &OS, const std::string &Banner="", bool ShouldPreserveUseListOrder=false)
Create and return a pass that writes the module to the specified raw_ostream.
unsigned initSizeRemarkInfo(Module &M)
Set the initial size of the module if the user has specified that they want remarks for size...
This file defines passes to print out IR in various granularities.
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
Pass * findAnalysisPass(AnalysisID AID)
Find the pass that implements Analysis AID.
void add(Pass *P)
Add a pass to the queue of passes to run.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
~FunctionPassManager() override
PMDataManager * top() const
Module * getParent()
Get the module that this global value is contained inside of...
virtual Pass * createPrinterPass(raw_ostream &OS, const std::string &Banner) const =0
createPrinterPass - Get a Pass appropriate to print the IR this pass operates on (Module, Function or MachineFunction).
bool run(Function &F)
run - Execute all of the passes scheduled for execution.
MPPassManager * getContainedManager(unsigned N)
virtual bool runOnFunction(Function &F)=0
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass...
const std::vector< const PassInfo * > & getInterfacesImplemented() const
getInterfacesImplemented - Return a list of all of the analysis group interfaces implemented by this ...
virtual bool runOnBasicBlock(BasicBlock &BB)=0
runOnBasicBlock - Virtual method overriden by subclasses to do the per-basicblock processing of the p...
unsigned getNumContainedPasses() const
StringRef getPassArgument() const
getPassArgument - Return the command line option that may be passed to 'opt' that will cause this pas...
This class implements an extremely fast bulk output stream that can only output to a stream...
bool doInitialization()
doInitialization - Run all of the initializers for the function passes.
StringRef - Represent a constant reference to a string, i.e.
Pass * createPrinterPass(raw_ostream &O, const std::string &Banner) const override
createPrinterPass - Get a module printer pass.
PassManager()
Create new pass manager.
ManagedStatic - This transparently changes the behavior of global statics to be lazily constructed on...
static cl::list< std::string > PrintFuncsList("filter-print-funcs", cl::value_desc("function names"), cl::desc("Only print IR for functions whose name " "match this for all print-[before|after][-all] " "options"), cl::CommaSeparated, cl::Hidden)
bool TimePassesIsEnabled
If the user specifies the -time-passes argument on an LLVM tool command line then the value of this b...
static cl::opt< bool > PrintAfterAll("print-after-all", llvm::cl::desc("Print IR after each pass"), cl::init(false), cl::Hidden)
unsigned getDepth() const
bool getPreservesAll() const
Determine whether a pass said it does not transform its input at all.
void dumpPreservedSet(const Pass *P) const
LocationClass< Ty > location(Ty &L)
Pass * createPrinterPass(raw_ostream &O, const std::string &Banner) const override
createPrinterPass - Get a function printer pass.
virtual void assignPassManager(PMStack &, PassManagerType)
Each pass is responsible for assigning a pass manager to itself.
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.