<div dir="ltr"><pre style="color:rgb(0,0,0);word-wrap:break-word;white-space:pre-wrap"><pre style="word-wrap:break-word;white-space:pre-wrap">+ bool notAddrTaken : 1; // Dose not have address taken.</pre>
</pre><pre style="color:rgb(0,0,0);word-wrap:break-word;white-space:pre-wrap">+If a global variable dose not have its address taken, it will be optionally
</pre><div>"does"</div><div><br></div><div>Given the awkwardness of reading this:</div><div><br></div><div><pre style="color:rgb(0,0,0);word-wrap:break-word;white-space:pre-wrap">+ GV->setNotAddressTaken(true);
</pre></div><div>Perhaps we'd like to spell the functions different, we can still use (though it's awkward) "notAddrTaken" for the IR notation how about just making all of the queries "addressTaken()" and then you can set it to false by default and propagate that way?</div>
<div><br></div><div>-eric</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Oct 21, 2013 at 11:27 AM, Shuxin Yang <span dir="ltr"><<a href="mailto:shuxin.llvm@gmail.com" target="_blank">shuxin.llvm@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
Ping.<br>
<br>
(add testing cases. Forget attaching testing case in my previous
mail). <br>
<div>Thanks<span class="HOEnZb"><font color="#888888"><br>
Shuxin</font></span><div><div class="h5"><br>
<br>
<br>
-------- Original Message --------
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<th align="RIGHT" nowrap valign="BASELINE">Subject:
</th>
<td>[Patch] Use address-taken to disambiguate global var and
indirect accesses</td>
</tr>
<tr>
<th align="RIGHT" nowrap valign="BASELINE">Date: </th>
<td>Tue, 15 Oct 2013 14:39:51 -0700</td>
</tr>
<tr>
<th align="RIGHT" nowrap valign="BASELINE">From: </th>
<td>Shuxin Yang <a href="mailto:shuxin.llvm@gmail.com" target="_blank"><shuxin.llvm@gmail.com></a></td>
</tr>
<tr>
<th align="RIGHT" nowrap valign="BASELINE">To: </th>
<td>Commit Messages and Patches for LLVM
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank"><llvm-commits@cs.uiuc.edu></a></td>
</tr>
</tbody>
</table>
<br>
<br>
<pre>Hi,
The attached patch is to take advantage of address-taken to
disambiguate global
variable and indirect memory accesses.
The motivation
===========
I was asked to investigate the problem where the static variable
is not hoisted as
loop invariant:
---------------
static int xyz;
void foo(int *p) {
for (int i = 0; i < xyz; i++)
*p++ = ....
}
-----------------
The compiler dose have a concept call "addr-capture". However, I
don't think it can
be used for disambiguate global variable and indirect access. The
reasons is that
a variable dose not have its address *CAPTURED*, dose not necessarily
mean this variable
cannot be indirectly accessed.
So, I rely on "address taken"
How it works
========
1. In globalopt, when a global var is identified as
not-addr-taken, cache the result
to GlobalVariable::notAddrTaken.
2. In alias-analyzer, supposed the mem-op involved are m1 and m2.
Let o1 and o2
be the "object" (obtained via get_underlying_object() of m1
and m2 respectively.
if O1 != O2 && one of the them are global-variable without
address taken,
then m1 and m2 are disjointed access.
Misc:
=========
Note that I *cache* the result of not-addr-taken. Unlike
function, it is far more expensive
to figure out if a globalvar has its address taken or not. So, it is not
appropriate to analyze
the address-taken on the fly.
On the other hand, I personally think not-addr-taken flag is
almost maintenance free.
(FIXME) Only few optimizer could make a not-addr-taken variable become
addr-taken (say, outlining),
and I don't think currently we have such passes (FIXME again!). In case
such rare cases take place,
it is up to the pass the to reset the not-addr-taken flags.
Of course, a variable previously considered addr-taken may later on
proved to be not-addr-taken.
In that case, compiler dose not have to update it -- it is
conservatively correct.
Performance impact
=============
Measured on an oldish Mac Tower with 2x 2.26Ghz Quad-Core Xeon. Both
base-line and
the change are measured for couple of times. I did take a look of why
Olden/power is sped up --
the loads of static variable "P" and "Q" are promoted in many places. I
have not yet got chance
to investigate why the speedup to pairlocalalign with O3 disappear in
O3+LTO.
o. test-suite w/ O3:
-------------------
Benchmarks/Olden/power/power 1.6129 1.354
-16.0518321036642
Benchmarks/mafft/pairlocalalign 31.4211 26.5794
-15.4090722476298
Benchmarks/Ptrdist/yacr2/yacr2 0.881 0.804
-8.74006810442678
o. test-suite w/ O3 + LTO
-------------------------
Benchmarks/Olden/power/power 1.6143 1.3419 -16.8741869540978
Applications/spiff/spiff 2.9203 2.849 -2.44152997979659
o. spec2kint w/ O3+LTO
----------------------
bzip2 75.02 73.92 -1.4
Thanks
Shuxin
</pre>
<br>
</div></div></div>
<br>
</div>
<br>_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
<br></blockquote></div><br></div>