summaryrefslogtreecommitdiff
path: root/lib/Transforms/Instrumentation/TraceValues.cpp
diff options
context:
space:
mode:
authorVikram S. Adve <vadve@cs.uiuc.edu>2003-07-11 21:57:43 +0000
committerVikram S. Adve <vadve@cs.uiuc.edu>2003-07-11 21:57:43 +0000
commit919fc8c367bb875326a2420041a385a3f5f6ad4f (patch)
tree43a6f63ef4390e8212e953e658446bb88bbb1468 /lib/Transforms/Instrumentation/TraceValues.cpp
parent0517c5ac92ecb4f8a4658fd1a5f3d33bd45acbe8 (diff)
downloadllvm-919fc8c367bb875326a2420041a385a3f5f6ad4f.tar.gz
llvm-919fc8c367bb875326a2420041a385a3f5f6ad4f.tar.bz2
llvm-919fc8c367bb875326a2420041a385a3f5f6ad4f.tar.xz
Trace loads and stores as they happen (stores were being
remembered in valuesStoredInFunction, but never traced at function return, and that's too late to be finding the error anyway). Stores trace both the value and the address being stored to, but after some experience I think only values should be traced. The pointer hash table just fills up far too quickly if every store address were traced. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7169 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Instrumentation/TraceValues.cpp')
-rw-r--r--lib/Transforms/Instrumentation/TraceValues.cpp27
1 files changed, 17 insertions, 10 deletions
diff --git a/lib/Transforms/Instrumentation/TraceValues.cpp b/lib/Transforms/Instrumentation/TraceValues.cpp
index 618466a403..ca5087a020 100644
--- a/lib/Transforms/Instrumentation/TraceValues.cpp
+++ b/lib/Transforms/Instrumentation/TraceValues.cpp
@@ -164,7 +164,9 @@ static inline GlobalVariable *getStringRef(Module *M, const string &str) {
//
// Check if this instruction has any uses outside its basic block,
-// or if it used by either a Call or Return instruction.
+// or if it used by either a Call or Return instruction (ditto).
+// (Values stored to memory within this BB are live at end of BB but are
+// traced at the store instruction, not where they are computed.)
//
static inline bool LiveAtBBExit(const Instruction* I) {
const BasicBlock *BB = I->getParent();
@@ -188,10 +190,16 @@ static inline bool TraceThisOpCode(unsigned opCode) {
}
+// Trace a value computed by an instruction if it is non-void, it is computed
+// by a real computation, not just a copy (see TraceThisOpCode), and
+// -- it is a load instruction: we want to check values read from memory
+// -- or it is live at exit from the basic block (i.e., ignore local temps)
+//
static bool ShouldTraceValue(const Instruction *I) {
return
- I->getType() != Type::VoidTy && LiveAtBBExit(I) &&
- TraceThisOpCode(I->getOpcode());
+ I->getType() != Type::VoidTy &&
+ TraceThisOpCode(I->getOpcode()) &&
+ (isa<LoadInst>(I) || LiveAtBBExit(I));
}
static string getPrintfCodeFor(const Value *V) {
@@ -331,14 +339,13 @@ static void TraceValuesAtBBExit(BasicBlock *BB,
//
for (BasicBlock::iterator II = BB->begin(); &*II != InsertPos; ++II) {
if (StoreInst *SI = dyn_cast<StoreInst>(II)) {
- assert(valuesStoredInFunction &&
- "Should not be printing a store instruction at function exit");
- LoadInst *LI = new LoadInst(SI->getPointerOperand(), "reload." +
- SI->getPointerOperand()->getName(),
- InsertPos);
- valuesStoredInFunction->push_back(LI);
+ // Trace the stored value and address
+ InsertVerbosePrintInst(SI->getOperand(0), BB, InsertPos,
+ " (store value) ", Printf, HashPtrToSeqNum);
+ InsertVerbosePrintInst(SI->getOperand(1), BB, InsertPos,
+ " (store addr ) ", Printf, HashPtrToSeqNum);
}
- if (ShouldTraceValue(II))
+ else if (ShouldTraceValue(II))
InsertVerbosePrintInst(II, BB, InsertPos, " ", Printf, HashPtrToSeqNum);
}
}