<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html;
      charset=windows-1252">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <br>
    <div class="moz-cite-prefix">On 08/17/2018 08:46 AM, Troy Johnson
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CY4PR11MB1397062B18744566C67323CAC63D0@CY4PR11MB1397.namprd11.prod.outlook.com">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      Thanks to both of you for clarifying.<br>
      <br>
      Bekket, local restrict is pretty common in my experience, at least
      with our users.  It would be good for it to work as expected.<br>
      <br>
      Hal, I appreciate the difficulty in doing the based-on analysis,
      but it needs to be understood that a C compiler was never really
      expected to do that analysis!  Being able to do it would be great,
      of course, but it is quite daunting and was not the original
      intent of restrict.  I have in fact worked with the original
      author of the restrict keyword and proposed WG14/N2260 to clarify
      its usage and intent.<br>
      <br>
      Basically, the based-on terminology was the least bad way anyone
      thought of at the time to describe the semantics.  The belief was
      that users would supply restrict on multiple pointers of the same
      type whenever none of them aliased, then use those pointers
      directly.  Doing the based-on analysis is similar to what's
      required to usefully interpret a single restrict-qualified pointer
      in isolation, and that's considered unreasonably hard.<br>
    </blockquote>
    <br>
    You're proposing that there is some common cases, dealing
    specifically with multiple restrict pointers, where the based-on
    relationship is clear, and handling those using the existing
    metadata. I'm not sure how limiting this would be, but certainly
    could be worth doing. We should discuss this in more detail.<br>
    <br>
    <blockquote type="cite"
cite="mid:CY4PR11MB1397062B18744566C67323CAC63D0@CY4PR11MB1397.namprd11.prod.outlook.com"><br>
      So I think this problem is quite solvable in the common (and
      recommended) case of the user specifying restrict liberally and
      accessing data directly via those pointers.<br>
      <br>
      The use case that I normally see is a bunch of local restricted
      pointers initialized once and indexed by some increasing integer. 
      The compiler would honor restrict if the user outlined the code
      into a separate function and the pointers were parameters
      instead.  Sometimes that is the recommended workaround, but it
      shouldn't be necessary.<br>
    </blockquote>
    <br>
    I agree. I'd like this workaround not to be necessary.<br>
    <br>
    <blockquote type="cite"
cite="mid:CY4PR11MB1397062B18744566C67323CAC63D0@CY4PR11MB1397.namprd11.prod.outlook.com"><br>
      I'm happy to discuss futher with whomever works on the related
      parts of Clang and LLVM.  I am not familiar with who that might
      be.<br>
    </blockquote>
    <br>
    I did most of the work associated with the llvm.noalias metadata and
    the proposed llvm.noalias patches. Others have been investigating
    this as well. I'm happy to discuss this with you (and, unless
    there's some reason to do otherwise, we can discuss this here, for
    LLVM issues, or on cfe-dev, for issues of how Clang translates C
    into LLVM).<br>
    <br>
    Thanks again,<br>
    Hal<br>
    <br>
    <blockquote type="cite"
cite="mid:CY4PR11MB1397062B18744566C67323CAC63D0@CY4PR11MB1397.namprd11.prod.outlook.com"><br>
      -Troy
      <hr style="display:inline-block;width:98%" tabindex="-1">
      <div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt"
          color="#000000" face="Calibri, sans-serif"><b>From:</b> Hal
          Finkel <a class="moz-txt-link-rfc2396E" href="mailto:hfinkel@anl.gov"><hfinkel@anl.gov></a><br>
          <b>Sent:</b> Thursday, August 16, 2018 10:31:52 PM<br>
          <b>To:</b> Bekket McClane; Troy Johnson<br>
          <b>Cc:</b> <a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
          <b>Subject:</b> Re: [llvm-dev] alias.scope and local
          restricted C pointers</font>
        <div> </div>
      </div>
      <meta content="text/html; charset=utf-8">
      <div style="background-color:#FFFFFF"><br>
        <div class="x_moz-cite-prefix">On 08/16/2018 07:52 PM, Bekket
          McClane via llvm-dev wrote:<br>
        </div>
        <blockquote type="cite"><br class="">
          <div><br class="">
            <blockquote type="cite" class="">
              <div class="">On Aug 16, 2018, at 4:41 PM, Troy Johnson
                via llvm-dev <<a
                  href="mailto:llvm-dev@lists.llvm.org" class=""
                  moz-do-not-send="true">llvm-dev@lists.llvm.org</a>>
                wrote:</div>
              <br class="x_Apple-interchange-newline">
              <div class="">
                <div class="x_WordSection1"
                  style="font-family:Helvetica; font-size:12px;
                  font-style:normal; font-weight:normal;
                  letter-spacing:normal; text-align:start;
                  text-indent:0px; text-transform:none;
                  white-space:normal; word-spacing:0px;
                  text-decoration:none">
                  <div class="" style="margin:0in 0in 0.0001pt;
                    font-size:11pt; font-family:Calibri,sans-serif">
                    Concerning slide 16 of<span
                      class="x_Apple-converted-space"> </span><a
