LLVM API Documentation

TraceValues.cpp File Reference

#include "llvm/Transforms/Instrumentation.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Instructions.h"
#include "llvm/Module.h"
#include "llvm/Pass.h"
#include "llvm/Assembly/Writer.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/ADT/StringExtras.h"
#include <algorithm>
#include <sstream>

Include dependency graph for TraceValues.cpp:

Go to the source code of this file.

Functions

static void TraceValuesAtBBExit (BasicBlock *BB, Function *Printf, Function *HashPtrToSeqNum, std::vector< Instruction * > *valuesStoredInFunction)
static bool TraceThisFunction (Function &F)
FunctionPassllvm::createTraceValuesPassForFunction ()
 Just trace functions.
FunctionPassllvm::createTraceValuesPassForBasicBlocks ()
 Trace BB's and functions.
static GlobalVariablegetStringRef (Module *M, const std::string &str)
static bool LiveAtBBExit (const Instruction *I)
static bool TraceThisOpCode (unsigned opCode)
static bool ShouldTraceValue (const Instruction *I)
static std::string getPrintfCodeFor (const Value *V)
static void InsertPrintInst (Value *V, BasicBlock *BB, Instruction *InsertBefore, std::string Message, Function *Printf, Function *HashPtrToSeqNum)
static void InsertVerbosePrintInst (Value *V, BasicBlock *BB, Instruction *InsertBefore, const std::string &Message, Function *Printf, Function *HashPtrToSeqNum)
static void InsertReleaseInst (Value *V, BasicBlock *BB, Instruction *InsertBefore, Function *ReleasePtrFunc)
static void InsertRecordInst (Value *V, BasicBlock *BB, Instruction *InsertBefore, Function *RecordPtrFunc)
static void ReleasePtrSeqNumbers (BasicBlock *BB, ExternalFuncs &externalFuncs)
static void InsertCodeToShowFunctionEntry (Function &F, Function *Printf, Function *HashPtrToSeqNum)
static void InsertCodeToShowFunctionExit (BasicBlock *BB, Function *Printf, Function *HashPtrToSeqNum)

Variables

static cl::opt< bool > DisablePtrHashing ("tracedisablehashdisable", cl::Hidden, cl::desc("Disable pointer hashing in the -trace or -tracem ""passes"))
static cl::list< std::string > TraceFuncNames ("tracefunc", cl::desc("Only trace specific functions in the ""-trace or -tracem passes"), cl::value_desc("function"), cl::Hidden)
FunctionPrintfFunc
FunctionHashPtrFunc
FunctionReleasePtrFunc
FunctionRecordPtrFunc
FunctionPushOnEntryFunc
FunctionReleaseOnReturnFunc
ExternalFuncs externalFuncs
RegisterOpt< FunctionTracer > X ("tracem","Insert Function trace code only")
RegisterOpt< BasicBlockTracer > Y ("trace","Insert BB and Function trace code")


Function Documentation

static std::string getPrintfCodeFor ( const Value V  )  [static]

Definition at line 210 of file TraceValues.cpp.

References DisablePtrHashing, and V.

Referenced by InsertPrintInst().

static GlobalVariable* getStringRef ( Module M,
const std::string &  str 
) [inline, static]

Definition at line 156 of file TraceValues.cpp.

References llvm::Module::getGlobalList(), llvm::Value::getType(), GV, and M.

Referenced by InsertPrintInst().

static void InsertCodeToShowFunctionEntry ( Function F,
Function Printf,
Function HashPtrToSeqNum 
) [inline, static]

Definition at line 358 of file TraceValues.cpp.

References BB, llvm::BasicBlock::begin(), E, F, I, InsertPos, InsertPrintInst(), InsertVerbosePrintInst(), llvm::utostr(), and llvm::WriteAsOperand().

static void InsertCodeToShowFunctionExit ( BasicBlock BB,
Function Printf,
Function HashPtrToSeqNum 
) [inline, static]

Definition at line 379 of file TraceValues.cpp.

References BB, llvm::BasicBlock::getParent(), llvm::Function::getReturnType(), llvm::ReturnInst::getReturnValue(), llvm::BasicBlock::getTerminator(), InsertPrintInst(), and llvm::WriteAsOperand().

static void InsertPrintInst ( Value V,
BasicBlock BB,
Instruction InsertBefore,
std::string  Message,
Function Printf,
Function HashPtrToSeqNum 
) [static]

Definition at line 226 of file TraceValues.cpp.

References BB, DisablePtrHashing, llvm::GlobalValue::getParent(), llvm::BasicBlock::getParent(), getPrintfCodeFor(), getStringRef(), I, llvm::InsertBefore(), Mod, and V.

