I wrote a llvm pass:
using namespace llvm;
namespace
{
struct CountOperands : public FunctionPass
{
std::map<std::string,int> opCounter;
static char ID;
/*Constructor*/
CountOperands() : FunctionPass(ID) {}
/*RunOnFuntion Method*/
virtual bool runOnFunction( Function &F)
{
errs() << "Function Name: " << F.getName() << "\n";
/*Reading the OpCode in the function*/
for (Function::iterator b = F.begin(), be = F.end(); b != be; ++b)
{
errs() << "##########Works fine "<<"\n";
for (BasicBlock::iterator i = b.begin(), ie = b.end(); i != ie; ++i)
{
errs()<<"##########Works fine till here "<<"\n";
if(BranchInst *pBranchInst=dyn_cast<BranchInst>(i))
{//the problem is here,there is a stack dump?why?
}
.....
whem I run the pass,the command is :
opt -load XX/XX.so <hello.bc> /dev/null
then I got a stack dump finally.why? could somebody help me?