From d6f16587ab292b20857933b3ba13d3d1c62a8d62 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 6 Mar 2009 06:45:05 +0000 Subject: Sprinkle some PrettyStackEntry magic into the passmanager. With this, we now get nice and happy stack traces when we crash in an optimizer or codegen. For example, an abort put in UnswitchLoops now looks like this: Stack dump: 0. Program arguments: clang pr3399.c -S -O3 1. parser at end of file 2. per-module optimization passes 3. Running pass 'CallGraph Pass Manager' on module 'pr3399.c'. 4. Running pass 'Loop Pass Manager' on function '@foo' 5. Running pass 'Unswitch loops' on basic block '%for.inc' Abort git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66260 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/PassManagers.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'include/llvm/PassManagers.h') diff --git a/include/llvm/PassManagers.h b/include/llvm/PassManagers.h index 2d68239..6e4f946 100644 --- a/include/llvm/PassManagers.h +++ b/include/llvm/PassManagers.h @@ -88,7 +88,12 @@ // MPPassManagers. //===----------------------------------------------------------------------===// +#include "llvm/Support/PrettyStackTrace.h" + namespace llvm { + class Pass; + class Value; + class Module; /// FunctionPassManager and PassManager, two top level managers, serve /// as the public interface of pass manager infrastructure. @@ -109,6 +114,24 @@ enum PassDebuggingString { ON_CG_MSG // "' on Call Graph ...\n'" }; +/// PassManagerPrettyStackEntry - This is used +class PassManagerPrettyStackEntry : public PrettyStackTraceEntry { + Pass *P; + Value *V; + Module *M; +public: + PassManagerPrettyStackEntry(Pass *p) + : P(p) {} // 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 // -- cgit v1.1