Go to the documentation of this file.
29 #define DEBUG_TYPE "loop-pass-manager"
35 class PrintLoopPassWrapper :
public LoopPass {
42 PrintLoopPassWrapper(
raw_ostream &OS,
const std::string &Banner)
51 if (BBI != L->
blocks().end() &&
58 StringRef getPassName()
const override {
return "Print Loop IR"; }
72 CurrentLoop =
nullptr;
84 for (
auto I = LQ.begin(),
E = LQ.end();
I !=
E; ++
I) {
107 Info.setPreservesAll();
112 "Must not delete loop outside the current loop tree!");
116 assert(LQ.back() == CurrentLoop &&
"Loop queue back isn't the current loop!");
119 if (&L == CurrentLoop) {
120 CurrentLoopDeleted =
true;
129 auto &LIWP = getAnalysis<LoopInfoWrapperPass>();
130 LI = &LIWP.getLoopInfo();
133 DominatorTree *DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
135 bool Changed =
false;
159 Changed |=
P->doInitialization(L, *
this);
166 bool EmitICRemark =
M.shouldEmitInstrCountChangedRemark();
170 FunctionSize =
F.getInstructionCount();
172 while (!LQ.empty()) {
173 CurrentLoopDeleted =
false;
174 CurrentLoop = LQ.back();
188 bool LocalChanged =
false;
192 #ifdef EXPENSIVE_CHECKS
195 LocalChanged =
P->runOnLoop(CurrentLoop, *
this);
197 #ifdef EXPENSIVE_CHECKS
198 if (!LocalChanged && (RefHash !=
P->structuralHash(
F))) {
199 llvm::errs() <<
"Pass modifies its input and doesn't report it: "
200 <<
P->getPassName() <<
"\n";
205 Changed |= LocalChanged;
207 unsigned NewSize =
F.getInstructionCount();
210 if (NewSize != FunctionSize) {
211 int64_t Delta =
static_cast<int64_t
>(NewSize) -
212 static_cast<int64_t
>(FunctionSize);
214 FunctionToInstrCount, &
F);
216 FunctionSize = NewSize;
223 CurrentLoopDeleted ?
"<deleted loop>"
227 if (!CurrentLoopDeleted) {
251 F.getContext().yield();
258 CurrentLoopDeleted ?
"<deleted>"
262 if (CurrentLoopDeleted)
270 if (CurrentLoopDeleted) {
284 Changed |=
P->doFinalization();
295 P->dumpPassStructure(
Offset + 1);
305 const std::string &Banner)
const {
306 return new PrintLoopPassWrapper(
O, Banner);
318 while (!PMS.
empty() &&
334 while (!PMS.
empty() &&
343 assert (!PMS.
empty() &&
"Unable to create Loop Pass Manager");
380 if (
F->hasOptNone()) {
383 <<
F->getName() <<
"\n");
void recordAvailableAnalysis(Pass *P)
Augment AvailableAnalysis by adding analysis made available by pass P.
This is an optimization pass for GlobalISel generic memory operations.
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
The TimeTraceScope is a helper class to call the begin and end functions of the time trace profiler.
Pass * createPrinterPass(raw_ostream &O, const std::string &Banner) const override
getPrinterPass - Get a pass to print the function corresponding to a Loop.
const Function * getParent() const
Return the enclosing method, or null if none.
Represents a single loop in the control flow graph.
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
bool contains(const LoopT *L) const
Return true if the specified loop is contained within in this loop.
void schedulePass(Pass *P)
Schedule pass P for execution.
void dumpPassInfo(Pass *P, enum PassDebuggingString S1, enum PassDebuggingString S2, StringRef Msg)
virtual bool isEnabled() const
isEnabled() should return true before calling shouldRunPass().
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
PassManagerType
Different types of internal pass managers.
static unsigned InstrCount
LoopPass * getContainedPass(unsigned N)
The legacy pass manager's analysis pass to compute loop information.
void push(PMDataManager *PM)
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
PassManagerPrettyStackEntry - This is used to print informative information about what pass is runnin...
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.
LLVM Basic Block Representation.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
PMDataManager provides the common place to manage the analysis data used by pass managers.
void dumpLastUses(Pass *P, unsigned Offset) const
LoopT * getParentLoop() const
Return the parent loop if it exists or nullptr for top level loops.
unsigned getNumContainedPasses() const
The TimeRegion class is used as a helper class to call the startTimer() and stopTimer() methods of th...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
void dumpPassStructure(unsigned Offset) override
Print passes managed by this manager.
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Extensions to this class implement mechanisms to disable passes and individual optimizations at compi...
static void addLoopIntoQueue(Loop *L, std::deque< Loop * > &LQ)
bool skipLoop(const Loop *L) const
Optional passes call this function to check whether the pass should be skipped.
void dumpPreservedSet(const Pass *P) const
Represent the analysis usage information of a pass.
iterator_range< block_iterator > blocks() const
void initializeAnalysisImpl(Pass *P)
All Required analyses should be available to the pass as it runs! Here we fill in the AnalysisImpls m...
void printLoop(Loop &L, raw_ostream &OS, const std::string &Banner="")
Function to print a loop's contents as LLVM's text IR assembly.
void verifyLoop() const
Verify loop structure.
Legacy analysis pass which computes a DominatorTree.
This class implements an extremely fast bulk output stream that can only output to a stream.
Analysis containing CSE Info
void getAnalysisUsage(AnalysisUsage &Info) const override
Pass Manager itself does not invalidate any analysis info.
void preparePassManager(PMStack &PMS) override
Check if available pass managers are suitable for this pass or not.
StringRef getName() const
PMDataManager * top() const
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
void erase_value(Container &C, ValueType V)
Wrapper function to remove a value from a container:
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Pass * getAsPass() override
PMTopLevelManager * getTopLevelManager()
void assignPassManager(PMStack &PMS, PassManagerType PMT) override
Assign pass manager to manage this pass.
Timer * getPassTimer(Pass *)
Request the timer for this legacy-pass-manager's pass instance.
void removeDeadPasses(Pass *P, StringRef Msg, enum PassDebuggingString)
Remove dead passes used by P.
bool isFunctionInPrintList(StringRef FunctionName)
bool preserveHigherLevelAnalysis(Pass *P)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void dumpRequiredSet(const Pass *P) const
bool isRecursivelyLCSSAForm(const DominatorTree &DT, const LoopInfo &LI, bool IgnoreTokens=true) const
Return true if this Loop and all inner subloops are in LCSSA form.
A Module instance is used to store all the information related to an LLVM module.
void initializeLCSSAVerificationPassPass(PassRegistry &)
bool mustPreserveAnalysisID(char &AID) const
mustPreserveAnalysisID - This method serves the same function as getAnalysisIfAvailable,...
virtual bool shouldRunPass(const StringRef PassName, StringRef IRDescription)
IRDescription is a textual description of the IR unit the pass is running over.
@ PMT_LoopPassManager
LPPassManager.
StringRef - Represent a constant reference to a string, i.e.
Analysis the ScalarEvolution expression for r is this
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool isOutermost() const
Return true if the loop does not have a parent (natural) loop.
virtual PassManagerType getPassManagerType() const
StringRef getName() const
Return a constant reference to the value's name.
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
void verifyPreservedAnalysis(Pass *P)
verifyPreservedAnalysis – Verify analysis presreved by pass P.
void removeNotPreservedAnalysis(Pass *P)
Remove Analysis that is not preserved by the pass.
PMStack - This class implements a stack data structure of PMDataManager pointers.
void setPreservesAll()
Set by analyses that do not transform their input at all.
void add(Pass *P, bool ProcessAnalysis=true)
Add pass P into the PassVector.
void markLoopAsDeleted(Loop &L)
BlockT * getHeader() const
void addIndirectPassManager(PMDataManager *Manager)
bool runOnFunction(Function &F) override
run - Execute all of the passes scheduled for execution.
Pass interface - Implemented by all 'passes'.
void freePass(Pass *P, StringRef Msg, enum PassDebuggingString)
Remove P.
raw_ostream & indent(unsigned NumSpaces)
indent - Insert 'NumSpaces' spaces.
static std::string getDescription(const Loop &L)
auto reverse(ContainerTy &&C)
PMTopLevelManager manages LastUser info and collects common APIs used by top level pass managers.
FunctionPass class - This class is used to implement most global optimizations.
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
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 populateInheritedAnalysis(PMStack &PMS)