<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 12/26/2015 02:17 AM, Amaury SECHET
via llvm-dev wrote:<br>
</div>
<blockquote
cite="mid:CANGV3T0KN3L9mbf=+w3ZppiEVcdtP_+K9kSr6+HnoKnG99t7VQ@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>
<div>I'm trying to fix that bug: <a moz-do-not-send="true"
href="https://llvm.org/bugs/show_bug.cgi?id=20049">https://llvm.org/bugs/show_bug.cgi?id=20049</a><br>
<br>
</div>
It turns out this is the kind of optimization that I really
need, as when it isn't done, all kind of other optimizations
opportunities down the road are not realized as they are not
exposed.<br>
<br>
</div>
I have no idea where to start digging for this. I assume there
is some kind of interaction between memory dependency and alias
analysis that is overly conservative. Can someone gives me some
infos on how the 2 interact together ? What is the code that is
supposed to remove these kind of loads ?<br>
</div>
</blockquote>
First, it looks like you're using an older version of LLVM (the load
syntax has changed). That's definitely not recommended since it
will greatly limit your choices when encountering an issue like
this.<br>
<br>
Second, the aliasing problem has to do with the effects of the
"allocmemory" callsite on a memory location associated with an
earlier alloca. There's nothing that prevents your allocmemory
function from writing to global state. You have to teach the alias
analysis that an unescaped noalias pointer can't alias the global
state allocmemory might access. Slightly surprised we don't get
this today, but oh well. Take a look at the
isNonEscapingLocalObject predicate in BasicAA. Then look at
"getModRefInfo(ImmutableCallSite CS, const MemoryLocation
&Loc)". Double check to make sure this is the one that MDA
actually calls. <br>
<br>
Third, you might want to take a look the new <tt class="docutils
literal"><span class="pre">inaccessiblememonly</span></tt><span
class="docutils literal"><span class="pre"> attribute. Depending
on how you're modelling your allocation, this might help resolve
the aliasing problem in different way. However, be aware that
this is *very* new. In particular, I triggered an optimizer bug
by adding the new attribute to your particular example. :( <br>
<br>
Fourth, have you considered implementing a simple escape
analysis pass? I notice that the store-load forwarding would
just fall out once you removed the last allocation. I believe
the fixed point would then become a function which returns the
constant answer and does nothing else. <br>
</span></span><tt class="docutils literal"><span class="pre"></span></tt><br>
Fifth, some pointers on debugging this yourself. GVN (which is the
one which does complicated *-load forwarding) calls MDA
(MemoryDepedenceAnalysis). Using the appropriate -debug-only
options will likely get you to the right area. You can also
consider using the MemDepPrinter pass to bypass GVN. I don't know
of a way to issue raw AA queries for testing. That would be useful,
but I don't know that we have it. <br>
<br>
Hope that helps. <br>
<blockquote
cite="mid:CANGV3T0KN3L9mbf=+w3ZppiEVcdtP_+K9kSr6+HnoKnG99t7VQ@mail.gmail.com"
type="cite">
<div dir="ltr"><br>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
</blockquote>
<br>
</body>
</html>