Writing a pass for the opt tool: likely documentation bug

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

Writing a pass for the opt tool: likely documentation bug

Sarah Thompson-2
Hi,

I'm currently attempting to implement a pass that will hopefully run
under the opt tool. Currently, I'm having some difficulties -- the
sample code for the Hello pass (see
http://llvm.org/docs/WritingAnLLVMPass.html) doesn't work. The first
error is that the section starting 'As a while, the cpp file looks
like:' omits the declaration for char Hello::ID = 0 that is given
separately above. If you add this, opt still fails with the message:

opt: /usr/local/rse/llvm/src/lib/VMCore/Pass.cpp:158: void <unnamed>::PassRegistrar::RegisterPass(llvm::PassInfo&): Assertion `Inserted && "Pass registered multiple times!"' failed.

which appears to be triggered by the RegisterPass<Hello> X... line in the source (the error disappears if you comment that line out, though for obvious reasons the pass won't work if you do that). I've checked, there definitely isn't anything weird going on that would cause more than one instance of RegisterPass<Hello> to be seen by the compiler.

I am intending to have a go at writing probably several passes that will attempt a SPIN-like code to code transformation that turns llvm bitcode into another piece of llvm bitcode that, when run, has the effect of model-checking the original program. I won't get much done if I can't make any of my passes work, of course, so any tips would be gratefully appreciated at this point!

(I'm using the LLVM 2.0 release version).

Thank you in advance,
Sarah


_______________________________________________
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: Writing a pass for the opt tool: likely documentation bug

Devang Patel
Sarah,

We have Hello pass in svn at

        lib/Transforms/Hello

This is a working example. I will update documentation to include  
"char Hello::ID = 0".

On Jul 25, 2007, at 1:51 PM, Sarah Thompson wrote:

> Hi,
>
> I'm currently attempting to implement a pass that will hopefully run
> under the opt tool. Currently, I'm having some difficulties -- the
> sample code for the Hello pass (see
> http://llvm.org/docs/WritingAnLLVMPass.html) doesn't work. The first
> error is that the section starting 'As a while, the cpp file looks
> like:' omits the declaration for char Hello::ID = 0 that is given
> separately above. If you add this, opt still fails with the message:
>
> opt: /usr/local/rse/llvm/src/lib/VMCore/Pass.cpp:158: void  
> <unnamed>::PassRegistrar::RegisterPass(llvm::PassInfo&): Assertion  
> `Inserted && "Pass registered multiple times!"' failed.
>
> which appears to be triggered by the RegisterPass<Hello> X... line  
> in the source (the error disappears if you comment that line out,  
> though for obvious reasons the pass won't work if you do that). I've  
> checked, there definitely isn't anything weird going on that would  
> cause more than one instance of RegisterPass<Hello> to be seen by  
> the compiler.

This may happen if either you're sharing ::ID for two passes or you're  
registering Hello twice.

-
Devang

>
>
> I am intending to have a go at writing probably several passes that  
> will attempt a SPIN-like code to code transformation that turns llvm  
> bitcode into another piece of llvm bitcode that, when run, has the  
> effect of model-checking the original program. I won't get much done  
> if I can't make any of my passes work, of course, so any tips would  
> be gratefully appreciated at this point!
>
> (I'm using the LLVM 2.0 release version).
>
> Thank you in advance,
> Sarah
>
>
> _______________________________________________
> 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: Writing a pass for the opt tool: likely documentation bug

Reid Spencer-2
It can also happen if you link *anything* from LLVM into the Hello.so.
Don't do that :)

Reid.

On Wed, 2007-07-25 at 14:02 -0700, Devang Patel wrote:

> Sarah,
>
> We have Hello pass in svn at
>
> lib/Transforms/Hello
>
> This is a working example. I will update documentation to include  
> "char Hello::ID = 0".
>
> On Jul 25, 2007, at 1:51 PM, Sarah Thompson wrote:
>
> > Hi,
> >
> > I'm currently attempting to implement a pass that will hopefully run
> > under the opt tool. Currently, I'm having some difficulties -- the
> > sample code for the Hello pass (see
> > http://llvm.org/docs/WritingAnLLVMPass.html) doesn't work. The first
> > error is that the section starting 'As a while, the cpp file looks
> > like:' omits the declaration for char Hello::ID = 0 that is given
> > separately above. If you add this, opt still fails with the message:
> >
> > opt: /usr/local/rse/llvm/src/lib/VMCore/Pass.cpp:158: void  
> > <unnamed>::PassRegistrar::RegisterPass(llvm::PassInfo&): Assertion  
> > `Inserted && "Pass registered multiple times!"' failed.
> >
> > which appears to be triggered by the RegisterPass<Hello> X... line  
> > in the source (the error disappears if you comment that line out,  
> > though for obvious reasons the pass won't work if you do that). I've  
> > checked, there definitely isn't anything weird going on that would  
> > cause more than one instance of RegisterPass<Hello> to be seen by  
> > the compiler.
>
> This may happen if either you're sharing ::ID for two passes or you're  
> registering Hello twice.
>
> -
> Devang
>
> >
> >
> > I am intending to have a go at writing probably several passes that  
> > will attempt a SPIN-like code to code transformation that turns llvm  
> > bitcode into another piece of llvm bitcode that, when run, has the  
> > effect of model-checking the original program. I won't get much done  
> > if I can't make any of my passes work, of course, so any tips would  
> > be gratefully appreciated at this point!
> >
> > (I'm using the LLVM 2.0 release version).
> >
> > Thank you in advance,
> > Sarah
> >
> >
> > _______________________________________________
> > 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

_______________________________________________
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: Writing a pass for the opt tool: likely documentation bug

Sarah Thompson-2
Reid Spencer wrote:
> It can also happen if you link *anything* from LLVM into the Hello.so.
> Don't do that :)
>
>  
I think this was probably it. I'm now up and running -- thanks for the
help all.

[s]

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev