[LLVMdev] Using LoopInfo in a ModulePass

Devang Patel devang.patel at gmail.com
Thu Oct 29 10:14:21 PDT 2009


On Thu, Oct 29, 2009 at 2:29 AM, Hans Wennborg <hans at hanshq.net> wrote:
> I'm writing a ModulePass that does work on a subset of the functions in
> a module.
>
> I would like to get the LoopInfo for the functions that it works with.
> Is there some way to do this? As I understand, only a FunctionPass can
> register LoopInfo as a required analysis.

LoopInfo is a FunctionPass and a ModulePass can use FunctionPass in
certain cases. So you can do
   getAnalysis<LoopInfo>(Fn)
to get loop info for Fn. Fn must be a function definition.

See, http://llvm.org/docs/WritingAnLLVMPass.html#ModulePass
-
Devang



More information about the llvm-dev mailing list