[llvm-dev] Find loops in LLVM bytecode
John Criswell via llvm-dev
llvm-dev at lists.llvm.org
Tue Sep 22 20:50:04 PDT 2015
On 9/22/15 8:22 PM, Jia-Ju Bai via llvm-dev wrote:
> I want to find simple loops in LLVM bytecode, and extract the basic
> information of the loop.
> For example:
> for (i=0; i<1000; i++)
> sum += i;
> I want to extract the bound [0, 1000), the loop variable "i" and the
> loop body (sum += i).
> What should I do?
> I read the LLVM API document, and find some useful classes like
> "Loop", "LoopInfo".
> But I do not know how to use them in detail.
> Could you please give me some help? A detailed usage may be more helpful.
I think you want to look at the LoopInfoWrapperPass (see the doxygen at
pass will use the analysis results from LoopInfoWrapperPass to get
references to LoopInfo objects which can then be used to find loops (if
memory serves me correctly).
> Best wishes,
> Jia-Ju Bai
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
Department of Computer Science, University of Rochester
More information about the llvm-dev