[LLVMdev] Writing a pass for the opt tool: likely documentation bug

Devang Patel dpatel at apple.com
Wed Jul 25 14:02:22 PDT 2007


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
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list