28 #define DEBUG_TYPE "loop-pass-manager"
34 class PrintLoopPassWrapper :
public LoopPass {
41 PrintLoopPassWrapper(
raw_ostream &OS,
const std::string &Banner)
51 if (BBI != L->
blocks().end() &&
71 CurrentLoop =
nullptr;
89 for (
auto I = LQ.begin(),
E = LQ.end();
I !=
E; ++
I) {
112 if (
BasicBlock *BB = dyn_cast<BasicBlock>(V)) {
151 auto &LIWP = getAnalysis<LoopInfoWrapperPass>();
152 LI = &LIWP.getLoopInfo();
153 DominatorTree *DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
154 bool Changed =
false;
183 while (!LQ.empty()) {
184 bool LoopWasDeleted =
false;
185 CurrentLoop = LQ.back();
201 Changed |= P->
runOnLoop(CurrentLoop, *
this);
203 LoopWasDeleted = CurrentLoop->
isInvalid();
207 LoopWasDeleted ?
"<deleted>"
211 if (LoopWasDeleted) {
251 if (LoopWasDeleted) {
273 errs().
indent(Offset*2) <<
"Loop Pass Manager\n";
286 const std::string &Banner)
const {
287 return new PrintLoopPassWrapper(O, Banner);
299 while (!PMS.
empty() &&
315 while (!PMS.
empty() &&
324 assert (!PMS.
empty() &&
"Unable to create Loop Pass Manager");
359 <<
"' in function " << F->
getName() <<
"\n");
Pass interface - Implemented by all 'passes'.
bool preserveHigherLevelAnalysis(Pass *P)
PassManagerType
Different types of internal pass managers.
bool shouldRunPass(const Pass *P, const UnitT &U)
Checks the bisect limit to determine if the specified pass should run.
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
void dumpLastUses(Pass *P, unsigned Offset) const
virtual void dumpPassStructure(unsigned Offset=0)
virtual void deleteAnalysisLoop(Loop *L)
Delete analysis info associated with Loop L.
raw_ostream & indent(unsigned NumSpaces)
indent - Insert 'NumSpaces' spaces.
void assignPassManager(PMStack &PMS, PassManagerType PMT) override
Assign pass manager to manage this pass.
void dumpRequiredSet(const Pass *P) const
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
LoopT * getParentLoop() const
void yield()
Calls the yield callback (if applicable).
Loop & addLoop(Loop *ParentLoop)
void dumpPassInfo(Pass *P, enum PassDebuggingString S1, enum PassDebuggingString S2, StringRef Msg)
BlockT * getHeader() const
virtual PassManagerType getPassManagerType() const
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.
StringRef getName() const
Return a constant reference to the value's name.
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.
AnalysisUsage & addRequired()
void freePass(Pass *P, StringRef Msg, enum PassDebuggingString)
Remove P.
void deleteSimpleAnalysisLoop(Loop *L)
Invoke deleteAnalysisLoop hook for all passes that implement simple analysis interface.
void verifyPreservedAnalysis(Pass *P)
verifyPreservedAnalysis – Verify analysis presreved by pass P.
bool mustPreserveAnalysisID(char &AID) const
mustPreserveAnalysisID - This method serves the same function as getAnalysisIfAvailable, but works if you just have an AnalysisID.
void populateInheritedAnalysis(PMStack &PMS)
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...
PassManagerPrettyStackEntry - This is used to print informative information about what pass is runnin...
auto reverse(ContainerTy &&C, typename std::enable_if< has_rbegin< ContainerTy >::value >::type *=nullptr) -> decltype(make_range(C.rbegin(), C.rend()))
Pass * createPrinterPass(raw_ostream &O, const std::string &Banner) const override
getPrinterPass - Get a pass to print the function corresponding to a Loop.
void add(Pass *P, bool ProcessAnalysis=true)
Add pass P into the PassVector.
void addChildLoop(LoopT *NewChild)
Add the specified loop to be a child of this loop.
unsigned getNumContainedPasses() const
This header provides classes for managing per-loop analyses.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
bool skipLoop(const Loop *L) const
Optional passes call this function to check whether the pass should be skipped.
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
iterator_range< block_iterator > blocks() const
void verifyLoop() const
Verify loop structure.
virtual bool doInitialization(Loop *L, LPPassManager &LPM)
void dumpPreservedSet(const Pass *P) const
LLVM Basic Block Representation.
This is an important class for using LLVM in a threaded context.
virtual bool doFinalization()
void addIndirectPassManager(PMDataManager *Manager)
void getAnalysisUsage(AnalysisUsage &Info) const override
Pass Manager itself does not invalidate any analysis info.
bool isRecursivelyLCSSAForm(DominatorTree &DT, const LoopInfo &LI) const
Return true if this Loop and all inner subloops are in LCSSA form.
Represent the analysis usage information of a pass.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
FunctionPass class - This class is used to implement most global optimizations.
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
void deleteSimpleAnalysisValue(Value *V, Loop *L)
deleteSimpleAnalysisValue - Invoke deleteAnalysisValue hook for all passes that implement simple anal...
void recordAvailableAnalysis(Pass *P)
Augment AvailableAnalysis by adding analysis made available by pass P.
void removeNotPreservedAnalysis(Pass *P)
Remove Analysis that is not preserved by the pass.
void removeDeadPasses(Pass *P, StringRef Msg, enum PassDebuggingString)
Remove dead passes used by P.
void addTopLevelLoop(LoopT *New)
This adds the specified loop to the collection of top-level loops.
This file declares the interface for bisecting optimizations.
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.
PMDataManager * top() const
void setPreservesAll()
Set by analyses that do not transform their input at all.
void dumpPassStructure(unsigned Offset) override
Print passes managed by this manager.
void preparePassManager(PMStack &PMS) override
Check if available pass managers are suitable for this pass or not.
virtual bool runOnLoop(Loop *L, LPPassManager &LPM)=0
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
void cloneBasicBlockSimpleAnalysis(BasicBlock *From, BasicBlock *To, Loop *L)
SimpleAnalysis - Provides simple interface to update analysis info maintained by various passes...
Represents a single loop in the control flow graph.
OptBisect & getOptBisect()
Access the object which manages optimization bisection for failure analysis.
LoopPass * getContainedPass(unsigned N)
void push(PMDataManager *PM)
PMDataManager provides the common place to manage the analysis data used by pass managers.
This file defines passes to print out IR in various granularities.
virtual void cloneBasicBlockAnalysis(BasicBlock *F, BasicBlock *T, Loop *L)
SimpleAnalysis - Provides simple interface to update analysis info maintained by various passes...
bool isInvalid()
Return true if this loop is no longer valid.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
virtual void deleteAnalysisValue(Value *V, Loop *L)
deleteAnalysisValue - Delete analysis info associated with value V.
bool runOnFunction(Function &F) override
run - Execute all of the passes scheduled for execution.
static void addLoopIntoQueue(Loop *L, std::deque< Loop * > &LQ)
This class implements an extremely fast bulk output stream that can only output to a stream...
The legacy pass manager's analysis pass to compute loop information.
Pass * getAsPass() override
Legacy analysis pass which computes a DominatorTree.
This header defines various interfaces for pass management in LLVM.
auto find_if(R &&Range, UnaryPredicate P) -> decltype(std::begin(Range))
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly...
void printLoop(Loop &L, raw_ostream &OS, const std::string &Banner="")
Function to print a loop's contents as LLVM's text IR assembly.