href="https://llvm.org/devmtg/2017-02-04/Restrict-Qualified-Pointers-in-LLVM.pdf"
                      class="" style="color:rgb(149,79,114);
                      text-decoration:underline" moz-do-not-send="true">https://llvm.org/devmtg/2017-02-04/Restrict-Qualified-Pointers-in-LLVM.pdf</a></div>
                  <div class="" style="margin:0in 0in 0.0001pt;
                    font-size:11pt; font-family:Calibri,sans-serif">
                     </div>
                  <div class="" style="margin:0in 0in 0.0001pt;
                    font-size:11pt; font-family:Calibri,sans-serif">
                    Specifically “Currently, LLVM only supports restrict
                    on function arguments, although we have a way to
                    preserve that information if the function is
                    inlined.”</div>
                  <div class="" style="margin:0in 0in 0.0001pt;
                    font-size:11pt; font-family:Calibri,sans-serif">
                     </div>
                  <div class="" style="margin:0in 0in 0.0001pt;
                    font-size:11pt; font-family:Calibri,sans-serif">
                    Is that statement still accurate? </div>
                </div>
              </div>
            </blockquote>
            <div><br class="">
            </div>
            <div>Yes, correct (actually I was just working on restrict,
              no_alias and alias.scope attributes). The inliner also
              propagates them correctly. </div>
            <br class="">
            <blockquote type="cite" class="">
              <div class="">
                <div class="x_WordSection1"
                  style="font-family:Helvetica; font-size:12px;
                  font-style:normal; font-weight:normal;
                  letter-spacing:normal; text-align:start;
                  text-indent:0px; text-transform:none;
                  white-space:normal; word-spacing:0px;
                  text-decoration:none">
                  <div class="" style="margin:0in 0in 0.0001pt;
                    font-size:11pt; font-family:Calibri,sans-serif">
                    It would seem that<span
                      class="x_Apple-converted-space"> </span><a
