[llvm-dev] Find loops in LLVM bytecode
Michael Zolotukhin via llvm-dev
llvm-dev at lists.llvm.org
Tue Sep 22 22:07:10 PDT 2015
> On Sep 22, 2015, at 8:50 PM, John Criswell via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 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 http://llvm.org/doxygen/classllvm_1_1LoopInfoWrapperPass.html). Your 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).
On top of that, you could be interesting in SCEV (ScalarEvolution) analysis, which will give you symbolic scalar-evolution expressions for every value in IR and for the loop trip-count.
> John Criswell
>> Best wishes,
>> Jia-Ju Bai
>> LLVM Developers mailing list
>> llvm-dev at lists.llvm.org
> John Criswell
> Assistant Professor
> Department of Computer Science, University of Rochester
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
More information about the llvm-dev