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?
Thanks,
Hanfeng
On 12/21/2011 06:54 AM, Eli Friedman wrote:> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20111221/b8429ed4/attachment.html>