<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p><font face="Hack Nerd Font Mono">From wikipedia
(<a class="moz-txt-link-freetext" href="https://en.wikipedia.org/wiki/Restrict">https://en.wikipedia.org/wiki/Restrict</a>)<br>
</font></p>
<p><br>
<font face="Hack Nerd Font Mono"><a
href="https://en.wikipedia.org/wiki/C%2B%2B" title="C++">C++</a>
does not have standard support for <code>restrict</code>, but
many compilers have equivalents that usually work in both C++
and C, such as the <a
href="https://en.wikipedia.org/wiki/GNU_Compiler_Collection"
title="GNU Compiler Collection">GCC</a>'s and <a
href="https://en.wikipedia.org/wiki/Clang" title="Clang">Clang</a>'s
<code>__restrict__</code>, and <a
href="https://en.wikipedia.org/wiki/Visual_C%2B%2B"
class="mw-redirect" title="Visual C++">Visual C++</a>'s <code>__declspec(restrict)</code>.
In addition, <code>__restrict</code> is supported by those
three compilers. The exact interpretation of these alternative
keywords vary by the compiler:
</font></p>
<p><font face="Hack Nerd Font Mono"><br>
</font></p>
<p><font face="Hack Nerd Font Mono">Hope this helps,</font></p>
<p><font face="Hack Nerd Font Mono">~ Johannes<br>
</font></p>
<p><font face="Hack Nerd Font Mono"></font><br>
</p>
<div class="moz-cite-prefix">On 6/29/20 11:51 AM, Bandhav Veluri via
llvm-dev wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAKyKabhF2-veri8eCfhwn9r+=sJstbS-UMrr-sVU++PiF-vw2Q@mail.gmail.com">
<pre class="moz-quote-pre" wrap="">Hi,
Later found out this is because some Newlib headers defined __restrict as
empty. __restrict__ seems to work...
What's the supposed difference between __restrict and __restrict__?
Thanks,
Bandhav
On Sun, Jun 28, 2020 at 1:18 AM Bandhav Veluri <a class="moz-txt-link-rfc2396E" href="mailto:bandhav.veluri00@gmail.com"><bandhav.veluri00@gmail.com></a>
wrote:
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">Hi,
I am observing a strange behaviour in which Clang ignores __restirct when
I include some standard headers.
For example, this code:
void vec_add(int* __restrict a,
int* __restrict b,
int n) {
#pragma unroll 4
for(int i=0; i<n; ++i) {
a[i] += b[i];
}
}
results in:
; Function Attrs: nofree norecurse nounwind
define dso_local void @_Z7vec_addPiS_i(i32* noalias nocapture %a, i32*
noalias nocapture readonly %b, i32 %n) local_unnam
ed_addr #0 {
entry:
.
.
...
(note the noaliass before function arguments).
But this code:
#include <cmath>
void vec_add(int* __restrict a,
int* __restrict b,
int n) {
#pragma unroll 4
for(int i=0; i<n; ++i) {
a[i] += b[i];
}
}
results in:
; Function Attrs: nofree norecurse nounwind
define dso_local void @_Z7vec_addPiS_i(i32* nocapture %a, i32* nocapture
readonly %b, i32 %n) local_unnamed_addr #0 {
entry:
%cmp6 = icmp sgt i32 %n, 0
br i1 %cmp6, label %for.body.preheader, label %for.cond.cleanup
.
.
...
I'm running this with LLVM RISC-V backend using RISC-V GCC compiled Newlib
as the C/C++ library.
Is it not okay to use GCC libraries with LLVM? Or could this be a specific
issue with Newlib's header files misinterpreted by Clang?
Thank you,
Bandhav
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">
</pre>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-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="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
</blockquote>
</body>
</html>