<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 04/11/2017 09:19 PM, Daniel Berlin
      via llvm-dev wrote:<br>
    </div>
    <blockquote
cite="mid:CAF4BwTVRbSFrrRPhe7pwrPN6uFCqGJ5HAJ377J0SNHa0t=MSqQ@mail.gmail.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <div dir="ltr"><br>
        <div class="gmail_extra"><br>
          <div class="gmail_quote">On Tue, Apr 11, 2017 at 7:02 PM,
            Daniel Berlin <span dir="ltr"><<a moz-do-not-send="true"
                href="mailto:dberlin@dberlin.org" target="_blank">dberlin@dberlin.org</a>></span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div dir="ltr">
                <div class="gmail_extra">
                  <div class="gmail_quote"><span class="">
                      <blockquote class="gmail_quote" style="margin:0 0
                        0 .8ex;border-left:1px #ccc
                        solid;padding-left:1ex"><br>
                        <span><br>
                          > It would require semantic changes to llvm
                          ir to fix this to properly<br>
                          > express object lifetimes that is
                          compatible with all the random babble<br>
                          > standards have written down :)<br>
                          > For now, the only sane solution IMHO, is
                          to say that no alias implies<br>
                          > pointer inequality, regardless of the
                          standards. Because the above can<br>
                          > occur in any situation noalias exists but
                          they are allowed to be pointer<br>
                          > equal (as mentioned, it's trivial to make
                          this happen in TBAA).<br>
                          <br>
                        </span>Just to be clear, you're suggesting that
                        we no longer mark malloc's<br>
                        return value as noalias?<br>
                      </blockquote>
                      <div><br>
                      </div>
                    </span>
                    <div>Actually, i'd suggest just letting it be a bug
                      :)</div>
                    <div>That's what other compilers seem to do.</div>
                    <div>You could hack around this in clang by using
                      the !alias.scope and !noalias form, and not
                      attaching the scope past the lifetime end.<br>
                    </div>
                    <div><br>
                    </div>
                    <div>But we don't optimize that.</div>
                  </div>
                </div>
              </div>
            </blockquote>
            <div><br>
            </div>
            <div>(by this i mean it's only used by memdep).</div>
            <div><br>
            </div>
            <div>I believe hal also has a noalias instrinsic proposal
              that would have been useful here.</div>
            <div><br>
            </div>
            <div>But thinking harder, it has the same problem because
              there is no way to end the lifetime of something in ssa,
              and thus, iif  do</div>
            <div>a1 = llvm.noalias(a)<br>
              b1 = llvm.noalias(b)</div>
            <div>if (a1 == b1)</div>
            <div>  oh crap</div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    Yep; doesn't help.<br>
    <br>
    <blockquote
cite="mid:CAF4BwTVRbSFrrRPhe7pwrPN6uFCqGJ5HAJ377J0SNHa0t=MSqQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">
            <div><br>
            </div>
            <div>So we can't use it to specify the lifetimes here.</div>
            <div><br>
            </div>
            <div><br>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    I feel like this is the perfect place for a pithy quote on self
    deception. The core problem here is that we allow the optimizer to
    rely on a lie (that all memory from malloc, and other noalias
    functions, is distinct). This, of course, is not really true. The
    consequence seems to be that if you write code that can observe the
    fallacy of this assumption - *even dead code* -  then the model
    breaks. Dead code can observe things, in this sense, I suppose, if
    there are no data dependencies or side effects that prevent the
    optimizer from making it speculatively live.<br>
    <br>
     -Hal<br>
    <br>
    <blockquote
cite="mid:CAF4BwTVRbSFrrRPhe7pwrPN6uFCqGJ5HAJ377J0SNHa0t=MSqQ@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>
    <pre class="moz-signature" cols="72">-- 
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory</pre>
  </body>
</html>