Referenced by InsertCodeToShowFunctionEntry(), InsertCodeToShowFunctionExit(), InsertVerbosePrintInst(), and TraceValuesAtBBExit().

static void InsertRecordInst ( Value V,
BasicBlock BB,
Instruction InsertBefore,
Function RecordPtrFunc 
) [static]

Definition at line 292 of file TraceValues.cpp.

References llvm::InsertBefore(), RecordPtrFunc, and V.

Referenced by ReleasePtrSeqNumbers().

static void InsertReleaseInst ( Value V,
BasicBlock BB,
Instruction InsertBefore,
Function ReleasePtrFunc 
) [static]

Definition at line 279 of file TraceValues.cpp.

References llvm::InsertBefore(), ReleasePtrFunc, and V.

Referenced by ReleasePtrSeqNumbers().

static void InsertVerbosePrintInst ( Value V,
BasicBlock BB,
Instruction InsertBefore,
const std::string &  Message,
Function Printf,
Function HashPtrToSeqNum 
) [static]

Definition at line 268 of file TraceValues.cpp.

References BB, llvm::InsertBefore(), InsertPrintInst(), V, and llvm::WriteAsOperand().

Referenced by InsertCodeToShowFunctionEntry(), and TraceValuesAtBBExit().

static bool LiveAtBBExit ( const Instruction I  )  [inline, static]

Definition at line 176 of file TraceValues.cpp.

References BB, llvm::Instruction::getParent(), U, llvm::Value::use_begin(), and llvm::Value::use_end().

Referenced by ShouldTraceValue().

static void ReleasePtrSeqNumbers ( BasicBlock BB,
ExternalFuncs &  externalFuncs 
) [static]

Definition at line 308 of file TraceValues.cpp.

References AI, BB, llvm::BasicBlock::begin(), llvm::BasicBlock::end(), externalFuncs, llvm::BasicBlock::getNext(), II, InsertRecordInst(), and InsertReleaseInst().

static bool ShouldTraceValue ( const Instruction I  )  [static]

Definition at line 203 of file TraceValues.cpp.

References llvm::Instruction::getOpcode(), llvm::Value::getType(), LiveAtBBExit(), and TraceThisOpCode().

Referenced by TraceValuesAtBBExit().

static bool TraceThisFunction ( Function F  )  [inline, static]

Definition at line 46 of file TraceValues.cpp.

References F, and TraceFuncNames.

static bool TraceThisOpCode ( unsigned  opCode  )  [inline, static]

Definition at line 187 of file TraceValues.cpp.

References llvm::Alloca, and llvm::PHI.

Referenced by ShouldTraceValue().

static void TraceValuesAtBBExit ( BasicBlock BB,
Function Printf,
Function HashPtrToSeqNum,
std::vector< Instruction * > *  valuesStoredInFunction 
) [static]

Definition at line 328 of file TraceValues.cpp.

References BB, llvm::BasicBlock::begin(), llvm::BasicBlock::getTerminator(), II, InsertPos, InsertPrintInst(), InsertVerbosePrintInst(), ShouldTraceValue(), and llvm::WriteAsOperand().


Variable Documentation

cl::opt<bool> DisablePtrHashing("tracedisablehashdisable", cl::Hidden, cl::desc("Disable pointer hashing in the -trace or -tracem ""passes")) [static]

Referenced by getPrintfCodeFor(), and InsertPrintInst().

ExternalFuncs externalFuncs

Definition at line 64 of file TraceValues.cpp.

Referenced by ReleasePtrSeqNumbers().

Function * HashPtrFunc

Definition at line 57 of file TraceValues.cpp.

Function* PrintfFunc

Definition at line 57 of file TraceValues.cpp.

Function * PushOnEntryFunc

Definition at line 58 of file TraceValues.cpp.

Function* RecordPtrFunc

Definition at line 58 of file TraceValues.cpp.

Referenced by InsertRecordInst().

Function * ReleaseOnReturnFunc

Definition at line 58 of file TraceValues.cpp.

Function * ReleasePtrFunc

Definition at line 57 of file TraceValues.cpp.

Referenced by InsertReleaseInst().

cl::list<std::string> TraceFuncNames("tracefunc", cl::desc("Only trace specific functions in the ""-trace or -tracem passes"), cl::value_desc("function"), cl::Hidden) [static]

Referenced by TraceThisFunction().

RegisterOpt<FunctionTracer> X("tracem","Insert Function trace code only") [static]

RegisterOpt<BasicBlockTracer> Y("trace","Insert BB and Function trace code") [static]