I am trying to find the data hazards using Pintool. I have written this:
TRACE_AddInstrumentFunction(Trace, 0); //called in main
class readStore //This is for both read and write. Named read for historical reasons...
{
public:
UINT64 addr;
std::vector<LEVEL_BASE::REG> vread_regs;
std::vector<LEVEL_BASE::REG> vwrite_regs;
};
Function Definition for Trace:
for(BBL bbl=TRACE_BblHead(trace);BBL_Valid(bbl);bbl= BBL_Next(bbl))
{
BBL_InsertCall(bbl, IPOINT_BEFORE, AFUNPTR(docount), IARG_UINT32, BBL_NumIns(bbl), IARG_END);
for(INS ins = BBL_InsHead(bbl); INS_Valid(ins); ins=INS_Next(ins))
{
LEVEL_BASE::REG readReg;
LEVEL_BASE::REG writeReg;
readStore *rs_temp= new readStore;
noRRegs=INS_MaxNumRRegs(ins); //get count of read regs
noWRegs=INS_MaxNumWRegs(ins);
for(UINT32 i=0;i<noRRegs;i++)
{
readReg =INS_RegR(ins,i); //returns readR type
if(REG_is_gr_type(readReg))
{
rs_temp->vread_regs.push_back(readReg) ;
}
//may want to add else condition
}
for(UINT32 j=0;j<noWRegs;j++) //store all write regs
{
writeReg= INS_RegW(ins,j);
if(REG_is_gr_type(writeReg))
{
rs_temp->vwrite_regs.push_back(writeReg);
}
}
rs_temp->addr= INS_Address(ins);
cout << rs_temp->addr;
cout << "\n";
readstore.push_back(*rs_temp);//array of objects with everything in it
My idea was to make a vector where I store all the instruction IP, the registers they write to and the registers they read from. I have done all this in the instrumentation function. Thereafter in the Fini Function, I simply calculate the Hazards using normal if-else conditions.
The problem I am facing is when I try to print the size of read_store
vector, I am getting a signficantly small number (around 10000) whereas the total number of instructions are >780K. Could someone tell me where I am going wrong?