<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body>
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>
<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>
<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>
<br>
-Troy
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Hal Finkel <hfinkel@anl.gov><br>
<b>Sent:</b> Thursday, August 16, 2018 10:31:52 PM<br>
<b>To:</b> Bekket McClane; Troy Johnson<br>
<b>Cc:</b> llvm-dev@lists.llvm.org<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="">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">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">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">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">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">llvm-dev@lists.llvm.org</a>
<a class="x_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="x_moz-signature" cols="72">--
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory</pre>
</div>
</body>
</html>