#ifndef __VALUE__COUNTER__H
#define __VALUE__COUNTER__H

#include "llvm/Pass.h"

#include <map>

namespace llvm
{
  class User;
}

struct ValueCounter : public llvm::ModulePass
{
  static char ID;

  ValueCounter():ModulePass((intptr_t)&ID){}
  size_t getValueCount(const llvm::Function &F) const;
  
  virtual bool runOnModule(llvm::Module &M);
  virtual void getAnalysisUsage(llvm::AnalysisUsage &AU) const;
  
private:
  void countFunction(const llvm::Function &F);
  void insertUser(value_set & vs, const llvm::User * u);
  
private:
  std::map<const llvm::Function*, size_t> _values;
};

#endif // __VALUE__COUNTER__H
