DOUT << "InsertInstrumentationCall (\"" << BB->getName ()
<< "\", \"" << FnName << "\", " << BBNumber << ")\n";
Module &M = *BB->getParent ()->getParent ();
- Function *InstrFn = M.getOrInsertFunction (FnName, Type::VoidTy,
+ Constant *InstrFn = M.getOrInsertFunction (FnName, Type::VoidTy,
Type::Int32Ty, (Type *)0);
- std::vector<Value*> Args (1);
- Args[0] = ConstantInt::get (Type::Int32Ty, BBNumber);
-
- // Insert the call after any alloca or PHI instructions...
+
+ // Insert the call after any alloca or PHI instructions.
BasicBlock::iterator InsertPos = BB->begin();
while (isa<AllocaInst>(InsertPos) || isa<PHINode>(InsertPos))
++InsertPos;
- new CallInst (InstrFn, Args, "", InsertPos);
+ new CallInst(InstrFn, ConstantInt::get (Type::Int32Ty, BBNumber),
+ "", InsertPos);
}
bool TraceBasicBlocks::runOnModule(Module &M) {
cl::value_desc("function"), cl::Hidden);
static void TraceValuesAtBBExit(BasicBlock *BB,
- Function *Printf, Function* HashPtrToSeqNum,
+ Constant *Printf, Constant* HashPtrToSeqNum,
std::vector<Instruction*> *valuesStoredInFunction);
// We trace a particular function if no functions to trace were specified
namespace {
struct ExternalFuncs {
- Function *PrintfFunc, *HashPtrFunc, *ReleasePtrFunc;
- Function *RecordPtrFunc, *PushOnEntryFunc, *ReleaseOnReturnFunc;
+ Constant *PrintfFunc, *HashPtrFunc, *ReleasePtrFunc;
+ Constant *RecordPtrFunc, *PushOnEntryFunc, *ReleaseOnReturnFunc;
void doInitialization(Module &M); // Add prototypes for external functions
};
static void InsertPrintInst(Value *V, BasicBlock *BB, Instruction *InsertBefore,
std::string Message,
- Function *Printf, Function* HashPtrToSeqNum) {
+ Constant *Printf, Constant* HashPtrToSeqNum) {
// Escape Message by replacing all % characters with %% chars.
std::string Tmp;
std::swap(Tmp, Message);
static void InsertVerbosePrintInst(Value *V, BasicBlock *BB,
Instruction *InsertBefore,
- const std::string &Message, Function *Printf,
- Function* HashPtrToSeqNum) {
+ const std::string &Message, Constant *Printf,
+ Constant * HashPtrToSeqNum) {
std::ostringstream OutStr;
if (V) WriteAsOperand(OutStr, V);
InsertPrintInst(V, BB, InsertBefore, Message+OutStr.str()+" = ",
static void
InsertReleaseInst(Value *V, BasicBlock *BB,
Instruction *InsertBefore,
- Function* ReleasePtrFunc) {
+ Constant *ReleasePtrFunc) {
const Type *SBP = PointerType::get(Type::Int8Ty);
if (V->getType() != SBP) // Cast pointer to be sbyte*
static void
InsertRecordInst(Value *V, BasicBlock *BB,
Instruction *InsertBefore,
- Function* RecordPtrFunc) {
+ Constant *RecordPtrFunc) {
const Type *SBP = PointerType::get(Type::Int8Ty);
if (V->getType() != SBP) // Cast pointer to be sbyte*
V = new BitCastInst(V, SBP, "RP_cast", InsertBefore);
// store instruction).
//
static void TraceValuesAtBBExit(BasicBlock *BB,
- Function *Printf, Function* HashPtrToSeqNum,
+ Constant *Printf, Constant * HashPtrToSeqNum,
std::vector<Instruction*> *valuesStoredInFunction) {
// Get an iterator to point to the insertion location, which is
// just before the terminator instruction.
}
}
-static inline void InsertCodeToShowFunctionEntry(Function &F, Function *Printf,
- Function* HashPtrToSeqNum){
+static inline void InsertCodeToShowFunctionEntry(Function &F, Constant *Printf,
+ Constant * HashPtrToSeqNum){
// Get an iterator to point to the insertion location
BasicBlock &BB = F.getEntryBlock();
Instruction *InsertPos = BB.begin();
static inline void InsertCodeToShowFunctionExit(BasicBlock *BB,
- Function *Printf,
- Function* HashPtrToSeqNum) {
+ Constant *Printf,
+ Constant * HashPtrToSeqNum) {
// Get an iterator to point to the insertion location
ReturnInst *Ret = cast<ReturnInst>(BB->getTerminator());