[LLVMdev] RegisterPass isAnalysis parameter

Tom Prince tom.prince at ualberta.net
Mon Mar 1 12:11:23 PST 2010


On Mon, Mar 01, 2010 at 09:56:34AM -0800, Trevor Harmon wrote:
> On Feb 26, 2010, at 7:42 PM, Tom Prince wrote:
> 
> >You cannot refer to anything in anonymous namespace by name from
> >another file, however, if you have a pointer, say, then you can
> >still use the
> >pointer.
> 
> Yes, that would make sense, except I don't see any pointers being
> passed. The relevant line in lib/Transforms/Hello.cpp is:
> 
> static RegisterPass<Hello> X("hello", "Hello World Pass");
> 
> This template declaration is, somehow, sufficient to give the
> PassManager access to Hello.

Have a look in include/llvm/PassSupport.h

That line defines a static global variable of type RegisterPass<Hello>.
As far as I can determine, the contructor of RegisterPass instantiates the template
callDefaultCtor, and passes a pointer to it to the constuctor of PassInfo, which
calls PassInfo::registerPass.

  Tom



More information about the llvm-dev mailing list