href="https://llvm.org/docs/LangRef.html#noalias-and-alias-scope-metadata"
                      class="" style="color:rgb(149,79,114);
                      text-decoration:underline" moz-do-not-send="true">https://llvm.org/docs/LangRef.html#noalias-and-alias-scope-metadata</a><span
                      class="x_Apple-converted-space"> </span>should be
                    sufficiently general to honor C’s restrict qualifier
                    on local pointers,</div>
                </div>
              </div>
            </blockquote>
            <blockquote type="cite" class="">
              <div class="">
                <div class="x_WordSection1"
                  style="font-family:Helvetica; font-size:12px;
                  font-style:normal; font-weight:normal;
                  letter-spacing:normal; text-align:start;
                  text-indent:0px; text-transform:none;
                  white-space:normal; word-spacing:0px;
                  text-decoration:none">
                  <div class="" style="margin:0in 0in 0.0001pt;
                    font-size:11pt; font-family:Calibri,sans-serif">
                    but it does not appear that Clang uses this part of
                    LLVM’s IR for that purpose today and thus local
                    restricts are ignored.</div>
                </div>
              </div>
            </blockquote>
            <div><br class="">
            </div>
            <div>I think that’s correct, but I haven’t come out with any
              scenarios regarding local variables/memory that can _not_
              be solved by AA. As BasicAA is able to solved most of the
              local cases, including malloc and some memory intrinsics.</div>
          </div>
        </blockquote>
        <br>
        int *restrict x = some_external_function();<br>
        int *restrict y = some_other_external_function();<br>
        <br>
        This is one of the fundamental use cases for restrict and
        BasicAA has nothing to offer in this regard. In other words,
        it's a mechanism for encoding an interface contract.<br>
        <br>
         -Hal<br>
        <br>
        <blockquote type="cite">
          <div>
            <div><br class="">
            </div>
            Best</div>
          <div>Bekket<br class="">
            <blockquote type="cite" class="">
              <div class="">
                <div class="x_WordSection1"
                  style="font-family:Helvetica; font-size:12px;
                  font-style:normal; font-weight:normal;
                  letter-spacing:normal; text-align:start;
                  text-indent:0px; text-transform:none;
                  white-space:normal; word-spacing:0px;
                  text-decoration:none">
                  <div class="" style="margin:0in 0in 0.0001pt;
                    font-size:11pt; font-family:Calibri,sans-serif">
                  </div>
                  <div class="" style="margin:0in 0in 0.0001pt;
                    font-size:11pt; font-family:Calibri,sans-serif">
                     </div>
                  <div class="" style="margin:0in 0in 0.0001pt;
                    font-size:11pt; font-family:Calibri,sans-serif">
                    Thanks,</div>
                  <div class="" style="margin:0in 0in 0.0001pt;
                    font-size:11pt; font-family:Calibri,sans-serif">
                    Troy</div>
                  <div class="" style="margin:0in 0in 0.0001pt;
                    font-size:11pt; font-family:Calibri,sans-serif">
                     </div>
                  <div class="" style="margin:0in 0in 0.0001pt;
                    font-size:11pt; font-family:Calibri,sans-serif">
                     </div>
                </div>
                <span class="" style="font-family:Helvetica;
                  font-size:12px; font-style:normal; font-weight:normal;
                  letter-spacing:normal; text-align:start;
                  text-indent:0px; text-transform:none;
                  white-space:normal; word-spacing:0px;
                  text-decoration:none; float:none;
                  display:inline!important">_______________________________________________</span><br
                  class="" style="font-family:Helvetica; font-size:12px;
                  font-style:normal; font-weight:normal;
                  letter-spacing:normal; text-align:start;
                  text-indent:0px; text-transform:none;
                  white-space:normal; word-spacing:0px;
                  text-decoration:none">
                <span class="" style="font-family:Helvetica;
                  font-size:12px; font-style:normal; font-weight:normal;
                  letter-spacing:normal; text-align:start;
                  text-indent:0px; text-transform:none;
                  white-space:normal; word-spacing:0px;
                  text-decoration:none; float:none;
                  display:inline!important">LLVM Developers mailing list</span><br
                  class="" style="font-family:Helvetica; font-size:12px;
                  font-style:normal; font-weight:normal;
                  letter-spacing:normal; text-align:start;
                  text-indent:0px; text-transform:none;
                  white-space:normal; word-spacing:0px;
                  text-decoration:none">
                <a href="mailto:llvm-dev@lists.llvm.org" class=""
                  style="color:rgb(149,79,114);
                  text-decoration:underline; font-family:Helvetica;
                  font-size:12px; font-style:normal; font-weight:normal;
                  letter-spacing:normal; orphans:auto; text-align:start;
                  text-indent:0px; text-transform:none;
                  white-space:normal; widows:auto; word-spacing:0px"
                  moz-do-not-send="true">llvm-dev@lists.llvm.org</a><br
                  class="" style="font-family:Helvetica; font-size:12px;
                  font-style:normal; font-weight:normal;
                  letter-spacing:normal; text-align:start;
                  text-indent:0px; text-transform:none;
                  white-space:normal; word-spacing:0px;
                  text-decoration:none">
                <a
                  href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev"
                  class="" style="color:rgb(149,79,114);
                  text-decoration:underline; font-family:Helvetica;
                  font-size:12px; font-style:normal; font-weight:normal;
                  letter-spacing:normal; orphans:auto; text-align:start;
                  text-indent:0px; text-transform:none;
                  white-space:normal; widows:auto; word-spacing:0px"
                  moz-do-not-send="true">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a></div>
            </blockquote>
          </div>
          <br class="">
          <br>
          <fieldset class="x_mimeAttachmentHeader"></fieldset>
          <br>
          <pre>_______________________________________________
LLVM Developers mailing list
<a class="x_moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org" moz-do-not-send="true">llvm-dev@lists.llvm.org</a>
<a class="x_moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" moz-do-not-send="true">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
        </blockquote>
        <br>
        <pre class="x_moz-signature" cols="72">-- 
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory</pre>
      </div>
    </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>