<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<font face="sans-serif">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,<br>
thread 1;<br>
....<br>
volatile int *c = &a;<br>
while (*c == 0);<br>
....<br>
<br>
thread 2:<br>
...<br>
a = 1;<br>
...<br>
<br>
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?<br>
</font>
<div class="moz-signature">
<style type="text/css">
#t1 {
font-family: System;
font-size: 14px;
color: #000000
}
</style>
<div id="t1"><br>
Thanks,<br>
Hanfeng<br>
</div>
</div>
<br>
On 12/21/2011 06:54 AM, Eli Friedman wrote:
<blockquote
cite="mid:CAJdarcHs-Xy=WYy2DraCFyArPHxFxeK8NxihVc4QUFJ3Tq3COg@mail.gmail.com"
type="cite">
<pre wrap="">On Mon, Dec 19, 2011 at 10:13 PM, Hanfeng Qin <a class="moz-txt-link-rfc2396E" href="mailto:hanfengtsin@gmail.com"><hanfengtsin@gmail.com></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">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.
</pre>
</blockquote>
<pre wrap="">
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
</pre>
</blockquote>
</body>
</html>