diff options
author | Chris Lattner <sabre@nondot.org> | 2001-11-12 16:19:45 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2001-11-12 16:19:45 +0000 |
commit | e2409064715ac156ead333a039107b6e14548050 (patch) | |
tree | fc91d9633f0a66f6df09758094b596ec453dd1e2 /lib/ExecutionEngine/Interpreter/Execution.cpp | |
parent | 8486cdd3f9850eb08fceea05deb6a0315e962574 (diff) |
Hack a structure profiling option together
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1267 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/Interpreter/Execution.cpp')
-rw-r--r-- | lib/ExecutionEngine/Interpreter/Execution.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp index 41948c5806..c19d15cff4 100644 --- a/lib/ExecutionEngine/Interpreter/Execution.cpp +++ b/lib/ExecutionEngine/Interpreter/Execution.cpp @@ -26,6 +26,14 @@ static TargetData TD("lli Interpreter"); CachedWriter CW; // Object to accelerate printing of LLVM +#ifdef PROFILE_STRUCTURE_FIELDS +#include "llvm/Support/CommandLine.h" +static cl::Flag ProfileStructureFields("profilestructfields", + "Profile Structure Field Accesses"); +#include <map> +static map<const StructType *, vector<unsigned> > FieldAccessCounts; +#endif + sigjmp_buf SignalRecoverBuffer; static bool InInstruction = false; @@ -628,6 +636,33 @@ void Interpreter::executeRetInst(ReturnInst *I, ExecutionContext &SF) { } else { ExitCode = 0; } + +#ifdef PROFILE_STRUCTURE_FIELDS + // Print out structure field accounting information... + if (!FieldAccessCounts.empty()) { + CW << "Field Access Profile Information:\n"; + map<const StructType *, vector<unsigned> >::iterator + I = FieldAccessCounts.begin(), E = FieldAccessCounts.end(); + for (; I != E; ++I) { + vector<unsigned> &OfC = I->second; + CW << " '" << (Value*)I->first << "'\t- Sum="; + + unsigned Sum = 0; + for (unsigned i = 0; i < OfC.size(); ++i) + Sum += OfC[i]; + CW << Sum << " - "; + + for (unsigned i = 0; i < OfC.size(); ++i) { + if (i) CW << ", "; + CW << OfC[i]; + } + CW << endl; + } + CW << endl; + FieldAccessCounts.clear(); + } +#endif + return; } @@ -723,6 +758,16 @@ static PointerTy getElementOffset(Instruction *I, unsigned ArgOff) { const ConstPoolUInt *CPU = cast<ConstPoolUInt>(I->getOperand(ArgOff++)); assert(CPU->getType() == Type::UByteTy); unsigned Index = CPU->getValue(); + +#ifdef PROFILE_STRUCTURE_FIELDS + if (ProfileStructureFields) { + // Do accounting for this field... + vector<unsigned> &OfC = FieldAccessCounts[STy]; + if (OfC.size() == 0) OfC.resize(STy->getElementTypes().size()); + OfC[Index]++; + } +#endif + Total += SLO->MemberOffsets[Index]; Ty = STy->getElementTypes()[Index]; } |