32 using namespace llvm::legacy;
46 Disabled, Arguments, Structure, Executions, Details
52 cl::desc(
"Print PassManager debugging information"),
54 clEnumVal(Disabled ,
"disable debug output"),
55 clEnumVal(Arguments ,
"print pass arguments to pass to 'opt'"),
56 clEnumVal(Structure ,
"print pass structure before run()"),
57 clEnumVal(Executions,
"print pass name before it is executed"),
58 clEnumVal(Details ,
"print pass details when it is executed"),
90 PassOptionList &PassesToPrint) {
91 for (
auto *PassInf : PassesToPrint) {
123 OS <<
"Releasing pass '";
125 OS <<
"Running pass '";
127 OS <<
P->getPassName() <<
"'";
130 OS <<
" on module '" << M->getModuleIdentifier() <<
"'.\n";
139 if (isa<Function>(V))
141 else if (isa<BasicBlock>(V))
147 V->printAsOperand(OS,
false, M);
163 explicit BBPassManager()
168 bool runOnFunction(
Function &
F)
override;
175 bool doInitialization(
Module &M)
override;
177 bool doFinalization(
Module &M)
override;
180 PMDataManager *getAsPMDataManager()
override {
return this; }
181 Pass *getAsPass()
override {
return this; }
183 const char *getPassName()
const override {
184 return "BasicBlock Pass Manager";
188 void dumpPassStructure(
unsigned Offset)
override {
189 dbgs().
indent(Offset*2) <<
"BasicBlockPass Manager\n";
190 for (
unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
193 dumpLastUses(BP, Offset+1);
198 assert(N < PassVector.size() &&
"Pass number out of range!");
220 virtual void anchor();
236 const std::string &Banner)
const override {
242 void releaseMemoryOnTheFly();
250 bool doInitialization(
Module &M)
override;
254 bool doFinalization(
Module &M)
override;
269 assert(N < PassManagers.size() &&
"Pass number out of range!");
275 void FunctionPassManagerImpl::anchor() {}
291 explicit MPPassManager() :
295 ~MPPassManager()
override {
296 for (
auto &OnTheFlyManager : OnTheFlyManagers) {
304 const std::string &Banner)
const override {
310 bool runOnModule(
Module &M);
317 bool doInitialization();
321 bool doFinalization();
331 void addLowerLevelRequiredPass(
Pass *
P,
Pass *RequiredPass)
override;
338 const char *getPassName()
const override {
339 return "Module Pass Manager";
342 PMDataManager *getAsPMDataManager()
override {
return this; }
343 Pass *getAsPass()
override {
return this; }
346 void dumpPassStructure(
unsigned Offset)
override {
347 dbgs().
indent(Offset*2) <<
"ModulePass Manager\n";
348 for (
unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
351 std::map<Pass *, FunctionPassManagerImpl *>::const_iterator
I =
352 OnTheFlyManagers.find(MP);
353 if (I != OnTheFlyManagers.end())
354 I->second->dumpPassStructure(Offset + 2);
355 dumpLastUses(MP, Offset+1);
360 assert(N < PassVector.size() &&
"Pass number out of range!");
371 std::map<Pass *, FunctionPassManagerImpl *> OnTheFlyManagers;
387 virtual void anchor();
402 const std::string &Banner)
const override {
415 bool doInitialization();
419 bool doFinalization();
433 assert(N < PassManagers.size() &&
"Pass number out of range!");
434 MPPassManager *MP =
static_cast<MPPassManager *
>(PassManagers[
N]);
439 void PassManagerImpl::anchor() {}
460 TimingInfo() : TG(
"... Pass execution timing report ...") {}
466 for (
auto &
I : TimingData)
474 static void createTheTimeInfo();
499 addPassManager(PMDM);
500 activeStack.push(PMDM);
510 for (
Pass *AP : AnalysisPasses) {
522 E = IDs.
end();
I != E; ++
I) {
523 Pass *AnalysisPass = findAnalysisPass(*
I);
524 assert(AnalysisPass &&
"Expected analysis pass to exist.");
526 assert(AR &&
"Expected analysis resolver to exist.");
529 if (PDepth == APDepth)
531 else if (PDepth > APDepth)
535 setLastUser(LastUses, P);
546 LUE = LastUser.end(); LUI != LUE; ++LUI) {
547 if (LUI->second == AP)
550 LastUser[LUI->first] =
P;
559 InversedLastUser.
find(P);
560 if (DMI == InversedLastUser.
end())
564 for (
Pass *LUP : LU) {
573 if (DMI != AnUsageMap.end())
574 AnUsage = DMI->second;
578 AnUsageMap[
P] = AnUsage;
605 bool checkAnalysis =
true;
606 while (checkAnalysis) {
607 checkAnalysis =
false;
611 E = RequiredSet.
end();
I != E; ++
I) {
619 dbgs() <<
"Pass '" << P->
getPassName() <<
"' is not initialized." <<
"\n";
620 dbgs() <<
"Verify if there is a pass dependency cycle." <<
"\n";
621 dbgs() <<
"Required Passes:" <<
"\n";
623 E = RequiredSet.
end(); I2 != E && I2 !=
I; ++I2) {
628 dbgs() <<
"\t" <<
"Error: Required pass not found! Possible causes:" <<
"\n";
629 dbgs() <<
"\t\t" <<
"- Pass misconfiguration (e.g.: missing macros)" <<
"\n";
630 dbgs() <<
"\t\t" <<
"- Corruption of the global PassRegistry" <<
"\n";
635 assert(PI &&
"Expected required passes to be initialized");
647 checkAnalysis =
true;
671 dbgs(), std::string(
"*** IR Dump Before ") + P->
getPassName() +
" ***");
680 dbgs(), std::string(
"*** IR Dump After ") + P->
getPassName() +
" ***");
696 for (
PMDataManager *IndirectPassManager : IndirectPassManagers)
697 if (
Pass *
P = IndirectPassManager->findAnalysisPass(AID,
false))
702 for (
auto I = ImmutablePasses.rbegin(), E = ImmutablePasses.rend();
I != E;
710 assert(PassInf &&
"Expected all immutable passes to be initialized");
711 const std::vector<const PassInfo*> &ImmPI =
714 if (PI->getTypeInfo() == AID)
722 const PassInfo *&PI = AnalysisPassInfos[AID];
727 "The pass info pointer changed for an analysis ID!");
739 for (
unsigned i = 0, e = ImmutablePasses.size(); i != e; ++i) {
740 ImmutablePasses[i]->dumpPassStructure(0);
748 Manager->getAsPass()->dumpPassStructure(1);
756 dbgs() <<
"Pass Arguments: ";
758 ImmutablePasses.begin(), E = ImmutablePasses.end();
I != E; ++
I)
760 assert(PI &&
"Expected all immutable passes to be initialized");
761 if (!PI->isAnalysisGroup())
762 dbgs() <<
" -" << PI->getPassArgument();
766 (*I)->dumpPassArguments();
773 (*I)->initializeAnalysisInfo();
777 I = IndirectPassManagers.begin(), E = IndirectPassManagers.end();
779 (*I)->initializeAnalysisInfo();
782 DME = LastUser.end(); DMI != DME; ++DMI) {
784 InversedLastUser.find(DMI->second);
785 if (InvDMI != InversedLastUser.end()) {
790 InversedLastUser[DMI->second] = L;
802 I = ImmutablePasses.begin(), E = ImmutablePasses.end();
I != E; ++
I)
806 DME = AnUsageMap.end(); DMI != DME; ++DMI)
817 AvailableAnalysis[PI] =
P;
819 assert(!AvailableAnalysis.empty());
826 for (
unsigned i = 0, e = II.size(); i != e; ++i)
827 AvailableAnalysis[II[i]->getTypeInfo()] =
P;
839 E = HigherLevelAnalysis.end();
I != E; ++
I) {
842 std::find(PreservedSet.
begin(), PreservedSet.
end(),
862 E = PreservedSet.
end();
I != E; ++
I) {
866 AP->verifyAnalysis();
879 E = AvailableAnalysis.end();
I != E; ) {
881 if (Info->second->getAsImmutablePass() ==
nullptr &&
882 std::find(PreservedSet.
begin(), PreservedSet.
end(), Info->first) ==
883 PreservedSet.
end()) {
886 Pass *S = Info->second;
890 AvailableAnalysis.erase(Info);
896 for (
unsigned Index = 0; Index <
PMT_Last; ++Index) {
905 if (Info->second->getAsImmutablePass() ==
nullptr &&
906 std::find(PreservedSet.
begin(), PreservedSet.
end(), Info->first) ==
907 PreservedSet.
end()) {
910 Pass *S = Info->second;
934 dbgs() <<
"' is the last user of following pass instances.";
935 dbgs() <<
" Free these instances\n";
939 E = DeadPasses.
end();
I != E; ++
I)
958 AvailableAnalysis.erase(PI);
962 const std::vector<const PassInfo*> &II = PInf->getInterfacesImplemented();
963 for (
unsigned i = 0, e = II.size(); i != e; ++i) {
965 AvailableAnalysis.find(II[i]->getTypeInfo());
966 if (Pos != AvailableAnalysis.end() && Pos->second ==
P)
967 AvailableAnalysis.erase(Pos);
984 if (!ProcessAnalysis) {
998 ReqAnalysisNotAvailable, P);
1000 E = RequiredPasses.
end();
I != E; ++
I) {
1001 Pass *PRequired = *
I;
1002 unsigned RDepth = 0;
1004 assert(PRequired->
getResolver() &&
"Analysis Resolver is not set");
1006 RDepth = DM.getDepth();
1008 if (PDepth == RDepth)
1010 else if (PDepth > RDepth) {
1014 HigherLevelAnalysis.push_back(PRequired);
1026 if (!TransferLastUses.
empty()) {
1029 TransferLastUses.
clear();
1034 I = ReqAnalysisNotAvailable.
begin(),
1035 E = ReqAnalysisNotAvailable.
end() ;
I != E; ++
I) {
1060 I = RequiredSet.
begin(), E = RequiredSet.
end();
I != E; ++
I) {
1069 E = IDs.
end();
I != E; ++
I) {
1094 assert(AR &&
"Analysis Resolver is not set");
1106 if (I != AvailableAnalysis.end())
1128 E = LUses.
end();
I != E; ++
I) {
1129 dbgs() <<
"--" << std::string(Offset*2,
' ');
1130 (*I)->dumpPassStructure(0);
1138 PMD->dumpPassArguments();
1142 if (!PI->isAnalysisGroup())
1143 dbgs() <<
" -" << PI->getPassArgument();
1153 << std::string(
getDepth() * 2 + 1,
' ');
1169 dbgs() <<
"' on BasicBlock '" << Msg <<
"'...\n";
1172 dbgs() <<
"' on Function '" << Msg <<
"'...\n";
1175 dbgs() <<
"' on Module '" << Msg <<
"'...\n";
1178 dbgs() <<
"' on Region '" << Msg <<
"'...\n";
1181 dbgs() <<
"' on Loop '" << Msg <<
"'...\n";
1184 dbgs() <<
"' on Call Graph Nodes '" << Msg <<
"'...\n";
1197 dumpAnalysisUsage(
"Required", P, analysisUsage.
getRequiredSet());
1209 void PMDataManager::dumpAnalysisUsage(
StringRef Msg,
const Pass *
P,
1214 dbgs() << (
const void*)P << std::string(
getDepth()*2+3,
' ') << Msg <<
" Analyses:";
1215 for (
unsigned i = 0; i != Set.
size(); ++i) {
1216 if (i)
dbgs() <<
',';
1221 dbgs() <<
" Uninitialized Pass";
1284 bool BBPassManager::runOnFunction(
Function &
F) {
1288 bool Changed = doInitialization(F);
1291 for (
unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
1293 bool LocalChanged =
false;
1296 dumpRequiredSet(BP);
1298 initializeAnalysisImpl(BP);
1308 Changed |= LocalChanged;
1312 dumpPreservedSet(BP);
1314 verifyPreservedAnalysis(BP);
1315 removeNotPreservedAnalysis(BP);
1316 recordAvailableAnalysis(BP);
1320 return doFinalization(F) || Changed;
1324 bool BBPassManager::doInitialization(
Module &M) {
1325 bool Changed =
false;
1327 for (
unsigned Index = 0; Index < getNumContainedPasses(); ++Index)
1328 Changed |= getContainedPass(Index)->doInitialization(M);
1333 bool BBPassManager::doFinalization(
Module &M) {
1334 bool Changed =
false;
1336 for (
int Index = getNumContainedPasses() - 1; Index >= 0; --Index)
1337 Changed |= getContainedPass(Index)->doFinalization(M);
1342 bool BBPassManager::doInitialization(
Function &F) {
1343 bool Changed =
false;
1345 for (
unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
1353 bool BBPassManager::doFinalization(
Function &F) {
1354 bool Changed =
false;
1356 for (
unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
1413 bool Changed =
false;
1419 Changed |= ImPass->doInitialization(M);
1428 bool Changed =
false;
1434 Changed |= ImPass->doFinalization(M);
1441 for (
unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
1444 assert(AR &&
"Analysis Resolver is not set");
1464 bool Changed =
false;
1465 TimingInfo::createTheTimeInfo();
1486 dbgs().
indent(Offset*2) <<
"FunctionPass Manager\n";
1487 for (
unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
1490 dumpLastUses(FP, Offset+1);
1502 bool Changed =
false;
1505 populateInheritedAnalysis(TPM->activeStack);
1507 for (
unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
1509 bool LocalChanged =
false;
1512 dumpRequiredSet(FP);
1514 initializeAnalysisImpl(FP);
1523 Changed |= LocalChanged;
1526 dumpPreservedSet(FP);
1528 verifyPreservedAnalysis(FP);
1529 removeNotPreservedAnalysis(FP);
1530 recordAvailableAnalysis(FP);
1537 bool Changed =
false;
1540 Changed |= runOnFunction(F);
1546 bool Changed =
false;
1548 for (
unsigned Index = 0; Index < getNumContainedPasses(); ++Index)
1549 Changed |= getContainedPass(Index)->doInitialization(M);
1555 bool Changed =
false;
1557 for (
int Index = getNumContainedPasses() - 1; Index >= 0; --Index)
1558 Changed |= getContainedPass(Index)->doFinalization(M);
1570 MPPassManager::runOnModule(
Module &M) {
1571 bool Changed =
false;
1574 for (
auto &OnTheFlyManager : OnTheFlyManagers) {
1580 for (
unsigned Index = 0; Index < getNumContainedPasses(); ++Index)
1581 Changed |= getContainedPass(Index)->doInitialization(M);
1583 for (
unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
1585 bool LocalChanged =
false;
1588 dumpRequiredSet(MP);
1590 initializeAnalysisImpl(MP);
1599 Changed |= LocalChanged;
1603 dumpPreservedSet(MP);
1605 verifyPreservedAnalysis(MP);
1606 removeNotPreservedAnalysis(MP);
1607 recordAvailableAnalysis(MP);
1612 for (
int Index = getNumContainedPasses() - 1; Index >= 0; --Index)
1613 Changed |= getContainedPass(Index)->doFinalization(M);
1616 for (
auto &OnTheFlyManager : OnTheFlyManagers) {
1630 void MPPassManager::addLowerLevelRequiredPass(
Pass *P,
Pass *RequiredPass) {
1632 "Unable to handle Pass that requires lower level Analysis pass");
1635 "Unable to handle Pass that requires lower level Analysis pass");
1645 OnTheFlyManagers[
P] = FPP;
1648 TPM->findAnalysisPassInfo(RequiredPass->
getPassID());
1650 Pass *FoundPass =
nullptr;
1651 if (RequiredPassPI && RequiredPassPI->
isAnalysis()) {
1656 FoundPass = RequiredPass;
1659 FPP->
add(RequiredPass);
1672 assert(FPP &&
"Unable to find on the fly pass");
1687 bool Changed =
false;
1688 TimingInfo::createTheTimeInfo();
1694 Changed |= ImPass->doInitialization(M);
1703 Changed |= ImPass->doFinalization(M);
1738 cl::desc(
"Time each pass, printing elapsed time for each on exit"));
1743 void TimingInfo::createTheTimeInfo() {
1775 assert(PM &&
"Unable to push. Pass Manager expected");
1776 assert(PM->
getDepth()==0 &&
"Pass Manager depth set too early");
1778 if (!this->empty()) {
1780 &&
"pushing bad pass manager to PMStack");
1783 assert(TPM &&
"Unable to find top level manager");
1784 TPM->addIndirectPassManager(PM);
1786 PM->
setDepth(this->top()->getDepth()+1);
1790 &&
"pushing bad pass manager to PMStack");
1800 dbgs() << Manager->getAsPass()->getPassName() <<
' ';
1811 while (!PMS.
empty()) {
1813 if (TopPMType == PreferredType)
1820 assert(!PMS.
empty() &&
"Unable to find appropriate Pass Manager");
1830 while (!PMS.
empty()) {
1842 assert(!PMS.
empty() &&
"Unable to create Function Pass Manager");
1875 BBP = (BBPassManager *)PMS.
top();
1879 assert(!PMS.
empty() &&
"Unable to create BasicBlock Pass Manager");
1883 BBP =
new BBPassManager();
1892 BBP->assignPassManager(PMS, PreferredType);
Pass interface - Implemented by all 'passes'.
std::string str() const
Provides conversion of the TimeValue into a readable time & date.
bool preserveHigherLevelAnalysis(Pass *P)
ValuesClass< DataType > LLVM_END_WITH_NULL values(const char *Arg, DataType Val, const char *Desc,...)
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()
virtual Pass * createPrinterPass(raw_ostream &O, const std::string &Banner) const =0
createPrinterPass - Get a Pass appropriate to print the IR this pass operates on (Module, Function or MachineFunction).
static TimeValue now()
This is a static constructor that returns a TimeValue that represents the current time...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
Pass * findAnalysisPass(AnalysisID AID, bool Direction)
Find the pass that implements Analysis AID.
const char * getPassName() const
getPassName - Return the friendly name for the pass, never returns null
static cl::opt< bool, true > EnableTiming("time-passes", cl::location(TimePassesIsEnabled), cl::desc("Time each pass, printing elapsed time for each on exit"))
virtual PMDataManager * getAsPMDataManager()
void dumpLastUses(Pass *P, unsigned Offset) const
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...
const std::vector< const PassInfo * > & getInterfacesImplemented() const
getInterfacesImplemented - Return a list of all of the analysis group interfaces implemented by this ...
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.
AnalysisID getPassID() const
getPassID - Return the PassID number that corresponds to this pass.
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...
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
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...
unsigned getNumContainedManagers() const
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)
virtual const char * getPassName() const
getPassName - Return a nice clean name for a pass.
static bool ShouldPrintBeforeOrAfterPass(const PassInfo *PI, PassOptionList &PassesToPrint)
This is a helper to determine whether to print IR before or after a pass.
const VectorType & getPreservedSet() const
void collectRequiredAnalysis(SmallVectorImpl< Pass * > &RequiredPasses, SmallVectorImpl< AnalysisID > &ReqPassNotAvailable, Pass *P)
Populate RequiredPasses with analysis pass that are required by pass P and are available.
const_iterator begin(StringRef path)
Get begin iterator over path.
void dumpRequiredSet(const Pass *P) const
void yield()
Calls the yield callback (if applicable).
Pass * getAsPass() override
PMTopLevelManager(PMDataManager *PMDM)
Initialize top level manager. Create first pass manager.
virtual void preparePassManager(PMStack &)
Check if available pass managers are suitable for this pass or not.
void dumpPassInfo(Pass *P, enum PassDebuggingString S1, enum PassDebuggingString S2, StringRef Msg)
virtual PassManagerType getPassManagerType() const
void setResolver(AnalysisResolver *AR)
Pass * createPass() const
createPass() - Use this method to create an instance of this pass.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const char *reason, bool gen_crash_diag=true)
Reports a serious error, calling any installed error handler.
DenseMap< AnalysisID, Pass * > * InheritedAnalysis[PMT_Last]
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)
StringRef getName() const
Return a constant reference to the value's name.
bool doFinalization(Module &M) override
doFinalization - Run all of the finalizers for the function passes.
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 add(Pass *P) override
Add a pass to the queue of passes to run.
void freePass(Pass *P, StringRef Msg, enum PassDebuggingString)
Remove P.
void dumpPassStructure(unsigned Offset) override
Print passes managed by this manager.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool isPassDebuggingExecutionsOrMore() const
isPassDebuggingExecutionsOrMore - Return true if -debug-pass=Executions or higher is specified...
virtual ~PMTopLevelManager()
Destructor.
virtual bool doFinalization(Module &)
doFinalization - Virtual method overriden by subclasses to do any necessary clean up after all passes...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void verifyPreservedAnalysis(Pass *P)
verifyPreservedAnalysis – Verify analysis presreved by pass P.
void initializeAnalysisInfo()
Initialize available analysis information.
virtual void addLowerLevelRequiredPass(Pass *P, Pass *RequiredPass)
Add RequiredPass into list of lower level passes required by pass P.
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...
const std::string & getModuleIdentifier() const
Get the module identifier which is, essentially, the name of the module.
#define clEnumVal(ENUMVAL, DESC)
PassManagerPrettyStackEntry - This is used to print informative information about what pass is runnin...
unsigned getDepth() const
void assignPassManager(PMStack &PMS, PassManagerType T) override
Find appropriate Module Pass Manager in the PM Stack and add self into that manager.
Timer - This class is used to track the amount of time spent between invocations of its startTimer()/...
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
PassManagerType getTopLevelPassManagerType() override
Pass * getAnalysisIfAvailable(AnalysisID ID, bool Direction) const
Return analysis result or null if it doesn't exist.
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.
unsigned getNumContainedPasses() const
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...
bool run(Function &F)
run - Execute all of the passes scheduled for execution.
virtual ImmutablePass * getAsImmutablePass()
virtual bool doInitialization(Module &)
doInitialization - Virtual method overridden by subclasses to do any necessary initialization before ...
static PassOptionList PrintAfter("print-after", llvm::cl::desc("Print IR after specified passes"), cl::Hidden)
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)
void dumpPreservedSet(const Pass *P) const
void print(raw_ostream &OS) const override
print - Emit information about this stack frame to OS.
const VectorType & getRequiredTransitiveSet() const
void releaseMemoryOnTheFly()
void addIndirectPassManager(PMDataManager *Manager)
Pass * getAsPass() override
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
void collectLastUses(SmallVectorImpl< Pass * > &LastUses, Pass *P)
Collect passes whose last user is P.
AnalysisResolver * getResolver() const
Represent the analysis usage information of a pass.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
PassManagerImpl manages MPPassManagers.
FunctionPass class - This class is used to implement most global optimizations.
static cl::opt< bool > PrintBeforeAll("print-before-all", llvm::cl::desc("Print IR before each pass"), cl::init(false))
void getAnalysisUsage(AnalysisUsage &Info) const override
Pass Manager itself does not invalidate any analysis info.
SmallVectorImpl< ImmutablePass * > & getImmutablePasses()
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.
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.
BasicBlockPass class - This class is used to implement most local optimizations.
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.
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"), clEnumValEnd))
void setLastUser(ArrayRef< Pass * > AnalysisPasses, Pass *P)
Set pass P as the last user of the given analysis passes.
static bool ShouldPrintBeforePass(const PassInfo *PI)
This is a utility to check whether a pass should have IR dumped before it.
void addImmutablePass(ImmutablePass *P)
Add immutable pass and initialize it.
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()
bool getPreservesAll() const
Determine whether a pass said it does not transform its input at all.
void removeNotPreservedAnalysis(Pass *P)
Remove Analysis that is not preserved by the pass.
Module.h This file contains the declarations for the Module class.
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)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
const char * getPassArgument() const
getPassArgument - Return the command line option that may be passed to 'opt' that will cause this pas...
SmallVector< Pass *, 16 > PassVector
PMDataManager * top() const
void clearAnalysisImpls()
Clear cache that is used to connect a pass to the the analysis (PassInfo).
Pass * findImplPass(AnalysisID PI)
Find pass that is implementing PI.
void setPreservesAll()
Set by analyses that do not transform their input at all.
PassManager< Function > FunctionPassManager
Convenience typedef for a pass manager over functions.
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.
const PassInfo * findAnalysisPassInfo(AnalysisID AID) const
Retrieve the PassInfo for an analysis.
void setTopLevelManager(PMTopLevelManager *T)
SmallVector< PMDataManager *, 8 > PassManagers
Collection of pass managers.
const VectorType & getRequiredSet() const
Manages a sequence of passes over units of IR.
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
PMDataManager & getPMDataManager()
FunctionPass * getContainedPass(unsigned N)
void cleanup()
cleanup - After running all passes, clean up pass manager cache.
static cl::opt< bool > PrintAfterAll("print-after-all", llvm::cl::desc("Print IR after each pass"), cl::init(false))
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...
iterator find(const KeyT &Val)
void dumpArguments() const
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.
const PassInfo * getPassInfo(const void *TI) const
getPassInfo - Look up a pass' corresponding PassInfo, indexed by the pass' type identifier (&MyPass::...
This file defines passes to print out IR in various granularities.
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.
void dumpPassArguments() const
~FunctionPassManager() override
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...
virtual bool runOnBasicBlock(BasicBlock &BB)=0
runOnBasicBlock - Virtual method overriden by subclasses to do the per-basicblock processing of the p...
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...
bool TimePassesIsEnabled
If the user specifies the -time-passes argument on an LLVM tool command line then the value of this b...
std::error_code materialize()
Make sure this GlobalValue is fully read.
LocationClass< Ty > location(Ty &L)
Pass * createPrinterPass(raw_ostream &O, const std::string &Banner) const override
createPrinterPass - Get a function printer pass.
virtual PassManagerType getPotentialPassManagerType() const
Return what kind of Pass Manager can manage this pass.
virtual void assignPassManager(PMStack &, PassManagerType)
Each pass is responsible for assigning a pass manager to itself.
LLVMContext & getContext() const
Get the global data context.