30#define DEBUG_TYPE "loop-pass-manager"
36class PrintLoopPassWrapper :
public LoopPass {
43 PrintLoopPassWrapper(
raw_ostream &OS,
const std::string &Banner)
52 if (BBI != L->blocks().end() &&
59 StringRef getPassName()
const override {
return "Print Loop IR"; }
62char PrintLoopPassWrapper::ID = 0;
73 CurrentLoop =
nullptr;
78 if (L.isOutermost()) {
85 for (
auto I = LQ.begin(), E = LQ.end();
I != E; ++
I) {
86 if (*
I == L.getParentLoop()) {
108 Info.setPreservesAll();
112 assert((&L == CurrentLoop || CurrentLoop->contains(&L)) &&
113 "Must not delete loop outside the current loop tree!");
117 assert(LQ.back() == CurrentLoop &&
"Loop queue back isn't the current loop!");
120 if (&L == CurrentLoop) {
121 CurrentLoopDeleted =
true;
131 LI = &LIWP.getLoopInfo();
160 Changed |=
P->doInitialization(L, *
this);
167 bool EmitICRemark = M.shouldEmitInstrCountChangedRemark();
171 FunctionSize =
F.getInstructionCount();
173 while (!LQ.empty()) {
174 CurrentLoopDeleted =
false;
175 CurrentLoop = LQ.back();
184 CurrentLoop->getHeader()->getName());
189 bool LocalChanged =
false;
193#ifdef EXPENSIVE_CHECKS
196 LocalChanged =
P->runOnLoop(CurrentLoop, *
this);
198#ifdef EXPENSIVE_CHECKS
199 if (!LocalChanged && (RefHash !=
P->structuralHash(
F))) {
200 llvm::errs() <<
"Pass modifies its input and doesn't report it: "
201 <<
P->getPassName() <<
"\n";
208 unsigned NewSize =
F.getInstructionCount();
211 if (NewSize != FunctionSize) {
212 int64_t Delta =
static_cast<int64_t
>(NewSize) -
213 static_cast<int64_t
>(FunctionSize);
215 FunctionToInstrCount, &
F);
217 FunctionSize = NewSize;
224 CurrentLoopDeleted ?
"<deleted loop>"
225 : CurrentLoop->getName());
228 if (!CurrentLoopDeleted) {
236 CurrentLoop->verifyLoop();
246 assert(CurrentLoop->isRecursivelyLCSSAForm(*DT, *LI));
252 F.getContext().yield();
259 CurrentLoopDeleted ?
"<deleted>"
260 : CurrentLoop->getHeader()->getName(),
263 if (CurrentLoopDeleted)
271 if (CurrentLoopDeleted) {
296 P->dumpPassStructure(
Offset + 1);
306 const std::string &Banner)
const {
307 return new PrintLoopPassWrapper(O, Banner);
319 while (!PMS.
empty() &&
335 while (!PMS.
empty() &&
344 assert (!PMS.
empty() &&
"Unable to create Loop Pass Manager");
372 const Function *
F = L->getHeader()->getParent();
376 const OptPassGate &Gate =
F->getContext().getOptPassGate();
381 if (
F->hasOptNone()) {
384 <<
F->getName() <<
"\n");
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static unsigned InstrCount
Module.h This file contains the declarations for the Module class.
static std::string getDescription(const Loop &L)
static void addLoopIntoQueue(Loop *L, std::deque< Loop * > &LQ)
This file declares the interface for bisecting optimizations.
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
This header defines classes/functions to handle pass execution timing information with interfaces for...
static TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton class")
Represent the analysis usage information of a pass.
void setPreservesAll()
Set by analyses that do not transform their input at all.
LLVM Basic Block Representation.
Legacy analysis pass which computes a DominatorTree.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
bool runOnFunction(Function &F) override
run - Execute all of the passes scheduled for execution.
Pass * getAsPass() override
void dumpPassStructure(unsigned Offset) override
Print passes managed by this manager.
void markLoopAsDeleted(Loop &L)
LoopPass * getContainedPass(unsigned N)
void getAnalysisUsage(AnalysisUsage &Info) const override
Pass Manager itself does not invalidate any analysis info.
The legacy pass manager's analysis pass to compute loop information.
void preparePassManager(PMStack &PMS) override
Check if available pass managers are suitable for this pass or not.
Pass * createPrinterPass(raw_ostream &O, const std::string &Banner) const override
getPrinterPass - Get a pass to print the function corresponding to a Loop.
void assignPassManager(PMStack &PMS, PassManagerType PMT) override
Assign pass manager to manage this pass.
bool skipLoop(const Loop *L) const
Optional passes call this function to check whether the pass should be skipped.
Represents a single loop in the control flow graph.
A Module instance is used to store all the information related to an LLVM module.
Extensions to this class implement mechanisms to disable passes and individual optimizations at compi...
virtual bool isEnabled() const
isEnabled() should return true before calling shouldRunPass().
virtual bool shouldRunPass(StringRef PassName, StringRef IRDescription) const
IRDescription is a textual description of the IR unit the pass is running over.
PMDataManager provides the common place to manage the analysis data used by pass managers.
void removeDeadPasses(Pass *P, StringRef Msg, enum PassDebuggingString)
Remove dead passes used by P.
void dumpLastUses(Pass *P, unsigned Offset) const
void recordAvailableAnalysis(Pass *P)
Augment AvailableAnalysis by adding analysis made available by pass P.
PMTopLevelManager * getTopLevelManager()
unsigned initSizeRemarkInfo(Module &M, StringMap< std::pair< unsigned, unsigned > > &FunctionToInstrCount)
Set the initial size of the module if the user has specified that they want remarks for size.
void dumpRequiredSet(const Pass *P) const
void initializeAnalysisImpl(Pass *P)
All Required analyses should be available to the pass as it runs!
void verifyPreservedAnalysis(Pass *P)
verifyPreservedAnalysis – Verify analysis presreved by pass P.
void freePass(Pass *P, StringRef Msg, enum PassDebuggingString)
Remove P.
bool preserveHigherLevelAnalysis(Pass *P)
unsigned getNumContainedPasses() const
virtual PassManagerType getPassManagerType() const
void emitInstrCountChangedRemark(Pass *P, Module &M, int64_t Delta, unsigned CountBefore, StringMap< std::pair< unsigned, unsigned > > &FunctionToInstrCount, Function *F=nullptr)
Emit a remark signifying that the number of IR instructions in the module changed.
void add(Pass *P, bool ProcessAnalysis=true)
Add pass P into the PassVector.
void populateInheritedAnalysis(PMStack &PMS)
void dumpPreservedSet(const Pass *P) const
void removeNotPreservedAnalysis(Pass *P)
Remove Analysis that is not preserved by the pass.
void dumpPassInfo(Pass *P, enum PassDebuggingString S1, enum PassDebuggingString S2, StringRef Msg)
PMStack - This class implements a stack data structure of PMDataManager pointers.
PMDataManager * top() const
LLVM_ABI void push(PMDataManager *PM)
PMTopLevelManager manages LastUser info and collects common APIs used by top level pass managers.
void addIndirectPassManager(PMDataManager *Manager)
void schedulePass(Pass *P)
Schedule pass P for execution.
PassManagerPrettyStackEntry - This is used to print informative information about what pass is runnin...
Pass interface - Implemented by all 'passes'.
bool mustPreserveAnalysisID(char &AID) const
mustPreserveAnalysisID - This method serves the same function as getAnalysisIfAvailable,...
Pass(PassKind K, char &pid)
AnalysisType & getAnalysis() const
getAnalysis<AnalysisType>() - This function is used by subclasses to get to the analysis information ...
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
StringRef - Represent a constant reference to a string, i.e.
The TimeRegion class is used as a helper class to call the startTimer() and stopTimer() methods of th...
The TimeTraceScope is a helper class to call the begin and end functions of the time trace profiler.
This class implements an extremely fast bulk output stream that can only output to a stream.
raw_ostream & indent(unsigned NumSpaces)
indent - Insert 'NumSpaces' spaces.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
PassManagerType
Different types of internal pass managers.
@ PMT_LoopPassManager
LPPassManager.
void erase(Container &C, ValueType V)
Wrapper function to remove a value from a container:
LLVM_ABI Timer * getPassTimer(Pass *)
Request the timer for this legacy-pass-manager's pass instance.
auto reverse(ContainerTy &&C)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool isFunctionInPrintList(StringRef FunctionName)
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI void printLoop(Loop &L, raw_ostream &OS, const std::string &Banner="")
Function to print a loop's contents as LLVM's text IR assembly.
LLVM_ABI LCSSAVerificationPass()