[LLVMdev] Loop exit condition analysis
Eli Friedman
eli.friedman at gmail.com
Tue Dec 20 14:54:16 PST 2011
On Mon, Dec 19, 2011 at 10:13 PM, Hanfeng Qin <hanfengtsin at gmail.com> wrote:
> Hi all,
> I am doing loop exit condition analysis. As the following sample code
> segments demonstrated,
>
> ....
> int *c = &a;
> while (*c == 0);
> ....
>
> I want to decide which variables are related to ending this spin-loop. E.g.,
> in above sample, c is the direct variable while a is an indirect one. Does
> LLVM provide any existing analysis tools or APIs I can leverage?
> I am new to compiler optimization. Wish any body can give some suggestions.
Well, first off, the given code isn't really a great example: LLVM
will hoist the load out of the loop, and it will never exit. I'll
assume you meant to write "volatile int *c".
For loop analysis in general, LLVM has an analysis called LoopInfo to
find loops and compute some properties of them. Your question isn't
really specific enough to give a more detailed answer.
-Eli
More information about the llvm-dev
mailing list