[LLVMdev] RegisterPass isAnalysis parameter

Trevor Harmon trevor.w.harmon at nasa.gov
Fri Feb 26 17:22:49 PST 2010


On Feb 25, 2010, at 5:45 PM, David A. Greene wrote:

> The RegisterPass template takes care of notifying the PassManager
> that the pass exists.  One of the advantages of PassManager is
> that it decouples pass execution from the rest of the infrastructure
> so the class need not be visible to anything outside the  
> implementation
> of the pass itself.

Even though the PassManager implements the Hollywood Principle,  
something outside of the pass implementation still has to invoke one  
of the runOn* functions. And I'm not understanding how this invocation  
can occur if the implementation is invisible. Maybe I should just  
chalk this up to template magic...

On a related note, the source code comments in PassSupport.h (line  
156) say that the RegisterPass instance should be declared in the  
global scope, and indeed, the Hello.cpp example puts it in the global  
scope. However, the "Writing an LLVM Pass" document puts it in the  
anonymous namespace, and when I tried this on my own pass  
implementation, it worked fine. Is there a particular reason why it  
has to be in the global scope? (Maybe if I understood the  
contradiction, I'd be able to understand my original question.)

Thanks,

Trevor




More information about the llvm-dev mailing list