Change over to use new style pass mechanism, now passes only expose small

creation functions in their public header file, unless they can help it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1816 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2002-02-26 21:46:54 +00:00
parent 3b2541424f
commit bd0ef77cde
32 changed files with 528 additions and 512 deletions

View File

@ -15,12 +15,55 @@
#include "llvm/Method.h"
#include "llvm/Module.h"
#include "llvm/SymbolTable.h"
#include "llvm/Pass.h"
#include "llvm/Assembly/Writer.h"
#include "Support/StringExtras.h"
#include <sstream>
using std::vector;
using std::string;
namespace {
class InsertTraceCode : public MethodPass {
bool TraceBasicBlockExits, TraceMethodExits;
Method *PrintfMeth;
public:
InsertTraceCode(bool traceBasicBlockExits, bool traceMethodExits)
: TraceBasicBlockExits(traceBasicBlockExits),
TraceMethodExits(traceMethodExits) {}
// Add a prototype for printf if it is not already in the program.
//
bool doInitialization(Module *M);
//--------------------------------------------------------------------------
// Function InsertCodeToTraceValues
//
// Inserts tracing code for all live values at basic block and/or method
// exits as specified by `traceBasicBlockExits' and `traceMethodExits'.
//
static bool doit(Method *M, bool traceBasicBlockExits,
bool traceMethodExits, Method *Printf);
// runOnMethod - This method does the work. Always successful.
//
bool runOnMethod(Method *M) {
return doit(M, TraceBasicBlockExits, TraceMethodExits, PrintfMeth);
}
};
} // end anonymous namespace
Pass *createTraceValuesPassForMethod() { // Just trace methods
return new InsertTraceCode(false, true);
}
Pass *createTraceValuesPassForBasicBlocks() { // Trace BB's and methods
return new InsertTraceCode(true, true);
}
// Add a prototype for printf if it is not already in the program.
//
bool InsertTraceCode::doInitialization(Module *M) {