32 #include <unordered_set>
34 using namespace llvm::legacy;
48 Disabled, Arguments, Structure, Executions, Details
54 cl::desc(
"Print PassManager debugging information"),
56 clEnumVal(Disabled ,
"disable debug output"),
57 clEnumVal(Arguments ,
"print pass arguments to pass to 'opt'"),
58 clEnumVal(Structure ,
"print pass structure before run()"),
59 clEnumVal(Executions,
"print pass name before it is executed"),
60 clEnumVal(Details ,
"print pass details when it is executed")));
89 cl::desc(
"Only print IR for functions whose name "
90 "match this for all print-[before|after][-all] "
98 PassOptionList &PassesToPrint) {
99 for (
auto *PassInf : PassesToPrint) {
121 static std::unordered_set<std::string> PrintFuncNames(
PrintFuncsList.begin(),
123 return PrintFuncNames.empty() || PrintFuncNames.count(FunctionName);
136 OS <<
"Releasing pass '";
138 OS <<
"Running pass '";
140 OS <<
P->getPassName() <<
"'";
143 OS <<
" on module '" << M->getModuleIdentifier() <<
"'.\n";
152 if (isa<Function>(V))
154 else if (isa<BasicBlock>(V))
160 V->printAsOperand(OS,
false, M);
176 explicit BBPassManager()
181 bool runOnFunction(
Function &
F)
override;
188 bool doInitialization(
Module &M)
override;
190 bool doFinalization(
Module &M)
override;
193 PMDataManager *getAsPMDataManager()
override {
return this; }
194 Pass *getAsPass()
override {
return this; }
196 StringRef getPassName()
const override {
return "BasicBlock Pass Manager"; }
199 void dumpPassStructure(
unsigned Offset)
override {
200 dbgs().
indent(Offset*2) <<
"BasicBlockPass Manager\n";
201 for (
unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
204 dumpLastUses(BP, Offset+1);
209 assert(N < PassVector.size() &&
"Pass number out of range!");
231 virtual void anchor();
247 const std::string &Banner)
const override {
253 void releaseMemoryOnTheFly();
261 bool doInitialization(
Module &M)
override;
265 bool doFinalization(
Module &M)
override;
280 assert(N < PassManagers.size() &&
"Pass number out of range!");
286 void FunctionPassManagerImpl::anchor() {}
302 explicit MPPassManager() :
306 ~MPPassManager()
override {
307 for (
auto &OnTheFlyManager : OnTheFlyManagers) {
315 const std::string &Banner)
const override {
321 bool runOnModule(
Module &M);
334 void addLowerLevelRequiredPass(
Pass *
P,
Pass *RequiredPass)
override;
341 StringRef getPassName()
const override {
return "Module Pass Manager"; }
343 PMDataManager *getAsPMDataManager()
override {
return this; }
344 Pass *getAsPass()
override {
return this; }
347 void dumpPassStructure(
unsigned Offset)
override {
348 dbgs().
indent(Offset*2) <<
"ModulePass Manager\n";
349 for (
unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
352 std::map<Pass *, FunctionPassManagerImpl *>::const_iterator
I =
353 OnTheFlyManagers.find(MP);
354 if (I != OnTheFlyManagers.end())
355 I->second->dumpPassStructure(Offset + 2);
356 dumpLastUses(MP, Offset+1);
361 assert(N < PassVector.size() &&
"Pass number out of range!");
372 std::map<Pass *, FunctionPassManagerImpl *> OnTheFlyManagers;
388 virtual void anchor();
403 const std::string &Banner)
const override {
426 assert(N < PassManagers.size() &&
"Pass number out of range!");
427 MPPassManager *MP =
static_cast<MPPassManager *
>(PassManagers[
N]);
432 void PassManagerImpl::anchor() {}
453 TimingInfo() : TG(
"pass",
"... Pass execution timing report ...") {}
459 for (
auto &
I : TimingData)
467 static void createTheTimeInfo();
483 T =
new Timer(PassName, PassName, TG);
499 addPassManager(PMDM);
500 activeStack.push(PMDM);
510 for (
Pass *AP : AnalysisPasses) {
522 Pass *AnalysisPass = findAnalysisPass(
ID);
523 assert(AnalysisPass &&
"Expected analysis pass to exist.");
525 assert(AR &&
"Expected analysis resolver to exist.");
528 if (PDepth == APDepth)
530 else if (PDepth > APDepth)
534 setLastUser(LastUses, P);
544 for (
auto LU : LastUser) {
548 LastUser[LU.first] =
P;
557 InversedLastUser.
find(P);
558 if (DMI == InversedLastUser.
end())
562 for (
Pass *LUP : LU) {
570 auto DMI = AnUsageMap.find(P);
571 if (DMI != AnUsageMap.end())
572 AnUsage = DMI->second;
583 AUFoldingSetNode* Node =
nullptr;
585 AUFoldingSetNode::Profile(ID, AU);
587 if (
auto *
N = UniqueAnalysisUsages.FindNodeOrInsertPos(ID, IP))
590 Node =
new (AUFoldingSetNodeAllocator.Allocate()) AUFoldingSetNode(AU);
591 UniqueAnalysisUsages.InsertNode(Node, IP);
593 assert(Node &&
"cached analysis usage must be non null");
595 AnUsageMap[
P] = &Node->AU;
623 bool checkAnalysis =
true;
624 while (checkAnalysis) {
625 checkAnalysis =
false;
636 dbgs() <<
"Pass '" << P->
getPassName() <<
"' is not initialized." <<
"\n";
637 dbgs() <<
"Verify if there is a pass dependency cycle." <<
"\n";
638 dbgs() <<
"Required Passes:" <<
"\n";
646 dbgs() <<
"\t" <<
"Error: Required pass not found! Possible causes:" <<
"\n";
647 dbgs() <<
"\t\t" <<
"- Pass misconfiguration (e.g.: missing macros)" <<
"\n";
648 dbgs() <<
"\t\t" <<
"- Corruption of the global PassRegistry" <<
"\n";
653 assert(PI &&
"Expected required passes to be initialized");
665 checkAnalysis =
true;
709 if (
Pass *
P = ImmutablePassMap.lookup(AID))
718 for (
PMDataManager *IndirectPassManager : IndirectPassManagers)
719 if (
Pass *
P = IndirectPassManager->findAnalysisPass(AID,
false))
726 const PassInfo *&PI = AnalysisPassInfos[AID];
731 "The pass info pointer changed for an analysis ID!");
738 ImmutablePasses.push_back(P);
744 ImmutablePassMap[AID] =
P;
749 assert(PassInf &&
"Expected all immutable passes to be initialized");
751 ImmutablePassMap[ImmPI->getTypeInfo()] =
P;
761 for (
unsigned i = 0, e = ImmutablePasses.size(); i != e; ++i) {
762 ImmutablePasses[i]->dumpPassStructure(0);
770 Manager->getAsPass()->dumpPassStructure(1);
778 dbgs() <<
"Pass Arguments: ";
781 assert(PI &&
"Expected all immutable passes to be initialized");
782 if (!PI->isAnalysisGroup())
783 dbgs() <<
" -" << PI->getPassArgument();
786 PM->dumpPassArguments();
792 PM->initializeAnalysisInfo();
796 IPM->initializeAnalysisInfo();
798 for (
auto LU : LastUser) {
820 AvailableAnalysis[PI] =
P;
822 assert(!AvailableAnalysis.empty());
829 for (
unsigned i = 0, e = II.size(); i != e; ++i)
830 AvailableAnalysis[II[i]->getTypeInfo()] =
P;
841 for (
Pass *P1 : HigherLevelAnalysis) {
842 if (P1->getAsImmutablePass() ==
nullptr &&
863 AP->verifyAnalysis();
876 E = AvailableAnalysis.end();
I !=
E; ) {
878 if (Info->second->getAsImmutablePass() ==
nullptr &&
882 Pass *S = Info->second;
886 AvailableAnalysis.erase(Info);
892 for (
unsigned Index = 0; Index <
PMT_Last; ++Index) {
901 if (Info->second->getAsImmutablePass() ==
nullptr &&
905 Pass *S = Info->second;
929 dbgs() <<
"' is the last user of following pass instances.";
930 dbgs() <<
" Free these instances\n";
933 for (
Pass *P : DeadPasses)
952 AvailableAnalysis.erase(PI);
956 const std::vector<const PassInfo*> &II = PInf->getInterfacesImplemented();
957 for (
unsigned i = 0, e = II.size(); i != e; ++i) {
959 AvailableAnalysis.find(II[i]->getTypeInfo());
960 if (Pos != AvailableAnalysis.end() && Pos->second ==
P)
961 AvailableAnalysis.erase(Pos);
978 if (!ProcessAnalysis) {
992 for (
Pass *PUsed : UsedPasses) {
995 assert(PUsed->getResolver() &&
"Analysis Resolver is not set");
996 PMDataManager &DM = PUsed->getResolver()->getPMDataManager();
997 RDepth = DM.getDepth();
999 if (PDepth == RDepth)
1001 else if (PDepth > RDepth) {
1005 HigherLevelAnalysis.push_back(PUsed);
1017 if (!TransferLastUses.
empty()) {
1020 TransferLastUses.
clear();
1048 for (
const auto &UsedID : AnUsage->
getUsedSet())
1080 assert(AR &&
"Analysis Resolver is not set");
1092 if (I != AvailableAnalysis.end())
1113 for (
Pass *P : LUses) {
1114 dbgs() <<
"--" << std::string(Offset*2,
' ');
1122 PMD->dumpPassArguments();
1126 if (!PI->isAnalysisGroup())
1127 dbgs() <<
" -" << PI->getPassArgument();
1137 << std::string(
getDepth() * 2 + 1,
' ');
1153 dbgs() <<
"' on BasicBlock '" << Msg <<
"'...\n";
1156 dbgs() <<
"' on Function '" << Msg <<
"'...\n";
1159 dbgs() <<
"' on Module '" << Msg <<
"'...\n";
1162 dbgs() <<
"' on Region '" << Msg <<
"'...\n";
1165 dbgs() <<
"' on Loop '" << Msg <<
"'...\n";
1168 dbgs() <<
"' on Call Graph Nodes '" << Msg <<
"'...\n";
1181 dumpAnalysisUsage(
"Required", P, analysisUsage.
getRequiredSet());
1199 dumpAnalysisUsage(
"Used", P, analysisUsage.
getUsedSet());
1202 void PMDataManager::dumpAnalysisUsage(
StringRef Msg,
const Pass *
P,
1207 dbgs() << (
const void*)P << std::string(
getDepth()*2+3,
' ') << Msg <<
" Analyses:";
1208 for (
unsigned i = 0; i != Set.
size(); ++i) {
1209 if (i)
dbgs() <<
',';
1214 dbgs() <<
" Uninitialized Pass";
1276 bool BBPassManager::runOnFunction(
Function &
F) {
1280 bool Changed = doInitialization(F);
1283 for (
unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
1285 bool LocalChanged =
false;
1288 dumpRequiredSet(BP);
1290 initializeAnalysisImpl(BP);
1300 Changed |= LocalChanged;
1304 dumpPreservedSet(BP);
1307 verifyPreservedAnalysis(BP);
1308 removeNotPreservedAnalysis(BP);
1309 recordAvailableAnalysis(BP);
1313 return doFinalization(F) || Changed;
1317 bool BBPassManager::doInitialization(
Module &M) {
1318 bool Changed =
false;
1320 for (
unsigned Index = 0; Index < getNumContainedPasses(); ++Index)
1321 Changed |= getContainedPass(Index)->doInitialization(M);
1326 bool BBPassManager::doFinalization(
Module &M) {
1327 bool Changed =
false;
1329 for (
int Index = getNumContainedPasses() - 1; Index >= 0; --Index)
1330 Changed |= getContainedPass(Index)->doFinalization(M);
1335 bool BBPassManager::doInitialization(
Function &F) {
1336 bool Changed =
false;
1338 for (
unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
1346 bool BBPassManager::doFinalization(
Function &F) {
1347 bool Changed =
false;
1349 for (
unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
1407 bool Changed =
false;
1413 Changed |= ImPass->doInitialization(M);
1422 bool Changed =
false;
1428 Changed |= ImPass->doFinalization(M);
1435 for (
unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
1438 assert(AR &&
"Analysis Resolver is not set");
1458 bool Changed =
false;
1459 TimingInfo::createTheTimeInfo();
1480 dbgs().
indent(Offset*2) <<
"FunctionPass Manager\n";
1481 for (
unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
1484 dumpLastUses(FP, Offset+1);
1496 bool Changed =
false;
1499 populateInheritedAnalysis(TPM->activeStack);
1501 for (
unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
1503 bool LocalChanged =
false;
1506 dumpRequiredSet(FP);
1508 initializeAnalysisImpl(FP);
1517 Changed |= LocalChanged;
1520 dumpPreservedSet(FP);
1523 verifyPreservedAnalysis(FP);
1524 removeNotPreservedAnalysis(FP);
1525 recordAvailableAnalysis(FP);
1532 bool Changed =
false;
1535 Changed |= runOnFunction(F);
1541 bool Changed =
false;
1543 for (
unsigned Index = 0; Index < getNumContainedPasses(); ++Index)
1544 Changed |= getContainedPass(Index)->doInitialization(M);
1550 bool Changed =
false;
1552 for (
int Index = getNumContainedPasses() - 1; Index >= 0; --Index)
1553 Changed |= getContainedPass(Index)->doFinalization(M);
1565 MPPassManager::runOnModule(
Module &M) {
1566 bool Changed =
false;
1569 for (
auto &OnTheFlyManager : OnTheFlyManagers) {
1575 for (
unsigned Index = 0; Index < getNumContainedPasses(); ++Index)
1576 Changed |= getContainedPass(Index)->doInitialization(M);
1578 for (
unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
1580 bool LocalChanged =
false;
1583 dumpRequiredSet(MP);
1585 initializeAnalysisImpl(MP);
1594 Changed |= LocalChanged;
1598 dumpPreservedSet(MP);
1601 verifyPreservedAnalysis(MP);
1602 removeNotPreservedAnalysis(MP);
1603 recordAvailableAnalysis(MP);
1608 for (
int Index = getNumContainedPasses() - 1; Index >= 0; --Index)
1609 Changed |= getContainedPass(Index)->doFinalization(M);
1612 for (
auto &OnTheFlyManager : OnTheFlyManagers) {
1626 void MPPassManager::addLowerLevelRequiredPass(
Pass *P,
Pass *RequiredPass) {
1628 "Unable to handle Pass that requires lower level Analysis pass");
1631 "Unable to handle Pass that requires lower level Analysis pass");
1641 OnTheFlyManagers[
P] = FPP;
1644 TPM->findAnalysisPassInfo(RequiredPass->
getPassID());
1646 Pass *FoundPass =
nullptr;
1647 if (RequiredPassPI && RequiredPassPI->
isAnalysis()) {
1652 FoundPass = RequiredPass;
1655 FPP->
add(RequiredPass);
1668 assert(FPP &&
"Unable to find on the fly pass");
1683 bool Changed =
false;
1684 TimingInfo::createTheTimeInfo();
1690 Changed |= ImPass->doInitialization(M);
1699 Changed |= ImPass->doFinalization(M);
1734 cl::desc(
"Time each pass, printing elapsed time for each on exit"));
1739 void TimingInfo::createTheTimeInfo() {
1778 assert(PM &&
"Unable to push. Pass Manager expected");
1781 if (!this->empty()) {
1783 &&
"pushing bad pass manager to PMStack");
1786 assert(TPM &&
"Unable to find top level manager");
1787 TPM->addIndirectPassManager(PM);
1789 PM->
setDepth(this->top()->getDepth()+1);
1793 &&
"pushing bad pass manager to PMStack");
1803 dbgs() << Manager->getAsPass()->getPassName() <<
' ';
1814 while (!PMS.
empty()) {
1816 if (TopPMType == PreferredType)
1823 assert(!PMS.
empty() &&
"Unable to find appropriate Pass Manager");
1833 while (!PMS.
empty()) {
1845 assert(!PMS.
empty() &&
"Unable to create Function Pass Manager");
1878 BBP = (BBPassManager *)PMS.
top();
1882 assert(!PMS.
empty() &&
"Unable to create BasicBlock Pass Manager");
1886 BBP =
new BBPassManager();
1895 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. ...
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.
#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
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)
void reportAndResetTimings()
If -time-passes has been specified, report the timings immediately and then reset the timers to zero...
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.
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...
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()
virtual bool doInitialization(Module &)
doInitialization - Virtual method overridden by subclasses to do any necessary initialization before ...
iterator find(const_arg_type_t< KeyT > Val)
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.
Function Alias Analysis false
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
LLVM Basic Block Representation.
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
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.
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.
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.
AnalysisUsage * findAnalysisUsage(Pass *P)
Find analysis usage information for the pass P.
llvm_unreachable("Unknown RegBank!")
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 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...
PassManager< Function > FunctionPassManager
Convenience typedef for a pass manager over functions.
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
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.