X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FPassManagers.h;h=ed1e80eae69cb477342722a887835734eef4ae28;hb=a782e75d487006cafffdc256b3c623307fee4dcf;hp=22d5062b6b1676e2e1a1b645945858ab14379c3f;hpb=d68a07650cdb2e18f18f362ba533459aa10e01b6;p=oota-llvm.git diff --git a/include/llvm/PassManagers.h b/include/llvm/PassManagers.h index 22d5062b6b1..ed1e80eae69 100644 --- a/include/llvm/PassManagers.h +++ b/include/llvm/PassManagers.h @@ -88,7 +88,14 @@ // MPPassManagers. //===----------------------------------------------------------------------===// +#include "llvm/Support/PrettyStackTrace.h" + namespace llvm { + class Module; + class Pass; + class StringRef; + class Value; + class Timer; /// FunctionPassManager and PassManager, two top level managers, serve /// as the public interface of pass manager infrastructure. @@ -109,6 +116,25 @@ enum PassDebuggingString { ON_CG_MSG // "' on Call Graph ...\n'" }; +/// PassManagerPrettyStackEntry - This is used to print informative information +/// about what pass is running when/if a stack trace is generated. +class PassManagerPrettyStackEntry : public PrettyStackTraceEntry { + Pass *P; + Value *V; + Module *M; +public: + explicit PassManagerPrettyStackEntry(Pass *p) + : P(p), V(0), M(0) {} // When P is releaseMemory'd. + PassManagerPrettyStackEntry(Pass *p, Value &v) + : P(p), V(&v), M(0) {} // When P is run on V + PassManagerPrettyStackEntry(Pass *p, Module &m) + : P(p), V(0), M(&m) {} // When P is run on M + + /// print - Emit information about this stack frame to OS. + virtual void print(raw_ostream &OS) const; +}; + + //===----------------------------------------------------------------------===// // PMStack // @@ -247,6 +273,8 @@ public: } virtual ~PMDataManager(); + + virtual Pass *getAsPass() = 0; /// Augment AvailableAnalysis by adding analysis made available by pass P. void recordAvailableAnalysis(Pass *P); @@ -254,14 +282,16 @@ public: /// verifyPreservedAnalysis -- Verify analysis presreved by pass P. void verifyPreservedAnalysis(Pass *P); - /// verifyDomInfo -- Verify dominator information if it is available. - void verifyDomInfo(Pass &P, Function &F); - /// Remove Analysis that is not preserved by the pass void removeNotPreservedAnalysis(Pass *P); - /// Remove dead passes - void removeDeadPasses(Pass *P, const char *Msg, enum PassDebuggingString); + /// Remove dead passes used by P. + void removeDeadPasses(Pass *P, StringRef Msg, + enum PassDebuggingString); + + /// Remove P. + void freePass(Pass *P, StringRef Msg, + enum PassDebuggingString); /// Add pass P into the PassVector. Update /// AvailableAnalysis appropriately if ProcessAnalysis is true. @@ -316,7 +346,7 @@ public: void dumpLastUses(Pass *P, unsigned Offset) const; void dumpPassArguments() const; void dumpPassInfo(Pass *P, enum PassDebuggingString S1, - enum PassDebuggingString S2, const char *Msg); + enum PassDebuggingString S2, StringRef Msg); void dumpRequiredSet(const Pass *P) const; void dumpPreservedSet(const Pass *P) const; @@ -354,13 +384,18 @@ protected: // then PMT_Last active pass mangers. std::map *InheritedAnalysis[PMT_Last]; + + /// isPassDebuggingExecutionsOrMore - Return true if -debug-pass=Executions + /// or higher is specified. + bool isPassDebuggingExecutionsOrMore() const; + private: - void dumpAnalysisUsage(const char *Msg, const Pass *P, - const AnalysisUsage::VectorType &Set) const; + void dumpAnalysisUsage(StringRef Msg, const Pass *P, + const AnalysisUsage::VectorType &Set) const; // Set of available Analysis. This information is used while scheduling - // pass. If a pass requires an analysis which is not not available then - // equired analysis pass is scheduled to run before the pass itself is + // pass. If a pass requires an analysis which is not available then + // the required analysis pass is scheduled to run before the pass itself is // scheduled to run. std::map AvailableAnalysis; @@ -378,18 +413,19 @@ private: /// It batches all function passes and basic block pass managers together and /// sequence them to process one function at a time before processing next /// function. - class FPPassManager : public ModulePass, public PMDataManager { - public: static char ID; explicit FPPassManager(int Depth) - : ModulePass(intptr_t(&ID)), PMDataManager(Depth) { } + : ModulePass(&ID), PMDataManager(Depth) { } /// run - Execute all of the passes scheduled for execution. Keep track of /// whether any of the passes modifies the module, and if so, return true. bool runOnFunction(Function &F); bool runOnModule(Module &M); + + /// cleanup - After running all passes, clean up pass manager cache. + void cleanup(); /// doInitialization - Run all of the initializers for the function passes. /// @@ -399,6 +435,9 @@ public: /// bool doFinalization(Module &M); + virtual PMDataManager *getAsPMDataManager() { return this; } + virtual Pass *getAsPass() { return this; } + /// Pass Manager itself does not invalidate any analysis info. void getAnalysisUsage(AnalysisUsage &Info) const { Info.setPreservesAll(); @@ -422,9 +461,8 @@ public: } }; -} +Timer *getPassTimer(Pass *); -extern void StartPassTimer(llvm::Pass *); -extern void StopPassTimer(llvm::Pass *); +} #endif