[LLVMdev] Purpose and usage of INITIALIZE_PASS_*

ryan stdstack at gmail.com
Mon Jan 28 10:26:09 PST 2013


Hi All,
Looking at the code of MemDepPrinter.cpp, I saw the

char MemDepPrinter::ID = 0;
> INITIALIZE_PASS_BEGIN(MemDepPrinter, "print-memdeps",
> "Print MemDeps of function", false, true)
> INITIALIZE_PASS_DEPENDENCY(MemoryDependenceAnalysis)
> INITIALIZE_PASS_END(MemDepPrinter, "print-memdeps",
> "Print MemDeps of function", false, true)

What's the purpose of the INITIALIZE_PASS_* macros? What's the
difference between using static RegisterPass...?

When I try to use these macros in user-defined passes. The compiler complains,

error: ‘initializeXXXPass’ was not declared in this scope
> error: ‘void llvm::initializeXXXPass(llvm::PassRegistry&)’ should have
> been declared inside ‘llvm’

Is it because they should only be used by internal LLVM passes?

I couldn't find related hints from the documentation.

Thanks!
ryan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130128/9afd80e0/attachment.html>


More information about the llvm-dev mailing list