<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 03/28/2017 04:32 AM, Hayrapetyan,
      Anahit via llvm-dev wrote:<br>
    </div>
    <blockquote cite="mid:f83e84abd96d42c1a37d0dc8eeab7ee0@tum.de"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
      <div id="divtagdefaultwrapper"
style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;">
        <div id="divtagdefaultwrapper" style="font-size:12pt;
          color:#000000; font-family:Calibri,Arial,Helvetica,sans-serif">
          <p><span id="ms-rterangepaste-start"></span><span
              id="docs-internal-guid-a663f343-143d-ef81-9e99-9c08bb7392cd">Hi,
            </span></p>
          <p><br>
          </p>
          <p dir="ltr" style="line-height:1.38; margin-top:0pt;
            margin-bottom:0pt"><span style="font-size:11pt; font-family:Arial; background-color:transparent; vertical-align:baseline; white-space:pre-wrap">I’m writing an analysis pass which is supposed to find instructions
 in a function that modify function’s by-ref arguments. For that I’m using llvm AliasAnalysis pass, particularly querying for ModRef info for instructions and function arguments, to see if a given instruction modifies a given argument. However, for functions
 with more than one by-ref argument, I get strange results. Instructions, which modify one of the arguments, are reported as modifying the others too - saying, ModRef info of those instructions is Mod for all arguments.</span></p>
          <p dir="ltr" style="line-height:1.38; margin-top:0pt;
            margin-bottom:0pt"><span style="font-size:11pt; font-family:Arial; background-color:transparent; vertical-align:baseline; white-space:pre-wrap">For this example</span></p>
        </div>
        <blockquote style="margin: 0 0 0 40px; border: none; padding:
          0px;">
          <div style="font-size:12pt; color:#000000;
            font-family:Calibri,Arial,Helvetica,sans-serif">
            <p dir="ltr" style="line-height:1.38; margin-top:0pt;
              margin-bottom:0pt"><span style="font-size:11pt; font-family:Arial; background-color:transparent; vertical-align:baseline; white-space:pre-wrap"><i>void function(int& n, int& m)</i></span></p>
          </div>
          <div style="font-size:12pt; color:#000000;
            font-family:Calibri,Arial,Helvetica,sans-serif">
            <p dir="ltr" style="line-height:1.38; margin-top:0pt;
              margin-bottom:0pt"><span style="font-size:11pt; font-family:Arial; background-color:transparent; vertical-align:baseline; white-space:pre-wrap"><i>{</i></span></p>
          </div>
          <div style="font-size:12pt; color:#000000;
            font-family:Calibri,Arial,Helvetica,sans-serif">
            <p dir="ltr" style="line-height:1.38; margin-top:0pt;
              margin-bottom:0pt"><span style="font-size:11pt; font-family:Arial; background-color:transparent; vertical-align:baseline; white-space:pre-wrap"><i>int tmp = m;</i></span></p>
          </div>
          <div style="font-size:12pt; color:#000000;
            font-family:Calibri,Arial,Helvetica,sans-serif">
            <p dir="ltr" style="line-height:1.38; margin-top:0pt;
              margin-bottom:0pt"><span style="font-size:11pt; font-family:Arial; background-color:transparent; vertical-align:baseline; white-space:pre-wrap"><i>n = tmp;</i></span></p>
          </div>
          <div style="font-size:12pt; color:#000000;
            font-family:Calibri,Arial,Helvetica,sans-serif">
            <p dir="ltr" style="line-height:1.38; margin-top:0pt;
              margin-bottom:0pt"><span style="font-size:11pt; font-family:Arial; background-color:transparent; vertical-align:baseline; white-space:pre-wrap"><i>}</i></span></p>
          </div>
        </blockquote>
        <div style="font-size:12pt; color:#000000;
          font-family:Calibri,Arial,Helvetica,sans-serif">
          <p dir="ltr" style="line-height:1.38; margin-top:0pt;
            margin-bottom:0pt"><span style="font-size:11pt; font-family:Arial; background-color:transparent; vertical-align:baseline; white-space:pre-wrap">

