[LLVMdev] how to use LoopInfo outside of LLVM

Chris Lattner sabre at nondot.org
Tue Jul 5 10:58:33 PDT 2005


On Sat, 25 Jun 2005, xujunjuan wrote:

> My project is outside of LLVM. Now I need get LoopInfo for a function. I 
> know that if my project were a pass inside LLVM. I can get LoopInfo by 
> "AU.addRequired<LoopInfo>()" and "getAnalysis<LoopInfo>()". Also I know 
> I can get a function pass by "llvm::FunctionPass* dce = 
> llvm::createDeadCodeEliminationPass(); dce->runOnFunction(*func)" 
> outside of LLVM. But I can't figure out a way to get LoopInfo outside of 
> LLVM. Is there any possible way to do it?

Hi,

I'm not sure what you mean by "outside of llvm".  You should be able to 
just make a pass manager and add an instance of the LoopInfo class to it.

Using runOnFunction like you do above is not a great idea: some passes 
initialize themselves and depend on other passes.  See this document for 
more information:

http://llvm.cs.uiuc.edu/docs/WritingAnLLVMPass.html

-Chris

-- 
http://nondot.org/sabre/
http://llvm.cs.uiuc.edu/




More information about the llvm-dev mailing list