31 #include <unordered_set>
33 using namespace llvm::legacy;
47 Disabled, Arguments, Structure, Executions, Details
53 cl::desc(
"Print PassManager debugging information"),
55 clEnumVal(Disabled ,
"disable debug output"),
56 clEnumVal(Arguments ,
"print pass arguments to pass to 'opt'"),
57 clEnumVal(Structure ,
"print pass structure before run()"),
58 clEnumVal(Executions,
"print pass name before it is executed"),
59 clEnumVal(Details ,
"print pass details when it is executed")));
88 cl::desc(
"Only print IR for functions whose name "
89 "match this for all print-[before|after][-all] "
97 PassOptionList &PassesToPrint) {
98 for (
auto *PassInf : PassesToPrint) {
120 static std::unordered_set<std::string> PrintFuncNames(
PrintFuncsList.begin(),
122 return PrintFuncNames.empty() || PrintFuncNames.count(FunctionName);
135 OS <<
"Releasing pass '";
137 OS <<
"Running pass '";
139 OS <<
P->getPassName() <<
"'";
142 OS <<
" on module '" << M->getModuleIdentifier() <<
"'.\n";
151 if (isa<Function>(V))
153 else if (isa<BasicBlock>(V))
159 V->printAsOperand(OS,
false, M);
175 explicit BBPassManager()
180 bool runOnFunction(
Function &
F)
override;
187 bool doInitialization(
Module &M)
override;
189 bool doFinalization(
Module &M)
override;
192 PMDataManager *getAsPMDataManager()
override {
return this; }
193 Pass *getAsPass()
override {
return this; }
195 StringRef getPassName()
const override {
return "BasicBlock Pass Manager"; }
198 void dumpPassStructure(
unsigned Offset)
override {
199 dbgs().
indent(Offset*2) <<
"BasicBlockPass Manager\n";
200 for (
unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
203 dumpLastUses(BP, Offset+1);
208 assert(N < PassVector.size() &&
"Pass number out of range!");
230 virtual void anchor();
246 const std::string &Banner)
const override {
252 void releaseMemoryOnTheFly();
260 bool doInitialization(
Module &M)
override;
264 bool doFinalization(
Module &M)
override;
279 assert(N < PassManagers.size() &&
"Pass number out of range!");
285 void FunctionPassManagerImpl::anchor() {}
301 explicit MPPassManager() :
305 ~MPPassManager()
override {
306 for (
auto &OnTheFlyManager : OnTheFlyManagers) {
314 const std::string &Banner)
const override {
320 bool runOnModule(
Module &M);
333 void addLowerLevelRequiredPass(
Pass *
P,
Pass *RequiredPass)
override;
340 StringRef getPassName()
const override {
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 {
425 assert(N < PassManagers.size() &&
"Pass number out of range!");
426 MPPassManager *MP =
static_cast<MPPassManager *
>(PassManagers[
N]);
431 void PassManagerImpl::anchor() {}
452 TimingInfo() : TG(
"pass",
"... Pass execution timing report ...") {}
458 for (
auto &
I : TimingData)
466 static void createTheTimeInfo();
477 T =
new Timer(PassName, PassName, TG);
493 addPassManager(PMDM);
494 activeStack.push(PMDM);
504 for (
Pass *AP : AnalysisPasses) {
516 Pass *AnalysisPass = findAnalysisPass(
ID);
517 assert(AnalysisPass &&
"Expected analysis pass to exist.");
519 assert(AR &&
"Expected analysis resolver to exist.");
522 if (PDepth == APDepth)
524 else if (PDepth > APDepth)
528 setLastUser(LastUses, P);
538 for (
auto LU : LastUser) {
542 LastUser[LU.first] =
P;
551 InversedLastUser.
find(P);
552 if (DMI == InversedLastUser.
end())
556 for (
Pass *LUP : LU) {
564 auto DMI = AnUsageMap.find(P);
565 if (DMI != AnUsageMap.end())
566 AnUsage = DMI->second;
577 AUFoldingSetNode* Node =
nullptr;
579 AUFoldingSetNode::Profile(ID, AU);
581 if (
auto *
N = UniqueAnalysisUsages.FindNodeOrInsertPos(ID, IP))
584 Node =
new (AUFoldingSetNodeAllocator.Allocate()) AUFoldingSetNode(AU);
585 UniqueAnalysisUsages.InsertNode(Node, IP);
587 assert(Node &&
"cached analysis usage must be non null");
589 AnUsageMap[
P] = &Node->AU;
590 AnUsage = &Node->AU;;
617 bool checkAnalysis =
true;
618 while (checkAnalysis) {
619 checkAnalysis =
false;
623 E = RequiredSet.
end();
I !=
E; ++
I) {
631 dbgs() <<
"Pass '" << P->
getPassName() <<
"' is not initialized." <<
"\n";
632 dbgs() <<
"Verify if there is a pass dependency cycle." <<
"\n";
633 dbgs() <<
"Required Passes:" <<
"\n";
635 E = RequiredSet.
end(); I2 !=
E && I2 !=
I; ++I2) {
640 dbgs() <<
"\t" <<
"Error: Required pass not found! Possible causes:" <<
"\n";
641 dbgs() <<
"\t\t" <<
"- Pass misconfiguration (e.g.: missing macros)" <<
"\n";
642 dbgs() <<
"\t\t" <<
"- Corruption of the global PassRegistry" <<
"\n";
647 assert(PI &&
"Expected required passes to be initialized");
659 checkAnalysis =
true;
703 if (
Pass *
P = ImmutablePassMap.lookup(AID))
712 for (
PMDataManager *IndirectPassManager : IndirectPassManagers)
713 if (
Pass *
P = IndirectPassManager->findAnalysisPass(AID,
false))
720 const PassInfo *&PI = AnalysisPassInfos[AID];
725 "The pass info pointer changed for an analysis ID!");
732 ImmutablePasses.push_back(P);
738 ImmutablePassMap[AID] =
P;
743 assert(PassInf &&
"Expected all immutable passes to be initialized");
745 ImmutablePassMap[ImmPI->getTypeInfo()] =
P;
755 for (
unsigned i = 0, e = ImmutablePasses.size();
i != e; ++
i) {
756 ImmutablePasses[
i]->dumpPassStructure(0);
764 Manager->getAsPass()->dumpPassStructure(1);
772 dbgs() <<
"Pass Arguments: ";
775 assert(PI &&
"Expected all immutable passes to be initialized");
776 if (!PI->isAnalysisGroup())
777 dbgs() <<
" -" << PI->getPassArgument();
780 PM->dumpPassArguments();
786 PM->initializeAnalysisInfo();
790 IPM->initializeAnalysisInfo();
792 for (
auto LU : LastUser) {
814 AvailableAnalysis[PI] =
P;
816 assert(!AvailableAnalysis.empty());
823 for (
unsigned i = 0, e = II.size();
i != e; ++
i)
824 AvailableAnalysis[II[
i]->getTypeInfo()] =
P;
835 for (
Pass *P1 : HigherLevelAnalysis) {
836 if (P1->getAsImmutablePass() ==
nullptr &&
857 AP->verifyAnalysis();
870 E = AvailableAnalysis.end();
I !=
E; ) {
872 if (Info->second->getAsImmutablePass() ==
nullptr &&
876 Pass *S = Info->second;
880 AvailableAnalysis.erase(Info);
886 for (
unsigned Index = 0; Index <
PMT_Last; ++Index) {
895 if (Info->second->getAsImmutablePass() ==
nullptr &&
899 Pass *S = Info->second;
923 dbgs() <<
"' is the last user of following pass instances.";
924 dbgs() <<
" Free these instances\n";
927 for (
Pass *P : DeadPasses)
946 AvailableAnalysis.erase(PI);
950 const std::vector<const PassInfo*> &II = PInf->getInterfacesImplemented();
951 for (
unsigned i = 0, e = II.size();
i != e; ++
i) {
953 AvailableAnalysis.find(II[
i]->getTypeInfo());
954 if (Pos != AvailableAnalysis.end() && Pos->second ==
P)
955 AvailableAnalysis.erase(Pos);
972 if (!ProcessAnalysis) {
986 for (
Pass *PUsed : UsedPasses) {
989 assert(PUsed->getResolver() &&
"Analysis Resolver is not set");
990 PMDataManager &DM = PUsed->getResolver()->getPMDataManager();
991 RDepth = DM.getDepth();
993 if (PDepth == RDepth)
995 else if (PDepth > RDepth) {
999 HigherLevelAnalysis.push_back(PUsed);
1011 if (!TransferLastUses.
empty()) {
1014 TransferLastUses.
clear();
1042 for (
const auto &UsedID : AnUsage->
getUsedSet())
1076 assert(AR &&
"Analysis Resolver is not set");
1088 if (I != AvailableAnalysis.end())
1110 E = LUses.
end();
I !=
E; ++
I) {
1111 dbgs() <<
"--" << std::string(Offset*2,
' ');
1112 (*I)->dumpPassStructure(0);
1120 PMD->dumpPassArguments();
1124 if (!PI->isAnalysisGroup())
1125 dbgs() <<
" -" << PI->getPassArgument();
1135 << std::string(
getDepth() * 2 + 1,
' ');
1151 dbgs() <<
"' on BasicBlock '" << Msg <<
"'...\n";
1154 dbgs() <<
"' on Function '" << Msg <<
"'...\n";
1157 dbgs() <<
"' on Module '" << Msg <<
"'...\n";
1160 dbgs() <<
"' on Region '" << Msg <<
"'...\n";
1163 dbgs() <<
"' on Loop '" << Msg <<
"'...\n";
1166 dbgs() <<
"' on Call Graph Nodes '" << Msg <<
"'...\n";
1179 dumpAnalysisUsage(
"Required", P, analysisUsage.
getRequiredSet());
1197 dumpAnalysisUsage(
"Used", P, analysisUsage.
getUsedSet());
1200 void PMDataManager::dumpAnalysisUsage(
StringRef Msg,
const Pass *
P,
1205 dbgs() << (
const void*)P << std::string(
getDepth()*2+3,
' ') << Msg <<
" Analyses:";
1206 for (
unsigned i = 0;
i != Set.
size(); ++
i) {
1207 if (
i)
dbgs() <<
',';
1212 dbgs() <<
" Uninitialized Pass";
1275 bool BBPassManager::runOnFunction(
Function &
F) {
1279 bool Changed = doInitialization(F);
1282 for (
unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
1284 bool LocalChanged =
false;
1287 dumpRequiredSet(BP);
1289 initializeAnalysisImpl(BP);
1299 Changed |= LocalChanged;
1303 dumpPreservedSet(BP);
1306 verifyPreservedAnalysis(BP);
1307 removeNotPreservedAnalysis(BP);
1308 recordAvailableAnalysis(BP);
1312 return doFinalization(F) || Changed;
1316 bool BBPassManager::doInitialization(
Module &M) {
1317 bool Changed =
false;
1319 for (
unsigned Index = 0; Index < getNumContainedPasses(); ++Index)
1320 Changed |= getContainedPass(Index)->doInitialization(M);
1325 bool BBPassManager::doFinalization(
Module &M) {
1326 bool Changed =
false;
1328 for (
int Index = getNumContainedPasses() - 1; Index >= 0; --Index)
1329 Changed |= getContainedPass(Index)->doFinalization(M);
1334 bool BBPassManager::doInitialization(
Function &F) {
1335 bool Changed =
false;
1337 for (
unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
1345 bool BBPassManager::doFinalization(
Function &F) {
1346 bool Changed =
false;
1348 for (
unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
1406 bool Changed =
false;
1412 Changed |= ImPass->doInitialization(M);
1421 bool Changed =
false;
1427 Changed |= ImPass->doFinalization(M);
1434 for (
unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
1437 assert(AR &&
"Analysis Resolver is not set");
1457 bool Changed =
false;
1458 TimingInfo::createTheTimeInfo();
1479 dbgs().
indent(Offset*2) <<
"FunctionPass Manager\n";
1480 for (
unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
1483 dumpLastUses(FP, Offset+1);
1495 bool Changed =
false;
1498 populateInheritedAnalysis(TPM->activeStack);
1500 for (
unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
1502 bool LocalChanged =
false;
1505 dumpRequiredSet(FP);
1507 initializeAnalysisImpl(FP);
1516 Changed |= LocalChanged;
1519 dumpPreservedSet(FP);
1522 verifyPreservedAnalysis(FP);
1523 removeNotPreservedAnalysis(FP);
1524 recordAvailableAnalysis(FP);
1531 bool Changed =
false;
1534 Changed |= runOnFunction(F);
1540 bool Changed =
false;
1542 for (
unsigned Index = 0; Index < getNumContainedPasses(); ++Index)
1543 Changed |= getContainedPass(Index)->doInitialization(M);
1549 bool Changed =
false;
1551 for (
int Index = getNumContainedPasses() - 1; Index >= 0; --Index)
1552 Changed |= getContainedPass(Index)->doFinalization(M);
1564 MPPassManager::runOnModule(
Module &M) {
1565 bool Changed =
false;
1568 for (
auto &OnTheFlyManager : OnTheFlyManagers) {
1574 for (
unsigned Index = 0; Index < getNumContainedPasses(); ++Index)
1575 Changed |= getContainedPass(Index)->doInitialization(M);
1577 for (
unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
1579 bool LocalChanged =
false;
1582 dumpRequiredSet(MP);
1584 initializeAnalysisImpl(MP);
1593 Changed |= LocalChanged;
1597 dumpPreservedSet(MP);
1600 verifyPreservedAnalysis(MP);
1601 removeNotPreservedAnalysis(MP);
1602 recordAvailableAnalysis(MP);
1607 for (
int Index = getNumContainedPasses() - 1; Index >= 0; --Index)
1608 Changed |= getContainedPass(Index)->doFinalization(M);
1611 for (
auto &OnTheFlyManager : OnTheFlyManagers) {
1625 void MPPassManager::addLowerLevelRequiredPass(
Pass *P,
Pass *RequiredPass) {
1627 "Unable to handle Pass that requires lower level Analysis pass");
1630 "Unable to handle Pass that requires lower level Analysis pass");
1640 OnTheFlyManagers[
P] = FPP;
1643 TPM->findAnalysisPassInfo(RequiredPass->
getPassID());
1645 Pass *FoundPass =
nullptr;
1646 if (RequiredPassPI && RequiredPassPI->
isAnalysis()) {
1651 FoundPass = RequiredPass;
1654 FPP->
add(RequiredPass);
1667 assert(FPP &&
"Unable to find on the fly pass");
1682 bool Changed =
false;
1683 TimingInfo::createTheTimeInfo();
1689 Changed |= ImPass->doInitialization(M);
1698 Changed |= ImPass->doFinalization(M);
1733 cl::desc(
"Time each pass, printing elapsed time for each on exit"));
1738 void TimingInfo::createTheTimeInfo() {
1770 assert(PM &&
"Unable to push. Pass Manager expected");
1773 if (!this->empty()) {
1775 &&
"pushing bad pass manager to PMStack");
1778 assert(TPM &&
"Unable to find top level manager");
1779 TPM->addIndirectPassManager(PM);
1781 PM->
setDepth(this->top()->getDepth()+1);
1785 &&
"pushing bad pass manager to PMStack");
1795 dbgs() << Manager->getAsPass()->getPassName() <<
' ';
1806 while (!PMS.
empty()) {
1808 if (TopPMType == PreferredType)
1815 assert(!PMS.
empty() &&
"Unable to find appropriate Pass Manager");
1825 while (!PMS.
empty()) {
1837 assert(!PMS.
empty() &&
"Unable to create Function Pass Manager");
1870 BBP = (BBPassManager *)PMS.
top();
1874 assert(!PMS.
empty() &&
"Unable to create BasicBlock Pass Manager");
1878 BBP =
new BBPassManager();
1887 BBP->assignPassManager(PMS, PreferredType);
Pass interface - Implemented by all 'passes'.
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()
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 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.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds...
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.
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)
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.
const VectorType & getPreservedSet() const
const_iterator begin(StringRef path)
Get begin iterator over path.
void dumpRequiredSet(const Pass *P) const
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
void yield()
Calls the yield callback (if applicable).
Pass * getAsPass() override
PMTopLevelManager(PMDataManager *PMDM)
Initialize top level manager. Create first pass manager.
void dumpUsedSet(const Pass *P) 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)
virtual void initializePass()
initializePass - This method may be overriden by immutable passes to allow them to perform various in...
virtual PassManagerType getPassManagerType() const
void setResolver(AnalysisResolver *AR)
Pass * createPass() const
createPass() - Use this method to create an instance of this pass.
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.
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...
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.
LLVM_NODISCARD bool empty() const
This class is used to track the amount of time spent between invocations of its startTimer()/stopTime...
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.
StringRef getPassArgument() const
getPassArgument - Return the command line option that may be passed to 'opt' that will cause this pas...
bool run(Module &M)
run - Execute all of the passes scheduled for execution.
Function Alias Analysis false
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 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 ...
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
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
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
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
static sys::TimePoint< std::chrono::seconds > now(bool Deterministic)
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 handleAllErrors(Error E, HandlerTs &&...Handlers)
Behaves the same as handleErrors, except that it requires that all errors be handled by the given han...
void getAnalysisUsage(AnalysisUsage &Info) const override
Pass Manager itself does not invalidate any analysis info.
SmallVectorImpl< ImmutablePass * > & getImmutablePasses()
const VectorType & getUsedSet() const
Error materialize()
Make sure this GlobalValue is fully read.
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.
#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.
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 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.
Iterator for intrusive lists based on ilist_node.
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...
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.
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.
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.
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.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
const VectorType & getRequiredSet() const
Manages a sequence of passes over a particular unit 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))
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
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...
StringRef getPassName() const
getPassName - Return the friendly name for the pass, never returns null
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.
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")))
void dumpPassArguments() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
~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...
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.
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.