InstVisitor usage problem

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

InstVisitor usage problem

JinHuang
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!
-Jin Huang
Reply | Threaded
Open this post in threaded view
|

Re: InstVisitor usage problem

Arnaud Allard de Grandmaison-2
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 <[hidden email]> 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
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: InstVisitor usage problem

JinHuang
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 <[hidden email]>
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 <[hidden email]> 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
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev



_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Kind Regards!
-Jin Huang
Reply | Threaded
Open this post in threaded view
|

Re: InstVisitor usage problem

JinHuang
I found that this error is caused by the visit(M) ,once I delete this. It runs without errors.
And, I found that some of my previous pass also can not run(didn't happen before) normally with the same error. If I delete the code which will reference the Module &M, the error disappear.
That is very strange. What's wrong with that?


2014/1/9 Jin Huang <[hidden email]>
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 <[hidden email]>
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 <[hidden email]> 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
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev





--
Kind Regards!
-Jin Huang

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Kind Regards!
-Jin Huang