[LLVMdev] InstVisitor usage problem

Jin Huang 54jin.huang at gmail.com
Thu Jan 9 06:14:04 PST 2014


Sorry, I copied  it from the shell, so the format may be not right! I used
the opt command just like you wrote!

Thanks.

-JinHuang


2014/1/9 Arnaud Allard de Grandmaison <arnaud.adegm at gmail.com>

> The opt invocation looks weird to me. I would expect something like:
>
> opt -load /home/king/llvm/Release+Asserts/lib/instVisit.so -visitInst
> load.bc
>
> Cheers,
> --
> Arnaud
>
>
> On Thu, Jan 9, 2014 at 1:49 PM, JinHuang <54jin.huang at gmail.com> wrote:
>
>> 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.
>> _______________________________________________
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140109/457d2b05/attachment.html>


More information about the llvm-dev mailing list