[LLVMdev] How to use a FunctionPass in a ModulePass?

Devang Patel devang.patel at gmail.com
Mon Aug 10 09:36:07 PDT 2009


On Mon, Aug 10, 2009 at 3:35 AM, gauss<gausszhch at gmail.com> wrote:
> Hi, all:
>
> I wanted to use a FunctionPass (e.g. MemoryDependenceAnalysis) in a
> ModulePass, and then I used the method
> "getAnalysis<MemoryDependenceAnalysis>(llvm::Function *)"  described at
> http://llvm.org/docs/WritingAnLLVMPass.html#ModulePass to get the
> FunctionPass. But , it still crashed when I invoked this pass in tool 'opt'.
>
> However, if I change my pass to inherit from FunctionPass, then everything
> goes well. But I must use the ModulePass to solve my problem. What can I do
> now?

As the docs say, the function pass must not require any other module
pass (or immutable pass) here. This is a limitation of current
implementation. I'll update docs to list "immutable pass" explicitly.

-
Devang




More information about the llvm-dev mailing list