[LLVMdev] InstVisitor usage problem
JinHuang
54jin.huang at gmail.com
Thu Jan 9 04:49:50 PST 2014
Hi.All
I had a problem in using llvm::InstVisitor class, my pass is like that:
using namespace llvm;
namespace
{
class InstVisit : public ModulePass,
public InstVisitor<InstVisit>
{
public :
static char ID;
InstVisit():ModulePass(ID){}
virtual bool runOnModule(Module &M)
{
visit(M);
return false;
}
void visitStoreInst(StoreInst &SI)
{
errs()<<"a store inst:"<<&SI<<"\n";
}
};
char InstVisit::ID = 0;
static RegisterPass<InstVisit>
X("visitInst","visit inst test");
}
then I use
opt -load /home/king/llvm/Release+Asserts/lib/instVisit.so
-visitInst<load.bc> /dev/null
to run the pass. but it appears such errors:
0 opt 0x00000000012700d2 llvm::sys::PrintStackTrace(_IO_FILE*)
+ 34
1 opt 0x000000000126fd29
2 libpthread.so.0 0x00007f9ba0336bd0
3 instVisit.so 0x00007f9b9f33a200
4 opt 0x00000000012081ef
llvm::MPPassManager::runOnModule(llvm::Module&) + 655
5 opt 0x0000000001209f7f
llvm::PassManagerImpl::run(llvm::Module&) + 223
6 opt 0x000000000057e1ac main + 3772
7 libc.so.6 0x00007f9b9f55eea5 __libc_start_main + 245
8 opt 0x000000000058fe65
Stack dump:
0. Program arguments: opt -load
/home/king/llvm/Release+Asserts/lib/instVisit.so -visitInst
1. Running pass 'visit inst test' on module '<stdin>'.
Segmentation fault (core dumped)
the load.c is :
int main() {
int x, y, z;
x = 12;
y = x + 22; /* load value of x that was just stored */
z = y + 33; /* load value of y that was just stored */
return z;
}
there is no stdin in the program .but why it says "Running pass 'visit inst
test' on module '<stdin>'."
Thank You!
-JinHuang
-----
Kind Regards!
-JinHuang
--
View this message in context: http://llvm.1065342.n5.nabble.com/InstVisitor-usage-problem-tp64909.html
Sent from the LLVM - Dev mailing list archive at Nabble.com.
More information about the llvm-dev
mailing list