how to use LoopInfo outside of LLVM

Hi,

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()” and “getAnalysis()”. 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?

Thanks,
-Junjuan

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