Index: lib/Analysis/InstCount.cpp =================================================================== --- lib/Analysis/InstCount.cpp +++ lib/Analysis/InstCount.cpp @@ -42,7 +42,16 @@ void visitBasicBlock(BasicBlock &BB) { ++TotalBlocks; } #define HANDLE_INST(N, OPCODE, CLASS) \ - void visit##OPCODE(CLASS &) { ++Num##OPCODE##Inst; ++TotalInsts; } + void visit##OPCODE(CLASS &) { \ + ++Num##OPCODE##Inst; ++TotalInsts; \ + if (N == Instruction::GetElementPtr || \ + N == Instruction::Load || \ + N == Instruction::Store || \ + N == Instruction::Call || \ + N == Instruction::Invoke || \ + N == Instruction::Alloca) \ + ++TotalMemInst; \ + } #include "llvm/IR/Instruction.def" @@ -76,13 +85,6 @@ // function. // bool InstCount::runOnFunction(Function &F) { - unsigned StartMemInsts = - NumGetElementPtrInst + NumLoadInst + NumStoreInst + NumCallInst + - NumInvokeInst + NumAllocaInst; visit(F); - unsigned EndMemInsts = - NumGetElementPtrInst + NumLoadInst + NumStoreInst + NumCallInst + - NumInvokeInst + NumAllocaInst; - TotalMemInst += EndMemInsts-StartMemInsts; return false; }