Loop exit condition analysis

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.

Best,
Hanfeng

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

Thanks for your suggestions. As you assumed, I really means that c is a volatile variable. Here I give detailed scenario. It is about ad-hoc synchronization detection. Consider we have two threads,
thread 1;

volatile int *c = &a;
while (*c == 0);

thread 2:

a = 1;

In this sample, the spin-loop is used as ad-hoc synchronization. We call variable a is a synchronization variable while c is a loop exit variable which depends on the former. I want to filter such spin-loop from general computation loop. To do this, as “Ad-hoc Synchronization Considered Harmful”[Xiong et al 2010] presented, I need to analysis the EDVs (Exit Dependent Variables). Thus my former question arises. However, I am not familiar with compiler optimization. Could you please give me some further suggestions?