</span></p>
          <p dir="ltr" style="line-height:1.38; margin-top:0pt;
            margin-bottom:0pt"><span style="font-size:11pt; font-family:Arial; background-color:transparent; vertical-align:baseline; white-space:pre-wrap">Arguments
<i>n</i> and <i>m</i> are marked as MayAlias, and storing <i>tmp</i> into <i>n</i> is reported to modify
<i>m</i> too.</span></p>
        </div>
      </div>
    </blockquote>
    <blockquote cite="mid:f83e84abd96d42c1a37d0dc8eeab7ee0@tum.de"
      type="cite">
      <div id="divtagdefaultwrapper"
style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;">
        <div style="font-size:12pt; color:#000000;
          font-family:Calibri,Arial,Helvetica,sans-serif">
          <br>
          <p dir="ltr" style="line-height:1.38; margin-top:0pt;
            margin-bottom:0pt"><span style="font-size:11pt; font-family:Arial; background-color:transparent; vertical-align:baseline; white-space:pre-wrap">I found a few discussions about this problem. In one of them,
 it was suggested to use cfl-aa, I tried it and it did not solve the problem.</span></p>
          <p dir="ltr" style="line-height:1.38; margin-top:0pt;
            margin-bottom:0pt"><span style="font-size:11pt; font-family:Arial; background-color:transparent; vertical-align:baseline; white-space:pre-wrap">In another one they said that this happens on purpose. llvm
 Alias Analysis marks function’s by-ref arguments MayAlias, as function may be called with arguments referencing the same variable.</span></p>
          <p dir="ltr" style="line-height:1.38; margin-top:0pt;
            margin-bottom:0pt"><span style="font-size:11pt; font-family:Arial; background-color:transparent; vertical-align:baseline; white-space:pre-wrap">

</span></p>
          <p dir="ltr" style="line-height:1.38; margin-top:0pt;
            margin-bottom:0pt"><span style="font-size:11pt; font-family:Arial; background-color:transparent; vertical-align:baseline; white-space:pre-wrap">So I would like to ask whether this is the case.</span></p>
        </div>
      </div>
    </blockquote>
    <br>
    Yes, this is the case. <br>
    It is legal to call the function as:<br>
    <br>
      int a = ...;<br>
      function(a, a);<br>
    <br>
    And so we need to make a conservative assumption.<br>
    <br>
    <blockquote cite="mid:f83e84abd96d42c1a37d0dc8eeab7ee0@tum.de"
      type="cite">
      <div id="divtagdefaultwrapper"
style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;">
        <div style="font-size:12pt; color:#000000;
          font-family:Calibri,Arial,Helvetica,sans-serif">
          <p dir="ltr" style="line-height:1.38; margin-top:0pt;
            margin-bottom:0pt"><span style="font-size:11pt; font-family:Arial; background-color:transparent; vertical-align:baseline; white-space:pre-wrap"> And if it
 is, is there a way to make llvm ignore this consideration?</span></p>
        </div>
      </div>
    </blockquote>
    <br>
    Yes, if you add __restrict__ (noalias as the IR level), then we'll
    assume they don't alias.<br>
    <br>
     -Hal<br>
    <br>
    <blockquote cite="mid:f83e84abd96d42c1a37d0dc8eeab7ee0@tum.de"
      type="cite">
      <div id="divtagdefaultwrapper"
style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;">
        <div style="font-size:12pt; color:#000000;
          font-family:Calibri,Arial,Helvetica,sans-serif">
          <p dir="ltr" style="line-height:1.38; margin-top:0pt;
            margin-bottom:0pt"><span style="font-size:11pt; font-family:Arial; background-color:transparent; vertical-align:baseline; white-space:pre-wrap">

</span></p>
          <p dir="ltr" style="line-height:1.38; margin-top:0pt;
            margin-bottom:0pt"><span style="font-size:11pt; font-family:Arial; background-color:transparent; vertical-align:baseline; white-space:pre-wrap">Thanks,</span></p>
          <p dir="ltr" style="line-height:1.38; margin-top:0pt;
            margin-bottom:0pt"><span style="font-size:11pt; font-family:Arial; background-color:transparent; vertical-align:baseline; white-space:pre-wrap">Anahit.</span></p>
          <br>
          <span id="ms-rterangepaste-end"></span><br>
        </div>
      </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>